@@ -189,14 +189,100 @@ static zend_function* ZEND_FASTCALL zend_jit_find_method_tmp_helper(zend_object
189189 return fbc ;
190190}
191191
192- static zend_execute_data * ZEND_FASTCALL zend_jit_push_static_metod_call_frame (zend_object * obj , zend_function * fbc , uint32_t num_args )
192+
193+ static zend_class_entry * ZEND_FASTCALL zend_jit_find_class_helper (zend_execute_data * execute_data )
194+ {
195+ const zend_op * opline = EX (opline );
196+ zend_class_entry * ce ;
197+
198+ if (opline -> op1_type == IS_CONST ) {
199+ /* no function found. try a static method in class */
200+ ce = CACHED_PTR (opline -> result .num );
201+ if (UNEXPECTED (ce == NULL )) {
202+ ce = zend_fetch_class_by_name (Z_STR_P (RT_CONSTANT (opline , opline -> op1 )), Z_STR_P (RT_CONSTANT (opline , opline -> op1 ) + 1 ), ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION );
203+ }
204+ } else if (opline -> op1_type == IS_UNUSED ) {
205+ ce = zend_fetch_class (NULL , opline -> op1 .num );
206+ } else {
207+ ce = Z_CE_P (EX_VAR (opline -> op1 .var ));
208+ }
209+ return ce ;
210+ }
211+
212+ static zend_function * ZEND_FASTCALL zend_jit_find_static_method_helper (zend_execute_data * execute_data , zend_class_entry * ce )
213+ {
214+ const zend_op * opline = EX (opline );
215+ zend_function * fbc ;
216+
217+ ZEND_ASSERT (opline -> op2_type == IS_CONST );
218+
219+ if (opline -> op1_type == IS_CONST &&
220+ EXPECTED ((fbc = CACHED_PTR (opline -> result .num + sizeof (void * ))) != NULL )) {
221+ /* nothing to do */
222+ } else if (opline -> op1_type != IS_CONST &&
223+ EXPECTED (CACHED_PTR (opline -> result .num ) == ce )) {
224+ fbc = CACHED_PTR (opline -> result .num + sizeof (void * ));
225+ } else if (opline -> op2_type != IS_UNUSED ) {
226+ zval * function_name = RT_CONSTANT (opline , opline -> op2 );
227+
228+ ZEND_ASSERT (Z_TYPE_P (function_name ) == IS_STRING );
229+ if (ce -> get_static_method ) {
230+ fbc = ce -> get_static_method (ce , Z_STR_P (function_name ));
231+ } else {
232+ fbc = zend_std_get_static_method (ce , Z_STR_P (function_name ), RT_CONSTANT (opline , opline -> op2 ) + 1 );
233+ }
234+ if (UNEXPECTED (fbc == NULL )) {
235+ if (EXPECTED (!EG (exception ))) {
236+ zend_undefined_method (ce , Z_STR_P (function_name ));
237+ }
238+ return NULL ;
239+ }
240+ if (EXPECTED (!(fbc -> common .fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE |ZEND_ACC_NEVER_CACHE ))) &&
241+ EXPECTED (!(fbc -> common .scope -> ce_flags & ZEND_ACC_TRAIT ))) {
242+ CACHE_POLYMORPHIC_PTR (opline -> result .num , ce , fbc );
243+ }
244+ if (EXPECTED (fbc -> type == ZEND_USER_FUNCTION ) && UNEXPECTED (!RUN_TIME_CACHE (& fbc -> op_array ))) {
245+ zend_init_func_run_time_cache (& fbc -> op_array );
246+ }
247+ } else {
248+ if (UNEXPECTED (ce -> constructor == NULL )) {
249+ zend_throw_error (NULL , "Cannot call constructor" );
250+ return NULL ;
251+ }
252+ if (Z_TYPE (EX (This )) == IS_OBJECT && Z_OBJ (EX (This ))-> ce != ce -> constructor -> common .scope && (ce -> constructor -> common .fn_flags & ZEND_ACC_PRIVATE )) {
253+ zend_throw_error (NULL , "Cannot call private %s::__construct()" , ZSTR_VAL (ce -> name ));
254+ return NULL ;;
255+ }
256+ fbc = ce -> constructor ;
257+ if (EXPECTED (fbc -> type == ZEND_USER_FUNCTION ) && UNEXPECTED (!RUN_TIME_CACHE (& fbc -> op_array ))) {
258+ zend_init_func_run_time_cache (& fbc -> op_array );
259+ }
260+ }
261+
262+ return fbc ;
263+ }
264+
265+ static zend_execute_data * ZEND_FASTCALL zend_jit_push_this_method_call_frame (zend_class_entry * scope , zend_function * fbc , uint32_t num_args )
266+ {
267+ zend_execute_data * execute_data = EG (current_execute_data );
268+
269+ if (Z_TYPE (EX (This )) != IS_OBJECT || !instanceof_function (Z_OBJCE (EX (This )), scope )) {
270+ zend_non_static_method_call (fbc );
271+ return NULL ;
272+ }
273+
274+ scope = (zend_class_entry * )Z_OBJ (EX (This ));
275+ return zend_vm_stack_push_call_frame (ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS , fbc , num_args , scope );
276+ }
277+
278+ static zend_execute_data * ZEND_FASTCALL zend_jit_push_static_method_call_frame (zend_object * obj , zend_function * fbc , uint32_t num_args )
193279{
194280 zend_class_entry * scope = obj -> ce ;
195281
196282 return zend_vm_stack_push_call_frame (ZEND_CALL_NESTED_FUNCTION , fbc , num_args , scope );
197283}
198284
199- static zend_execute_data * ZEND_FASTCALL zend_jit_push_static_metod_call_frame_tmp (zend_object * obj , zend_function * fbc , uint32_t num_args )
285+ static zend_execute_data * ZEND_FASTCALL zend_jit_push_static_method_call_frame_tmp (zend_object * obj , zend_function * fbc , uint32_t num_args )
200286{
201287 zend_class_entry * scope = obj -> ce ;
202288
0 commit comments