static FORCE_INLINE void scan_object(Collector* collector, Partial_Reveal_Object *p_obj) { assert((((POINTER_SIZE_INT)p_obj) % GC_OBJECT_ALIGNMENT) == 0); if (!object_has_ref_field(p_obj)) return; REF *p_ref; /* scan array object */ if (object_is_array(p_obj)) { Partial_Reveal_Object* array = p_obj; assert(!obj_is_primitive_array(array)); I_32 array_length = vector_get_length((Vector_Handle) array); for (int i = 0; i < array_length; i++) { p_ref= (REF *)vector_get_element_address_ref((Vector_Handle) array, i); scan_slot(collector, p_ref); } return; /* array can't be a reference object, directly return. */ } /* scan non-array object */ unsigned int num_refs = object_ref_field_num(p_obj); int *ref_iterator = object_ref_iterator_init(p_obj); for(unsigned int i=0; i<num_refs; i++){ REF* p_ref = object_ref_iterator_get(ref_iterator+i, p_obj); scan_slot(collector, p_ref); } #ifndef BUILD_IN_REFERENT scan_weak_reference(collector, p_obj, scan_slot); #endif return; }
static FORCE_INLINE void scan_object(Collector* collector, Partial_Reveal_Object *p_obj) { vm_notify_obj_alive( (void *)p_obj); assert((((POINTER_SIZE_INT)p_obj) % GC_OBJECT_ALIGNMENT) == 0); Partial_Reveal_VTable *vtable = decode_vt(obj_get_vt(p_obj)); if(TRACE_JLC_VIA_VTABLE) if(vtable->vtmark == VT_UNMARKED) { vtable->vtmark = VT_MARKED; if(obj_mark_in_vt(vtable->jlC)) collector_tracestack_push(collector, vtable->jlC); } if( !object_has_ref_field(p_obj) ) return; REF *p_ref; if (object_is_array(p_obj)) { /* scan array object */ Partial_Reveal_Array* array = (Partial_Reveal_Array*)p_obj; unsigned int array_length = array->array_len; p_ref = (REF *)((POINTER_SIZE_INT)array + (int)array_first_element_offset(array)); for (unsigned int i = 0; i < array_length; i++) { scan_slot(collector, p_ref+i); } }else{ /* scan non-array object */ unsigned int num_refs = object_ref_field_num(p_obj); int* ref_iterator = object_ref_iterator_init(p_obj); for(unsigned int i=0; i<num_refs; i++){ p_ref = object_ref_iterator_get(ref_iterator+i, p_obj); scan_slot(collector, p_ref); } #ifndef BUILD_IN_REFERENT scan_weak_reference(collector, p_obj, scan_slot); #endif } return; }
static FORCE_INLINE void scan_object(Conclctor* marker, Partial_Reveal_Object *p_obj) { assert((((POINTER_SIZE_INT)p_obj) % GC_OBJECT_ALIGNMENT) == 0); if(obj_is_dirty_in_table(p_obj)){ assert(obj_is_mark_black_in_table(p_obj)); return; } if(!object_has_ref_field(p_obj)) return; REF *p_ref; if(object_is_array(p_obj)){ /* scan array object */ Partial_Reveal_Array *array = (Partial_Reveal_Array*)p_obj; unsigned int array_length = array->array_len; p_ref = (REF *)((POINTER_SIZE_INT)array + (int)array_first_element_offset(array)); for (unsigned int i = 0; i < array_length; i++) scan_slot((Collector*)marker, p_ref+i); return; } /* scan non-array object */ unsigned int num_refs = object_ref_field_num(p_obj); int *ref_iterator = object_ref_iterator_init(p_obj); for(unsigned int i=0; i<num_refs; i++){ p_ref = object_ref_iterator_get(ref_iterator+i, p_obj); scan_slot((Collector*)marker, p_ref); } #ifndef BUILD_IN_REFERENT scan_weak_reference_direct((Collector*)marker, p_obj, scan_slot); #endif }
static FORCE_INLINE void scan_object(Heap_Verifier* heap_verifier, Partial_Reveal_Object *p_obj) { GC_Verifier* gc_verifier = heap_verifier->gc_verifier; #if !defined(USE_UNIQUE_MARK_SWEEP_GC) && !defined(USE_UNIQUE_MOVE_COMPACT_GC) if(gc_verifier->is_before_fallback_collection) { if(obj_belongs_to_nos(p_obj) && obj_is_fw_in_oi(p_obj)){ assert(obj_get_vt(p_obj) == obj_get_vt(obj_get_fw_in_oi(p_obj))); p_obj = obj_get_fw_in_oi(p_obj); assert(p_obj); } } #endif if(!obj_mark_in_vt(p_obj)) return; if( !major_is_marksweep() && p_obj >= los_boundary ){ Block_Header* block = GC_BLOCK_HEADER(p_obj); if( heap_verifier->is_before_gc) block->num_live_objs++; /* we can't set block->num_live_objs = 0 if !is_before_gc, because the some blocks may be freed hence not visited after GC. So we should reset it in GC space reset functions. */ } verify_object_header(p_obj, heap_verifier); verifier_update_verify_info(p_obj, heap_verifier); /*FIXME: */ if (!object_has_ref_field(p_obj)) return; REF* p_ref; if (object_is_array(p_obj)) { Partial_Reveal_Array* array = (Partial_Reveal_Array*)p_obj; unsigned int array_length = array->array_len; p_ref = (REF*)((POINTER_SIZE_INT)array + (int)array_first_element_offset(array)); for (unsigned int i = 0; i < array_length; i++) { scan_slot(heap_verifier, p_ref+i); } }else{ unsigned int num_refs = object_ref_field_num(p_obj); int* ref_iterator = object_ref_iterator_init(p_obj); for(unsigned int i=0; i<num_refs; i++){ p_ref = object_ref_iterator_get(ref_iterator+i, p_obj); scan_slot(heap_verifier, p_ref); } #ifndef BUILD_IN_REFERENT WeakReferenceType type = special_reference_type(p_obj); if(type == SOFT_REFERENCE && verifier_collect_is_minor(gc_verifier)){ p_ref = obj_get_referent_field(p_obj); scan_slot(heap_verifier, p_ref); } #endif } return; }