Changed ZEND_CLONE->extended_value meaning to relative offset (previously it was absolute opline number)

This commit is contained in:
Dmitry Stogov 2015-10-30 14:53:53 +03:00
parent 880965b95e
commit 3e89c883bb
7 changed files with 82 additions and 73 deletions

View file

@ -646,6 +646,10 @@ ZEND_API int pass_two(zend_op_array *op_array)
case ZEND_DECLARE_ANON_CLASS:
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
break;
case ZEND_CATCH:
/* absolute index to relative offset */
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
break;
case ZEND_JMPZNZ:
/* absolute index to relative offset */
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);

View file

@ -2591,7 +2591,7 @@ ZEND_VM_HANDLER(44, ZEND_JMPNZ, CONST|TMPVAR|CV, JMP_ADDR)
ZEND_VM_JMP(opline);
}
ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, JMP_ADDR, JMP_REL)
ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, JMP_ADDR, JMP_ADDR)
{
USE_OPLINE
zend_free_op free_op1;
@ -4205,7 +4205,7 @@ ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY)
HANDLE_EXCEPTION();
}
ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ADDR)
{
USE_OPLINE
zend_class_entry *ce, *catch_ce;
@ -4215,8 +4215,8 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
/* Check whether an exception has been thrown, if not, jump over code */
zend_exception_restore();
if (EG(exception) == NULL) {
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
ZEND_VM_CONTINUE(); /* CHECK_ME */
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
ZEND_VM_CONTINUE();
}
catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
if (UNEXPECTED(catch_ce == NULL)) {
@ -4238,8 +4238,8 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
zend_throw_exception_internal(NULL);
HANDLE_EXCEPTION();
}
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
ZEND_VM_CONTINUE(); /* CHECK_ME */
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
ZEND_VM_CONTINUE();
}
}
@ -6097,7 +6097,7 @@ ZEND_VM_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR)
}
}
ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_REL)
ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR)
{
USE_OPLINE
zval *array;
@ -6274,7 +6274,7 @@ ZEND_VM_C_LABEL(fe_fetch_r_exit):
ZEND_VM_NEXT_OPCODE();
}
ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_REL)
ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR)
{
USE_OPLINE
zval *array;

View file

@ -9395,8 +9395,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
/* Check whether an exception has been thrown, if not, jump over code */
zend_exception_restore();
if (EG(exception) == NULL) {
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
ZEND_VM_CONTINUE(); /* CHECK_ME */
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
ZEND_VM_CONTINUE();
}
catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
if (UNEXPECTED(catch_ce == NULL)) {
@ -9418,8 +9418,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
zend_throw_exception_internal(NULL);
HANDLE_EXCEPTION();
}
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
ZEND_VM_CONTINUE(); /* CHECK_ME */
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
ZEND_VM_CONTINUE();
}
}

View file

@ -71,18 +71,17 @@ $vm_op_flags = array(
"ZEND_VM_EXT_NUM" => 1<<16,
"ZEND_VM_EXT_VAR" => 1<<17,
"ZEND_VM_EXT_JMP_ABS" => 1<<18,
"ZEND_VM_EXT_JMP_REL" => 1<<19,
"ZEND_VM_EXT_DIM_OBJ" => 1<<20,
"ZEND_VM_EXT_CLASS_FETCH" => 1<<21,
"ZEND_VM_EXT_CONST_FETCH" => 1<<22,
"ZEND_VM_EXT_VAR_FETCH" => 1<<23,
"ZEND_VM_EXT_ARRAY_INIT" => 1<<24,
"ZEND_VM_EXT_TYPE" => 1<<25,
"ZEND_VM_EXT_EVAL" => 1<<26,
"ZEND_VM_EXT_FAST_CALL" => 1<<27,
"ZEND_VM_EXT_FAST_RET" => 1<<28,
"ZEND_VM_EXT_ISSET" => 1<<29,
"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,
);
foreach ($vm_op_flags as $name => $val) {
@ -105,8 +104,7 @@ $vm_op_decode = array(
$vm_ext_decode = array(
"NUM" => ZEND_VM_EXT_NUM,
"VAR" => ZEND_VM_EXT_VAR,
"JMP_ABS" => ZEND_VM_EXT_JMP_ABS,
"JMP_REL" => ZEND_VM_EXT_JMP_REL,
"JMP_ADDR" => ZEND_VM_EXT_JMP_ADDR,
"DIM_OBJ" => ZEND_VM_EXT_DIM_OBJ,
"CLASS_FETCH" => ZEND_VM_EXT_CLASS_FETCH,
"CONST_FETCH" => ZEND_VM_EXT_CONST_FETCH,

View file

@ -228,19 +228,19 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00000707,
0x00000707,
0x00000707,
0x02000003,
0x01000003,
0x00000003,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00100701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00080701,
0x00000001,
0x00000001,
0x00000001,
@ -252,7 +252,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00000010,
0x00001007,
0x00001007,
0x00081007,
0x00041007,
0x00001007,
0x00001007,
0x00000707,
@ -278,35 +278,35 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00011003,
0x00010300,
0x00000005,
0x01000703,
0x00800703,
0x00010703,
0x04000007,
0x00800107,
0x02000007,
0x00400107,
0x00000701,
0x00000701,
0x00001003,
0x00080001,
0x00040001,
0x00000007,
0x00800107,
0x00400107,
0x00000707,
0x00000703,
0x00800107,
0x00400107,
0x00000701,
0x00000701,
0x00800107,
0x00400107,
0x00000701,
0x00000701,
0x00800107,
0x00400107,
0x00000707,
0x00000707,
0x00800107,
0x00400107,
0x00000703,
0x00000703,
0x00800107,
0x00400107,
0x00000701,
0x00000701,
0x00000307,
0x00400301,
0x00200301,
0x00000000,
0x00000000,
0x00000000,
@ -316,13 +316,13 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00000801,
0x00040103,
0x00000003,
0x00200700,
0x00100700,
0x00000007,
0x00000003,
0x00010707,
0x00010703,
0x20800107,
0x20000707,
0x10400107,
0x10000707,
0x00000803,
0x00000801,
0x00010703,
@ -330,10 +330,10 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00000801,
0x00000007,
0x00000003,
0x02000003,
0x01000003,
0x00000103,
0x00001003,
0x00080001,
0x00040001,
0x00000005,
0x00010700,
0x00000000,
@ -355,7 +355,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00020000,
0x00000000,
0x00000701,
0x20000707,
0x10000707,
0x00000000,
0x00000000,
0x00001000,
@ -364,17 +364,17 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00000000,
0x00000000,
0x00000101,
0x00200000,
0x00100000,
0x00000000,
0x00000000,
0x00000303,
0x00000003,
0x08002010,
0x10002000,
0x04002010,
0x08002000,
0x00000008,
0x00000000,
0x00000707,
0x00100701,
0x00080701,
0x00000301,
0x00001003,
0x00000707,
@ -387,7 +387,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
0x00000307,
0x00000307,
0x00000307,
0x20000307,
0x10000307,
0x00000303,
};

View file

@ -42,18 +42,17 @@
#define ZEND_VM_OP2_JMP_ABS 0x00002000
#define ZEND_VM_EXT_NUM 0x00010000
#define ZEND_VM_EXT_VAR 0x00020000
#define ZEND_VM_EXT_JMP_ABS 0x00040000
#define ZEND_VM_EXT_JMP_REL 0x00080000
#define ZEND_VM_EXT_DIM_OBJ 0x00100000
#define ZEND_VM_EXT_CLASS_FETCH 0x00200000
#define ZEND_VM_EXT_CONST_FETCH 0x00400000
#define ZEND_VM_EXT_VAR_FETCH 0x00800000
#define ZEND_VM_EXT_ARRAY_INIT 0x01000000
#define ZEND_VM_EXT_TYPE 0x02000000
#define ZEND_VM_EXT_EVAL 0x04000000
#define ZEND_VM_EXT_FAST_CALL 0x08000000
#define ZEND_VM_EXT_FAST_RET 0x10000000
#define ZEND_VM_EXT_ISSET 0x20000000
#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
BEGIN_EXTERN_C()

View file

@ -516,6 +516,10 @@ static void zend_accel_optimize(zend_op_array *op_array,
case ZEND_DECLARE_ANON_INHERITED_CLASS:
ZEND_PASS_TWO_UNDO_JMP_TARGET(op_array, opline, ZEND_OP1(opline));
break;
case ZEND_CATCH:
/* relative offset into absolute index */
opline->extended_value = ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value);
break;
case ZEND_JMPZNZ:
/* relative offset into absolute index */
opline->extended_value = ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value);
@ -560,6 +564,10 @@ static void zend_accel_optimize(zend_op_array *op_array,
case ZEND_DECLARE_ANON_INHERITED_CLASS:
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, ZEND_OP1(opline));
break;
case ZEND_CATCH:
/* absolute index to relative offset */
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
break;
case ZEND_JMPZNZ:
/* absolute index to relative offset */
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);