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