89
89
90
90
#define TMP_ZVAL_OFFSET 0
91
91
#define DASM_ALIGNMENT 16
92
- #define MAX_IMM12 0xfff // maximum value for imm12
92
+ #define MAX_IMM12 0xfff // maximum value for imm12
93
+ #define LDR_STR_IMM (MAX_IMM12 * 8) // maximum value for imm12 * 8
93
94
94
95
#include "Zend/zend_cpuinfo.h"
95
96
@@ -1458,8 +1459,7 @@ static int zend_jit_undefined_function_stub(dasm_State **Dst)
1458
1459
| LOAD_ADDR CARG2, "Call to undefined function %s()"
1459
1460
| ldr CARG3w, [REG0, #offsetof(zend_op, op2.constant)]
1460
1461
| sxtw CARG3, CARG3w
1461
- | add REG0, REG0, CARG3
1462
- | ldr CARG3, [REG0]
1462
+ | ldr CARG3, [REG0, CARG3]
1463
1463
| add CARG3, CARG3, #offsetof(zend_string, val)
1464
1464
| EXT_CALL zend_throw_error, REG0
1465
1465
| b ->exception_handler
@@ -4876,6 +4876,7 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t
4876
4876
| EXT_CALL zend_jit_init_func_run_time_cache_helper, REG0
4877
4877
| ldr REG1, EX->run_time_cache
4878
4878
| mov REG0, RETVALx
4879
+ || ZEND_ASSERT(opline->result.num <= LDR_STR_IMM);
4879
4880
| str REG0, [REG1, #opline->result.num]
4880
4881
| b >3
4881
4882
} else {
@@ -5380,7 +5381,9 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
5380
5381
for (i = call_num_args; i < func->op_array.last_var; i++) {
5381
5382
uint32_t n = EX_NUM_TO_VAR(i);
5382
5383
| // ZVAL_UNDEF(EX_VAR(n))
5383
- | str wzr, [RX, #(n + offsetof(zval,u1.type_info))]
5384
+ || ZEND_ASSERT(n <= MAX_IMM12);
5385
+ | add TMP1, RX, #n
5386
+ | SET_Z_TYPE_INFO TMP1, IS_UNDEF, TMP2w
5384
5387
}
5385
5388
5386
5389
if (call_num_args <= func->op_array.num_args) {
@@ -5403,25 +5406,26 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
5403
5406
| LOAD_IP_ADDR (func->op_array.opcodes + num_args)
5404
5407
} else {
5405
5408
| ldr REG0, EX->func
5409
+ || ZEND_ASSERT((num_args * sizeof(zend_op)) <= MAX_IMM12);
5406
5410
if (GCC_GLOBAL_REGS) {
5407
5411
| ldr IP, [REG0, #offsetof(zend_op_array, opcodes)]
5408
5412
if (num_args) {
5409
5413
| add IP, IP, #(num_args * sizeof(zend_op))
5410
5414
}
5411
5415
} else {
5412
- | ldr REG1 , [REG0, #offsetof(zend_op_array, opcodes)]
5416
+ | ldr FCARG1x , [REG0, #offsetof(zend_op_array, opcodes)]
5413
5417
if (num_args) {
5414
- | add REG1, REG1 , #(num_args * sizeof(zend_op))
5418
+ | add FCARG1x, FCARG1x , #(num_args * sizeof(zend_op))
5415
5419
}
5416
- | str REG1 , EX->opline
5420
+ | str FCARG1x , EX->opline
5417
5421
}
5418
5422
}
5419
5423
5420
5424
if (!trace && op_array == &func->op_array) {
5421
5425
/* recursive call */
5422
5426
if (ZEND_OBSERVER_ENABLED) {
5423
5427
| SAVE_IP
5424
- | mov CARG1 , FP
5428
+ | mov FCARG1x , FP
5425
5429
| EXT_CALL zend_observer_fcall_begin, REG0
5426
5430
}
5427
5431
#ifdef CONTEXT_THREADED_JIT
@@ -5440,12 +5444,12 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
5440
5444
} else if (GCC_GLOBAL_REGS) {
5441
5445
| ldr IP, [REG0, #offsetof(zend_op_array, opcodes)]
5442
5446
} else {
5443
- | ldr CARG1 , [REG0, #offsetof(zend_op_array, opcodes)]
5444
- | str CARG1 , EX->opline
5447
+ | ldr FCARG1x , [REG0, #offsetof(zend_op_array, opcodes)]
5448
+ | str FCARG1x , EX->opline
5445
5449
}
5446
5450
}
5447
5451
if (!GCC_GLOBAL_REGS) {
5448
- | mov CARG1 , FP
5452
+ | mov FCARG1x , FP
5449
5453
}
5450
5454
| EXT_CALL zend_jit_copy_extra_args_helper, REG0
5451
5455
}
@@ -5460,10 +5464,10 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
5460
5464
| str FCARG1x, EX->opline
5461
5465
}
5462
5466
if (func) {
5463
- | brk #0 // TODO
5464
5467
| // num_args = EX_NUM_ARGS();
5465
5468
| ldr REG1w, [FP, #offsetof(zend_execute_data, This.u2.num_args)]
5466
5469
| // if (UNEXPECTED(num_args > first_extra_arg))
5470
+ || ZEND_ASSERT(func->op_array.num_args <= MAX_IMM12);
5467
5471
| cmp REG1w, #(func->op_array.num_args)
5468
5472
} else {
5469
5473
| // first_extra_arg = op_array->num_args;
@@ -5494,7 +5498,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
5494
5498
|1:
5495
5499
| // if (EXPECTED((int)num_args < op_array->last_var)) {
5496
5500
if (func) {
5497
- | movz REG2w, #( func->op_array.last_var)
5501
+ | LOAD_32BIT_VAL REG2w, func->op_array.last_var
5498
5502
} else {
5499
5503
| ldr REG2w, [REG0, #offsetof(zend_op_array, last_var)]
5500
5504
}
0 commit comments