Search in sources :

Example 56 with UnsignedWord

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;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord)

Example 57 with UnsignedWord

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();
    }
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 58 with UnsignedWord

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);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) DynamicHub(com.oracle.svm.core.hub.DynamicHub)

Example 59 with UnsignedWord

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));
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 60 with UnsignedWord

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;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Aggregations

UnsignedWord (org.graalvm.word.UnsignedWord)137 Pointer (org.graalvm.word.Pointer)43 Log (com.oracle.svm.core.log.Log)30 DynamicHub (com.oracle.svm.core.hub.DynamicHub)11 Fold (org.graalvm.compiler.api.replacements.Fold)11 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)9 Snippet (org.graalvm.compiler.api.replacements.Snippet)9 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)6 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)4 WordBase (org.graalvm.word.WordBase)4 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)3 ValueInfo (com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo)3 UnalignedHeader (com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader)3 XOptions (com.oracle.svm.core.option.XOptions)3 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)3 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)2 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)2 SubstrateForeignCallTarget (com.oracle.svm.core.snippets.SubstrateForeignCallTarget)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 JavaKind (jdk.vm.ci.meta.JavaKind)2