Skip to content

Commit c8c4132

Browse files
shqkingdstogov
authored andcommitted
Support failed JIT test case: reg_alloc_003.phpt
Opcodes for $test are: BB0: 0000 #1.CV0($char_code) [rc1, rcn, any] = RECV 1 BB1: 0001 #2.T1 [rc1, ...] = BW_AND #1.CV0($char_code) ... 0002 #3.T2 [bool] RANGE[0..1] = BOOL_NOT #2.T1 [rc1, ...] 0003 #4.T1 [bool] RANGE[0..1] = IS_EQUAL #1.CV0($char_code) ... 0004 JMPZ #4.T1 [bool] RANGE[0..1] BB3 ... New path is covered in function zend_jit_long_math_helper() for opcode BW_AND. New path is covered in function zend_jit_bool_jmpznz() for opcode BOOL_NOT. Major changes lie in functions zend_jit_cmp(), zend_jit_cmp_slow() and zend_jit_check_exception_undef_result() to support opocdes IS_EQUAL and JMPZ.
1 parent f133644 commit c8c4132

File tree

1 file changed

+100
-5
lines changed

1 file changed

+100
-5
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,8 @@ static int zend_jit_check_exception(dasm_State **Dst)
22952295
static int zend_jit_check_exception_undef_result(dasm_State **Dst, const zend_op *opline)
22962296
{
22972297
if (opline->result_type & (IS_TMP_VAR|IS_VAR)) {
2298-
| brk #0 // TODO
2298+
| MEM_LOAD_CMP_ZTS ldr, xzr, executor_globals, exception, REG0, TMP1
2299+
| bne ->exception_handler_undef
22992300
return 1;
23002301
}
23012302
return zend_jit_check_exception(Dst);
@@ -3274,7 +3275,6 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
32743275
zval tmp;
32753276

32763277
if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)) {
3277-
| brk #0 // TODO
32783278
| IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >6, TMP1w, TMP2
32793279
}
32803280
if (!same_ops && (op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG))) {
@@ -5008,7 +5008,46 @@ static int zend_jit_cmp_double_double(dasm_State **Dst, const zend_op *opline, z
50085008

50095009
static int zend_jit_cmp_slow(dasm_State **Dst, const zend_op *opline, zend_jit_addr res_addr, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr)
50105010
{
5011-
| brk #0 // TODO
5011+
| LONG_CMP_WITH_CONST cmp, res_addr, Z_L(0), TMP1, TMP2
5012+
if (smart_branch_opcode) {
5013+
if (smart_branch_opcode == ZEND_JMPZ_EX ||
5014+
smart_branch_opcode == ZEND_JMPNZ_EX) {
5015+
| brk #0 // TODO
5016+
}
5017+
if (smart_branch_opcode == ZEND_JMPZ ||
5018+
smart_branch_opcode == ZEND_JMPZ_EX) {
5019+
switch (opline->opcode) {
5020+
case ZEND_IS_EQUAL:
5021+
case ZEND_CASE:
5022+
if (exit_addr) {
5023+
| brk #0 // TODO
5024+
} else {
5025+
| bne => target_label
5026+
}
5027+
break;
5028+
case ZEND_IS_NOT_EQUAL:
5029+
| brk #0 // TODO
5030+
break;
5031+
case ZEND_IS_SMALLER:
5032+
| brk #0 // TODO
5033+
break;
5034+
case ZEND_IS_SMALLER_OR_EQUAL:
5035+
| brk #0 // TODO
5036+
break;
5037+
default:
5038+
ZEND_UNREACHABLE();
5039+
}
5040+
} else if (smart_branch_opcode == ZEND_JMPNZ ||
5041+
smart_branch_opcode == ZEND_JMPNZ_EX) {
5042+
| brk #0 // TODO
5043+
} else if (smart_branch_opcode == ZEND_JMPZNZ) {
5044+
| brk #0 // TODO
5045+
} else {
5046+
ZEND_UNREACHABLE();
5047+
}
5048+
} else {
5049+
| brk #0 // TODO
5050+
}
50125051

50135052
return 1;
50145053
}
@@ -5115,7 +5154,42 @@ static int zend_jit_cmp(dasm_State **Dst,
51155154
|.cold_code
51165155
|9:
51175156
}
5118-
| brk #0 // TODO
5157+
| SET_EX_OPLINE opline, REG0
5158+
if (Z_MODE(op1_addr) == IS_REG) {
5159+
zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op1.var);
5160+
if (!zend_jit_spill_store(Dst, op1_addr, real_addr, op1_info, 1)) {
5161+
return 0;
5162+
}
5163+
op1_addr = real_addr;
5164+
}
5165+
if (Z_MODE(op2_addr) == IS_REG) {
5166+
zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op2.var);
5167+
if (!zend_jit_spill_store(Dst, op2_addr, real_addr, op2_info, 1)) {
5168+
return 0;
5169+
}
5170+
op2_addr = real_addr;
5171+
}
5172+
| LOAD_ZVAL_ADDR FCARG2x, op1_addr
5173+
if (opline->op1_type == IS_CV && (op1_info & MAY_BE_UNDEF)) {
5174+
| brk #0 // TODO
5175+
}
5176+
if (opline->op2_type == IS_CV && (op2_info & MAY_BE_UNDEF)) {
5177+
| brk #0 // TODO
5178+
} else {
5179+
| LOAD_ZVAL_ADDR CARG3, op2_addr
5180+
}
5181+
| LOAD_ZVAL_ADDR FCARG1x, res_addr
5182+
| EXT_CALL compare_function, REG0
5183+
if (opline->opcode != ZEND_CASE) {
5184+
| FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline, ZREG_TMP1, ZREG_TMP2
5185+
}
5186+
| FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline, ZREG_TMP1, ZREG_TMP2
5187+
if (may_throw) {
5188+
zend_jit_check_exception_undef_result(Dst, opline);
5189+
}
5190+
if (!zend_jit_cmp_slow(Dst, opline, res_addr, smart_branch_opcode, target_label, target_label2, exit_addr)) {
5191+
return 0;
5192+
}
51195193
if (has_slow) {
51205194
| b >6
51215195
|.code
@@ -5334,7 +5408,28 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
53345408
if (op1_info & (MAY_BE_ANY-(MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG))) {
53355409
| IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >2, TMP1w, TMP2
53365410
}
5337-
| brk #0
5411+
if (Z_MODE(op1_addr) == IS_REG) {
5412+
| brk #0 // TODO
5413+
| tst Rx(Z_REG(op1_addr)), Rx(Z_REG(op1_addr))
5414+
} else {
5415+
| LONG_CMP_WITH_CONST cmp, op1_addr, Z_L(0), TMP1, TMP2
5416+
}
5417+
if (set_bool) {
5418+
| cset REG0w, ne
5419+
if (set_bool_not) {
5420+
| neg REG0w, REG0w
5421+
| add REG0w, REG0w, #3
5422+
} else {
5423+
| brk #0 // TODO
5424+
| add REG0w, REG0w, #2
5425+
}
5426+
| SET_ZVAL_TYPE_INFO_FROM_REG res_addr, REG0w, TMP1
5427+
}
5428+
if (exit_addr) {
5429+
| brk #0 // TODO
5430+
} else if (true_label != (uint32_t)-1 || false_label != (uint32_t)-1) {
5431+
| brk #0 // TODO
5432+
}
53385433
}
53395434

53405435
if ((op1_info & MAY_BE_ANY) == MAY_BE_DOUBLE) {

0 commit comments

Comments
 (0)