Skip to content

Commit 3e89c88

Browse files
committed
Changed ZEND_CLONE->extended_value meaning to relative offset (previously it was absolute opline number)
1 parent 880965b commit 3e89c88

File tree

7 files changed

+82
-73
lines changed

7 files changed

+82
-73
lines changed

Zend/zend_opcode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ ZEND_API int pass_two(zend_op_array *op_array)
646646
case ZEND_DECLARE_ANON_CLASS:
647647
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
648648
break;
649+
case ZEND_CATCH:
650+
/* absolute index to relative offset */
651+
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
652+
break;
649653
case ZEND_JMPZNZ:
650654
/* absolute index to relative offset */
651655
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);

Zend/zend_vm_def.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,7 +2591,7 @@ ZEND_VM_HANDLER(44, ZEND_JMPNZ, CONST|TMPVAR|CV, JMP_ADDR)
25912591
ZEND_VM_JMP(opline);
25922592
}
25932593

2594-
ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, JMP_ADDR, JMP_REL)
2594+
ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, JMP_ADDR, JMP_ADDR)
25952595
{
25962596
USE_OPLINE
25972597
zend_free_op free_op1;
@@ -4205,7 +4205,7 @@ ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY)
42054205
HANDLE_EXCEPTION();
42064206
}
42074207

4208-
ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
4208+
ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ADDR)
42094209
{
42104210
USE_OPLINE
42114211
zend_class_entry *ce, *catch_ce;
@@ -4215,8 +4215,8 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
42154215
/* Check whether an exception has been thrown, if not, jump over code */
42164216
zend_exception_restore();
42174217
if (EG(exception) == NULL) {
4218-
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
4219-
ZEND_VM_CONTINUE(); /* CHECK_ME */
4218+
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
4219+
ZEND_VM_CONTINUE();
42204220
}
42214221
catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
42224222
if (UNEXPECTED(catch_ce == NULL)) {
@@ -4238,8 +4238,8 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
42384238
zend_throw_exception_internal(NULL);
42394239
HANDLE_EXCEPTION();
42404240
}
4241-
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
4242-
ZEND_VM_CONTINUE(); /* CHECK_ME */
4241+
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
4242+
ZEND_VM_CONTINUE();
42434243
}
42444244
}
42454245

@@ -6097,7 +6097,7 @@ ZEND_VM_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR)
60976097
}
60986098
}
60996099

6100-
ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_REL)
6100+
ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR)
61016101
{
61026102
USE_OPLINE
61036103
zval *array;
@@ -6274,7 +6274,7 @@ ZEND_VM_C_LABEL(fe_fetch_r_exit):
62746274
ZEND_VM_NEXT_OPCODE();
62756275
}
62766276

6277-
ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_REL)
6277+
ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR)
62786278
{
62796279
USE_OPLINE
62806280
zval *array;

Zend/zend_vm_execute.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9395,8 +9395,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
93959395
/* Check whether an exception has been thrown, if not, jump over code */
93969396
zend_exception_restore();
93979397
if (EG(exception) == NULL) {
9398-
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
9399-
ZEND_VM_CONTINUE(); /* CHECK_ME */
9398+
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
9399+
ZEND_VM_CONTINUE();
94009400
}
94019401
catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
94029402
if (UNEXPECTED(catch_ce == NULL)) {
@@ -9418,8 +9418,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
94189418
zend_throw_exception_internal(NULL);
94199419
HANDLE_EXCEPTION();
94209420
}
9421-
ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
9422-
ZEND_VM_CONTINUE(); /* CHECK_ME */
9421+
ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
9422+
ZEND_VM_CONTINUE();
94239423
}
94249424
}
94259425

Zend/zend_vm_gen.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@
7171

7272
"ZEND_VM_EXT_NUM" => 1<<16,
7373
"ZEND_VM_EXT_VAR" => 1<<17,
74-
"ZEND_VM_EXT_JMP_ABS" => 1<<18,
75-
"ZEND_VM_EXT_JMP_REL" => 1<<19,
76-
"ZEND_VM_EXT_DIM_OBJ" => 1<<20,
77-
"ZEND_VM_EXT_CLASS_FETCH" => 1<<21,
78-
"ZEND_VM_EXT_CONST_FETCH" => 1<<22,
79-
"ZEND_VM_EXT_VAR_FETCH" => 1<<23,
80-
"ZEND_VM_EXT_ARRAY_INIT" => 1<<24,
81-
"ZEND_VM_EXT_TYPE" => 1<<25,
82-
"ZEND_VM_EXT_EVAL" => 1<<26,
83-
"ZEND_VM_EXT_FAST_CALL" => 1<<27,
84-
"ZEND_VM_EXT_FAST_RET" => 1<<28,
85-
"ZEND_VM_EXT_ISSET" => 1<<29,
74+
"ZEND_VM_EXT_JMP_ADDR" => 1<<18,
75+
"ZEND_VM_EXT_DIM_OBJ" => 1<<19,
76+
"ZEND_VM_EXT_CLASS_FETCH" => 1<<20,
77+
"ZEND_VM_EXT_CONST_FETCH" => 1<<21,
78+
"ZEND_VM_EXT_VAR_FETCH" => 1<<22,
79+
"ZEND_VM_EXT_ARRAY_INIT" => 1<<23,
80+
"ZEND_VM_EXT_TYPE" => 1<<24,
81+
"ZEND_VM_EXT_EVAL" => 1<<25,
82+
"ZEND_VM_EXT_FAST_CALL" => 1<<26,
83+
"ZEND_VM_EXT_FAST_RET" => 1<<27,
84+
"ZEND_VM_EXT_ISSET" => 1<<28,
8685
);
8786

8887
foreach ($vm_op_flags as $name => $val) {
@@ -105,8 +104,7 @@
105104
$vm_ext_decode = array(
106105
"NUM" => ZEND_VM_EXT_NUM,
107106
"VAR" => ZEND_VM_EXT_VAR,
108-
"JMP_ABS" => ZEND_VM_EXT_JMP_ABS,
109-
"JMP_REL" => ZEND_VM_EXT_JMP_REL,
107+
"JMP_ADDR" => ZEND_VM_EXT_JMP_ADDR,
110108
"DIM_OBJ" => ZEND_VM_EXT_DIM_OBJ,
111109
"CLASS_FETCH" => ZEND_VM_EXT_CLASS_FETCH,
112110
"CONST_FETCH" => ZEND_VM_EXT_CONST_FETCH,

Zend/zend_vm_opcodes.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,19 @@ static uint32_t zend_vm_opcodes_flags[182] = {
228228
0x00000707,
229229
0x00000707,
230230
0x00000707,
231-
0x02000003,
231+
0x01000003,
232232
0x00000003,
233-
0x00100701,
234-
0x00100701,
235-
0x00100701,
236-
0x00100701,
237-
0x00100701,
238-
0x00100701,
239-
0x00100701,
240-
0x00100701,
241-
0x00100701,
242-
0x00100701,
243-
0x00100701,
233+
0x00080701,
234+
0x00080701,
235+
0x00080701,
236+
0x00080701,
237+
0x00080701,
238+
0x00080701,
239+
0x00080701,
240+
0x00080701,
241+
0x00080701,
242+
0x00080701,
243+
0x00080701,
244244
0x00000001,
245245
0x00000001,
246246
0x00000001,
@@ -252,7 +252,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
252252
0x00000010,
253253
0x00001007,
254254
0x00001007,
255-
0x00081007,
255+
0x00041007,
256256
0x00001007,
257257
0x00001007,
258258
0x00000707,
@@ -278,35 +278,35 @@ static uint32_t zend_vm_opcodes_flags[182] = {
278278
0x00011003,
279279
0x00010300,
280280
0x00000005,
281-
0x01000703,
281+
0x00800703,
282282
0x00010703,
283-
0x04000007,
284-
0x00800107,
283+
0x02000007,
284+
0x00400107,
285285
0x00000701,
286286
0x00000701,
287287
0x00001003,
288-
0x00080001,
288+
0x00040001,
289289
0x00000007,
290-
0x00800107,
290+
0x00400107,
291291
0x00000707,
292292
0x00000703,
293-
0x00800107,
293+
0x00400107,
294294
0x00000701,
295295
0x00000701,
296-
0x00800107,
296+
0x00400107,
297297
0x00000701,
298298
0x00000701,
299-
0x00800107,
299+
0x00400107,
300300
0x00000707,
301301
0x00000707,
302-
0x00800107,
302+
0x00400107,
303303
0x00000703,
304304
0x00000703,
305-
0x00800107,
305+
0x00400107,
306306
0x00000701,
307307
0x00000701,
308308
0x00000307,
309-
0x00400301,
309+
0x00200301,
310310
0x00000000,
311311
0x00000000,
312312
0x00000000,
@@ -316,24 +316,24 @@ static uint32_t zend_vm_opcodes_flags[182] = {
316316
0x00000801,
317317
0x00040103,
318318
0x00000003,
319-
0x00200700,
319+
0x00100700,
320320
0x00000007,
321321
0x00000003,
322322
0x00010707,
323323
0x00010703,
324-
0x20800107,
325-
0x20000707,
324+
0x10400107,
325+
0x10000707,
326326
0x00000803,
327327
0x00000801,
328328
0x00010703,
329329
0x00000000,
330330
0x00000801,
331331
0x00000007,
332332
0x00000003,
333-
0x02000003,
333+
0x01000003,
334334
0x00000103,
335335
0x00001003,
336-
0x00080001,
336+
0x00040001,
337337
0x00000005,
338338
0x00010700,
339339
0x00000000,
@@ -355,7 +355,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
355355
0x00020000,
356356
0x00000000,
357357
0x00000701,
358-
0x20000707,
358+
0x10000707,
359359
0x00000000,
360360
0x00000000,
361361
0x00001000,
@@ -364,17 +364,17 @@ static uint32_t zend_vm_opcodes_flags[182] = {
364364
0x00000000,
365365
0x00000000,
366366
0x00000101,
367-
0x00200000,
367+
0x00100000,
368368
0x00000000,
369369
0x00000000,
370370
0x00000303,
371371
0x00000003,
372-
0x08002010,
373-
0x10002000,
372+
0x04002010,
373+
0x08002000,
374374
0x00000008,
375375
0x00000000,
376376
0x00000707,
377-
0x00100701,
377+
0x00080701,
378378
0x00000301,
379379
0x00001003,
380380
0x00000707,
@@ -387,7 +387,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
387387
0x00000307,
388388
0x00000307,
389389
0x00000307,
390-
0x20000307,
390+
0x10000307,
391391
0x00000303,
392392
};
393393

Zend/zend_vm_opcodes.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,17 @@
4242
#define ZEND_VM_OP2_JMP_ABS 0x00002000
4343
#define ZEND_VM_EXT_NUM 0x00010000
4444
#define ZEND_VM_EXT_VAR 0x00020000
45-
#define ZEND_VM_EXT_JMP_ABS 0x00040000
46-
#define ZEND_VM_EXT_JMP_REL 0x00080000
47-
#define ZEND_VM_EXT_DIM_OBJ 0x00100000
48-
#define ZEND_VM_EXT_CLASS_FETCH 0x00200000
49-
#define ZEND_VM_EXT_CONST_FETCH 0x00400000
50-
#define ZEND_VM_EXT_VAR_FETCH 0x00800000
51-
#define ZEND_VM_EXT_ARRAY_INIT 0x01000000
52-
#define ZEND_VM_EXT_TYPE 0x02000000
53-
#define ZEND_VM_EXT_EVAL 0x04000000
54-
#define ZEND_VM_EXT_FAST_CALL 0x08000000
55-
#define ZEND_VM_EXT_FAST_RET 0x10000000
56-
#define ZEND_VM_EXT_ISSET 0x20000000
45+
#define ZEND_VM_EXT_JMP_ADDR 0x00040000
46+
#define ZEND_VM_EXT_DIM_OBJ 0x00080000
47+
#define ZEND_VM_EXT_CLASS_FETCH 0x00100000
48+
#define ZEND_VM_EXT_CONST_FETCH 0x00200000
49+
#define ZEND_VM_EXT_VAR_FETCH 0x00400000
50+
#define ZEND_VM_EXT_ARRAY_INIT 0x00800000
51+
#define ZEND_VM_EXT_TYPE 0x01000000
52+
#define ZEND_VM_EXT_EVAL 0x02000000
53+
#define ZEND_VM_EXT_FAST_CALL 0x04000000
54+
#define ZEND_VM_EXT_FAST_RET 0x08000000
55+
#define ZEND_VM_EXT_ISSET 0x10000000
5756

5857
BEGIN_EXTERN_C()
5958

ext/opcache/Optimizer/zend_optimizer.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,10 @@ static void zend_accel_optimize(zend_op_array *op_array,
516516
case ZEND_DECLARE_ANON_INHERITED_CLASS:
517517
ZEND_PASS_TWO_UNDO_JMP_TARGET(op_array, opline, ZEND_OP1(opline));
518518
break;
519+
case ZEND_CATCH:
520+
/* relative offset into absolute index */
521+
opline->extended_value = ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value);
522+
break;
519523
case ZEND_JMPZNZ:
520524
/* relative offset into absolute index */
521525
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,
560564
case ZEND_DECLARE_ANON_INHERITED_CLASS:
561565
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, ZEND_OP1(opline));
562566
break;
567+
case ZEND_CATCH:
568+
/* absolute index to relative offset */
569+
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
570+
break;
563571
case ZEND_JMPZNZ:
564572
/* absolute index to relative offset */
565573
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);

0 commit comments

Comments
 (0)