Search in sources :

Example 91 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class BumpPointer method linearScan.

/**
 * Perform a linear scan through the objects allocated by this bump pointer.
 *
 * @param scanner The scan object to delegate scanning to.
 */
@Inline
public final void linearScan(LinearScan scanner) {
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert(allowScanning);
    /* Has this allocator ever allocated anything? */
    if (initialRegion.isZero())
        return;
    /* Loop through active regions or until the last region */
    Address start = initialRegion;
    while (!start.isZero()) {
        // Scan this region
        scanRegion(scanner, start);
        // Move on to next
        start = getNextRegion(start);
    }
}
Also used : Address(org.vmmagic.unboxed.Address) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 92 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class MarkCompactCollector method compact.

/**
 * Perform the compacting phase of the collection.
 */
public void compact() {
    if (regions.isZero())
        return;
    toCursor.init(regions);
    fromCursor.init(regions);
    /* Loop through active regions or until the last region */
    while (fromCursor.isValid()) {
        if (VERBOSE) {
            Log.write("Compacting from region ", fromCursor.getRegion());
            Log.writeln(" to region ", toCursor.getRegion());
        }
        /* Loop through the objects in the region */
        while (fromCursor.hasMoreObjects()) {
            ObjectReference current = fromCursor.advanceToObject();
            fromCursor.advanceToObjectEnd(current);
            ObjectReference copyTo = MarkCompactSpace.getForwardingPointer(current);
            if (VM.VERIFY_ASSERTIONS)
                VM.assertions._assert(!copyTo.toAddress().EQ(Address.fromIntZeroExtend(VM.ALIGNMENT_VALUE)));
            if (!copyTo.isNull() && Space.isInSpace(MC.MARK_COMPACT, copyTo)) {
                if (VM.VERIFY_ASSERTIONS) {
                    if (MarkCompactSpace.isMarked(current)) {
                        Log.write("Object ", current);
                        Log.writeln(" is marked during the compact phase");
                        VM.objectModel.dumpObject(current);
                    }
                    VM.assertions._assert(!MarkCompactSpace.isMarked(current));
                }
                if (!toCursor.isInRegion(copyTo)) {
                    // Update metadata and move on
                    toCursor.finishAndAdvanceToNextRegion();
                }
                if (VM.VERIFY_ASSERTIONS)
                    VM.assertions._assert(toCursor.isInRegion(copyTo));
                toCursor.copy(current, copyTo);
                if (VM.VERIFY_ASSERTIONS)
                    VM.assertions._assert(toCursor.isInRegion(copyTo));
                MarkCompactSpace.setForwardingPointer(copyTo, ObjectReference.nullReference());
            }
        }
        fromCursor.advanceToNextRegion();
    }
    /* Fix up the last object pointer etc */
    toCursor.finish();
    /*
     * Return unused pages to the global page resource
     */
    Address region = toCursor.snip();
    while (!region.isZero()) {
        Address nextRegion = MarkCompactLocal.getNextRegion(region);
        space.release(region);
        region = nextRegion;
    }
}
Also used : Address(org.vmmagic.unboxed.Address) ObjectReference(org.vmmagic.unboxed.ObjectReference)

Example 93 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class SimulatedMemory method zero.

/**
 * Zero a region of memory.
 * @param start Start of address range (inclusive)
 * @param size Length in bytes of range to zero
 */
public static void zero(Address start, long size) {
    Clock.stop();
    Trace.trace(Item.MEMORY, "zero(%s,%d)\n", start.toString(), size);
    if (size < 0) {
        System.out.printf("start: %s, size: %d %n", start, size);
    }
    assert (size >= 0) : "Can't zero negative size: int to long conversion gone wrong ?";
    assert (size % BYTES_IN_WORD == 0) : "Must zero word rounded bytes";
    Clock.start();
    MemoryPage page = getPage(start);
    Address pageAddress = start;
    for (int i = 0; i < size; i += BYTES_IN_INT) {
        Address curAddr = start.plus(i);
        if (!onSamePage(pageAddress, curAddr)) {
            page = getPage(curAddr);
            pageAddress = curAddr;
        }
        page.setInt(curAddr, 0);
        Clock.tick();
    }
}
Also used : Address(org.vmmagic.unboxed.Address)

Example 94 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class SimulatedMemory method unmap.

/**
 * Unmaps an area of virtual memory.
 *
 * @param start the address of the start of the area to be mapped
 * @param size the size, in bytes, of the area to be mapped
 * @return <code>true</code> if successful, otherwise
 * <code>false</code>
 */
public static boolean unmap(Address start, int size) {
    Clock.stop();
    Trace.trace(Item.MEMORY, "map(%s,%d)\n", start.toString(), size);
    Address last = start.plus(size);
    assert size % BYTES_IN_PAGE == 0;
    assert start.toWord().and(Word.fromIntSignExtend(~PAGE_MASK)).EQ(Word.zero());
    Clock.start();
    for (Address p = start; p.LT(last); p = p.plus(BYTES_IN_PAGE)) {
        pageTable.unmapPage(p);
        Clock.tick();
    }
    return true;
}
Also used : Address(org.vmmagic.unboxed.Address)

Example 95 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class SimulatedMemory method unprotect.

/**
 * Allows access to an area of virtual memory.
 *
 * @param start the address of the start of the area to be mapped
 * @param size the size, in bytes, of the area to be mapped
 * @return <code>true</code> if successful, otherwise
 * <code>false</code>
 */
public static boolean unprotect(Address start, int size) {
    Clock.stop();
    assert start.toWord().and(Word.fromIntSignExtend(~PAGE_MASK)).EQ(Word.zero());
    Trace.trace(Item.MEMORY, "unprotect(%s,%d)\n", start.toString(), size);
    Clock.start();
    Address last = start.plus(size);
    for (Address p = start; p.LT(last); p = p.plus(BYTES_IN_PAGE)) {
        pageTable.setReadable(p);
        Clock.tick();
    }
    return true;
}
Also used : Address(org.vmmagic.unboxed.Address)

Aggregations

Address (org.vmmagic.unboxed.Address)281 Offset (org.vmmagic.unboxed.Offset)48 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)30 NoInline (org.vmmagic.pragma.NoInline)30 Test (org.junit.Test)24 Entrypoint (org.vmmagic.pragma.Entrypoint)22 TypeReference (org.jikesrvm.classloader.TypeReference)21 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)17 RVMType (org.jikesrvm.classloader.RVMType)16 Inline (org.vmmagic.pragma.Inline)15 Uninterruptible (org.vmmagic.pragma.Uninterruptible)14 Word (org.vmmagic.unboxed.Word)14 BaseMMTkTest (org.mmtk.harness.tests.BaseMMTkTest)13 Unpreemptible (org.vmmagic.pragma.Unpreemptible)12 ObjectReference (org.vmmagic.unboxed.ObjectReference)12 Interruptible (org.vmmagic.pragma.Interruptible)11 Extent (org.vmmagic.unboxed.Extent)11 RVMClass (org.jikesrvm.classloader.RVMClass)9 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8