From 17a3b48454547c659dbd5fad66313006371b080e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 31 Jan 2018 11:18:41 +0300 Subject: [PATCH] Make IS_UNUSED to be zero. --- UPGRADING.INTERNALS | 4 ++++ Zend/zend.c | 12 ------------ Zend/zend_compile.h | 4 ++-- Zend/zend_opcode.c | 1 - Zend/zend_vm_execute.h | 24 ++++-------------------- Zend/zend_vm_gen.php | 24 ++++-------------------- 6 files changed, 14 insertions(+), 55 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 69e073a4d3..631ddf693c 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -15,6 +15,7 @@ PHP 7.3 INTERNALS UPGRADE NOTES l. php_hrtime_current() m. zend_cpu_supports() n. IS_TYPE_COPYABLE + o. IS_UNUSED 2. Build system changes a. Unix build system changes @@ -110,6 +111,9 @@ PHP 7.3 INTERNALS UPGRADE NOTES IS_ARRAY type (it may be IS_TYPE_REFCOUNTED or not). All the related macros: Z_COPYABLE..., Z_IMMUTABLE... are kept for compatibility. + o. IS_UNUSED became zero and can't be used as a bitmask (there were no such + usages in PHP sources). + ======================== 2. Build system changes ======================== diff --git a/Zend/zend.c b/Zend/zend.c index a915de1b3e..aae1d13b11 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -534,19 +534,10 @@ static void zend_init_exception_op(void) /* {{{ */ { memset(EG(exception_op), 0, sizeof(EG(exception_op))); EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION; - EG(exception_op)[0].op1_type = IS_UNUSED; - EG(exception_op)[0].op2_type = IS_UNUSED; - EG(exception_op)[0].result_type = IS_UNUSED; ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)); EG(exception_op)[1].opcode = ZEND_HANDLE_EXCEPTION; - EG(exception_op)[1].op1_type = IS_UNUSED; - EG(exception_op)[1].op2_type = IS_UNUSED; - EG(exception_op)[1].result_type = IS_UNUSED; ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+1); EG(exception_op)[2].opcode = ZEND_HANDLE_EXCEPTION; - EG(exception_op)[2].op1_type = IS_UNUSED; - EG(exception_op)[2].op2_type = IS_UNUSED; - EG(exception_op)[2].result_type = IS_UNUSED; ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+2); } /* }}} */ @@ -555,9 +546,6 @@ static void zend_init_call_trampoline_op(void) /* {{{ */ { memset(&EG(call_trampoline_op), 0, sizeof(EG(call_trampoline_op))); EG(call_trampoline_op).opcode = ZEND_CALL_TRAMPOLINE; - EG(call_trampoline_op).op1_type = IS_UNUSED; - EG(call_trampoline_op).op2_type = IS_UNUSED; - EG(call_trampoline_op).result_type = IS_UNUSED; ZEND_VM_SET_OPCODE_HANDLER(&EG(call_trampoline_op)); } /* }}} */ diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 44fe1f3074..228111e29e 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -660,11 +660,11 @@ struct _zend_execute_data { #endif +#define IS_UNUSED 0 /* Unused operand */ #define IS_CONST (1<<0) #define IS_TMP_VAR (1<<1) #define IS_VAR (1<<2) -#define IS_UNUSED (1<<3) /* Unused variable */ -#define IS_CV (1<<4) /* Compiled variable */ +#define IS_CV (1<<3) /* Compiled variable */ #include "zend_globals.h" diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index e814052ab4..a0301a9add 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -458,7 +458,6 @@ void init_op(zend_op *op) { memset(op, 0, sizeof(zend_op)); op->lineno = CG(zend_lineno); - SET_UNUSED(op->result); } zend_op *get_next_op(zend_op_array *op_array) diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 40341937fd..71b496d643 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -66995,7 +66995,7 @@ ZEND_API int zend_vm_kind(void) static const void *zend_vm_get_opcode_handler_ex(uint32_t spec, const zend_op* op) { static const int zend_vm_decode[] = { - _UNUSED_CODE, /* 0 */ + _UNUSED_CODE, /* 0 = IS_UNUSED */ _CONST_CODE, /* 1 = IS_CONST */ _TMP_CODE, /* 2 = IS_TMP_VAR */ _UNUSED_CODE, /* 3 */ @@ -67003,15 +67003,7 @@ static const void *zend_vm_get_opcode_handler_ex(uint32_t spec, const zend_op* o _UNUSED_CODE, /* 5 */ _UNUSED_CODE, /* 6 */ _UNUSED_CODE, /* 7 */ - _UNUSED_CODE, /* 8 = IS_UNUSED */ - _UNUSED_CODE, /* 9 */ - _UNUSED_CODE, /* 10 */ - _UNUSED_CODE, /* 11 */ - _UNUSED_CODE, /* 12 */ - _UNUSED_CODE, /* 13 */ - _UNUSED_CODE, /* 14 */ - _UNUSED_CODE, /* 15 */ - _CV_CODE /* 16 = IS_CV */ + _CV_CODE /* 8 = IS_CV */ }; uint32_t offset = 0; if (spec & SPEC_RULE_OP1) offset = offset * 5 + zend_vm_decode[op->op1_type]; @@ -67050,7 +67042,7 @@ static const void *zend_vm_get_opcode_handler_func(zend_uchar opcode, const zend { uint32_t spec = zend_spec_handlers[opcode]; static const int zend_vm_decode[] = { - _UNUSED_CODE, /* 0 */ + _UNUSED_CODE, /* 0 = IS_UNUSED */ _CONST_CODE, /* 1 = IS_CONST */ _TMP_CODE, /* 2 = IS_TMP_VAR */ _UNUSED_CODE, /* 3 */ @@ -67058,15 +67050,7 @@ static const void *zend_vm_get_opcode_handler_func(zend_uchar opcode, const zend _UNUSED_CODE, /* 5 */ _UNUSED_CODE, /* 6 */ _UNUSED_CODE, /* 7 */ - _UNUSED_CODE, /* 8 = IS_UNUSED */ - _UNUSED_CODE, /* 9 */ - _UNUSED_CODE, /* 10 */ - _UNUSED_CODE, /* 11 */ - _UNUSED_CODE, /* 12 */ - _UNUSED_CODE, /* 13 */ - _UNUSED_CODE, /* 14 */ - _UNUSED_CODE, /* 15 */ - _CV_CODE /* 16 = IS_CV */ + _CV_CODE /* 8 = IS_CV */ }; uint32_t offset = 0; if (spec & SPEC_RULE_OP1) offset = offset * 5 + zend_vm_decode[op->op1_type]; diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index 5d5f734a23..413d4de2e2 100644 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -2451,7 +2451,7 @@ function gen_vm($def, $skel) { out($f, "\treturn zend_opcode_handlers[spec];\n"); } else { out($f, "\tstatic const int zend_vm_decode[] = {\n"); - out($f, "\t\t_UNUSED_CODE, /* 0 */\n"); + out($f, "\t\t_UNUSED_CODE, /* 0 = IS_UNUSED */\n"); out($f, "\t\t_CONST_CODE, /* 1 = IS_CONST */\n"); out($f, "\t\t_TMP_CODE, /* 2 = IS_TMP_VAR */\n"); out($f, "\t\t_UNUSED_CODE, /* 3 */\n"); @@ -2459,15 +2459,7 @@ function gen_vm($def, $skel) { out($f, "\t\t_UNUSED_CODE, /* 5 */\n"); out($f, "\t\t_UNUSED_CODE, /* 6 */\n"); out($f, "\t\t_UNUSED_CODE, /* 7 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 8 = IS_UNUSED */\n"); - out($f, "\t\t_UNUSED_CODE, /* 9 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 10 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 11 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 12 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 13 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 14 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 15 */\n"); - out($f, "\t\t_CV_CODE /* 16 = IS_CV */\n"); + out($f, "\t\t_CV_CODE /* 8 = IS_CV */\n"); out($f, "\t};\n"); out($f, "\tuint32_t offset = 0;\n"); out($f, "\tif (spec & SPEC_RULE_OP1) offset = offset * 5 + zend_vm_decode[op->op1_type];\n"); @@ -2525,7 +2517,7 @@ function gen_vm($def, $skel) { out($f, "\treturn zend_opcode_handler_funcs[spec];\n"); } else { out($f, "\tstatic const int zend_vm_decode[] = {\n"); - out($f, "\t\t_UNUSED_CODE, /* 0 */\n"); + out($f, "\t\t_UNUSED_CODE, /* 0 = IS_UNUSED */\n"); out($f, "\t\t_CONST_CODE, /* 1 = IS_CONST */\n"); out($f, "\t\t_TMP_CODE, /* 2 = IS_TMP_VAR */\n"); out($f, "\t\t_UNUSED_CODE, /* 3 */\n"); @@ -2533,15 +2525,7 @@ function gen_vm($def, $skel) { out($f, "\t\t_UNUSED_CODE, /* 5 */\n"); out($f, "\t\t_UNUSED_CODE, /* 6 */\n"); out($f, "\t\t_UNUSED_CODE, /* 7 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 8 = IS_UNUSED */\n"); - out($f, "\t\t_UNUSED_CODE, /* 9 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 10 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 11 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 12 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 13 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 14 */\n"); - out($f, "\t\t_UNUSED_CODE, /* 15 */\n"); - out($f, "\t\t_CV_CODE /* 16 = IS_CV */\n"); + out($f, "\t\t_CV_CODE /* 8 = IS_CV */\n"); out($f, "\t};\n"); out($f, "\tuint32_t offset = 0;\n"); out($f, "\tif (spec & SPEC_RULE_OP1) offset = offset * 5 + zend_vm_decode[op->op1_type];\n"); -- 2.40.0