Ejemplo n.º 1
0
static void scan_array(Object_With_Header *obj)
{
    Vector_Handle vector = (Vector_Handle)obj->start();
    int32 length = vector_get_length(vector);
    Type_Info_Handle tih = class_get_element_type_info(obj->vt()->gcvt->ch);
    if(type_info_is_reference(tih) ||
       type_info_is_vector(tih) ||
       type_info_is_general_array(tih)) {
        Managed_Object_Handle *first_elem_addr =
            vector_get_element_address_ref(vector, 0);
        if (GC::compressing_references) {
            for(int i = 0; i < length; i++) {
                COMPRESSED_REFERENCE elem = ((COMPRESSED_REFERENCE *)first_elem_addr)[i];
                mark_recursive((void *)elem, /*is_compressed_root*/ true);
            }
        } else {
            for(int i = 0; i < length; i++) {
                mark_recursive(first_elem_addr[i], /*is_compressed_root*/ false);
            }
        }
    } else if(type_info_is_primitive(tih)) {
    } else if(type_info_is_unboxed(tih)) {
        Class_Handle ech = type_info_get_class(tih);
        assert(ech);
        int first_elem_offset = vector_first_element_offset_unboxed(ech);
        int base_offset = 0;//(int)class_get_unboxed_data_offset(ech);
        int elem_size = class_element_size(obj->vt()->gcvt->ch);
        Vtable_GC *evt = (Vtable_GC *)class_get_vtable(ech);
        uint16 *offsets = evt->gcvt->offsets;
        int curr_elem_offset = first_elem_offset;
        for(int i = 0; i < length; i++) {
            uint16 *o = offsets;
            while(*o) {
                int adjusted_offset = curr_elem_offset + *o - base_offset;
                Managed_Object_Handle *slot = (Managed_Object_Handle *)(((Byte *)vector) + adjusted_offset);
                mark_recursive(*slot, /*is_compressed_root*/ GC::compressing_references);
                o++;
            }
            curr_elem_offset += elem_size;
        }
    } else {
        ABORT("All possible cases should already be covered");
    }
} //scan_array
Ejemplo n.º 2
0
static bool is_reference(Type_Info_Handle tih)
{
    return type_info_is_reference(tih) || type_info_is_vector(tih);
} //is_reference