Skip to content

Commit e138961

Browse files
committed
Remove zend_exception_save() and zend_exception_restore()
These are leftovers from the pre-PHP-7.0 era.
1 parent be1993b commit e138961

File tree

12 files changed

+2
-63
lines changed

12 files changed

+2
-63
lines changed

Zend/zend.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,6 @@ ZEND_API zend_result zend_execute_script(int type, zval *retval, zend_file_handl
19751975
zend_result ret = SUCCESS;
19761976
if (op_array) {
19771977
zend_execute(op_array, retval);
1978-
zend_exception_restore();
19791978
if (UNEXPECTED(EG(exception))) {
19801979
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
19811980
zend_user_exception_handler();

Zend/zend_exceptions.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -145,31 +145,6 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
145145
}
146146
/* }}} */
147147

148-
void zend_exception_save(void) /* {{{ */
149-
{
150-
if (EG(prev_exception)) {
151-
zend_exception_set_previous(EG(exception), EG(prev_exception));
152-
}
153-
if (EG(exception)) {
154-
EG(prev_exception) = EG(exception);
155-
}
156-
EG(exception) = NULL;
157-
}
158-
/* }}} */
159-
160-
void zend_exception_restore(void) /* {{{ */
161-
{
162-
if (EG(prev_exception)) {
163-
if (EG(exception)) {
164-
zend_exception_set_previous(EG(exception), EG(prev_exception));
165-
} else {
166-
EG(exception) = EG(prev_exception);
167-
}
168-
EG(prev_exception) = NULL;
169-
}
170-
}
171-
/* }}} */
172-
173148
static zend_always_inline bool is_handle_exception_set(void) {
174149
zend_execute_data *execute_data = EG(current_execute_data);
175150
return !execute_data
@@ -241,10 +216,6 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception) /*
241216
ZEND_API void zend_clear_exception(void) /* {{{ */
242217
{
243218
zend_object *exception;
244-
if (EG(prev_exception)) {
245-
OBJ_RELEASE(EG(prev_exception));
246-
EG(prev_exception) = NULL;
247-
}
248219
if (!EG(exception)) {
249220
return;
250221
}

Zend/zend_exceptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ extern ZEND_API zend_class_entry *zend_ce_unhandled_match_error;
4141
extern ZEND_API zend_class_entry *zend_ce_request_parse_body_exception;
4242

4343
ZEND_API void zend_exception_set_previous(zend_object *exception, zend_object *add_previous);
44-
ZEND_API void zend_exception_save(void);
45-
ZEND_API void zend_exception_restore(void);
4644

4745
ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception);
4846

Zend/zend_execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,7 @@ ZEND_API bool zend_internal_call_should_throw(const zend_function *fbc, zend_exe
13171317

13181318
if ((fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) &&
13191319
!zend_verify_internal_arg_types(fbc, call)) {
1320+
zend_clear_exception();
13201321
return 1;
13211322
}
13221323

Zend/zend_execute_API.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ void init_executor(void) /* {{{ */
176176
ZEND_ATOMIC_BOOL_INIT(&EG(timed_out), false);
177177

178178
EG(exception) = NULL;
179-
EG(prev_exception) = NULL;
180179

181180
EG(fake_scope) = NULL;
182181
EG(trampoline).common.function_name = NULL;
@@ -1272,9 +1271,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
12721271
zend_long previous_lineno = EG(lineno_override);
12731272
EG(filename_override) = NULL;
12741273
EG(lineno_override) = -1;
1275-
zend_exception_save();
12761274
ce = zend_autoload(autoload_name, lc_name);
1277-
zend_exception_restore();
12781275
EG(filename_override) = previous_filename;
12791276
EG(lineno_override) = previous_lineno;
12801277

Zend/zend_globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ struct _zend_executor_globals {
255255

256256
zend_objects_store objects_store;
257257
zend_lazy_objects_store lazy_objects_store;
258-
zend_object *exception, *prev_exception;
258+
zend_object *exception;
259259
const zend_op *opline_before_exception;
260260
zend_op exception_op[3];
261261

Zend/zend_language_scanner.l

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,7 +2764,6 @@ skip_escape_conversion:
27642764
27652765
zend_ptr_stack_reverse_apply(&current_state.heredoc_label_stack, copy_heredoc_label_stack);
27662766
2767-
zend_exception_save();
27682767
while (heredoc_nesting_level) {
27692768
zval zv;
27702769
int retval;
@@ -2793,7 +2792,6 @@ skip_escape_conversion:
27932792
heredoc_nesting_level = 0;
27942793
}
27952794
}
2796-
zend_exception_restore();
27972795
27982796
if (
27992797
(first_token == T_VARIABLE

Zend/zend_vm_def.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4797,10 +4797,8 @@ ZEND_VM_COLD_CONST_HANDLER(108, ZEND_THROW, CONST|TMPVAR|CV, ANY)
47974797
}
47984798
} while (0);
47994799

4800-
zend_exception_save();
48014800
Z_TRY_ADDREF_P(value);
48024801
zend_throw_exception_object(value);
4803-
zend_exception_restore();
48044802
FREE_OP1();
48054803
HANDLE_EXCEPTION();
48064804
}
@@ -4813,7 +4811,6 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, JMP_ADDR, LAST_CATCH|CACHE_SLOT)
48134811

48144812
SAVE_OPLINE();
48154813
/* Check whether an exception has been thrown, if not, jump over code */
4816-
zend_exception_restore();
48174814
if (EG(exception) == NULL) {
48184815
ZEND_VM_JMP_EX(OP_JMP_ADDR(opline, opline->op2), 0);
48194816
}

Zend/zend_vm_execute.h

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

ext/opcache/ZendAccelerator.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4641,7 +4641,6 @@ static zend_result accel_preload(const char *config, bool in_child)
46414641
zend_destroy_file_handle(&file_handle);
46424642
if (op_array) {
46434643
zend_execute(op_array, NULL);
4644-
zend_exception_restore();
46454644
if (UNEXPECTED(EG(exception))) {
46464645
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
46474646
zend_user_exception_handler();

0 commit comments

Comments
 (0)