Skip to content

Commit 51cf97d

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Improve $this->property access in closures
2 parents 088e547 + d1a0b93 commit 51cf97d

File tree

5 files changed

+282
-94
lines changed

5 files changed

+282
-94
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,6 +2679,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
26792679
zend_jit_addr op1_addr, op1_def_addr, op2_addr, op2_def_addr, res_addr;
26802680
zend_class_entry *ce;
26812681
bool ce_is_instanceof;
2682+
bool on_this;
26822683

26832684
if (JIT_G(bisect_limit)) {
26842685
jit_bisect_pos++;
@@ -3139,11 +3140,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
31393140
}
31403141
ce = NULL;
31413142
ce_is_instanceof = 0;
3143+
on_this = 0;
31423144
if (opline->op1_type == IS_UNUSED) {
31433145
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
31443146
ce = op_array->scope;
31453147
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
31463148
op1_addr = 0;
3149+
on_this = 1;
31473150
} else {
31483151
op1_info = OP1_INFO();
31493152
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3160,10 +3163,18 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
31603163
}
31613164
}
31623165
}
3166+
if (ssa->ops && ssa->vars) {
3167+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3168+
if (ssa_op->op1_use >= 0) {
3169+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3170+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3171+
}
3172+
}
3173+
}
31633174
}
31643175
if (!zend_jit_incdec_obj(&dasm_state, opline, op_array, ssa, ssa_op,
31653176
op1_info, op1_addr,
3166-
0, ce, ce_is_instanceof, 0, NULL, IS_UNKNOWN,
3177+
0, ce, ce_is_instanceof, on_this, 0, NULL, IS_UNKNOWN,
31673178
zend_may_throw(opline, ssa_op, op_array, ssa))) {
31683179
goto jit_failure;
31693180
}
@@ -3186,11 +3197,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
31863197
}
31873198
ce = NULL;
31883199
ce_is_instanceof = 0;
3200+
on_this = 0;
31893201
if (opline->op1_type == IS_UNUSED) {
31903202
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
31913203
ce = op_array->scope;
31923204
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
31933205
op1_addr = 0;
3206+
on_this = 1;
31943207
} else {
31953208
op1_info = OP1_INFO();
31963209
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3207,10 +3220,18 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32073220
}
32083221
}
32093222
}
3223+
if (ssa->ops && ssa->vars) {
3224+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3225+
if (ssa_op->op1_use >= 0) {
3226+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3227+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3228+
}
3229+
}
3230+
}
32103231
}
32113232
if (!zend_jit_assign_obj_op(&dasm_state, opline, op_array, ssa, ssa_op,
32123233
op1_info, op1_addr, OP1_DATA_INFO(), OP1_DATA_RANGE(),
3213-
0, ce, ce_is_instanceof, 0, NULL, IS_UNKNOWN,
3234+
0, ce, ce_is_instanceof, on_this, 0, NULL, IS_UNKNOWN,
32143235
zend_may_throw(opline, ssa_op, op_array, ssa))) {
32153236
goto jit_failure;
32163237
}
@@ -3226,11 +3247,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32263247
}
32273248
ce = NULL;
32283249
ce_is_instanceof = 0;
3250+
on_this = 0;
32293251
if (opline->op1_type == IS_UNUSED) {
32303252
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
32313253
ce = op_array->scope;
32323254
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
32333255
op1_addr = 0;
3256+
on_this = 1;
32343257
} else {
32353258
op1_info = OP1_INFO();
32363259
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3247,10 +3270,18 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32473270
}
32483271
}
32493272
}
3273+
if (ssa->ops && ssa->vars) {
3274+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3275+
if (ssa_op->op1_use >= 0) {
3276+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3277+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3278+
}
3279+
}
3280+
}
32503281
}
32513282
if (!zend_jit_assign_obj(&dasm_state, opline, op_array, ssa, ssa_op,
32523283
op1_info, op1_addr, OP1_DATA_INFO(),
3253-
0, ce, ce_is_instanceof, 0, NULL, IS_UNKNOWN,
3284+
0, ce, ce_is_instanceof, on_this, 0, NULL, IS_UNKNOWN,
32543285
zend_may_throw(opline, ssa_op, op_array, ssa))) {
32553286
goto jit_failure;
32563287
}
@@ -3734,11 +3765,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
37343765
}
37353766
ce = NULL;
37363767
ce_is_instanceof = 0;
3768+
on_this = 0;
37373769
if (opline->op1_type == IS_UNUSED) {
37383770
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
37393771
op1_addr = 0;
37403772
ce = op_array->scope;
37413773
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3774+
on_this = 1;
37423775
} else {
37433776
op1_info = OP1_INFO();
37443777
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3755,9 +3788,17 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
37553788
}
37563789
}
37573790
}
3791+
if (ssa->ops && ssa->vars) {
3792+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3793+
if (ssa_op->op1_use >= 0) {
3794+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3795+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3796+
}
3797+
}
3798+
}
37583799
}
37593800
if (!zend_jit_fetch_obj(&dasm_state, opline, op_array, ssa, ssa_op,
3760-
op1_info, op1_addr, 0, ce, ce_is_instanceof, 0, 0, NULL,
3801+
op1_info, op1_addr, 0, ce, ce_is_instanceof, on_this, 0, 0, NULL,
37613802
IS_UNKNOWN,
37623803
zend_may_throw(opline, ssa_op, op_array, ssa))) {
37633804
goto jit_failure;
@@ -3883,11 +3924,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
38833924
}
38843925
ce = NULL;
38853926
ce_is_instanceof = 0;
3927+
on_this = 0;
38863928
if (opline->op1_type == IS_UNUSED) {
38873929
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
38883930
op1_addr = 0;
38893931
ce = op_array->scope;
38903932
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3933+
on_this = 1;
38913934
} else {
38923935
op1_info = OP1_INFO();
38933936
if (!(op1_info & MAY_BE_OBJECT)) {
@@ -3904,9 +3947,17 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
39043947
}
39053948
}
39063949
}
3950+
if (ssa->ops && ssa->vars) {
3951+
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes];
3952+
if (ssa_op->op1_use >= 0) {
3953+
if (ssa->vars[ssa_op->op1_use].definition >= 0) {
3954+
on_this = op_array->opcodes[ssa->vars[ssa_op->op1_use].definition].opcode == ZEND_FETCH_THIS;
3955+
}
3956+
}
3957+
}
39073958
}
39083959
if (!zend_jit_init_method_call(&dasm_state, opline, b, op_array, ssa, ssa_op, call_level,
3909-
op1_info, op1_addr, ce, ce_is_instanceof, 0, NULL,
3960+
op1_info, op1_addr, ce, ce_is_instanceof, on_this, 0, NULL,
39103961
NULL, 0, 0)) {
39113962
goto jit_failure;
39123963
}

0 commit comments

Comments
 (0)