From 6d681876eed27e4d048b64f51188a64efcd2aff4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 6 Aug 2015 15:40:40 +0300 Subject: [PATCH] Get rid of memcpy() in MAKE_NOP() --- Zend/zend_compile.h | 12 +++++++----- ext/opcache/Optimizer/zend_optimizer_internal.h | 17 ++++++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 2db45e54fe..e3c2b00ea8 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -36,11 +36,13 @@ #define SET_UNUSED(op) op ## _type = IS_UNUSED #define MAKE_NOP(opline) do { \ - opline->opcode = ZEND_NOP; \ - memset(&opline->result, 0, sizeof(opline->result)); \ - memset(&opline->op1, 0, sizeof(opline->op1)); \ - memset(&opline->op2, 0, sizeof(opline->op2)); \ - opline->result_type = opline->op1_type = opline->op2_type = IS_UNUSED; \ + (opline)->op1.num = 0; \ + (opline)->op2.num = 0; \ + (opline)->result.num = 0; \ + (opline)->opcode = ZEND_NOP; \ + (opline)->op1_type = IS_UNUSED; \ + (opline)->op2_type = IS_UNUSED; \ + (opline)->result_type = IS_UNUSED; \ } while (0) #define RESET_DOC_COMMENT() do { \ diff --git a/ext/opcache/Optimizer/zend_optimizer_internal.h b/ext/opcache/Optimizer/zend_optimizer_internal.h index c2f97ff715..ca452670d7 100644 --- a/ext/opcache/Optimizer/zend_optimizer_internal.h +++ b/ext/opcache/Optimizer/zend_optimizer_internal.h @@ -34,14 +34,17 @@ #undef MAKE_NOP -#define MAKE_NOP(opline) do { \ +#define MAKE_NOP(opline) do { \ + (opline)->op1.num = 0; \ + (opline)->op2.num = 0; \ + (opline)->result.num = 0; \ (opline)->opcode = ZEND_NOP; \ - memset(&(opline)->result, 0, sizeof((opline)->result)); \ - memset(&(opline)->op1, 0, sizeof((opline)->op1)); \ - memset(&(opline)->op2, 0, sizeof((opline)->op2)); \ - (opline)->result_type = (opline)->op1_type = (opline)->op2_type=IS_UNUSED; \ - zend_vm_set_opcode_handler(opline); \ -} while (0); + (opline)->op1_type = IS_UNUSED; \ + (opline)->op2_type = IS_UNUSED; \ + (opline)->result_type = IS_UNUSED; \ + zend_vm_set_opcode_handler(opline); \ +} while (0) + #define RESULT_USED(op) (((op->result_type & IS_VAR) && !(op->result_type & EXT_TYPE_UNUSED)) || op->result_type == IS_TMP_VAR) #define RESULT_UNUSED(op) ((op->result_type & EXT_TYPE_UNUSED) != 0) #define SAME_VAR(op1, op2) ((((op1 ## _type & IS_VAR) && (op2 ## _type & IS_VAR)) || (op1 ## _type == IS_TMP_VAR && op2 ## _type == IS_TMP_VAR)) && op1.var == op2.var) -- 2.40.0