From 859e87f425a7ad7089e673c1852ef3d8c4563c04 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 20 Jul 2020 21:33:25 -0400 Subject: [PATCH] refactor: remove extraneous zeroing out --- runtime/include/arch/aarch64/context.h | 3 --- runtime/include/arch/context.h | 14 +++++--------- runtime/include/arch/x86_64/context.h | 3 --- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/runtime/include/arch/aarch64/context.h b/runtime/include/arch/aarch64/context.h index a03a233..29dbd48 100644 --- a/runtime/include/arch/aarch64/context.h +++ b/runtime/include/arch/aarch64/context.h @@ -17,9 +17,6 @@ arch_context_init(struct arch_context *actx, reg_t ip, reg_t sp) { assert(actx->variant == arch_context_unused); - memset(&actx->mctx, 0, sizeof(mcontext_t)); - memset((void *)actx->regs, 0, sizeof(reg_t) * ureg_count); - actx->regs[ureg_rsp] = sp; actx->regs[ureg_rip] = ip; actx->variant = arch_context_fast; diff --git a/runtime/include/arch/context.h b/runtime/include/arch/context.h index 9e2551a..1c92c8c 100644 --- a/runtime/include/arch/context.h +++ b/runtime/include/arch/context.h @@ -31,7 +31,7 @@ /** * Restore a full mcontext - * Writes sandbox_context to active_context and then zeroes sandbox_context out + * Writes sandbox_context to active_context * @param active_context - the context of the current worker thread * @param sandbox_context - the context that we want to restore */ @@ -73,11 +73,9 @@ arch_context_restore(mcontext_t *active_context, struct arch_context *sandbox_co assert(sandbox_context->regs[ureg_rip]); assert(sandbox_context->regs[ureg_rsp]); - active_context->gregs[REG_RSP] = sandbox_context->regs[ureg_rsp]; - active_context->gregs[REG_RIP] = sandbox_context->regs[ureg_rip] + ARCH_SIG_JMP_OFF; - sandbox_context->regs[ureg_rsp] = 0; - sandbox_context->regs[ureg_rip] = 0; - sandbox_context->variant = arch_context_running; + active_context->gregs[REG_RSP] = sandbox_context->regs[ureg_rsp]; + active_context->gregs[REG_RIP] = sandbox_context->regs[ureg_rip] + ARCH_SIG_JMP_OFF; + sandbox_context->variant = arch_context_running; } /** @@ -101,9 +99,7 @@ arch_mcontext_save(struct arch_context *sandbox_context, const mcontext_t *activ assert(active_context->gregs[REG_RIP] != 0); assert(active_context->gregs[REG_RSP] != 0); - sandbox_context->variant = arch_context_slow; - sandbox_context->regs[ureg_rsp] = 0; - sandbox_context->regs[ureg_rip] = 0; + sandbox_context->variant = arch_context_slow; /* Copy mcontext */ memcpy(&sandbox_context->mctx, active_context, sizeof(mcontext_t)); diff --git a/runtime/include/arch/x86_64/context.h b/runtime/include/arch/x86_64/context.h index 95bbbf4..2aa3e0c 100644 --- a/runtime/include/arch/x86_64/context.h +++ b/runtime/include/arch/x86_64/context.h @@ -14,9 +14,6 @@ */ static void __attribute__((noinline)) arch_context_init(struct arch_context *actx, reg_t ip, reg_t sp) { - memset(&actx->mctx, 0, sizeof(mcontext_t)); - memset((void *)actx->regs, 0, sizeof(reg_t) * ureg_count); - if (sp) { /* * context_switch conventions: bp is expected to be on top of the stack