@@ -439,7 +439,14 @@ static uint8_t zend_jit_trace_bad_stop_event(const zend_op *opline, int count)
439
439
return 0 ;
440
440
}
441
441
442
- static int zend_jit_trace_record_fake_init_call_ex (zend_execute_data * call , zend_jit_trace_rec * trace_buffer , int idx , uint32_t is_megamorphic , uint32_t * megamorphic , uint32_t level , uint32_t init_level , uint32_t * call_level )
442
+ /* Workaround for PHP-8.0 */
443
+ #ifndef ZEND_CALL_JIT_RESERVED
444
+ # define ZEND_CALL_JIT_RESERVED (1<<29)
445
+ #endif
446
+
447
+ #define ZEND_CALL_MEGAMORPHIC ZEND_CALL_JIT_RESERVED
448
+
449
+ static int zend_jit_trace_record_fake_init_call_ex (zend_execute_data * call , zend_jit_trace_rec * trace_buffer , int idx , uint32_t is_megamorphic , uint32_t init_level )
443
450
{
444
451
zend_jit_trace_stop stop ZEND_ATTRIBUTE_UNUSED = ZEND_JIT_TRACE_STOP_ERROR ;
445
452
@@ -448,7 +455,7 @@ static int zend_jit_trace_record_fake_init_call_ex(zend_execute_data *call, zend
448
455
zend_jit_op_array_trace_extension * jit_extension ;
449
456
450
457
if (call -> prev_execute_data ) {
451
- idx = zend_jit_trace_record_fake_init_call_ex (call -> prev_execute_data , trace_buffer , idx , is_megamorphic , megamorphic , level , init_level + 1 , call_level );
458
+ idx = zend_jit_trace_record_fake_init_call_ex (call -> prev_execute_data , trace_buffer , idx , is_megamorphic , init_level + 1 );
452
459
if (idx < 0 ) {
453
460
return idx ;
454
461
}
@@ -479,32 +486,16 @@ static int zend_jit_trace_record_fake_init_call_ex(zend_execute_data *call, zend
479
486
&& ((ZEND_CALL_INFO (call ) & ZEND_CALL_DYNAMIC )
480
487
|| func -> common .scope )) {
481
488
func = NULL ;
482
- * megamorphic |= (1 << (level + * call_level ));
483
- } else {
484
- * megamorphic &= ~(1 << (level + * call_level ));
489
+ ZEND_ADD_CALL_FLAG (EX (call ), ZEND_CALL_MEGAMORPHIC );
485
490
}
486
- (* call_level )++ ;
487
491
TRACE_RECORD (ZEND_JIT_TRACE_INIT_CALL , ZEND_JIT_TRACE_FAKE_INFO (init_level ), func );
488
492
} while (0 );
489
493
return idx ;
490
494
}
491
495
492
- static int zend_jit_trace_record_fake_init_call (zend_execute_data * call , zend_jit_trace_rec * trace_buffer , int idx , uint32_t is_megamorphic , uint32_t * megamorphic , uint32_t level )
496
+ static int zend_jit_trace_record_fake_init_call (zend_execute_data * call , zend_jit_trace_rec * trace_buffer , int idx , uint32_t is_megamorphic )
493
497
{
494
- uint32_t call_level = 0 ;
495
-
496
- return zend_jit_trace_record_fake_init_call_ex (call , trace_buffer , idx , is_megamorphic , megamorphic , level , 0 , & call_level );
497
- }
498
-
499
- static int zend_jit_trace_call_level (const zend_execute_data * call )
500
- {
501
- int call_level = 0 ;
502
-
503
- while (call -> prev_execute_data ) {
504
- call_level ++ ;
505
- call = call -> prev_execute_data ;
506
- }
507
- return call_level ;
498
+ return zend_jit_trace_record_fake_init_call_ex (call , trace_buffer , idx , is_megamorphic , 0 );
508
499
}
509
500
510
501
static int zend_jit_trace_subtrace (zend_jit_trace_rec * trace_buffer , int start , int end , uint8_t event , const zend_op_array * op_array , const zend_op * opline )
@@ -558,7 +549,6 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
558
549
zend_jit_trace_stop halt = 0 ;
559
550
int level = 0 ;
560
551
int ret_level = 0 ;
561
- int call_level ;
562
552
zend_vm_opcode_handler_t handler ;
563
553
const zend_op_array * op_array ;
564
554
zend_jit_op_array_trace_extension * jit_extension ;
@@ -575,7 +565,6 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
575
565
int last_loop = -1 ;
576
566
int last_loop_level = -1 ;
577
567
const zend_op * last_loop_opline = NULL ;
578
- uint32_t megamorphic = 0 ;
579
568
const zend_op_array * unrolled_calls [ZEND_JIT_TRACE_MAX_CALL_DEPTH + ZEND_JIT_TRACE_MAX_RET_DEPTH ];
580
569
#ifdef HAVE_GCC_GLOBAL_REGS
581
570
zend_execute_data * prev_execute_data = ex ;
@@ -613,7 +602,7 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
613
602
}
614
603
615
604
if (prev_call ) {
616
- int ret = zend_jit_trace_record_fake_init_call (prev_call , trace_buffer , idx , is_megamorphic , & megamorphic , ret_level + level );
605
+ int ret = zend_jit_trace_record_fake_init_call (prev_call , trace_buffer , idx , is_megamorphic );
617
606
if (ret < 0 ) {
618
607
TRACE_END (ZEND_JIT_TRACE_END , ZEND_JIT_TRACE_STOP_BAD_FUNC , opline );
619
608
#ifdef HAVE_GCC_GLOBAL_REGS
@@ -723,8 +712,7 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
723
712
|| opline -> opcode == ZEND_DO_ICALL
724
713
|| opline -> opcode == ZEND_DO_UCALL
725
714
|| opline -> opcode == ZEND_DO_FCALL_BY_NAME ) {
726
- call_level = zend_jit_trace_call_level (EX (call ));
727
- if (megamorphic & (1 << (ret_level + level + call_level ))) {
715
+ if (ZEND_CALL_INFO (EX (call )) & ZEND_CALL_MEGAMORPHIC ) {
728
716
stop = ZEND_JIT_TRACE_STOP_INTERPRETER ;
729
717
break ;
730
718
}
@@ -852,7 +840,7 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
852
840
last_loop_opline = NULL ;
853
841
854
842
if (prev_call ) {
855
- int ret = zend_jit_trace_record_fake_init_call (prev_call , trace_buffer , idx , 0 , & megamorphic , ret_level + level );
843
+ int ret = zend_jit_trace_record_fake_init_call (prev_call , trace_buffer , idx , 0 );
856
844
if (ret < 0 ) {
857
845
stop = ZEND_JIT_TRACE_STOP_BAD_FUNC ;
858
846
break ;
@@ -935,12 +923,8 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
935
923
&& trace_buffer [1 ].opline == opline - 1 ) {
936
924
func = NULL ;
937
925
}
938
- call_level = zend_jit_trace_call_level (EX (call ));
939
- ZEND_ASSERT (ret_level + level + call_level < 32 );
940
- if (func ) {
941
- megamorphic &= ~(1 << (ret_level + level + call_level ));
942
- } else {
943
- megamorphic |= (1 << (ret_level + level + call_level ));
926
+ if (!func ) {
927
+ ZEND_ADD_CALL_FLAG (EX (call ), ZEND_CALL_MEGAMORPHIC );
944
928
}
945
929
TRACE_RECORD (ZEND_JIT_TRACE_INIT_CALL , 0 , func );
946
930
}
0 commit comments