Search in sources :

Example 1 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class MonitorSnippets method checkCounter.

@Snippet
private static void checkCounter(@ConstantParameter String errMsg) {
    final Word counter = MonitorCounterNode.counter();
    final int count = counter.readInt(0, MONITOR_COUNTER_LOCATION);
    if (count != 0) {
        vmError(errMsg, count);
    }
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 2 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class MonitorSnippets method monitorexit.

@Snippet
public static void monitorexit(Object object, @ConstantParameter int lockDepth, @ConstantParameter Register threadRegister, @ConstantParameter boolean trace, @ConstantParameter OptionValues options, @ConstantParameter Counters counters) {
    trace(trace, "           object: 0x%016lx\n", Word.objectToTrackedPointer(object));
    final Word mark = loadWordFromObject(object, markOffset(INJECTED_VMCONFIG));
    if (useBiasedLocking(INJECTED_VMCONFIG)) {
        // Check for biased locking unlock case, which is a no-op
        // Note: we do not have to check the thread ID for two reasons.
        // First, the interpreter checks for IllegalMonitorStateException at
        // a higher level. Second, if the bias was revoked while we held the
        // lock, the object could not be rebiased toward another thread, so
        // the bias bit would be clear.
        trace(trace, "             mark: 0x%016lx\n", mark);
        if (probability(FREQUENT_PROBABILITY, mark.and(biasedLockMaskInPlace(INJECTED_VMCONFIG)).equal(WordFactory.unsigned(biasedLockPattern(INJECTED_VMCONFIG))))) {
            endLockScope();
            decCounter(options);
            traceObject(trace, "-lock{bias}", object, false, options);
            counters.unlockBias.inc();
            return;
        }
    }
    final Word lock = CurrentLockNode.currentLock(lockDepth);
    // Load displaced mark
    final Word displacedMark = lock.readWord(lockDisplacedMarkOffset(INJECTED_VMCONFIG), DISPLACED_MARK_WORD_LOCATION);
    trace(trace, "    displacedMark: 0x%016lx\n", displacedMark);
    if (probability(NOT_LIKELY_PROBABILITY, displacedMark.equal(0))) {
        // Recursive locking => done
        traceObject(trace, "-lock{recursive}", object, false, options);
        counters.unlockCasRecursive.inc();
    } else {
        if (!tryExitInflated(object, mark, lock, threadRegister, trace, options, counters)) {
            verifyOop(object);
            // Test if object's mark word is pointing to the displaced mark word, and if so,
            // restore
            // the displaced mark in the object - if the object's mark word is not pointing to
            // the displaced mark word, do unlocking via runtime call.
            Pointer objectPointer = Word.objectToTrackedPointer(object);
            if (probability(VERY_FAST_PATH_PROBABILITY, objectPointer.logicCompareAndSwapWord(markOffset(INJECTED_VMCONFIG), lock, displacedMark, MARK_WORD_LOCATION))) {
                traceObject(trace, "-lock{cas}", object, false, options);
                counters.unlockCas.inc();
            } else {
                // The object's mark word was not pointing to the displaced header
                traceObject(trace, "-lock{stub}", object, false, options);
                counters.unlockStub.inc();
                monitorexitStubC(MONITOREXIT, object, lock);
            }
        }
    }
    endLockScope();
    decCounter(options);
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord) Pointer(org.graalvm.word.Pointer) KlassPointer(org.graalvm.compiler.hotspot.word.KlassPointer) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 3 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class NewObjectSnippets method allocateArrayImpl.

private static Object allocateArrayImpl(KlassPointer hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents, Register threadRegister, boolean maybeUnroll, String typeContext, boolean skipNegativeCheck, OptionValues options, Counters counters) {
    Object result;
    int allocationSize = arrayAllocationSize(length, headerSize, log2ElementSize);
    Word thread = registerAsWord(threadRegister);
    Word top = readTlabTop(thread);
    Word end = readTlabEnd(thread);
    Word newTop = top.add(allocationSize);
    if (probability(FREQUENT_PROBABILITY, skipNegativeCheck || belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) && useTLAB(INJECTED_VMCONFIG) && probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
        writeTlabTop(thread, newTop);
        emitPrefetchAllocate(newTop, true);
        if (counters != null && counters.arrayLoopInit != null) {
            counters.arrayLoopInit.inc();
        }
        result = formatArray(hub, allocationSize, length, headerSize, top, prototypeMarkWord, fillContents, maybeUnroll, counters);
    } else {
        result = newArray(HotSpotBackend.NEW_ARRAY, hub, length, fillContents);
    }
    profileAllocation("array", allocationSize, typeContext, options);
    return result;
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord) HotSpotReplacementsUtil.loadKlassFromObject(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.loadKlassFromObject)

Example 4 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class NewObjectSnippets method newmultiarray.

/**
 * Calls the runtime stub for implementing MULTIANEWARRAY.
 */
@Snippet
public static Object newmultiarray(KlassPointer hub, @ConstantParameter int rank, @VarargsParameter int[] dimensions) {
    Word dims = DimensionsNode.allocaDimsArray(rank);
    ExplodeLoopNode.explodeLoop();
    for (int i = 0; i < rank; i++) {
        dims.writeInt(i * 4, dimensions[i], LocationIdentity.init());
    }
    return newArrayCall(HotSpotBackend.NEW_MULTI_ARRAY, hub, rank, dims);
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 5 with Word

use of org.graalvm.compiler.word.Word in project graal by oracle.

the class NewObjectSnippets method formatObject.

/**
 * Formats some allocated memory with an object header and zeroes out the rest.
 */
protected static Object formatObject(KlassPointer hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, Counters counters) {
    Word prototypeMarkWord = useBiasedLocking(INJECTED_VMCONFIG) ? hub.readWord(prototypeMarkWordOffset(INJECTED_VMCONFIG), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord;
    initializeObjectHeader(memory, prototypeMarkWord, hub);
    if (fillContents) {
        zeroMemory(size, memory, constantSize, instanceHeaderSize(INJECTED_VMCONFIG), false, counters);
    } else if (REPLACEMENTS_ASSERTIONS_ENABLED) {
        fillWithGarbage(size, memory, constantSize, instanceHeaderSize(INJECTED_VMCONFIG), false, counters);
    }
    MembarNode.memoryBarrier(MemoryBarriers.STORE_STORE, LocationIdentity.init());
    return memory.toObjectNonNull();
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)

Aggregations

Word (org.graalvm.compiler.word.Word)53 HotSpotReplacementsUtil.registerAsWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)32 Snippet (org.graalvm.compiler.api.replacements.Snippet)22 Pointer (org.graalvm.word.Pointer)12 UnsignedWord (org.graalvm.word.UnsignedWord)7 MethodSubstitution (org.graalvm.compiler.api.replacements.MethodSubstitution)5 KlassPointer (org.graalvm.compiler.hotspot.word.KlassPointer)5 HotSpotReplacementsUtil.tlabIntArrayMarkWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.tlabIntArrayMarkWord)4 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)2 HotSpotReplacementsUtil.loadKlassFromObject (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.loadKlassFromObject)2 SignedWord (org.graalvm.word.SignedWord)2 Substitute (com.oracle.svm.core.annotate.Substitute)1 SubstrateObjectConstant (com.oracle.svm.core.meta.SubstrateObjectConstant)1 Pwd.passwd (com.oracle.svm.core.posix.headers.Pwd.passwd)1 Pwd.passwdPointer (com.oracle.svm.core.posix.headers.Pwd.passwdPointer)1 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)1 HotSpotReplacementsUtil.arrayPrototypeMarkWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.arrayPrototypeMarkWord)1 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)1 Isolate (org.graalvm.nativeimage.Isolate)1 PinnedObject (org.graalvm.nativeimage.PinnedObject)1