Zend: use zend_object* for zend_closure this_ptr field - #23246
Conversation
3bad973 to
9322da2
Compare
DanielEScherzer
left a comment
There was a problem hiding this comment.
okay for ext/reflection, two suggestions elsewhere
| zval instance; | ||
| ZVAL_OBJ(&instance, Z_OBJ(call->This)); | ||
|
|
||
| zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE(instance), &instance); | ||
| zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE(instance), Z_OBJ(instance)); |
There was a problem hiding this comment.
seems like this is doing an unnecessary setup of instance only to extract the object that we already have
| zval instance; | |
| ZVAL_OBJ(&instance, Z_OBJ(call->This)); | |
| zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE(instance), &instance); | |
| zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE(instance), Z_OBJ(instance)); | |
| zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE(call->This), Z_OBJ(call->This)); |
There was a problem hiding this comment.
I thought so too, but in reality it is needed to preserve the "this" of the current frame (I think) as call->This is pointing to the VM stack.
There was a problem hiding this comment.
okay, then can I suggest adding a comment to explain that so that others don't try to do the simplification that looked obvious to me?
There was a problem hiding this comment.
Okay, turns out it no longer gives test failures so I'll drop it.
These look right. The double load appears to be optimized out, but for clarity it would be worth it to de-duplicate. Also it looks like that the line |
Instead of a zval*, this is in preparation for converting the this_ptr field of zend_closure to zend_object*
Instead of a zval
9322da2 to
6fa9ff0
Compare
The main motivation was to convert
Z_PARAM_OBJECT{_OR_NULL}toZ_PARAM_OBJ{_OR_NULL}, but I do think working with azend_object*makes the code more legible and there are no question if this zval can ever be a different type.Not fully certain about the JIT changes, as maybe the double load is inefficient?