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;
}
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);
}
}
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);
}
}
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());
}
}
}
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);
}
}
}
Aggregations