Search in sources :

Example 6 with CollectorContext

use of org.mmtk.plan.CollectorContext in project JikesRVM by JikesRVM.

the class ObjectModel method copyScalar.

@Inline
private ObjectReference copyScalar(ObjectReference from, TIB tib, RVMClass type, int allocator) {
    int bytes = org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(from.toObject(), type);
    int align = org.jikesrvm.objectmodel.ObjectModel.getAlignment(type, from.toObject());
    int offset = org.jikesrvm.objectmodel.ObjectModel.getOffsetForAlignment(type, from);
    CollectorContext context = VM.activePlan.collector();
    allocator = context.copyCheckAllocator(from, bytes, align, allocator);
    Address region = MemoryManager.allocateSpace(context, bytes, align, offset, allocator, from);
    Object toObj = org.jikesrvm.objectmodel.ObjectModel.moveObject(region, from.toObject(), bytes, type);
    ObjectReference to = ObjectReference.fromObject(toObj);
    context.postCopy(to, ObjectReference.fromObject(tib), bytes, allocator);
    return to;
}
Also used : Address(org.vmmagic.unboxed.Address) ObjectReference(org.vmmagic.unboxed.ObjectReference) CollectorContext(org.mmtk.plan.CollectorContext) Inline(org.vmmagic.pragma.Inline)

Example 7 with CollectorContext

use of org.mmtk.plan.CollectorContext in project JikesRVM by JikesRVM.

the class ObjectModel method copyArray.

@Inline
private ObjectReference copyArray(ObjectReference from, TIB tib, RVMArray type, int allocator) {
    int elements = Magic.getArrayLength(from.toObject());
    int bytes = org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(from.toObject(), type, elements);
    int align = org.jikesrvm.objectmodel.ObjectModel.getAlignment(type, from.toObject());
    int offset = org.jikesrvm.objectmodel.ObjectModel.getOffsetForAlignment(type, from);
    CollectorContext context = VM.activePlan.collector();
    allocator = context.copyCheckAllocator(from, bytes, align, allocator);
    Address region = MemoryManager.allocateSpace(context, bytes, align, offset, allocator, from);
    Object toObj = org.jikesrvm.objectmodel.ObjectModel.moveObject(region, from.toObject(), bytes, type);
    ObjectReference to = ObjectReference.fromObject(toObj);
    context.postCopy(to, ObjectReference.fromObject(tib), bytes, allocator);
    if (type == RVMType.CodeArrayType) {
        // sync all moved code arrays to get icache and dcache in sync
        // immediately.
        int dataSize = bytes - org.jikesrvm.objectmodel.ObjectModel.computeHeaderSize(Magic.getObjectType(toObj));
        org.jikesrvm.runtime.Memory.sync(to.toAddress(), dataSize);
    }
    return to;
}
Also used : Address(org.vmmagic.unboxed.Address) ObjectReference(org.vmmagic.unboxed.ObjectReference) CollectorContext(org.mmtk.plan.CollectorContext) Inline(org.vmmagic.pragma.Inline)

Aggregations

CollectorContext (org.mmtk.plan.CollectorContext)7 Address (org.vmmagic.unboxed.Address)3 Inline (org.vmmagic.pragma.Inline)2 ObjectReference (org.vmmagic.unboxed.ObjectReference)2 Test (org.junit.Test)1