Skip to content

Commit f133644

Browse files
shqkingdstogov
authored andcommitted
Support failed JIT test case: jmpz_ex_001.phpt
Opcodes for $Test::method are: BB0: 0000 #0.T0 [rcn, any] = FETCH_OBJ_R THIS string("prop") 0001 #1.T0 [bool] RANGE[0..1] = JMPZ_EX #0.T0 [rcn, any] BB3 BB1: 0002 #2.T1 [rcn, any] = FETCH_OBJ_R THIS string("prop") 0003 INIT_METHOD_CALL 0 #2.T1 [rcn, any] string("method2") 0004 php#3.V1 [ref, rc1, rcn, any] = DO_FCALL ... New path is covered in functions zend_jit_fetch_obj() and zend_jit_zval_copy_deref() for FETCH_OBJ_R THIS opcode. New path is covered in function zend_jit_init_method_call() for opcode INIT_METHOD_CALL. Major chagnes lie in function zend_jit_bool_jmpznz() to support opcode JMPZ_EX. Note that macro ZVAL_DTOR_FUNC is updated to remove the hard-coded use of REG0.
1 parent 0a97554 commit f133644

File tree

1 file changed

+74
-7
lines changed

1 file changed

+74
-7
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ static void* dasm_labels[zend_lb_MAX];
10791079
|| if (opline) {
10801080
| brk #0 // TODO
10811081
|| }
1082-
| EXT_CALL zend_objects_store_del, REG0
1082+
| EXT_CALL zend_objects_store_del, tmp_reg
10831083
|| break;
10841084
|| }
10851085
|| }
@@ -5267,7 +5267,6 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
52675267
if ((op1_info & MAY_BE_UNDEF) && (op1_info & MAY_BE_ANY)) {
52685268
set_delayed = 1;
52695269
} else {
5270-
| brk #0 // TODO
52715270
| SET_ZVAL_TYPE_INFO_FROM_REG res_addr, REG0w, TMP1
52725271
}
52735272
}
@@ -5332,13 +5331,83 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
53325331

53335332
if (op1_info & MAY_BE_LONG) {
53345333
|2:
5335-
| brk #0 // TODO
5334+
if (op1_info & (MAY_BE_ANY-(MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG))) {
5335+
| IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >2, TMP1w, TMP2
5336+
}
5337+
| brk #0
53365338
}
53375339

53385340
if ((op1_info & MAY_BE_ANY) == MAY_BE_DOUBLE) {
53395341
| brk #0 // TODO
53405342
} else if (op1_info & (MAY_BE_ANY - (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG))) {
5341-
| brk #0 // TODO
5343+
if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG)) {
5344+
|.cold_code
5345+
|2:
5346+
}
5347+
if (Z_REG(op1_addr) != ZREG_FCARG1x || Z_OFFSET(op1_addr) != 0) {
5348+
| LOAD_ZVAL_ADDR FCARG1x, op1_addr
5349+
}
5350+
| SET_EX_OPLINE opline, REG0
5351+
| EXT_CALL zend_is_true, REG0
5352+
| mov REG0, RETVALx
5353+
5354+
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) &&
5355+
(op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
5356+
op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op1.var);
5357+
5358+
if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
5359+
| IF_NOT_ZVAL_REFCOUNTED op1_addr, >3, TMP1w, TMP2
5360+
}
5361+
| GET_ZVAL_PTR FCARG1x, op1_addr, TMP1
5362+
| GC_DELREF FCARG1x, TMP1w
5363+
| bne >3
5364+
| brk #0 // TODO: currently jump to label 3.
5365+
// In x86, r0 is used in macro ZVAL_DTOR_FUNC as temporary register, hence, r0 should be saved/restored
5366+
// before/after this macro. In AArch64, TMP1 is used. As a result, we needn't save/resotre REG0.
5367+
| ZVAL_DTOR_FUNC op1_info, opline, TMP1
5368+
|3:
5369+
}
5370+
if (may_throw) {
5371+
| MEM_LOAD_CMP_ZTS ldr, xzr, executor_globals, exception, REG1, TMP1
5372+
| bne ->exception_handler_undef
5373+
}
5374+
5375+
if (set_bool) {
5376+
if (set_bool_not) {
5377+
| brk #0 // TODO
5378+
| neg REG0w, REG0w
5379+
| add REG0w, REG0w, #3
5380+
} else {
5381+
| add REG0w, REG0w, #2
5382+
}
5383+
| SET_ZVAL_TYPE_INFO_FROM_REG res_addr, REG0w, TMP1
5384+
if (exit_addr) {
5385+
| brk #0 // TODO
5386+
} else if (true_label != (uint32_t)-1 || false_label != (uint32_t)-1) {
5387+
| CMP_ZVAL_TYPE res_addr, IS_FALSE, TMP1w, TMP2
5388+
if (true_label != (uint32_t)-1) {
5389+
| brk #0 // TODO
5390+
| bne =>true_label
5391+
if (false_label != (uint32_t)-1) {
5392+
| b =>false_label
5393+
} else if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG)) {
5394+
| b >9
5395+
}
5396+
} else {
5397+
| beq =>false_label
5398+
}
5399+
}
5400+
if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG)) {
5401+
| b >9
5402+
|.code
5403+
}
5404+
} else {
5405+
| brk #0 // TODO
5406+
5407+
if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG)) {
5408+
|.code
5409+
}
5410+
}
53425411
}
53435412

53445413
|9:
@@ -6012,7 +6081,6 @@ static int zend_jit_init_method_call(dasm_State **Dst,
60126081
| mov CARG3, sp
60136082
| SET_EX_OPLINE opline, REG0
60146083
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && !use_this) {
6015-
| brk #0 // TODO
60166084
| EXT_CALL zend_jit_find_method_tmp_helper, REG0
60176085
} else {
60186086
| EXT_CALL zend_jit_find_method_helper, REG0
@@ -7496,9 +7564,9 @@ static int zend_jit_zval_copy_deref(dasm_State **Dst, zend_jit_addr res_addr, ze
74967564
| lsr TMP1w, REG2w, #8
74977565
| and TMP1w, TMP1w, #0xff // TMP1w -> 8-15 bits of REG2w
74987566
| IF_NOT_REFCOUNTED TMP1w, >2
7499-
| brk #0 // TODO: currently jump to label 2 directly.
75007567
| and TMP2w, REG2w, #0xff // TMP2w -> low 8 bits of REG2w
75017568
| IF_NOT_TYPE TMP2w, IS_REFERENCE, >1
7569+
| brk #0 // TODO
75027570
| add TMP3, REG1, #offsetof(zend_reference, val)
75037571
| GET_Z_TYPE_INFO REG2w, TMP3
75047572
| GET_Z_PTR REG1, TMP3
@@ -8128,7 +8196,6 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
81288196
prop_info = zend_get_known_property_info(op_array, ce, Z_STR_P(member), opline->op1_type == IS_UNUSED, op_array->filename);
81298197

81308198
if (opline->op1_type == IS_UNUSED || use_this) {
8131-
| brk #0 // TODO
81328199
| GET_ZVAL_PTR FCARG1x, this_addr, TMP1
81338200
} else {
81348201
if (opline->op1_type == IS_VAR

0 commit comments

Comments
 (0)