Skip to content

Commit dcef190

Browse files
committed
Try to figure out how to free arguments
1 parent 4087ca2 commit dcef190

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

Zend/zend_vm_def.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7981,6 +7981,73 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
79817981
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)
79827982
|| !instanceof_function(zend_ce_exception, EG(exception)->ce)) {
79837983
cleanup_unfinished_calls(execute_data, throw_op_num);
7984+
} else if (UNEXPECTED(EX(call))) {
7985+
zend_execute_data *call = EX(call);
7986+
zend_op *opline = EX(func)->op_array.opcodes + throw_op_num;
7987+
bool do_exit = false;
7988+
unsigned int level = 0;
7989+
7990+
printf("Opcode %d\n", opline->opcode);
7991+
/* Decrement opline */
7992+
opline--;
7993+
7994+
do {
7995+
switch (opline->opcode) {
7996+
case ZEND_DO_FCALL:
7997+
case ZEND_DO_ICALL:
7998+
case ZEND_DO_UCALL:
7999+
case ZEND_DO_FCALL_BY_NAME:
8000+
level++;
8001+
break;
8002+
case ZEND_INIT_FCALL:
8003+
case ZEND_INIT_FCALL_BY_NAME:
8004+
case ZEND_INIT_NS_FCALL_BY_NAME:
8005+
case ZEND_INIT_DYNAMIC_CALL:
8006+
case ZEND_INIT_USER_CALL:
8007+
case ZEND_INIT_METHOD_CALL:
8008+
case ZEND_INIT_STATIC_METHOD_CALL:
8009+
case ZEND_NEW:
8010+
if (level == 0) {
8011+
ZEND_CALL_NUM_ARGS(call) = 0;
8012+
do_exit = true;
8013+
}
8014+
level--;
8015+
break;
8016+
case ZEND_SEND_VAL:
8017+
case ZEND_SEND_VAL_EX:
8018+
case ZEND_SEND_VAR:
8019+
case ZEND_SEND_VAR_EX:
8020+
case ZEND_SEND_FUNC_ARG:
8021+
case ZEND_SEND_REF:
8022+
case ZEND_SEND_VAR_NO_REF:
8023+
case ZEND_SEND_VAR_NO_REF_EX:
8024+
case ZEND_SEND_USER:
8025+
if (level == 0) {
8026+
/* For named args, the number of arguments is up to date. */
8027+
if (opline->op2_type != IS_CONST) {
8028+
ZEND_CALL_NUM_ARGS(call) = opline->op2.num;
8029+
}
8030+
do_exit = true;
8031+
}
8032+
break;
8033+
case ZEND_SEND_ARRAY:
8034+
case ZEND_SEND_UNPACK:
8035+
case ZEND_CHECK_UNDEF_ARGS:
8036+
if (level == 0) {
8037+
do_exit = true;
8038+
}
8039+
break;
8040+
}
8041+
if (!do_exit) {
8042+
opline--;
8043+
}
8044+
} while (!do_exit);
8045+
8046+
//zend_vm_stack_free_args(call);
8047+
//zend_vm_stack_free_extra_args(call);
8048+
//EX(call) = call->prev_execute_data;
8049+
//zend_vm_stack_free_call_frame(call);
8050+
//call = EX(call);
79848051
}
79858052

79868053
if (throw_op->result_type & (IS_VAR | IS_TMP_VAR)) {

Zend/zend_vm_execute.h

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

0 commit comments

Comments
 (0)