Lines Matching refs:obj

96 static void zend_lazy_object_set_info(zend_object *obj, zend_lazy_object_info *info)  in zend_lazy_object_set_info()  argument
98 ZEND_ASSERT(zend_object_is_lazy(obj)); in zend_lazy_object_set_info()
100 zval *zv = zend_hash_index_add_new_ptr(&EG(lazy_objects_store).infos, obj->handle, info); in zend_lazy_object_set_info()
105 static zend_lazy_object_info* zend_lazy_object_get_info(zend_object *obj) in zend_lazy_object_get_info() argument
107 ZEND_ASSERT(zend_object_is_lazy(obj)); in zend_lazy_object_get_info()
109 zend_lazy_object_info *info = zend_hash_index_find_ptr(&EG(lazy_objects_store).infos, obj->handle); in zend_lazy_object_get_info()
115 static bool zend_lazy_object_has_stale_info(zend_object *obj) in zend_lazy_object_has_stale_info() argument
117 return zend_hash_index_find_ptr(&EG(lazy_objects_store).infos, obj->handle); in zend_lazy_object_has_stale_info()
120 zval* zend_lazy_object_get_initializer_zv(zend_object *obj) in zend_lazy_object_get_initializer_zv() argument
122 ZEND_ASSERT(!zend_lazy_object_initialized(obj)); in zend_lazy_object_get_initializer_zv()
124 zend_lazy_object_info *info = zend_lazy_object_get_info(obj); in zend_lazy_object_get_initializer_zv()
131 static zend_fcall_info_cache* zend_lazy_object_get_initializer_fcc(zend_object *obj) in zend_lazy_object_get_initializer_fcc() argument
133 ZEND_ASSERT(!zend_lazy_object_initialized(obj)); in zend_lazy_object_get_initializer_fcc()
135 zend_lazy_object_info *info = zend_lazy_object_get_info(obj); in zend_lazy_object_get_initializer_fcc()
142 zend_object* zend_lazy_object_get_instance(zend_object *obj) in zend_lazy_object_get_instance() argument
144 ZEND_ASSERT(zend_lazy_object_initialized(obj)); in zend_lazy_object_get_instance()
146 if (zend_object_is_lazy_proxy(obj)) { in zend_lazy_object_get_instance()
147 zend_lazy_object_info *info = zend_lazy_object_get_info(obj); in zend_lazy_object_get_instance()
154 return obj; in zend_lazy_object_get_instance()
157 zend_lazy_object_flags_t zend_lazy_object_get_flags(zend_object *obj) in zend_lazy_object_get_flags() argument
159 return zend_lazy_object_get_info(obj)->flags; in zend_lazy_object_get_flags()
162 void zend_lazy_object_del_info(zend_object *obj) in zend_lazy_object_del_info() argument
164 zend_result res = zend_hash_index_del(&EG(lazy_objects_store).infos, obj->handle); in zend_lazy_object_del_info()
168 bool zend_lazy_object_decr_lazy_props(zend_object *obj) in zend_lazy_object_decr_lazy_props() argument
170 ZEND_ASSERT(zend_object_is_lazy(obj)); in zend_lazy_object_decr_lazy_props()
171 ZEND_ASSERT(!zend_lazy_object_initialized(obj)); in zend_lazy_object_decr_lazy_props()
173 zend_lazy_object_info *info = zend_lazy_object_get_info(obj); in zend_lazy_object_decr_lazy_props()
225 ZEND_API zend_object *zend_object_make_lazy(zend_object *obj, in zend_object_make_lazy() argument
233 ZEND_ASSERT(!obj || (!zend_object_is_lazy(obj) || zend_lazy_object_initialized(obj))); in zend_object_make_lazy()
234 ZEND_ASSERT(!obj || instanceof_function(obj->ce, reflection_ce)); in zend_object_make_lazy()
252 if (!obj) { in zend_object_make_lazy()
269 obj = zend_objects_new(reflection_ce); in zend_object_make_lazy()
271 for (int i = 0; i < obj->ce->default_properties_count; i++) { in zend_object_make_lazy()
272 zval *p = &obj->properties_table[i]; in zend_object_make_lazy()
274 if (EXPECTED(obj->ce->properties_info_table[i])) { in zend_object_make_lazy()
282 if (zlo_is_iterating(obj)) { in zend_object_make_lazy()
286 if (zend_object_is_lazy(obj)) { in zend_object_make_lazy()
287 ZEND_ASSERT(zend_object_is_lazy_proxy(obj) && zend_lazy_object_initialized(obj)); in zend_object_make_lazy()
288 OBJ_EXTRA_FLAGS(obj) &= ~(IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY); in zend_object_make_lazy()
289 zend_lazy_object_del_info(obj); in zend_object_make_lazy()
291 if (zend_lazy_object_has_stale_info(obj)) { in zend_object_make_lazy()
297 && !(OBJ_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) { in zend_object_make_lazy()
298 if (obj->handlers->dtor_obj != zend_objects_destroy_object in zend_object_make_lazy()
299 || obj->ce->destructor) { in zend_object_make_lazy()
300 GC_ADD_FLAGS(obj, IS_OBJ_DESTRUCTOR_CALLED); in zend_object_make_lazy()
301 GC_ADDREF(obj); in zend_object_make_lazy()
302 obj->handlers->dtor_obj(obj); in zend_object_make_lazy()
303 GC_DELREF(obj); in zend_object_make_lazy()
311 GC_DEL_FLAGS(obj, IS_OBJ_DESTRUCTOR_CALLED); in zend_object_make_lazy()
315 if (obj->properties) { in zend_object_make_lazy()
316 if (UNEXPECTED(GC_REFCOUNT(obj->properties) > 1)) { in zend_object_make_lazy()
317 if (EXPECTED(!(GC_FLAGS(obj->properties) & IS_ARRAY_IMMUTABLE))) { in zend_object_make_lazy()
318 GC_DELREF(obj->properties); in zend_object_make_lazy()
320 obj->properties = zend_array_dup(obj->properties); in zend_object_make_lazy()
322 zend_hash_reverse_apply(obj->properties, zlo_hash_remove_dyn_props_func); in zend_object_make_lazy()
327 zend_property_info *prop_info = obj->ce->properties_info_table[i]; in zend_object_make_lazy()
329 zval *p = &obj->properties_table[i]; in zend_object_make_lazy()
333 && ((obj->ce->ce_flags & ZEND_ACC_FINAL) || (prop_info->flags & ZEND_ACC_FINAL))) { in zend_object_make_lazy()
336 zend_object_dtor_property(obj, p); in zend_object_make_lazy()
349 return obj; in zend_object_make_lazy()
352 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED; in zend_object_make_lazy()
355 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_PROXY; in zend_object_make_lazy()
365 zend_lazy_object_set_info(obj, info); in zend_object_make_lazy()
367 return obj; in zend_object_make_lazy()
376 ZEND_API zend_object *zend_lazy_object_mark_as_initialized(zend_object *obj) in zend_lazy_object_mark_as_initialized() argument
378 ZEND_ASSERT(zend_object_is_lazy(obj)); in zend_lazy_object_mark_as_initialized()
379 ZEND_ASSERT(!zend_lazy_object_initialized(obj)); in zend_lazy_object_mark_as_initialized()
381 zend_class_entry *ce = obj->ce; in zend_lazy_object_mark_as_initialized()
386 zval *properties_table = obj->properties_table; in zend_lazy_object_mark_as_initialized()
388 OBJ_EXTRA_FLAGS(obj) &= ~(IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY); in zend_lazy_object_mark_as_initialized()
396 zend_lazy_object_del_info(obj); in zend_lazy_object_mark_as_initialized()
398 return obj; in zend_lazy_object_mark_as_initialized()
402 static void zend_lazy_object_revert_init(zend_object *obj, zval *properties_table_snapshot, HashTab… in zend_lazy_object_revert_init() argument
404 zend_class_entry *ce = obj->ce; in zend_lazy_object_revert_init()
408 zval *properties_table = obj->properties_table; in zend_lazy_object_revert_init()
412 zend_object_dtor_property(obj, p); in zend_lazy_object_revert_init()
424 if (obj->properties != properties_snapshot) { in zend_lazy_object_revert_init()
426 zend_release_properties(obj->properties); in zend_lazy_object_revert_init()
427 obj->properties = properties_snapshot; in zend_lazy_object_revert_init()
432 } else if (obj->properties) { in zend_lazy_object_revert_init()
433 zend_release_properties(obj->properties); in zend_lazy_object_revert_init()
434 obj->properties = NULL; in zend_lazy_object_revert_init()
437 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED; in zend_lazy_object_revert_init()
462 static zend_object *zend_lazy_object_init_proxy(zend_object *obj) in zend_lazy_object_init_proxy() argument
464 ZEND_ASSERT(zend_object_is_lazy_proxy(obj)); in zend_lazy_object_init_proxy()
465 ZEND_ASSERT(!zend_lazy_object_initialized(obj)); in zend_lazy_object_init_proxy()
468 GC_ADDREF(obj); in zend_lazy_object_init_proxy()
470 zend_lazy_object_info *info = zend_lazy_object_get_info(obj); in zend_lazy_object_init_proxy()
473 OBJ_EXTRA_FLAGS(obj) &= ~(IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY); in zend_lazy_object_init_proxy()
483 ZVAL_OBJ(&zobj, obj); in zend_lazy_object_init_proxy()
488 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY; in zend_lazy_object_init_proxy()
493 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY; in zend_lazy_object_init_proxy()
495 ZSTR_VAL(obj->ce->name), in zend_lazy_object_init_proxy()
501 if (UNEXPECTED(Z_TYPE(retval) != IS_OBJECT || !zend_lazy_object_compatible(Z_OBJ(retval), obj))) { in zend_lazy_object_init_proxy()
502 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY; in zend_lazy_object_init_proxy()
505 ZSTR_VAL(obj->ce->name)); in zend_lazy_object_init_proxy()
510 if (UNEXPECTED(Z_OBJ(retval) == obj || zend_object_is_lazy(Z_OBJ(retval)))) { in zend_lazy_object_init_proxy()
511 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED|IS_OBJ_LAZY_PROXY; in zend_lazy_object_init_proxy()
521 OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_PROXY; in zend_lazy_object_init_proxy()
525 zend_object_dtor_dynamic_properties(obj); in zend_lazy_object_init_proxy()
526 obj->properties = NULL; in zend_lazy_object_init_proxy()
530 zend_object_dtor_property(obj, &obj->properties_table[i]); in zend_lazy_object_init_proxy()
531 ZVAL_UNDEF(&obj->properties_table[i]); in zend_lazy_object_init_proxy()
532 Z_PROP_FLAG_P(&obj->properties_table[i]) = IS_PROP_UNINIT | IS_PROP_LAZY; in zend_lazy_object_init_proxy()
539 if (UNEXPECTED(GC_DELREF(obj) == 0)) { in zend_lazy_object_init_proxy()
541 zend_objects_store_del(obj); in zend_lazy_object_init_proxy()
544 gc_check_possible_root((zend_refcounted*) obj); in zend_lazy_object_init_proxy()
551 ZEND_API zend_object *zend_lazy_object_init(zend_object *obj) in zend_lazy_object_init() argument
553 ZEND_ASSERT(zend_object_is_lazy(obj)); in zend_lazy_object_init()
561 if (zend_lazy_object_initialized(obj)) { in zend_lazy_object_init()
562 ZEND_ASSERT(zend_object_is_lazy_proxy(obj)); in zend_lazy_object_init()
563 zend_lazy_object_info *info = zend_lazy_object_get_info(obj); in zend_lazy_object_init()
571 zend_class_entry *ce = obj->ce; in zend_lazy_object_init()
575 if (zend_object_is_lazy_proxy(obj)) { in zend_lazy_object_init()
576 return zend_lazy_object_init_proxy(obj); in zend_lazy_object_init()
580 GC_ADDREF(obj); in zend_lazy_object_init()
582 zend_fcall_info_cache *initializer = zend_lazy_object_get_initializer_fcc(obj); in zend_lazy_object_init()
585 OBJ_EXTRA_FLAGS(obj) &= ~IS_OBJ_LAZY_UNINITIALIZED; in zend_lazy_object_init()
588 HashTable *properties_snapshot = obj->properties; in zend_lazy_object_init()
599 zval *properties_table = obj->properties_table; in zend_lazy_object_init()
617 ZVAL_OBJ(&zobj, obj); in zend_lazy_object_init()
622 zend_lazy_object_revert_init(obj, properties_table_snapshot, properties_snapshot); in zend_lazy_object_init()
627 zend_lazy_object_revert_init(obj, properties_table_snapshot, properties_snapshot); in zend_lazy_object_init()
634 for (int i = 0; i < obj->ce->default_properties_count; i++) { in zend_lazy_object_init()
650 zend_lazy_object_del_info(obj); in zend_lazy_object_init()
652 instance = obj; in zend_lazy_object_init()
655 if (UNEXPECTED(GC_DELREF(obj) == 0)) { in zend_lazy_object_init()
657 zend_objects_store_del(obj); in zend_lazy_object_init()
660 gc_check_possible_root((zend_refcounted*) obj); in zend_lazy_object_init()
667 void zend_lazy_object_realize(zend_object *obj) in zend_lazy_object_realize() argument
669 ZEND_ASSERT(zend_object_is_lazy(obj)); in zend_lazy_object_realize()
670 ZEND_ASSERT(!zend_lazy_object_initialized(obj)); in zend_lazy_object_realize()
672 zend_lazy_object_del_info(obj); in zend_lazy_object_realize()
675 for (int i = 0; i < obj->ce->default_properties_count; i++) { in zend_lazy_object_realize()
676 ZEND_ASSERT(!(Z_PROP_FLAG_P(&obj->properties_table[i]) & IS_PROP_LAZY)); in zend_lazy_object_realize()
680 OBJ_EXTRA_FLAGS(obj) &= ~(IS_OBJ_LAZY_UNINITIALIZED | IS_OBJ_LAZY_PROXY); in zend_lazy_object_realize()
802 zend_property_info *zend_lazy_object_get_property_info_for_slot(zend_object *obj, zval *slot) in zend_lazy_object_get_property_info_for_slot() argument
804 ZEND_ASSERT(zend_object_is_lazy_proxy(obj)); in zend_lazy_object_get_property_info_for_slot()
806 zend_property_info **table = obj->ce->properties_info_table; in zend_lazy_object_get_property_info_for_slot()
807 intptr_t prop_num = slot - obj->properties_table; in zend_lazy_object_get_property_info_for_slot()
808 if (prop_num >= 0 && prop_num < obj->ce->default_properties_count) { in zend_lazy_object_get_property_info_for_slot()
812 if (!zend_lazy_object_initialized(obj)) { in zend_lazy_object_get_property_info_for_slot()
816 obj = zend_lazy_object_get_instance(obj); in zend_lazy_object_get_property_info_for_slot()
817 return zend_get_property_info_for_slot(obj, slot); in zend_lazy_object_get_property_info_for_slot()