summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2019-02-07 21:05:46 +0300
committerDmitry Stogov <dmitry@zend.com>2019-02-07 21:05:46 +0300
commitf45e0ce928e1d02e872d8805f4476a1ba072e8d1 (patch)
tree1d809b6432a5fc653ecd4b5cb3f53faf5e04daff /Zend
parent2306c855abf504579aa2d2ca732dbb8c44d17f29 (diff)
downloadphp-git-f45e0ce928e1d02e872d8805f4476a1ba072e8d1.tar.gz
Remove ZEND_OVERLOADED_FUNCTION and corresponding call_method object handler
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/overloaded_func_001.phpt10
-rw-r--r--Zend/zend_API.c18
-rw-r--r--Zend/zend_compile.h2
-rw-r--r--Zend/zend_execute.c37
-rw-r--r--Zend/zend_execute.h2
-rw-r--r--Zend/zend_execute_API.c28
-rw-r--r--Zend/zend_iterators.c1
-rw-r--r--Zend/zend_object_handlers.c1
-rw-r--r--Zend/zend_object_handlers.h2
-rw-r--r--Zend/zend_vm_def.h19
-rw-r--r--Zend/zend_vm_execute.h38
11 files changed, 19 insertions, 139 deletions
diff --git a/Zend/tests/overloaded_func_001.phpt b/Zend/tests/overloaded_func_001.phpt
index 31585d505a..7fc435f920 100644
--- a/Zend/tests/overloaded_func_001.phpt
+++ b/Zend/tests/overloaded_func_001.phpt
@@ -6,10 +6,10 @@ if (!extension_loaded('zend-test')) die('skip zend-test extension not loaded');
?>
--FILE--
<?php
+$o = new _ZendTestChildClass();
+var_dump($o->test());
var_dump(_ZendTestClass::test());
?>
---EXPECTF--
-Fatal error: Uncaught Error: Cannot call overloaded function for non-object in %soverloaded_func_001.php:%d
-Stack trace:
-#0 {main}
- thrown in %soverloaded_func_001.php on line %d
+--EXPECT--
+string(4) "test"
+string(4) "test"
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index b51d6bd408..0b745161ff 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3014,8 +3014,7 @@ get_function_via_handler:
(!fcc->function_handler->common.scope ||
!instanceof_function(ce_org, fcc->function_handler->common.scope))) {
if (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
- if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
- fcc->function_handler->common.function_name) {
+ if (fcc->function_handler->common.function_name) {
zend_string_release_ex(fcc->function_handler->common.function_name, 0);
}
zend_free_trampoline(fcc->function_handler);
@@ -3206,11 +3205,8 @@ check_func:
ret = zend_is_callable_check_func(check_flags, callable, fcc, strict_class, error);
if (fcc == &fcc_local &&
fcc->function_handler &&
- ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) ||
- fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
- fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
- if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
- fcc->function_handler->common.function_name) {
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
+ if (fcc->function_handler->common.function_name) {
zend_string_release_ex(fcc->function_handler->common.function_name, 0);
}
zend_free_trampoline(fcc->function_handler);
@@ -3322,12 +3318,8 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam
add_next_index_str(callable, zend_string_copy(fcc.function_handler->common.function_name));
}
if (fcc.function_handler &&
- ((fcc.function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) ||
- fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
- fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
- if (fcc.function_handler->type != ZEND_OVERLOADED_FUNCTION) {
- zend_string_release_ex(fcc.function_handler->common.function_name, 0);
- }
+ (fcc.function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
+ zend_string_release_ex(fcc.function_handler->common.function_name, 0);
zend_free_trampoline(fcc.function_handler);
}
return 1;
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 62d17b4e11..6c1be2fdc0 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -875,9 +875,7 @@ void zend_assert_valid_class_name(const zend_string *const_name);
#define ZEND_INTERNAL_FUNCTION 1
#define ZEND_USER_FUNCTION 2
-#define ZEND_OVERLOADED_FUNCTION 3
#define ZEND_EVAL_CODE 4
-#define ZEND_OVERLOADED_FUNCTION_TEMPORARY 5
/* A quick check (type == ZEND_USER_FUNCTION || type == ZEND_EVAL_CODE) */
#define ZEND_USER_CODE(type) ((type & 1) == 0)
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index edaed2c63f..e33506d775 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -4069,43 +4069,6 @@ already_compiled:
}
/* }}} */
-ZEND_API int ZEND_FASTCALL zend_do_fcall_overloaded(zend_execute_data *call, zval *ret) /* {{{ */
-{
- zend_function *fbc = call->func;
- zend_object *object;
-
- /* Not sure what should be done here if it's a static method */
- if (UNEXPECTED(Z_TYPE(call->This) != IS_OBJECT)) {
- zend_vm_stack_free_args(call);
- if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- zend_string_release_ex(fbc->common.function_name, 0);
- }
- efree(fbc);
- zend_vm_stack_free_call_frame(call);
-
- zend_throw_error(NULL, "Cannot call overloaded function for non-object");
- return 0;
- }
-
- object = Z_OBJ(call->This);
-
- ZVAL_NULL(ret);
-
- EG(current_execute_data) = call;
- object->handlers->call_method(fbc->common.function_name, object, call, ret);
- EG(current_execute_data) = call->prev_execute_data;
-
- zend_vm_stack_free_args(call);
-
- if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- zend_string_release_ex(fbc->common.function_name, 0);
- }
- efree(fbc);
-
- return 1;
-}
-/* }}} */
-
static zend_never_inline zend_bool ZEND_FASTCALL zend_fe_reset_iterator(zval *array_ptr, int by_ref OPLINE_DC EXECUTE_DATA_DC) /* {{{ */
{
zend_class_entry *ce = Z_OBJCE_P(array_ptr);
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index a73982ab91..76f7d09f43 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -375,8 +375,6 @@ ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table);
ZEND_API void zend_free_compiled_variables(zend_execute_data *execute_data);
ZEND_API void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num);
-ZEND_API int ZEND_FASTCALL zend_do_fcall_overloaded(zend_execute_data *call, zval *ret);
-
#define CACHE_ADDR(num) \
((void**)((char*)EX_RUN_TIME_CACHE() + (num)))
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index fb6faad8af..de85e2ea6c 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -772,8 +772,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
/* We must re-initialize function again */
fci_cache->function_handler = NULL;
}
- } else if (func->type == ZEND_INTERNAL_FUNCTION) {
+ } else {
int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
+
+ ZEND_ASSERT(func->type == ZEND_INTERNAL_FUNCTION);
ZVAL_NULL(fci->retval);
call->prev_execute_data = EG(current_execute_data);
call->return_value = NULL; /* this is not a constructor call */
@@ -796,30 +798,6 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
/* We must re-initialize function again */
fci_cache->function_handler = NULL;
}
- } else { /* ZEND_OVERLOADED_FUNCTION */
- ZVAL_NULL(fci->retval);
-
- /* Not sure what should be done here if it's a static method */
- if (fci->object) {
- call->prev_execute_data = EG(current_execute_data);
- EG(current_execute_data) = call;
- fci->object->handlers->call_method(func->common.function_name, fci->object, call, fci->retval);
- EG(current_execute_data) = call->prev_execute_data;
- } else {
- zend_throw_error(NULL, "Cannot call overloaded function for non-object");
- }
-
- zend_vm_stack_free_args(call);
-
- if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- zend_string_release_ex(func->common.function_name, 0);
- }
- efree(func);
-
- if (EG(exception)) {
- zval_ptr_dtor(fci->retval);
- ZVAL_UNDEF(fci->retval);
- }
}
zend_vm_stack_free_call_frame(call);
diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c
index bb3cf1b6a2..7e920c00d8 100644
--- a/Zend/zend_iterators.c
+++ b/Zend/zend_iterators.c
@@ -44,7 +44,6 @@ static const zend_object_handlers iterator_object_handlers = {
NULL, /* unset dim */
NULL, /* props get */
NULL, /* method get */
- NULL, /* call */
NULL, /* get ctor */
NULL, /* get class name */
NULL, /* compare */
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index eb853064c2..520610327f 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1845,7 +1845,6 @@ ZEND_API const zend_object_handlers std_object_handlers = {
zend_std_unset_dimension, /* unset_dimension */
zend_std_get_properties, /* get_properties */
zend_std_get_method, /* get_method */
- NULL, /* call_method */
zend_std_get_constructor, /* get_constructor */
zend_std_get_class_name, /* get_class_name */
zend_std_compare_objects, /* compare_objects */
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index 64356bcb04..ff4f025970 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -120,7 +120,6 @@ typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zen
/* args on stack! */
/* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this.
*/
-typedef int (*zend_object_call_method_t)(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS);
typedef zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const zval *key);
typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object);
@@ -171,7 +170,6 @@ struct _zend_object_handlers {
zend_object_unset_dimension_t unset_dimension; /* required */
zend_object_get_properties_t get_properties; /* required */
zend_object_get_method_t get_method; /* required */
- zend_object_call_method_t call_method; /* optional */
zend_object_get_constructor_t get_constructor; /* required */
zend_object_get_class_name_t get_class_name; /* required */
zend_object_compare_t compare_objects; /* optional */
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 9b808a6e12..5114b2275c 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -4019,9 +4019,10 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
- } else if (EXPECTED(fbc->type < ZEND_USER_FUNCTION)) {
+ } else {
zval retval;
+ ZEND_ASSERT(fbc->type == ZEND_INTERNAL_FUNCTION);
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
@@ -4056,22 +4057,6 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
if (!RETURN_VALUE_USED(opline)) {
zval_ptr_dtor(ret);
}
-
- } else { /* ZEND_OVERLOADED_FUNCTION */
- zval retval;
-
- ret = RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : &retval;
-
- call->prev_execute_data = execute_data;
-
- if (UNEXPECTED(!zend_do_fcall_overloaded(call, ret))) {
- UNDEF_RESULT();
- HANDLE_EXCEPTION();
- }
-
- if (!RETURN_VALUE_USED(opline)) {
- zval_ptr_dtor(ret);
- }
}
ZEND_VM_C_LABEL(fcall_end):
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 13e096363d..a7a17c64af 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -963,9 +963,10 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
- } else if (EXPECTED(fbc->type < ZEND_USER_FUNCTION)) {
+ } else {
zval retval;
+ ZEND_ASSERT(fbc->type == ZEND_INTERNAL_FUNCTION);
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
@@ -1000,22 +1001,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
if (!0) {
zval_ptr_dtor(ret);
}
-
- } else { /* ZEND_OVERLOADED_FUNCTION */
- zval retval;
-
- ret = 0 ? EX_VAR(opline->result.var) : &retval;
-
- call->prev_execute_data = execute_data;
-
- if (UNEXPECTED(!zend_do_fcall_overloaded(call, ret))) {
- UNDEF_RESULT();
- HANDLE_EXCEPTION();
- }
-
- if (!0) {
- zval_ptr_dtor(ret);
- }
}
fcall_end:
@@ -1084,9 +1069,10 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
- } else if (EXPECTED(fbc->type < ZEND_USER_FUNCTION)) {
+ } else {
zval retval;
+ ZEND_ASSERT(fbc->type == ZEND_INTERNAL_FUNCTION);
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
@@ -1121,22 +1107,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
if (!1) {
zval_ptr_dtor(ret);
}
-
- } else { /* ZEND_OVERLOADED_FUNCTION */
- zval retval;
-
- ret = 1 ? EX_VAR(opline->result.var) : &retval;
-
- call->prev_execute_data = execute_data;
-
- if (UNEXPECTED(!zend_do_fcall_overloaded(call, ret))) {
- UNDEF_RESULT();
- HANDLE_EXCEPTION();
- }
-
- if (!1) {
- zval_ptr_dtor(ret);
- }
}
fcall_end: