use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class OldGeneration method promoteAlignedObject.
private Object promoteAlignedObject(Object original) {
final Log trace = Log.noopLog().string("[OldGeneration.promoteAlignedObject:").string(" original: ").object(original);
assert ObjectHeaderImpl.getObjectHeaderImpl().isAlignedObject(original);
final AlignedHeapChunk.AlignedHeader originalChunk = AlignedHeapChunk.getEnclosingAlignedHeapChunk(original);
final Space originalSpace = originalChunk.getSpace();
trace.string(" originalSpace: ").string(originalSpace.getName());
Object result = original;
if (shouldPromoteFrom(originalSpace)) {
trace.string(" promoting");
if (HeapOptions.TraceObjectPromotion.getValue()) {
final Log promotionTrace = Log.log().string("[OldGeneration.promoteAlignedObject:").string(" original: ").object(original);
final UnsignedWord size = LayoutEncoding.getSizeFromObject(original);
promotionTrace.string(" size: ").unsigned(size).string("]").newline();
}
result = getToSpace().promoteAlignedObject(original);
} else {
trace.string(" not promoting");
}
trace.string(" returns: ").object(result);
if (trace.isEnabled()) {
final AlignedHeapChunk.AlignedHeader resultChunk = AlignedHeapChunk.getEnclosingAlignedHeapChunk(result);
final Space resultSpace = resultChunk.getSpace();
trace.string(" resultSpace: ").string(resultSpace.getName());
}
trace.string("]").newline();
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class PinnedAllocatorImpl method tryReuseExistingChunk.
/**
* Look for an existing pinned chunk that still has a reasonable amount of memory available, and
* re-use that as the initial pinned chunk by registering it with the TLAB.
*/
private void tryReuseExistingChunk(ThreadLocalAllocation.Descriptor tlab) {
VMOperation.guaranteeInProgress("PinnedAllocatorImpl.pushPinnedAllocatorImpl.tryReuseExistingChunk but not in VMOperation.");
Space pSpace = HeapImpl.getHeapImpl().getOldGeneration().getPinnedFromSpace();
AlignedHeapChunk.AlignedHeader largestChunk = WordFactory.nullPointer();
UnsignedWord largestAvailable = WordFactory.zero();
for (AlignedHeapChunk.AlignedHeader aChunk = pSpace.getFirstAlignedHeapChunk(); aChunk.isNonNull(); aChunk = aChunk.getNext()) {
UnsignedWord chunkAvailable = AlignedHeapChunk.availableObjectMemoryOfAlignedHeapChunk(aChunk);
// TODO: Should "10 * 1024" be a HeapPolicy option?
if (chunkAvailable.aboveThan(largestAvailable) && chunkAvailable.aboveThan(10 * 1024)) {
largestChunk = aChunk;
largestAvailable = chunkAvailable;
}
}
assert ThreadLocalAllocation.verifyUninitialized(tlab);
if (largestChunk.isNonNull()) {
log().string("[PinnedAllocatorImpl.tryReuseExistingChunk:").string(" tlab: ").hex(tlab);
log().string(" available bytes: ").unsigned(largestAvailable);
log().string(" re-using largestChunk: ").hex(largestChunk);
log().string(" chunk space: ").string(largestChunk.getSpace().getName());
log().string("]").newline();
/* We found an existing pinned chunk to re-use. */
pSpace.extractAlignedHeapChunk(largestChunk);
reuseExistingChunkUninterruptibly(largestChunk, tlab);
/* Register the existing chunk as pinned. */
pushPinnedChunks(tlab);
} else {
log().string("[PinnedAllocatorImpl.tryReuseExistingChunk:").string(" tlab: ").hex(tlab).string(" available bytes: ").unsigned(largestAvailable).string(" not reusing a chunk]").newline();
}
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class PinnedObjectImpl method addressOfArrayElement.
@Override
@SuppressWarnings("unchecked")
public <T extends PointerBase> T addressOfArrayElement(int index) {
if (referent == null) {
throw new NullPointerException("null PinnedObject");
}
final DynamicHub hub = ObjectHeader.readDynamicHubFromObject(referent);
final UnsignedWord offsetOfArrayElement = LayoutEncoding.getArrayElementOffset(hub.getLayoutEncoding(), index);
return (T) addressOfObject().add(offsetOfArrayElement);
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class Space method getUnalignedChunkBytes.
/**
* Aggregate the bytes in unaligned chunks.
*/
private UnsignedWord getUnalignedChunkBytes() {
final UnsignedWord unalignedChunkCount = WordFactory.unsigned(getAccounting().getUnalignedChunkCount());
final UnsignedWord unalignedChunkOverhead = UnalignedHeapChunk.getUnalignedHeapOverhead();
return getAccounting().getUnalignedChunkBytes().add(unalignedChunkCount.multiply(unalignedChunkOverhead));
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class Space method getAlignedObjectBytes.
/**
* Aggregate the bytes in Object in aligned chunks.
*/
private UnsignedWord getAlignedObjectBytes() {
UnsignedWord result = WordFactory.zero();
AlignedHeapChunk.AlignedHeader aChunk = getFirstAlignedHeapChunk();
while (aChunk.isNonNull()) {
final UnsignedWord allocatedBytes = aChunk.getTop().subtract(AlignedHeapChunk.getObjectsStart(aChunk));
result = result.add(allocatedBytes);
aChunk = aChunk.getNext();
}
return result;
}
Aggregations