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);
}
}
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;
}
}
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();
}
}
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;
}
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;
}
Aggregations