Skip to content

Commit 532fed0

Browse files
committed
Apply obvious simplification
1 parent b2e7b73 commit 532fed0

File tree

7 files changed

+8
-22
lines changed

7 files changed

+8
-22
lines changed

NEWS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ PHP NEWS
3030
. Fixed bug GH-14267 (opcache.jit=off does not allow enabling JIT at runtime).
3131
(ilutov)
3232
. Fixed TLS access in JIT on FreeBSD/amd64. (Arnaud)
33+
. Fixed bug GH-13817 (Segmentation fault for enabled observers after pass 4).
34+
(Bob)
3335

3436
- Soap:
3537
. Fixed bug #47925 (PHPClient can't decompress response). (nielsdos)
@@ -142,8 +144,6 @@ PHP NEWS
142144
- Opcache:
143145
. Fixed incorrect assumptions across compilation units for static calls.
144146
(ilutov)
145-
. Fixed bug GH-13817 (Segmentation fault for enabled observers after pass 4).
146-
(Bob)
147147

148148
- OpenSSL:
149149
. Fixed bug GH-10495 (feof on OpenSSL stream hangs indefinitely).

Zend/Optimizer/compact_vars.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void zend_optimizer_compact_vars(zend_op_array *op_array) {
117117
op_array->last_var = num_cvs;
118118
}
119119

120-
op_array->T = num_tmps;
120+
op_array->T = num_tmps + ZEND_OBSERVER_ENABLED; // reserve last temporary for observers if enabled
121121

122122
free_alloca(vars_map, use_heap2);
123123
}

Zend/Optimizer/optimize_func_calls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
195195
/* nothing to do */
196196
} else if (fcall->opcode == ZEND_INIT_FCALL_BY_NAME) {
197197
fcall->opcode = ZEND_INIT_FCALL;
198-
fcall->op1.num = zend_vm_calc_ct_used_stack(fcall->extended_value, call_stack[call].func);
198+
fcall->op1.num = zend_vm_calc_used_stack(fcall->extended_value, call_stack[call].func);
199199
literal_dtor(&ZEND_OP2_LITERAL(fcall));
200200
fcall->op2.constant = fcall->op2.constant + 1;
201201
if (opline->opcode != ZEND_CALLABLE_CONVERT) {
202202
opline->opcode = zend_get_call_op(fcall, call_stack[call].func);
203203
}
204204
} else if (fcall->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
205205
fcall->opcode = ZEND_INIT_FCALL;
206-
fcall->op1.num = zend_vm_calc_ct_used_stack(fcall->extended_value, call_stack[call].func);
206+
fcall->op1.num = zend_vm_calc_used_stack(fcall->extended_value, call_stack[call].func);
207207
literal_dtor(&op_array->literals[fcall->op2.constant]);
208208
literal_dtor(&op_array->literals[fcall->op2.constant + 2]);
209209
fcall->op2.constant = fcall->op2.constant + 1;

Zend/Optimizer/optimize_temp_vars_5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,5 @@ void zend_optimize_temporary_variables(zend_op_array *op_array, zend_optimizer_c
173173
}
174174

175175
zend_arena_release(&ctx->arena, checkpoint);
176-
op_array->T = max + 1;
176+
op_array->T = max + 1 + ZEND_OBSERVER_ENABLED; // reserve last temporary for observers if enabled
177177
}

Zend/Optimizer/zend_optimizer.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,6 @@ static void zend_revert_pass_two(zend_op_array *op_array)
10971097
}
10981098
#endif
10991099

1100-
op_array->T -= ZEND_OBSERVER_ENABLED;
1101-
11021100
op_array->fn_flags &= ~ZEND_ACC_DONE_PASS_TWO;
11031101
}
11041102

@@ -1128,8 +1126,6 @@ static void zend_redo_pass_two(zend_op_array *op_array)
11281126
}
11291127
#endif
11301128

1131-
op_array->T += ZEND_OBSERVER_ENABLED; // reserve last temporary for observers if enabled
1132-
11331129
opline = op_array->opcodes;
11341130
end = opline + op_array->last;
11351131
while (opline < end) {
@@ -1238,8 +1234,6 @@ static void zend_redo_pass_two_ex(zend_op_array *op_array, zend_ssa *ssa)
12381234
}
12391235
#endif
12401236

1241-
op_array->T += ZEND_OBSERVER_ENABLED; // reserve last temporary for observers if enabled
1242-
12431237
opline = op_array->opcodes;
12441238
end = opline + op_array->last;
12451239
while (opline < end) {
@@ -1364,7 +1358,7 @@ static void zend_adjust_fcall_stack_size(zend_op_array *op_array, zend_optimizer
13641358
&ctx->script->function_table,
13651359
Z_STR_P(RT_CONSTANT(opline, opline->op2)));
13661360
if (func) {
1367-
opline->op1.num = zend_vm_calc_ct_used_stack(opline->extended_value, func);
1361+
opline->op1.num = zend_vm_calc_used_stack(opline->extended_value, func);
13681362
}
13691363
}
13701364
opline++;
@@ -1383,7 +1377,7 @@ static void zend_adjust_fcall_stack_size_graph(zend_op_array *op_array)
13831377

13841378
if (opline && call_info->callee_func && opline->opcode == ZEND_INIT_FCALL) {
13851379
ZEND_ASSERT(!call_info->is_prototype);
1386-
opline->op1.num = zend_vm_calc_ct_used_stack(opline->extended_value, call_info->callee_func);
1380+
opline->op1.num = zend_vm_calc_used_stack(opline->extended_value, call_info->callee_func);
13871381
}
13881382
call_info = call_info->next_callee;
13891383
}

Zend/zend_execute.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,6 @@ ZEND_API void* zend_vm_stack_extend(size_t size)
226226
return ptr;
227227
}
228228

229-
ZEND_API uint32_t zend_vm_calc_ct_used_stack(uint32_t num_args, zend_function *func)
230-
{
231-
return zend_vm_calc_used_stack(num_args, func) + ((func->common.fn_flags & ZEND_ACC_DONE_PASS_TWO) == 0 && ZEND_USER_CODE(func->type) ? ZEND_OBSERVER_ENABLED : 0) * sizeof(zval);
232-
}
233-
234229
ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data, uint32_t var)
235230
{
236231
return EX_VAR(var);

Zend/zend_execute.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,6 @@ static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, ze
255255
return used_stack * sizeof(zval);
256256
}
257257

258-
// Handle a possibly currently not applied pass_two
259-
ZEND_API uint32_t zend_vm_calc_ct_used_stack(uint32_t num_args, zend_function *func);
260-
261258
static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t call_info, zend_function *func, uint32_t num_args, void *object_or_called_scope)
262259
{
263260
uint32_t used_stack = zend_vm_calc_used_stack(num_args, func);

0 commit comments

Comments
 (0)