Skip to content

Commit f8e45ff

Browse files
committed
cleanup
1 parent ab6865c commit f8e45ff

File tree

2 files changed

+25
-231
lines changed

2 files changed

+25
-231
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 22 additions & 228 deletions
Original file line numberDiff line numberDiff line change
@@ -5018,11 +5018,12 @@ static int zend_jit_inc_dec(zend_jit_ctx *jit, const zend_op *opline, uint32_t o
50185018
zend_jit_if_true(jit, if_typed);
50195019

50205020
if (RETURN_VALUE_USED(opline)) {
5021-
//???? if (Z_MODE(res_addr) == IS_REG) {
5021+
if (Z_MODE(res_addr) == IS_REG) {
5022+
ZEND_ASSERT(0 && "NIY");
50225023
//???? arg2 = zend_jit_zval_addr(jit, ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var));
5023-
//???? } else {
5024+
} else {
50245025
arg2 = zend_jit_zval_addr(jit, res_addr);
5025-
//???? }
5026+
}
50265027
} else {
50275028
arg2 = IR_NULL;
50285029
}
@@ -5265,202 +5266,6 @@ static int zend_jit_math_long_long(zend_jit_ctx *jit,
52655266
}
52665267
}
52675268

5268-
#if 0
5269-
//???
5270-
zend_reg result_reg;
5271-
zend_reg tmp_reg = ZREG_R0;
5272-
5273-
if (Z_MODE(res_addr) == IS_REG && (res_info & MAY_BE_LONG)) {
5274-
if (may_overflow && (res_info & MAY_BE_GUARD)
5275-
&& JIT_G(current_frame)
5276-
&& zend_jit_opline_uses_reg(opline, Z_REG(res_addr))) {
5277-
result_reg = ZREG_R0;
5278-
} else {
5279-
result_reg = Z_REG(res_addr);
5280-
}
5281-
} else if (Z_MODE(op1_addr) == IS_REG && Z_LAST_USE(op1_addr) && !may_overflow) {
5282-
result_reg = Z_REG(op1_addr);
5283-
} else if (Z_REG(res_addr) != ZREG_R0) {
5284-
result_reg = ZREG_R0;
5285-
} else {
5286-
/* ASSIGN_DIM_OP */
5287-
result_reg = ZREG_FCARG1;
5288-
tmp_reg = ZREG_FCARG1;
5289-
}
5290-
5291-
if (opcode == ZEND_MUL &&
5292-
Z_MODE(op2_addr) == IS_CONST_ZVAL &&
5293-
Z_LVAL_P(Z_ZV(op2_addr)) == 2) {
5294-
if (Z_MODE(op1_addr) == IS_REG && !may_overflow) {
5295-
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))+Ra(Z_REG(op1_addr))]
5296-
} else {
5297-
| GET_ZVAL_LVAL result_reg, op1_addr
5298-
| add Ra(result_reg), Ra(result_reg)
5299-
}
5300-
} else if (opcode == ZEND_MUL &&
5301-
Z_MODE(op2_addr) == IS_CONST_ZVAL &&
5302-
!may_overflow &&
5303-
Z_LVAL_P(Z_ZV(op2_addr)) > 0 &&
5304-
zend_long_is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr)))) {
5305-
| GET_ZVAL_LVAL result_reg, op1_addr
5306-
| shl Ra(result_reg), zend_long_floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
5307-
} else if (opcode == ZEND_MUL &&
5308-
Z_MODE(op1_addr) == IS_CONST_ZVAL &&
5309-
Z_LVAL_P(Z_ZV(op1_addr)) == 2) {
5310-
if (Z_MODE(op2_addr) == IS_REG && !may_overflow) {
5311-
| lea Ra(result_reg), [Ra(Z_REG(op2_addr))+Ra(Z_REG(op2_addr))]
5312-
} else {
5313-
| GET_ZVAL_LVAL result_reg, op2_addr
5314-
| add Ra(result_reg), Ra(result_reg)
5315-
}
5316-
} else if (opcode == ZEND_MUL &&
5317-
Z_MODE(op1_addr) == IS_CONST_ZVAL &&
5318-
!may_overflow &&
5319-
Z_LVAL_P(Z_ZV(op1_addr)) > 0 &&
5320-
zend_long_is_power_of_two(Z_LVAL_P(Z_ZV(op1_addr)))) {
5321-
| GET_ZVAL_LVAL result_reg, op2_addr
5322-
| shl Ra(result_reg), zend_long_floor_log2(Z_LVAL_P(Z_ZV(op1_addr)))
5323-
} else if (opcode == ZEND_DIV &&
5324-
(Z_MODE(op2_addr) == IS_CONST_ZVAL &&
5325-
zend_long_is_power_of_two(Z_LVAL_P(Z_ZV(op2_addr))))) {
5326-
| GET_ZVAL_LVAL result_reg, op1_addr
5327-
| shr Ra(result_reg), zend_long_floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
5328-
} else if (opcode == ZEND_ADD &&
5329-
!may_overflow &&
5330-
Z_MODE(op1_addr) == IS_REG &&
5331-
Z_MODE(op2_addr) == IS_CONST_ZVAL &&
5332-
IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op2_addr)))) {
5333-
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))+Z_LVAL_P(Z_ZV(op2_addr))]
5334-
} else if (opcode == ZEND_ADD &&
5335-
!may_overflow &&
5336-
Z_MODE(op2_addr) == IS_REG &&
5337-
Z_MODE(op1_addr) == IS_CONST_ZVAL &&
5338-
IS_SIGNED_32BIT(Z_LVAL_P(Z_ZV(op1_addr)))) {
5339-
| lea Ra(result_reg), [Ra(Z_REG(op2_addr))+Z_LVAL_P(Z_ZV(op1_addr))]
5340-
} else if (opcode == ZEND_SUB &&
5341-
!may_overflow &&
5342-
Z_MODE(op1_addr) == IS_REG &&
5343-
Z_MODE(op2_addr) == IS_CONST_ZVAL &&
5344-
IS_SIGNED_32BIT(-Z_LVAL_P(Z_ZV(op2_addr)))) {
5345-
| lea Ra(result_reg), [Ra(Z_REG(op1_addr))-Z_LVAL_P(Z_ZV(op2_addr))]
5346-
} else {
5347-
| GET_ZVAL_LVAL result_reg, op1_addr
5348-
if ((opcode == ZEND_ADD || opcode == ZEND_SUB)
5349-
&& Z_MODE(op2_addr) == IS_CONST_ZVAL
5350-
&& Z_LVAL_P(Z_ZV(op2_addr)) == 0) {
5351-
/* +/- 0 */
5352-
may_overflow = 0;
5353-
} else if (same_ops && opcode != ZEND_DIV) {
5354-
| LONG_MATH_REG opcode, Ra(result_reg), Ra(result_reg)
5355-
} else {
5356-
zend_reg tmp_reg;
5357-
5358-
if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_R0) {
5359-
tmp_reg = ZREG_R1;
5360-
} else if (result_reg != ZREG_R0) {
5361-
tmp_reg = ZREG_R0;
5362-
} else {
5363-
tmp_reg = ZREG_R1;
5364-
}
5365-
| LONG_MATH opcode, result_reg, op2_addr, tmp_reg
5366-
(void)tmp_reg;
5367-
}
5368-
}
5369-
if (may_overflow) {
5370-
if (res_info & MAY_BE_GUARD) {
5371-
int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0);
5372-
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
5373-
if ((res_info & MAY_BE_ANY) == MAY_BE_LONG) {
5374-
| jo &exit_addr
5375-
if (Z_MODE(res_addr) == IS_REG && result_reg != Z_REG(res_addr)) {
5376-
| mov Ra(Z_REG(res_addr)), Ra(result_reg)
5377-
}
5378-
} else if ((res_info & MAY_BE_ANY) == MAY_BE_DOUBLE) {
5379-
| jno &exit_addr
5380-
} else {
5381-
ZEND_UNREACHABLE();
5382-
}
5383-
} else {
5384-
if (res_info & MAY_BE_LONG) {
5385-
| jo >1
5386-
} else {
5387-
| jno >1
5388-
}
5389-
}
5390-
}
5391-
5392-
if (Z_MODE(res_addr) == IS_MEM_ZVAL && (res_info & MAY_BE_LONG)) {
5393-
| SET_ZVAL_LVAL res_addr, Ra(result_reg)
5394-
if (Z_MODE(op1_addr) != IS_MEM_ZVAL || Z_REG(op1_addr) != Z_REG(res_addr) || Z_OFFSET(op1_addr) != Z_OFFSET(res_addr)) {
5395-
if ((res_use_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF|MAY_BE_GUARD)) != MAY_BE_LONG) {
5396-
| SET_ZVAL_TYPE_INFO res_addr, IS_LONG
5397-
}
5398-
}
5399-
}
5400-
5401-
if (may_overflow && (!(res_info & MAY_BE_GUARD) || (res_info & MAY_BE_ANY) == MAY_BE_DOUBLE)) {
5402-
zend_reg tmp_reg1 = ZREG_XMM0;
5403-
zend_reg tmp_reg2 = ZREG_XMM1;
5404-
5405-
if (res_info & MAY_BE_LONG) {
5406-
|.cold_code
5407-
|1:
5408-
}
5409-
5410-
do {
5411-
if ((sizeof(void*) == 8 || Z_MODE(res_addr) != IS_REG) &&
5412-
((Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op1_addr)) == 1) ||
5413-
(Z_MODE(op2_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op2_addr)) == 1))) {
5414-
if (opcode == ZEND_ADD) {
5415-
|.if X64
5416-
| mov64 Ra(tmp_reg), 0x43e0000000000000
5417-
if (Z_MODE(res_addr) == IS_REG) {
5418-
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), Ra(tmp_reg)
5419-
} else {
5420-
| SET_ZVAL_LVAL res_addr, Ra(tmp_reg)
5421-
}
5422-
|.else
5423-
| SET_ZVAL_LVAL res_addr, 0
5424-
| SET_ZVAL_W2 res_addr, 0x41e00000
5425-
|.endif
5426-
break;
5427-
} else if (opcode == ZEND_SUB) {
5428-
|.if X64
5429-
| mov64 Ra(tmp_reg), 0xc3e0000000000000
5430-
if (Z_MODE(res_addr) == IS_REG) {
5431-
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), Ra(tmp_reg)
5432-
} else {
5433-
| SET_ZVAL_LVAL res_addr, Ra(tmp_reg)
5434-
}
5435-
|.else
5436-
| SET_ZVAL_LVAL res_addr, 0x00200000
5437-
| SET_ZVAL_W2 res_addr, 0xc1e00000
5438-
|.endif
5439-
break;
5440-
}
5441-
}
5442-
5443-
| DOUBLE_GET_ZVAL_LVAL tmp_reg1, op1_addr, tmp_reg
5444-
| DOUBLE_GET_ZVAL_LVAL tmp_reg2, op2_addr, tmp_reg
5445-
if (CAN_USE_AVX()) {
5446-
| AVX_MATH_REG opcode, tmp_reg1, tmp_reg1, tmp_reg2
5447-
} else {
5448-
| SSE_MATH_REG opcode, tmp_reg1, tmp_reg2
5449-
}
5450-
| DOUBLE_SET_ZVAL_DVAL res_addr, tmp_reg1
5451-
} while (0);
5452-
5453-
if (Z_MODE(res_addr) == IS_MEM_ZVAL
5454-
&& (res_use_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF|MAY_BE_GUARD)) != MAY_BE_DOUBLE) {
5455-
| SET_ZVAL_TYPE_INFO res_addr, IS_DOUBLE
5456-
}
5457-
if (res_info & MAY_BE_LONG) {
5458-
| jmp >2
5459-
|.code
5460-
}
5461-
|2:
5462-
}
5463-
#endif
54645269
return 1;
54655270
}
54665271

@@ -7123,12 +6928,12 @@ static int zend_jit_cmp_long_long(zend_jit_ctx *jit,
71236928
const void *exit_addr,
71246929
bool skip_comparison)
71256930
{
7126-
// bool swap = 0;
7127-
// bool result;
71286931
ir_op op;
71296932
ir_ref op1, op2, ref;
7130-
71316933
#if 0
6934+
//???
6935+
bool result;
6936+
71326937
if (zend_jit_is_constant_cmp_long_long(opline, op1_range, op1_addr, op2_range, op2_addr, &result)) {
71336938
if (!smart_branch_opcode ||
71346939
smart_branch_opcode == ZEND_JMPZ_EX ||
@@ -7141,21 +6946,19 @@ static int zend_jit_cmp_long_long(zend_jit_ctx *jit,
71416946
jit->bb_end_ref[jit->b] = zend_jit_end(jit);
71426947
jit->control = IR_UNUSED;
71436948
jit->b = -1;
7144-
#if 0
71456949
if (smart_branch_opcode == ZEND_JMPZ ||
71466950
smart_branch_opcode == ZEND_JMPZ_EX) {
71476951
if (!result) {
7148-
//??? | jmp => target_label
6952+
| jmp => target_label
71496953
}
71506954
} else if (smart_branch_opcode == ZEND_JMPNZ ||
71516955
smart_branch_opcode == ZEND_JMPNZ_EX) {
71526956
if (result) {
7153-
//??? | jmp => target_label
6957+
| jmp => target_label
71546958
}
71556959
} else {
71566960
ZEND_UNREACHABLE();
71576961
}
7158-
#endif
71596962
}
71606963
return 1;
71616964
}
@@ -8350,11 +8153,13 @@ static int zend_jit_defined(zend_jit_ctx *jit, const zend_op *opline, zend_uchar
83508153

83518154
static int zend_jit_escape_if_undef(zend_jit_ctx *jit, int var, uint32_t flags, const zend_op *opline, int8_t reg)
83528155
{
8353-
#if 0 //???
8354-
zend_jit_addr val_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0);
8156+
zend_jit_addr reg_addr = ZEND_ADDR_REF_ZVAL(zend_jit_deopt_rload(jit, IR_ADDR, reg));
8157+
ir_ref if_def = zend_jit_if(jit, zend_jit_zval_type(jit, reg_addr));
83558158

8356-
| IF_NOT_ZVAL_TYPE val_addr, IS_UNDEF, >1
8159+
zend_jit_if_false_cold(jit, if_def);
8160+
jit->control = ir_emit1(&jit->ctx, IR_TRAP, jit->control); // NIY ???
83578161

8162+
#if 0 //???
83588163
if (flags & ZEND_JIT_EXIT_RESTORE_CALL) {
83598164
if (!zend_jit_save_call_chain(Dst, -1)) {
83608165
return 0;
@@ -8379,6 +8184,11 @@ static int zend_jit_escape_if_undef(zend_jit_ctx *jit, int var, uint32_t flags,
83798184
| jmp ->trace_escape
83808185
|1:
83818186
#endif
8187+
8188+
zend_jit_load_ip_addr(jit, opline - 1);
8189+
zend_jit_ijmp(jit, zend_jit_stub_addr(jit, jit_stub_trace_escape));
8190+
8191+
zend_jit_if_true(jit, if_def);
83828192
return 1;
83838193
}
83848194

@@ -11272,11 +11082,7 @@ static int zend_jit_verify_arg_type(zend_jit_ctx *jit, const zend_op *opline, ze
1127211082
}
1127311083
}
1127411084

11275-
// if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
11276-
zend_jit_set_ex_opline(jit, opline);
11277-
// } else {
11278-
//??? | ADDR_STORE aword EX->opline, opline, r0
11279-
// }
11085+
zend_jit_set_ex_opline(jit, opline);
1128011086
ref = zend_jit_call_2(jit, IR_BOOL,
1128111087
zend_jit_const_func_addr(jit, (uintptr_t)zend_jit_verify_arg_slow, IR_CONST_FASTCALL_FUNC),
1128211088
ref,
@@ -11337,11 +11143,7 @@ static int zend_jit_recv(zend_jit_ctx *jit, const zend_op *opline, const zend_op
1133711143
if_ok = zend_jit_if(jit, cond);
1133811144
zend_jit_if_false_cold(jit, if_ok);
1133911145

11340-
// if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
11341-
zend_jit_set_ex_opline(jit, opline);
11342-
// } else {
11343-
//??? | ADDR_STORE aword EX->opline, opline, r0
11344-
// }
11146+
zend_jit_set_ex_opline(jit, opline);
1134511147
zend_jit_call_1(jit, IR_VOID,
1134611148
zend_jit_const_func_addr(jit, (uintptr_t)zend_missing_arg_error, IR_CONST_FASTCALL_FUNC),
1134711149
zend_jit_fp(jit));
@@ -11403,13 +11205,7 @@ static int zend_jit_recv_init(zend_jit_ctx *jit, const zend_op *opline, const ze
1140311205
}
1140411206

1140511207
if (Z_CONSTANT_P(zv)) {
11406-
// if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
11407-
zend_jit_set_ex_opline(jit, opline);
11408-
//???- | SET_EX_OPLINE opline, r0
11409-
// } else {
11410-
//??? | ADDR_STORE aword EX->opline, opline, r0
11411-
// }
11412-
11208+
zend_jit_set_ex_opline(jit, opline);
1141311209
ref = zend_jit_call_2(jit, IR_I32,
1141411210
zend_jit_const_func_addr(jit, (uintptr_t)zval_update_constant_ex, IR_CONST_FASTCALL_FUNC),
1141511211
zend_jit_zval_addr(jit, res_addr),
@@ -17719,8 +17515,6 @@ static int zend_jit_trace_start(zend_jit_ctx *jit,
1771917515
} else {
1772017516
zend_jit_rload(jit, type, reg);
1772117517
}
17722-
//??? } else if (STACK_REG(parent_stack, i) == ZREG_ZVAL_COPY_GPR0) {
17723-
//??? ZEND_REGSET_EXCL(regset, ZREG_R0);
1772417518
}
1772517519
}
1772617520
}

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,7 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
28772877
RA_IVAL_START(i, 0);
28782878
if (i < parent_vars_count
28792879
&& STACK_REG(parent_stack, i) != ZREG_NONE
2880-
#ifndef ZEND_JIT_IR //???
2880+
#ifndef ZEND_JIT_IR
28812881
&& STACK_REG(parent_stack, i) < ZREG_NUM
28822882
#endif
28832883
) {
@@ -3979,7 +3979,7 @@ static int zend_jit_trace_deoptimization(
39793979
#endif
39803980
}
39813981

3982-
#ifndef ZEND_JIT_IR //???
3982+
#ifndef ZEND_JIT_IR
39833983
if (has_unsaved_vars
39843984
&& (has_constants
39853985
|| (flags & (ZEND_JIT_EXIT_RESTORE_CALL|ZEND_JIT_EXIT_FREE_OP1|ZEND_JIT_EXIT_FREE_OP2)))) {
@@ -7793,7 +7793,7 @@ static const void *zend_jit_trace_exit_to_vm(uint32_t trace_num, uint32_t exit_n
77937793
opline = zend_jit_traces[trace_num].exit_info[exit_num].opline;
77947794
if (opline) {
77957795
if (opline == zend_jit_traces[zend_jit_traces[trace_num].root].opline) {
7796-
#ifndef ZEND_JIT_IR //??????
7796+
#ifndef ZEND_JIT_IR
77977797
/* prevent endless loop */
77987798
original_handler = 1;
77997799
#else

0 commit comments

Comments
 (0)