Search in sources :

Example 96 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class FirstObjectTable method getPointerAtOffset.

/**
 * Turn an entry from the table into a Pointer into a memory region.
 */
private static Pointer getPointerAtOffset(Pointer memory, UnsignedWord currentIndex, int currentEntry) {
    /* This does not need the table because I've already read the entry from it. */
    assert isMemoryOffsetEntry(currentEntry) : "Entry out of bounds.";
    final UnsignedWord indexOffset = indexToMemoryOffset(currentIndex);
    final UnsignedWord entryOffset = entryToMemoryOffset(currentEntry);
    return memory.add(indexOffset).subtract(entryOffset);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 97 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class FirstObjectTable method memoryOffsetToEntry.

/**
 * Turn a memory offset into a table entry.
 */
private static int memoryOffsetToEntry(UnsignedWord memoryOffset) {
    assert memoryOffset.belowThan(MEMORY_BYTES_PER_ENTRY) : "Offset out of bounds.";
    /* Scale the offset and negate it to produce an entry. */
    final UnsignedWord scaledOffset = memoryOffset.unsignedDivide(memoryOffsetScale());
    assert scaledOffset.multiply(memoryOffsetScale()).equal(memoryOffset) : "Not a multiple.";
    final long result = (-scaledOffset.rawValue());
    assert ((MEMORY_OFFSET_MIN <= result) && (result <= MEMORY_OFFSET_MAX)) : "Scaled offset out of bounds.";
    return (int) result;
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 98 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class GarbageCollectorManagementFactory method collect.

/*
     * Collection methods.
     */
@Override
public void collect(String cause) {
    final UnsignedWord requestingEpoch = possibleCollectionPrologue();
    /* Collect without allocating. */
    collectWithoutAllocating(cause);
    /* Do anything necessary now that allocation, etc., is allowed. */
    possibleCollectionEpilogue(requestingEpoch);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord)

Example 99 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class GarbageCollectorManagementFactory method printGCAfter.

private void printGCAfter(String cause) {
    final Log verboseGCLog = Log.log();
    final HeapImpl heap = HeapImpl.getHeapImpl();
    if (SubstrateOptions.PrintGC.getValue() || SubstrateOptions.VerboseGC.getValue()) {
        if (SubstrateOptions.PrintGC.getValue()) {
            final Log printGCLog = Log.log();
            final UnsignedWord sizeAfter = heap.getUsedChunkBytes();
            printGCLog.string("[");
            if (SubstrateOptions.PrintGCTimeStamps.getValue()) {
                final long finishNanos = collectionTimer.getFinish();
                printGCLog.unsigned(TimeUtils.roundNanosToMillis(Timer.getTimeSinceFirstAllocation(finishNanos))).string(" msec: ");
            }
            printGCLog.string(completeCollection ? "Full GC" : "Incremental GC");
            printGCLog.string(" (").string(cause).string(") ");
            printGCLog.unsigned(sizeBefore.unsignedDivide(1024));
            printGCLog.string("K->");
            printGCLog.unsigned(sizeAfter.unsignedDivide(1024)).string("K, ");
            printGCLog.rational(collectionTimer.getCollectedNanos(), TimeUtils.nanosPerSecond, DECIMALS_IN_TIME_PRINTING).string(" secs");
            printGCLog.string("]").newline();
        }
        if (SubstrateOptions.VerboseGC.getValue()) {
            verboseGCLog.string(" [");
            final long finishNanos = collectionTimer.getFinish();
            if (SubstrateOptions.PrintGCTimeStamps.getValue()) {
                verboseGCLog.unsigned(TimeUtils.roundNanosToMillis(Timer.getTimeSinceFirstAllocation(finishNanos))).string(" msec: ");
            } else {
                verboseGCLog.unsigned(finishNanos);
            }
            verboseGCLog.string(" GC:").string(" after ").string("  epoch: ").unsigned(getCollectionEpoch()).string("  cause: ").string(cause);
            verboseGCLog.string("  policy: ");
            getPolicy().nameToLog(verboseGCLog);
            verboseGCLog.string("  type: ").string(completeCollection ? "complete" : "incremental");
            if (HeapOptions.PrintHeapShape.getValue()) {
                heap.report(verboseGCLog);
            }
            if (!HeapOptions.PrintGCTimes.getValue()) {
                verboseGCLog.newline();
                verboseGCLog.string("  collection time: ").unsigned(collectionTimer.getCollectedNanos()).string(" nanoSeconds");
            } else {
                logGCTimers(verboseGCLog);
            }
            verboseGCLog.string("]");
            verboseGCLog.string("]").newline();
        }
    }
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord)

Example 100 with UnsignedWord

use of org.graalvm.word.UnsignedWord in project graal by oracle.

the class Space method copyAlignedObject.

/**
 * Copy an Object into the given memory.
 */
private Object copyAlignedObject(Object originalObj) {
    VMOperation.guaranteeInProgress("Should only be called from the collector.");
    assert ObjectHeaderImpl.getObjectHeaderImpl().isAlignedObject(originalObj);
    final Log trace = Log.noopLog().string("[SpaceImpl.copyAlignedObject:");
    trace.string("  originalObj: ").object(originalObj);
    /* ObjectAccess.writeWord needs an Object as a 0th argument. */
    /* - Allocate memory for the copy in this Space. */
    final UnsignedWord copySize = LayoutEncoding.getSizeFromObject(originalObj);
    trace.string("  copySize: ").unsigned(copySize);
    final Pointer copyMemory = allocateMemory(copySize);
    trace.string("  copyMemory: ").hex(copyMemory);
    if (copyMemory.isNull()) {
        /* TODO: Promotion failure! */
        final Log failureLog = Log.log().string("[!SpaceImpl.copyAlignedObject:");
        failureLog.string("  failure to allocate ").unsigned(copySize).string(" bytes").string("!]").newline();
        return null;
    }
    /* - Copy the Object. */
    final Pointer originalMemory = Word.objectToUntrackedPointer(originalObj);
    UnsignedWord offset = WordFactory.zero();
    while (offset.belowThan(copySize)) {
        /*
             * This copies words, without regard to whether they are pointers and so need to dirty
             * remembered sets, etc. That's okay, because when the dust settles, anything the copy
             * references will be in the old Space, so any card remembered sets for the object can
             * be "clean". This writes the hub from the original over the hub installed by the
             * allocateArray or allocateObject. That shouldn't be an issue, here.
             */
        copyMemory.writeWord(offset, originalMemory.readWord(offset));
        offset = offset.add(ConfigurationValues.getTarget().wordSize);
    }
    final Object copyObj = copyMemory.toObject();
    /* Note that the object needs a remembered set. */
    setAlignedRememberedSet(copyObj);
    trace.string("  copyObj: ").object(copyObj).string("]").newline();
    return copyObj;
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord) Pointer(org.graalvm.word.Pointer)

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