Skip to content

Commit cd7cf53

Browse files
committed
implement some CR feedback
1 parent a696e66 commit cd7cf53

File tree

5 files changed

+34
-22
lines changed

5 files changed

+34
-22
lines changed

UPGRADING.INTERNALS

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
336336
* DO_ICALL, DO_FCALL, and DO_FCALL_BY_NAME now call zend_interrupt_function
337337
while the internal frame is still on the stack. This means interrupt handlers
338338
will now see the internal call. If your interrupt handler does something like
339-
switching EG(current_execute_data), it probably needs to do something more
340-
similar to a fiber switch, or at least not do so when internal frames are on
341-
top anymore.
342-
343-
* RETURN, RETURN_BY_REF, GENERATOR_RETURN, and CALL_TRAMPOLINE now do a check
344-
for a VM interrupt and call zend_timeout/zend_interrupt_function after the
345-
ZEND_OBSERVER_FCALL_END call.
346-
339+
switching EG(current_execute_data), it should not do so if an internal func
340+
is on top.
347341
* New FRAMELESS_ICALL_[0,3] opcodes for faster internal function calls have been
348342
added. These opcodes don't create a stack frame, but pass arguments via opcode
349343
operands. They only work for functions that are known at compile-time, and

Zend/zend.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,15 @@ extern ZEND_API zend_write_func_t zend_write;
342342
extern ZEND_API FILE *(*zend_fopen)(zend_string *filename, zend_string **opened_path);
343343
extern ZEND_API void (*zend_ticks_function)(int ticks);
344344

345-
/* Called by the VM in certain places like at the end of function calls or
346-
* jumps, if EG(vm_interrupt) has been set.
345+
/* Called by the VM in certain places like at the loop header, user function
346+
* entry, and after internal function calls, if EG(vm_interrupt) has been set.
347347
*
348348
* If this is used to switch the EG(current_execute_data), such as implementing
349349
* a coroutine scheduler, then it needs to check the top frame to see if it's
350-
* an internal function. If so, it needs to do something similar to a fiber
351-
* switch, or at the very least delay switching until the internal frame is no
352-
* longer on top. Prior to PHP 8.0, this check was not necessary. In PHP 8.0
350+
* an internal function. If an internal function is on top, then the frame
351+
* shouldn't be switched away.
352+
*
353+
* Prior to PHP 8.0, this check was not necessary. In PHP 8.0,
353354
* zend_call_function started calling zend_interrupt_function, and in 8.4 the
354355
* DO_*CALL* opcodes started calling the zend_interrupt_function while the
355356
* internal frame is still on top.

Zend/zend_execute.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5520,7 +5520,8 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint
55205520

55215521
#define ZEND_VM_SET_OPCODE(new_op) \
55225522
CHECK_SYMBOL_TABLES() \
5523-
OPLINE = new_op;
5523+
OPLINE = new_op; \
5524+
ZEND_VM_INTERRUPT_CHECK()
55245525

55255526
#define ZEND_VM_SET_RELATIVE_OPCODE(opline, offset) \
55265527
ZEND_VM_SET_OPCODE(ZEND_OFFSET_TO_OPLINE(opline, offset))

Zend/zend_vm_def.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4099,6 +4099,8 @@ ZEND_VM_HOT_HANDLER(129, ZEND_DO_ICALL, ANY, ANY, SPEC(RETVAL,OBSERVER))
40994099
}
41004100

41014101
ZEND_VM_SET_OPCODE(opline + 1);
4102+
CHECK_SYMBOL_TABLES()
4103+
OPLINE = opline + 1;
41024104
ZEND_VM_CONTINUE();
41034105
}
41044106

@@ -4227,7 +4229,8 @@ ZEND_VM_C_LABEL(fcall_by_name_end):
42274229
zend_rethrow_exception(execute_data);
42284230
HANDLE_EXCEPTION();
42294231
}
4230-
ZEND_VM_SET_OPCODE(opline + 1);
4232+
CHECK_SYMBOL_TABLES()
4233+
OPLINE = opline + 1;
42314234
ZEND_VM_CONTINUE();
42324235
}
42334236

@@ -4347,7 +4350,8 @@ ZEND_VM_C_LABEL(fcall_end):
43474350
HANDLE_EXCEPTION();
43484351
}
43494352

4350-
ZEND_VM_SET_OPCODE(opline + 1);
4353+
CHECK_SYMBOL_TABLES()
4354+
OPLINE = opline + 1;
43514355
ZEND_VM_CONTINUE();
43524356
}
43534357

Zend/zend_vm_execute.h

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)