23
23
#include "Zend/zend_exceptions.h"
24
24
#include "Zend/zend_constants.h"
25
25
#include "Zend/zend_ini.h"
26
+ #include "Zend/zend_attributes.h"
26
27
#include "zend_smart_str.h"
27
28
#include "jit/zend_jit.h"
28
29
@@ -3384,28 +3385,29 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array)
3384
3385
return SUCCESS ;
3385
3386
}
3386
3387
3387
- static int zend_needs_manual_jit (const zend_op_array * op_array )
3388
+ static int zend_jit_disabled (const zend_op_array * op_array )
3388
3389
{
3389
- if (op_array -> doc_comment ) {
3390
- const char * s = ZSTR_VAL (op_array -> doc_comment );
3391
- const char * p = strstr (s , "@jit" );
3390
+ zend_attribute * jit = zend_get_attribute_str (op_array -> attributes , "jit" , sizeof ("jit" )- 1 );
3392
3391
3393
- if (p ) {
3394
- size_t l = ZSTR_LEN (op_array -> doc_comment );
3392
+ if (jit == NULL || jit -> argc == 0 ) {
3393
+ return 0 ;
3394
+ }
3395
3395
3396
- if ((p == s + 3 || * (p - 1 ) <= ' ' ) &&
3397
- (p + 6 == s + l || * (p + 4 ) <= ' ' )) {
3398
- return 1 ;
3399
- }
3400
- }
3396
+ if (zend_string_equals_literal_ci (Z_STR (jit -> args [0 ].value ), "off" )) {
3397
+ return 1 ;
3401
3398
}
3399
+
3402
3400
return 0 ;
3403
3401
}
3404
3402
3405
3403
#include "jit/zend_jit_trace.c"
3406
3404
3407
3405
ZEND_EXT_API int zend_jit_op_array (zend_op_array * op_array , zend_script * script )
3408
3406
{
3407
+ if (zend_jit_disabled (op_array )) {
3408
+ return SUCCESS ;
3409
+ }
3410
+
3409
3411
if (dasm_ptr == NULL ) {
3410
3412
return FAILURE ;
3411
3413
}
@@ -3455,12 +3457,6 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
3455
3457
return zend_jit_setup_hot_trace_counters (op_array );
3456
3458
} else if (JIT_G (trigger ) == ZEND_JIT_ON_SCRIPT_LOAD ) {
3457
3459
return zend_real_jit_func (op_array , script , NULL );
3458
- } else if (JIT_G (trigger ) == ZEND_JIT_ON_DOC_COMMENT ) {
3459
- if (zend_needs_manual_jit (op_array )) {
3460
- return zend_real_jit_func (op_array , script , NULL );
3461
- } else {
3462
- return SUCCESS ;
3463
- }
3464
3460
} else {
3465
3461
ZEND_UNREACHABLE ();
3466
3462
}
@@ -3495,21 +3491,19 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
3495
3491
goto jit_failure ;
3496
3492
}
3497
3493
}
3498
- } else if (JIT_G (trigger ) == ZEND_JIT_ON_SCRIPT_LOAD ||
3499
- JIT_G ( trigger ) == ZEND_JIT_ON_DOC_COMMENT ) {
3494
+ } else if (JIT_G (trigger ) == ZEND_JIT_ON_SCRIPT_LOAD ) {
3495
+ int do_jit = 1 ;
3500
3496
3501
- if (JIT_G (trigger ) == ZEND_JIT_ON_DOC_COMMENT ) {
3502
- int do_jit = 0 ;
3503
- for (i = 0 ; i < call_graph .op_arrays_count ; i ++ ) {
3504
- if (zend_needs_manual_jit (call_graph .op_arrays [i ])) {
3505
- do_jit = 1 ;
3506
- break ;
3507
- }
3508
- }
3509
- if (!do_jit ) {
3510
- goto jit_failure ;
3497
+ for (i = 0 ; i < call_graph .op_arrays_count ; i ++ ) {
3498
+ if (zend_jit_disabled (call_graph .op_arrays [i ])) {
3499
+ do_jit = 0 ;
3500
+ break ;
3511
3501
}
3512
3502
}
3503
+ if (!do_jit ) {
3504
+ goto jit_failure ;
3505
+ }
3506
+
3513
3507
for (i = 0 ; i < call_graph .op_arrays_count ; i ++ ) {
3514
3508
info = ZEND_FUNC_INFO (call_graph .op_arrays [i ]);
3515
3509
if (info ) {
@@ -3531,10 +3525,6 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
3531
3525
}
3532
3526
3533
3527
for (i = 0 ; i < call_graph .op_arrays_count ; i ++ ) {
3534
- if (JIT_G (trigger ) == ZEND_JIT_ON_DOC_COMMENT &&
3535
- !zend_needs_manual_jit (call_graph .op_arrays [i ])) {
3536
- continue ;
3537
- }
3538
3528
info = ZEND_FUNC_INFO (call_graph .op_arrays [i ]);
3539
3529
if (info ) {
3540
3530
if (zend_jit_op_array_analyze2 (call_graph .op_arrays [i ], script , & info -> ssa , ZCG (accel_directives ).optimization_level ) != SUCCESS ) {
@@ -3546,10 +3536,6 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
3546
3536
3547
3537
if (JIT_G (debug ) & ZEND_JIT_DEBUG_SSA ) {
3548
3538
for (i = 0 ; i < call_graph .op_arrays_count ; i ++ ) {
3549
- if (JIT_G (trigger ) == ZEND_JIT_ON_DOC_COMMENT &&
3550
- !zend_needs_manual_jit (call_graph .op_arrays [i ])) {
3551
- continue ;
3552
- }
3553
3539
info = ZEND_FUNC_INFO (call_graph .op_arrays [i ]);
3554
3540
if (info ) {
3555
3541
zend_dump_op_array (call_graph .op_arrays [i ], ZEND_DUMP_HIDE_UNREACHABLE |ZEND_DUMP_RC_INFERENCE |ZEND_DUMP_SSA , "JIT" , & info -> ssa );
@@ -3558,10 +3544,6 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
3558
3544
}
3559
3545
3560
3546
for (i = 0 ; i < call_graph .op_arrays_count ; i ++ ) {
3561
- if (JIT_G (trigger ) == ZEND_JIT_ON_DOC_COMMENT &&
3562
- !zend_needs_manual_jit (call_graph .op_arrays [i ])) {
3563
- continue ;
3564
- }
3565
3547
info = ZEND_FUNC_INFO (call_graph .op_arrays [i ]);
3566
3548
if (info ) {
3567
3549
if (zend_jit (call_graph .op_arrays [i ], & info -> ssa , NULL ) != SUCCESS ) {
@@ -3602,8 +3584,7 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
3602
3584
return SUCCESS ;
3603
3585
3604
3586
jit_failure :
3605
- if (JIT_G (trigger ) == ZEND_JIT_ON_SCRIPT_LOAD ||
3606
- JIT_G (trigger ) == ZEND_JIT_ON_DOC_COMMENT ) {
3587
+ if (JIT_G (trigger ) == ZEND_JIT_ON_SCRIPT_LOAD ) {
3607
3588
for (i = 0 ; i < call_graph .op_arrays_count ; i ++ ) {
3608
3589
ZEND_SET_FUNC_INFO (call_graph .op_arrays [i ], NULL );
3609
3590
}
@@ -3716,6 +3697,7 @@ static int zend_jit_parse_config_num(zend_long jit)
3716
3697
3717
3698
jit /= 10 ;
3718
3699
if (jit % 10 > 5 ) return FAILURE ;
3700
+ if (jit % 10 == 4 ) return FAILURE ;
3719
3701
JIT_G (trigger ) = jit % 10 ;
3720
3702
3721
3703
jit /= 10 ;
0 commit comments