From: Dmitry Stogov Date: Thu, 10 Dec 2015 22:45:26 +0000 (+0300) Subject: Use more compact description encoding schema to free some bits X-Git-Tag: php-7.1.0alpha1~667 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc368109932fbde3b6edc2c59ff7edd4f01cfe4c;p=php Use more compact description encoding schema to free some bits --- diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index e2e1859172..31104fd975 100644 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -58,35 +58,38 @@ $vm_op_flags = array( "ZEND_VM_OP1_SPEC" => 1<<0, "ZEND_VM_OP1_CONST" => 1<<1, "ZEND_VM_OP1_TMPVAR" => 1<<2, - "ZEND_VM_OP1_NUM" => 1<<3, - "ZEND_VM_OP1_JMP_ADDR" => 1<<4, - "ZEND_VM_OP1_TRY_CATCH" => 1<<5, - "ZEND_VM_OP1_LIVE_RANGE" => 1<<6, + "ZEND_VM_OP1_MASK" => 0xf0, + "ZEND_VM_OP1_NUM" => 0x10, + "ZEND_VM_OP1_JMP_ADDR" => 0x20, + "ZEND_VM_OP1_TRY_CATCH" => 0x30, + "ZEND_VM_OP1_LIVE_RANGE" => 0x40, "ZEND_VM_OP2_SPEC" => 1<<8, "ZEND_VM_OP2_CONST" => 1<<9, "ZEND_VM_OP2_TMPVAR" => 1<<10, - "ZEND_VM_OP2_NUM" => 1<<11, - "ZEND_VM_OP2_JMP_ADDR" => 1<<12, - "ZEND_VM_OP2_TRY_CATCH" => 1<<13, - "ZEND_VM_OP2_LIVE_RANGE" => 1<<14, - - "ZEND_VM_EXT_NUM" => 1<<16, - "ZEND_VM_EXT_VAR" => 1<<17, - "ZEND_VM_EXT_JMP_ADDR" => 1<<18, - "ZEND_VM_EXT_DIM_OBJ" => 1<<19, - "ZEND_VM_EXT_CLASS_FETCH" => 1<<20, - "ZEND_VM_EXT_CONST_FETCH" => 1<<21, - "ZEND_VM_EXT_VAR_FETCH" => 1<<22, - "ZEND_VM_EXT_ARRAY_INIT" => 1<<23, - "ZEND_VM_EXT_TYPE" => 1<<24, - "ZEND_VM_EXT_EVAL" => 1<<25, - "ZEND_VM_EXT_FAST_CALL" => 1<<26, - "ZEND_VM_EXT_FAST_RET" => 1<<27, - "ZEND_VM_EXT_ISSET" => 1<<28, - "ZEND_VM_EXT_ARG_NUM" => 1<<29, - "ZEND_VM_EXT_REF" => 1<<30, - "ZEND_VM_EXT_SRC" => 1<<31, + "ZEND_VM_OP2_MASK" => 0xf000, + "ZEND_VM_OP2_NUM" => 0x1000, + "ZEND_VM_OP2_JMP_ADDR" => 0x2000, + "ZEND_VM_OP2_TRY_CATCH" => 0x3000, + "ZEND_VM_OP2_LIVE_RANGE" => 0x4000, + + "ZEND_VM_EXT_VAR_FETCH" => 1<<16, + "ZEND_VM_EXT_ISSET" => 1<<17, + "ZEND_VM_EXT_ARG_NUM" => 1<<18, + "ZEND_VM_EXT_ARRAY_INIT" => 1<<19, + "ZEND_VM_EXT_REF" => 1<<20, + "ZEND_VM_EXT_MASK" => 0xff000000, + "ZEND_VM_EXT_NUM" => 0x01000000, + "ZEND_VM_EXT_VAR" => 0x02000000, + "ZEND_VM_EXT_JMP_ADDR" => 0x03000000, + "ZEND_VM_EXT_DIM_OBJ" => 0x04000000, + "ZEND_VM_EXT_CLASS_FETCH" => 0x05000000, + "ZEND_VM_EXT_CONST_FETCH" => 0x06000000, + "ZEND_VM_EXT_TYPE" => 0x07000000, + "ZEND_VM_EXT_EVAL" => 0x08000000, + "ZEND_VM_EXT_FAST_CALL" => 0x09000000, + "ZEND_VM_EXT_FAST_RET" => 0x0a000000, + "ZEND_VM_EXT_SRC" => 0x0b000000, ); foreach ($vm_op_flags as $name => $val) { diff --git a/Zend/zend_vm_opcodes.c b/Zend/zend_vm_opcodes.c index 2e9a13f6a4..61edefe96b 100644 --- a/Zend/zend_vm_opcodes.c +++ b/Zend/zend_vm_opcodes.c @@ -228,114 +228,114 @@ static uint32_t zend_vm_opcodes_flags[182] = { 0x00000707, 0x00000707, 0x00000707, - 0x01000003, + 0x07000003, 0x00000003, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, - 0x00080701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, + 0x04000701, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000301, - 0x80000101, + 0x0b000101, 0x00000007, 0x00000000, - 0x00000010, - 0x00001007, - 0x00001007, - 0x00041007, - 0x00001007, - 0x00001007, + 0x00000020, + 0x00002007, + 0x00002007, + 0x03002007, + 0x00002007, + 0x00002007, 0x00000707, 0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000707, - 0x00010701, - 0x00010701, - 0x00010701, + 0x01000701, + 0x01000701, + 0x01000701, 0x00000000, 0x00000001, - 0x00010300, + 0x01000300, 0x00000000, - 0x00010300, + 0x01000300, 0x00000003, - 0x00000008, - 0x00000308, - 0x00000803, - 0x00000801, - 0x00000801, - 0x00011003, - 0x00010300, + 0x00000010, + 0x00000310, + 0x00001003, + 0x00001001, + 0x00001001, + 0x01002003, + 0x01000300, 0x00004005, - 0x40800703, - 0x40000703, - 0x02000007, - 0x10400107, + 0x00180703, + 0x00100703, + 0x08000007, + 0x00030107, 0x00000701, 0x00000701, - 0x00001003, - 0x00040001, + 0x00002003, + 0x03000001, 0x00000007, - 0x00400107, + 0x00010107, 0x00000707, 0x00000703, - 0x00400107, + 0x00010107, 0x00000701, 0x00000701, - 0x00400107, + 0x00010107, 0x00000701, 0x00000701, - 0x00400107, + 0x00010107, 0x00000707, 0x00000707, - 0x20400107, - 0x00010703, - 0x00010703, - 0x00400107, + 0x00050107, + 0x01000703, + 0x01000703, + 0x00010107, 0x00000701, 0x00000701, 0x00000307, - 0x00200301, + 0x06000301, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00010000, - 0x00010801, - 0x00040103, + 0x01000000, + 0x01001001, + 0x03000103, 0x00000003, - 0x00100700, + 0x05000700, 0x00000007, - 0x80000003, - 0x00010707, - 0x00010703, - 0x10400107, - 0x10000707, - 0x00000803, - 0x00000801, - 0x00010703, + 0x0b000003, + 0x01000707, + 0x01000703, + 0x00030107, + 0x00020707, + 0x00001003, + 0x00001001, + 0x01000703, 0x00000000, - 0x00000801, + 0x00001001, 0x00000007, 0x00000003, - 0x01000003, + 0x07000003, 0x00000103, - 0x00001003, - 0x00040001, + 0x00002003, + 0x03000001, 0x00004005, - 0x00010700, + 0x01000700, 0x00000000, 0x00000000, 0x00000000, @@ -347,47 +347,47 @@ static uint32_t zend_vm_opcodes_flags[182] = { 0x00000000, 0x00000305, 0x00000000, - 0x00020000, + 0x02000000, 0x00000000, 0x00000003, 0x00000303, 0x00000300, - 0x00020000, + 0x02000000, 0x00000000, 0x00000701, - 0x10000707, + 0x00020707, 0x00000000, 0x00000000, - 0x00001000, - 0x00001003, + 0x00002000, + 0x00002003, 0x00000103, 0x00000000, 0x00000000, 0x00000101, - 0x00100000, + 0x05000000, 0x00000000, 0x00000000, - 0x80000303, + 0x0b000303, 0x00000003, - 0x04002010, - 0x08002000, - 0x00000008, + 0x09003020, + 0x0a003000, + 0x00000010, 0x00000000, 0x00000707, - 0x00080701, + 0x04000701, 0x00000301, - 0x00001003, + 0x00002003, 0x00000707, - 0x00000010, - 0x00020010, + 0x00000020, + 0x02000020, 0x00000307, 0x00000307, 0x00000307, 0x00000307, - 0x00010307, + 0x01000307, 0x00000307, 0x00000307, - 0x10000307, + 0x00020307, 0x00000303, }; diff --git a/Zend/zend_vm_opcodes.h b/Zend/zend_vm_opcodes.h index 8d156a98d2..358afc6fe1 100644 --- a/Zend/zend_vm_opcodes.h +++ b/Zend/zend_vm_opcodes.h @@ -31,33 +31,36 @@ #define ZEND_VM_OP1_SPEC 0x00000001 #define ZEND_VM_OP1_CONST 0x00000002 #define ZEND_VM_OP1_TMPVAR 0x00000004 -#define ZEND_VM_OP1_NUM 0x00000008 -#define ZEND_VM_OP1_JMP_ADDR 0x00000010 -#define ZEND_VM_OP1_TRY_CATCH 0x00000020 +#define ZEND_VM_OP1_MASK 0x000000f0 +#define ZEND_VM_OP1_NUM 0x00000010 +#define ZEND_VM_OP1_JMP_ADDR 0x00000020 +#define ZEND_VM_OP1_TRY_CATCH 0x00000030 #define ZEND_VM_OP1_LIVE_RANGE 0x00000040 #define ZEND_VM_OP2_SPEC 0x00000100 #define ZEND_VM_OP2_CONST 0x00000200 #define ZEND_VM_OP2_TMPVAR 0x00000400 -#define ZEND_VM_OP2_NUM 0x00000800 -#define ZEND_VM_OP2_JMP_ADDR 0x00001000 -#define ZEND_VM_OP2_TRY_CATCH 0x00002000 +#define ZEND_VM_OP2_MASK 0x0000f000 +#define ZEND_VM_OP2_NUM 0x00001000 +#define ZEND_VM_OP2_JMP_ADDR 0x00002000 +#define ZEND_VM_OP2_TRY_CATCH 0x00003000 #define ZEND_VM_OP2_LIVE_RANGE 0x00004000 -#define ZEND_VM_EXT_NUM 0x00010000 -#define ZEND_VM_EXT_VAR 0x00020000 -#define ZEND_VM_EXT_JMP_ADDR 0x00040000 -#define ZEND_VM_EXT_DIM_OBJ 0x00080000 -#define ZEND_VM_EXT_CLASS_FETCH 0x00100000 -#define ZEND_VM_EXT_CONST_FETCH 0x00200000 -#define ZEND_VM_EXT_VAR_FETCH 0x00400000 -#define ZEND_VM_EXT_ARRAY_INIT 0x00800000 -#define ZEND_VM_EXT_TYPE 0x01000000 -#define ZEND_VM_EXT_EVAL 0x02000000 -#define ZEND_VM_EXT_FAST_CALL 0x04000000 -#define ZEND_VM_EXT_FAST_RET 0x08000000 -#define ZEND_VM_EXT_ISSET 0x10000000 -#define ZEND_VM_EXT_ARG_NUM 0x20000000 -#define ZEND_VM_EXT_REF 0x40000000 -#define ZEND_VM_EXT_SRC 0x80000000 +#define ZEND_VM_EXT_VAR_FETCH 0x00010000 +#define ZEND_VM_EXT_ISSET 0x00020000 +#define ZEND_VM_EXT_ARG_NUM 0x00040000 +#define ZEND_VM_EXT_ARRAY_INIT 0x00080000 +#define ZEND_VM_EXT_REF 0x00100000 +#define ZEND_VM_EXT_MASK 0xff000000 +#define ZEND_VM_EXT_NUM 0x01000000 +#define ZEND_VM_EXT_VAR 0x02000000 +#define ZEND_VM_EXT_JMP_ADDR 0x03000000 +#define ZEND_VM_EXT_DIM_OBJ 0x04000000 +#define ZEND_VM_EXT_CLASS_FETCH 0x05000000 +#define ZEND_VM_EXT_CONST_FETCH 0x06000000 +#define ZEND_VM_EXT_TYPE 0x07000000 +#define ZEND_VM_EXT_EVAL 0x08000000 +#define ZEND_VM_EXT_FAST_CALL 0x09000000 +#define ZEND_VM_EXT_FAST_RET 0x0a000000 +#define ZEND_VM_EXT_SRC 0x0b000000 BEGIN_EXTERN_C() diff --git a/ext/opcache/Optimizer/zend_dump.c b/ext/opcache/Optimizer/zend_dump.c index 66a28e31a3..24a164dda7 100644 --- a/ext/opcache/Optimizer/zend_dump.c +++ b/ext/opcache/Optimizer/zend_dump.c @@ -62,15 +62,15 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * len = fprintf(stderr, "L%u:", (uint32_t)(opline - op_array->opcodes)); } fprintf(stderr, "%*c%s", 8-len, ' ', name ? (name + 5) : "???"); - if (ZEND_VM_EXT_NUM & flags) { + if (ZEND_VM_EXT_NUM == (flags & ZEND_VM_EXT_MASK)) { fprintf(stderr, " %u", opline->extended_value); - } else if (ZEND_VM_EXT_DIM_OBJ & flags) { + } else if (ZEND_VM_EXT_DIM_OBJ == (flags & ZEND_VM_EXT_MASK)) { if (opline->extended_value == ZEND_ASSIGN_DIM) { fprintf(stderr, " (dim)"); } else if (opline->extended_value == ZEND_ASSIGN_OBJ) { fprintf(stderr, " (obj)"); } - } else if (ZEND_VM_EXT_CLASS_FETCH & flags) { + } else if (ZEND_VM_EXT_CLASS_FETCH == (flags & ZEND_VM_EXT_MASK)) { switch (opline->extended_value & ZEND_FETCH_CLASS_MASK) { case ZEND_FETCH_CLASS_SELF: fprintf(stderr, " (self)"); @@ -100,7 +100,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * if (opline->extended_value & ZEND_FETCH_CLASS_EXCEPTION) { fprintf(stderr, " (exception)"); } - } else if (ZEND_VM_EXT_CONST_FETCH & flags) { + } else if (ZEND_VM_EXT_CONST_FETCH == (flags & ZEND_VM_EXT_MASK)) { if (opline->extended_value & IS_CONSTANT_UNQUALIFIED) { fprintf(stderr, " (unqualified)"); } @@ -110,7 +110,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * if (opline->extended_value & IS_CONSTANT_IN_NAMESPACE) { fprintf(stderr, " (in-namespace)"); } - } else if (ZEND_VM_EXT_TYPE & flags) { + } else if (ZEND_VM_EXT_TYPE == (flags & ZEND_VM_EXT_MASK)) { switch (opline->extended_value) { case IS_NULL: fprintf(stderr, " (null)"); @@ -152,7 +152,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * fprintf(stderr, " (\?\?\?)"); break; } - } else if (ZEND_VM_EXT_EVAL & flags) { + } else if (ZEND_VM_EXT_EVAL == (flags & ZEND_VM_EXT_MASK)) { switch (opline->extended_value) { case ZEND_EVAL: fprintf(stderr, " (eval)"); @@ -173,17 +173,17 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * fprintf(stderr, " (\?\?\?)"); break; } - } else if (ZEND_VM_EXT_FAST_CALL & flags) { + } else if (ZEND_VM_EXT_FAST_CALL == (flags & ZEND_VM_EXT_MASK)) { if (opline->extended_value == ZEND_FAST_CALL_FROM_FINALLY) { fprintf(stderr, " (from-finally)"); } - } else if (ZEND_VM_EXT_FAST_RET & flags) { + } else if (ZEND_VM_EXT_FAST_RET == (flags & ZEND_VM_EXT_MASK)) { if (opline->extended_value == ZEND_FAST_RET_TO_CATCH) { fprintf(stderr, " (to-catch)"); } else if (opline->extended_value == ZEND_FAST_RET_TO_FINALLY) { fprintf(stderr, " (to-finally)"); } - } else if (ZEND_VM_EXT_SRC & flags) { + } else if (ZEND_VM_EXT_SRC == (flags & ZEND_VM_EXT_MASK)) { if (opline->extended_value == ZEND_RETURNS_VALUE) { fprintf(stderr, " (value)"); } else if (opline->extended_value == ZEND_RETURNS_FUNCTION) { @@ -234,17 +234,17 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * } } } - if (ZEND_VM_OP1_JMP_ADDR & flags) { + if (ZEND_VM_OP1_JMP_ADDR == (flags & ZEND_VM_OP1_MASK)) { if (b) { fprintf(stderr, " BB%d", b->successors[n++]); } else { fprintf(stderr, " L%u", (uint32_t)(OP_JMP_ADDR(opline, opline->op1) - op_array->opcodes)); } - } else if (ZEND_VM_OP1_NUM & flags) { + } else if (ZEND_VM_OP1_NUM == (flags & ZEND_VM_OP1_MASK)) { fprintf(stderr, " %u", opline->op1.num); - } else if (ZEND_VM_OP1_TRY_CATCH & flags) { + } else if (ZEND_VM_OP1_TRY_CATCH == (flags & ZEND_VM_OP1_MASK)) { fprintf(stderr, " try-catch(%u)", opline->op1.num); - } else if (ZEND_VM_OP1_LIVE_RANGE & flags) { + } else if (ZEND_VM_OP1_LIVE_RANGE == (flags & ZEND_VM_OP1_MASK)) { if (opline->extended_value & ZEND_FREE_ON_RETURN) { fprintf(stderr, " live-range(%u)", opline->op1.num); } @@ -257,17 +257,17 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * } else if ( opline->op1_type == IS_TMP_VAR) { fprintf(stderr, " T%u", EX_VAR_TO_NUM(opline->op1.var)); } - if (ZEND_VM_OP2_JMP_ADDR & flags) { + if (ZEND_VM_OP2_JMP_ADDR == (flags & ZEND_VM_OP2_MASK)) { if (b) { fprintf(stderr, " BB%d", b->successors[n++]); } else { fprintf(stderr, " L%u", (uint32_t)(OP_JMP_ADDR(opline, opline->op2) - op_array->opcodes)); } - } else if (ZEND_VM_OP2_NUM & flags) { + } else if (ZEND_VM_OP2_NUM == (flags & ZEND_VM_OP2_MASK)) { fprintf(stderr, " %u", opline->op2.num); - } else if (ZEND_VM_OP2_TRY_CATCH & flags) { + } else if (ZEND_VM_OP2_TRY_CATCH == (flags & ZEND_VM_OP2_MASK)) { fprintf(stderr, " try-catch(%u)", opline->op2.num); - } else if (ZEND_VM_OP2_LIVE_RANGE & flags) { + } else if (ZEND_VM_OP2_LIVE_RANGE == (flags & ZEND_VM_OP2_MASK)) { if (opline->extended_value & ZEND_FREE_ON_RETURN) { fprintf(stderr, " live-range(%u)", opline->op2.num); } @@ -280,7 +280,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * } else if ( opline->op2_type == IS_TMP_VAR) { fprintf(stderr, " T%u", EX_VAR_TO_NUM(opline->op2.var)); } - if (ZEND_VM_EXT_JMP_ADDR & flags) { + if (ZEND_VM_EXT_JMP_ADDR == (flags & ZEND_VM_EXT_MASK)) { if (opline->opcode != ZEND_CATCH || !opline->result.num) { if (b) { fprintf(stderr, " BB%d", b->successors[n++]); @@ -288,7 +288,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * fprintf(stderr, " L%u", (uint32_t)ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value)); } } - } else if (ZEND_VM_EXT_VAR & flags) { + } else if (ZEND_VM_EXT_VAR == (flags & ZEND_VM_EXT_MASK)) { fprintf(stderr, " V%u", EX_VAR_TO_NUM(opline->extended_value)); } if (opline->result_type == IS_CONST) {