Skip to content

Commit 626bc3a

Browse files
committed
More accurate handling of global registers (allow VM with single global register)
1 parent c4b77e0 commit 626bc3a

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

Zend/zend_execute.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,28 @@
6363
# pragma GCC diagnostic ignored "-Wvolatile-register-var"
6464
register zend_execute_data* volatile execute_data __asm__(ZEND_VM_FP_GLOBAL_REG);
6565
# pragma GCC diagnostic warning "-Wvolatile-register-var"
66+
#endif
67+
68+
#ifdef ZEND_VM_FP_GLOBAL_REG
6669
# define EXECUTE_DATA_D void
6770
# define EXECUTE_DATA_C
6871
# define EXECUTE_DATA_DC
6972
# define EXECUTE_DATA_CC
7073
# define NO_EXECUTE_DATA_CC
71-
# define OPLINE_D void
72-
# define OPLINE_C
73-
# define OPLINE_DC
74-
# define OPLINE_CC
7574
#else
7675
# define EXECUTE_DATA_D zend_execute_data* execute_data
7776
# define EXECUTE_DATA_C execute_data
7877
# define EXECUTE_DATA_DC , EXECUTE_DATA_D
7978
# define EXECUTE_DATA_CC , EXECUTE_DATA_C
8079
# define NO_EXECUTE_DATA_CC , NULL
80+
#endif
81+
82+
#ifdef ZEND_VM_IP_GLOBAL_REG
83+
# define OPLINE_D void
84+
# define OPLINE_C
85+
# define OPLINE_DC
86+
# define OPLINE_CC
87+
#else
8188
# define OPLINE_D const zend_op* opline
8289
# define OPLINE_C opline
8390
# define OPLINE_DC , OPLINE_D
@@ -3306,7 +3313,7 @@ static zend_never_inline void zend_copy_extra_args(EXECUTE_DATA_D)
33063313

33073314
if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
33083315
/* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
3309-
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
3316+
#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
33103317
opline += first_extra_arg;
33113318
#else
33123319
EX(opline) += first_extra_arg;
@@ -3358,7 +3365,7 @@ static zend_always_inline void i_init_func_execute_data(zend_op_array *op_array,
33583365
uint32_t first_extra_arg, num_args;
33593366
ZEND_ASSERT(EX(func) == (zend_function*)op_array);
33603367

3361-
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
3368+
#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
33623369
opline = op_array->opcodes;
33633370
#else
33643371
EX(opline) = op_array->opcodes;
@@ -3375,7 +3382,7 @@ static zend_always_inline void i_init_func_execute_data(zend_op_array *op_array,
33753382
}
33763383
} else if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
33773384
/* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
3378-
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
3385+
#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
33793386
opline += num_args;
33803387
#else
33813388
EX(opline) += num_args;
@@ -3388,7 +3395,7 @@ static zend_always_inline void i_init_func_execute_data(zend_op_array *op_array,
33883395
EX_LOAD_RUN_TIME_CACHE(op_array);
33893396

33903397
EG(current_execute_data) = execute_data;
3391-
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
3398+
#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
33923399
EX(opline) = opline;
33933400
#endif
33943401
}
@@ -3471,7 +3478,11 @@ ZEND_API void zend_init_func_execute_data(zend_execute_data *ex, zend_op_array *
34713478
{
34723479
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
34733480
zend_execute_data *orig_execute_data = execute_data;
3481+
#endif
3482+
#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
34743483
const zend_op *orig_opline = opline;
3484+
#endif
3485+
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
34753486
execute_data = ex;
34763487
#else
34773488
zend_execute_data *execute_data = ex;
@@ -3483,9 +3494,11 @@ ZEND_API void zend_init_func_execute_data(zend_execute_data *ex, zend_op_array *
34833494
}
34843495
i_init_func_execute_data(op_array, return_value, 1 EXECUTE_DATA_CC);
34853496

3486-
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
3497+
#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
34873498
EX(opline) = opline;
34883499
opline = orig_opline;
3500+
#endif
3501+
#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
34893502
execute_data = orig_execute_data;
34903503
#endif
34913504
}

Zend/zend_vm_execute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67892,8 +67892,12 @@ ZEND_API void execute_ex(zend_execute_data *ex)
6789267892
ZEND_YIELD_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
6789367893
HYBRID_BREAK();
6789467894
HYBRID_CASE(HYBRID_HALT):
67895+
#ifdef ZEND_VM_FP_GLOBAL_REG
6789567896
execute_data = orig_execute_data;
67897+
#endif
67898+
#ifdef ZEND_VM_IP_GLOBAL_REG
6789667899
opline = orig_opline;
67900+
#endif
6789767901
return;
6789867902
HYBRID_DEFAULT:
6789967903
VM_TRACE(ZEND_NULL)

Zend/zend_vm_gen.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,8 +1814,12 @@ function gen_executor_code($f, $spec, $kind, $prolog, &$switch_labels = array())
18141814
break;
18151815
case ZEND_VM_KIND_HYBRID:
18161816
out($f,"\t\t\tHYBRID_CASE(HYBRID_HALT):\n");
1817+
out($f,"#ifdef ZEND_VM_FP_GLOBAL_REG\n");
18171818
out($f,"\t\t\t\texecute_data = orig_execute_data;\n");
1819+
out($f,"#endif\n");
1820+
out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
18181821
out($f,"\t\t\t\topline = orig_opline;\n");
1822+
out($f,"#endif\n");
18191823
out($f,"\t\t\t\treturn;\n");
18201824
out($f,"\t\t\tHYBRID_DEFAULT:\n");
18211825
out($f,"\t\t\t\tVM_TRACE(ZEND_NULL)\n");

0 commit comments

Comments
 (0)