static void trace_object(Conclctor* marker, Partial_Reveal_Object *p_obj) { scan_object(marker, p_obj); obj_mark_black_in_table(p_obj, marker); Vector_Block *trace_stack = marker->trace_stack; while(!vector_stack_is_empty(trace_stack)){ p_obj = (Partial_Reveal_Object*)vector_stack_pop(trace_stack); scan_object(marker, p_obj); obj_mark_black_in_table(p_obj, marker); trace_stack = marker->trace_stack; } }
/*This function is for concurrent mark.*/ static void write_barrier_rem_obj_snapshot(Managed_Object_Handle p_obj_holding_ref) { Mutator *mutator = (Mutator *)gc_get_tls(); REF* p_obj_slot; if(obj_need_take_snapshot((Partial_Reveal_Object*)p_obj_holding_ref)){ if (object_is_array((Partial_Reveal_Object*)p_obj_holding_ref)) { Partial_Reveal_Object* array = (Partial_Reveal_Object*)p_obj_holding_ref; assert(!obj_is_primitive_array(array)); Partial_Reveal_Object* obj_to_snapshot; I_32 array_length = vector_get_length((Vector_Handle) array); for (int i = 0; i < array_length; i++) { p_obj_slot = (REF*)vector_get_element_address_ref((Vector_Handle) array, i); obj_to_snapshot = (Partial_Reveal_Object*)read_slot(p_obj_slot); if (obj_to_snapshot != NULL) mutator_dirtyset_add_entry(mutator, obj_to_snapshot); } }else{ /* scan non-array object */ Partial_Reveal_Object* p_obj = (Partial_Reveal_Object*)p_obj_holding_ref; unsigned int num_refs = object_ref_field_num(p_obj); int *ref_iterator = object_ref_iterator_init(p_obj); Partial_Reveal_Object* obj_to_snapshot; for(unsigned int i=0; i<num_refs; i++){ p_obj_slot = object_ref_iterator_get(ref_iterator+i, p_obj); obj_to_snapshot = (Partial_Reveal_Object*)read_slot(p_obj_slot); if (obj_to_snapshot != NULL) mutator_dirtyset_add_entry(mutator, obj_to_snapshot); } if(is_reference_obj(p_obj)){ REF* p_referent_field = obj_get_referent_field(p_obj); obj_to_snapshot = (Partial_Reveal_Object*)read_slot(p_referent_field); if (obj_to_snapshot != NULL) mutator_dirtyset_add_entry(mutator, obj_to_snapshot); } } obj_mark_gray_in_table((Partial_Reveal_Object *) p_obj_holding_ref); // now, the black-only obj (no gray bit been set) will also be scaned by marker, here mark it to gray to prevent this, just a workaround obj_mark_black_in_table((Partial_Reveal_Object *) p_obj_holding_ref, mutator); obj_dirty_in_table((Partial_Reveal_Object *) p_obj_holding_ref); } }