Search in sources :

Example 31 with Word

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

the class MonitorSnippets method tryExitInflated.

private static boolean tryExitInflated(Object object, Word mark, Word lock, Register threadRegister, boolean trace, OptionValues options, Counters counters) {
    if (!inlineFastUnlockSupported(options)) {
        return false;
    }
    if (probability(SLOW_PATH_PROBABILITY, mark.and(monitorMask(INJECTED_VMCONFIG)).notEqual(0))) {
        // Inflated case
        // mark is a pointer to the ObjectMonitor + monitorMask
        Word monitor = mark.subtract(monitorMask(INJECTED_VMCONFIG));
        int ownerOffset = objectMonitorOwnerOffset(INJECTED_VMCONFIG);
        Word owner = monitor.readWord(ownerOffset, OBJECT_MONITOR_OWNER_LOCATION);
        int recursionsOffset = objectMonitorRecursionsOffset(INJECTED_VMCONFIG);
        Word recursions = monitor.readWord(recursionsOffset, OBJECT_MONITOR_RECURSION_LOCATION);
        Word thread = registerAsWord(threadRegister);
        if (probability(FAST_PATH_PROBABILITY, owner.xor(thread).or(recursions).equal(0))) {
            // owner == thread && recursions == 0
            int cxqOffset = objectMonitorCxqOffset(INJECTED_VMCONFIG);
            Word cxq = monitor.readWord(cxqOffset, OBJECT_MONITOR_CXQ_LOCATION);
            int entryListOffset = objectMonitorEntryListOffset(INJECTED_VMCONFIG);
            Word entryList = monitor.readWord(entryListOffset, OBJECT_MONITOR_ENTRY_LIST_LOCATION);
            if (probability(FREQUENT_PROBABILITY, cxq.or(entryList).equal(0))) {
                // cxq == 0 && entryList == 0
                // Nobody is waiting, success
                // release_store
                MembarNode.memoryBarrier(LOAD_STORE | STORE_STORE);
                monitor.writeWord(ownerOffset, WordFactory.zero());
                traceObject(trace, "-lock{inflated:simple}", object, false, options);
                counters.unlockInflatedSimple.inc();
                return true;
            }
        }
        counters.unlockStubInflated.inc();
        traceObject(trace, "-lock{stub:inflated}", object, false, options);
        monitorexitStubC(MONITOREXIT, object, lock);
        return true;
    }
    return false;
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)

Example 32 with Word

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

the class MonitorSnippets method incCounter.

public static void incCounter(OptionValues options) {
    if (verifyBalancedMonitors(options)) {
        final Word counter = MonitorCounterNode.counter();
        final int count = counter.readInt(0, MONITOR_COUNTER_LOCATION);
        counter.writeInt(0, count + 1, MONITOR_COUNTER_LOCATION);
    }
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)

Example 33 with Word

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

the class MonitorSnippets method decCounter.

public static void decCounter(OptionValues options) {
    if (verifyBalancedMonitors(options)) {
        final Word counter = MonitorCounterNode.counter();
        final int count = counter.readInt(0, MONITOR_COUNTER_LOCATION);
        counter.writeInt(0, count - 1, MONITOR_COUNTER_LOCATION);
    }
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)

Example 34 with Word

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

the class NewObjectSnippets method fillMemory.

private static void fillMemory(long value, int size, Word memory, boolean constantSize, int startOffset, boolean manualUnroll, Counters counters) {
    ReplacementsUtil.runtimeAssert((size & 0x7) == 0, "unaligned object size");
    int offset = startOffset;
    if ((offset & 0x7) != 0) {
        memory.writeInt(offset, (int) value, LocationIdentity.init());
        offset += 4;
    }
    ReplacementsUtil.runtimeAssert((offset & 0x7) == 0, "unaligned offset");
    if (manualUnroll && ((size - offset) / 8) <= MAX_UNROLLED_OBJECT_ZEROING_STORES) {
        ReplacementsUtil.staticAssert(!constantSize, "size shouldn't be constant at instantiation time");
        // break statement will trim excess stores.
        if (counters != null && counters.instanceSeqInit != null) {
            counters.instanceSeqInit.inc();
        }
        explodeLoop();
        for (int i = 0; i < MAX_UNROLLED_OBJECT_ZEROING_STORES; i++, offset += 8) {
            if (offset == size) {
                break;
            }
            memory.initializeLong(offset, value, LocationIdentity.init());
        }
    } else {
        // Use Word instead of int to avoid extension to long in generated code
        Word off = WordFactory.signed(offset);
        if (constantSize && ((size - offset) / 8) <= MAX_UNROLLED_OBJECT_ZEROING_STORES) {
            if (counters != null && counters.instanceSeqInit != null) {
                counters.instanceSeqInit.inc();
            }
            explodeLoop();
        } else {
            if (counters != null && counters.instanceLoopInit != null) {
                counters.instanceLoopInit.inc();
            }
        }
        for (; off.rawValue() < size; off = off.add(8)) {
            memory.initializeLong(off, value, LocationIdentity.init());
        }
    }
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)

Example 35 with Word

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

the class NewObjectSnippets method verifyHeap.

@Snippet
protected static void verifyHeap(@ConstantParameter Register threadRegister) {
    Word thread = registerAsWord(threadRegister);
    Word topValue = readTlabTop(thread);
    if (!topValue.equal(WordFactory.zero())) {
        Word topValueContents = topValue.readWord(0, MARK_WORD_LOCATION);
        if (topValueContents.equal(WordFactory.zero())) {
            AssertionSnippets.vmMessageC(AssertionSnippets.ASSERTION_VM_MESSAGE_C, true, cstring("overzeroing of TLAB detected"), 0L, 0L, 0L);
        }
    }
}
Also used : Word(org.graalvm.compiler.word.Word) HotSpotReplacementsUtil.registerAsWord(org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord) Snippet(org.graalvm.compiler.api.replacements.Snippet)

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