use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class AllocationSnippets method formatArraySnippet.
@Snippet
public static Object formatArraySnippet(Word memory, DynamicHub hub, int length, boolean rememberedSet, boolean unaligned) {
DynamicHub hubNonNull = (DynamicHub) PiNode.piCastNonNull(hub, SnippetAnchorNode.anchor());
int layoutEncoding = hubNonNull.getLayoutEncoding();
UnsignedWord size = LayoutEncoding.getArraySize(layoutEncoding, length);
emitPrefetchAllocate(memory, true);
return formatArrayImpl(memory, hubNonNull, length, layoutEncoding, size, true, rememberedSet, unaligned);
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class AllocationSnippets method fastNewArray.
public static Object fastNewArray(DynamicHub hub, int length, int layoutEncoding, boolean fillContents, AllocationCounter counter) {
checkHub(hub);
/*
* Note: layoutEncoding is passed in as a @ConstantParameter so that much of the array size
* computation can be folded away early when preparing the snippet.
*/
UnsignedWord size = LayoutEncoding.getArraySize(layoutEncoding, length);
profileAllocation(size, counter);
Object result = fastNewArrayUninterruptibly(hub, length, layoutEncoding, fillContents, size);
if (result == null) {
result = callSlowNewArray(SLOW_NEW_ARRAY, hub.asClass(), length);
}
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class AllocationSnippets method doCloneUninterruptibly.
@Uninterruptible(reason = "Copies via Pointers")
private static // TODO: What if the bytes being written need remembered set operations?
Object doCloneUninterruptibly(Object thisObject, Object thatObject, UnsignedWord firstFieldOffset, UnsignedWord size) {
Pointer thatMemory = Word.objectToUntrackedPointer(thatObject);
/*
* Copy the thisObj over thatMemory. Excluding the hub to make sure that no GC-relevant
* header bits are transfered from thisObj to the clone.
*/
Pointer thisMemory = Word.objectToUntrackedPointer(thisObject);
UnsignedWord offset = firstFieldOffset;
while (offset.belowThan(size)) {
thatMemory.writeWord(offset, thisMemory.readWord(offset));
offset = offset.add(ConfigurationValues.getTarget().wordSize);
}
final Object result = thatMemory.toObjectNonNull();
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class AllocationSnippets method newInstance.
public static Object newInstance(DynamicHub hub, int encoding, @ConstantParameter boolean constantSize, @ConstantParameter boolean fillContents, AllocationCounter counter) {
checkHub(hub);
UnsignedWord size = LayoutEncoding.getInstanceSize(encoding);
profileAllocation(size, counter);
Pointer memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.regularTLAB.getAddress(), size);
Object result;
if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, memory.isNonNull())) {
result = formatObjectImpl(memory, hub, size, constantSize, fillContents, false);
} else {
result = callSlowNewInstance(SLOW_NEW_INSTANCE, hub.asClass());
}
return PiNode.piCastToSnippetReplaceeStamp(result);
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class BarrierSnippetCountersFeature method postWriteBarrierSnippet.
/**
* Given an object, dirty the card for the object.
*
* @param object The object to which the write has been done.
*/
@Snippet
public static void postWriteBarrierSnippet(Object object) {
counters().postWriteBarrier.inc();
// Get the Object to which the write happened.
final Object fixedObject = FixedValueAnchorNode.getObject(object);
// Get the ObjectHeader from the Object.
final UnsignedWord objectHeader = ObjectHeader.readHeaderFromObject(fixedObject);
// Does the ObjectHeader indicate that I need a barrier?
final boolean needsBarrier = ObjectHeaderImpl.hasRememberedSet(objectHeader);
if (BranchProbabilityNode.probability(BranchProbabilityNode.FREQUENT_PROBABILITY, !needsBarrier)) {
// Most likely (?): expect that no barrier is needed.
return;
}
// The object needs a write-barrier. Is it aligned or unaligned?
final boolean unaligned = ObjectHeaderImpl.isHeapObjectUnaligned(objectHeader);
if (BranchProbabilityNode.probability(BranchProbabilityNode.LIKELY_PROBABILITY, !unaligned)) {
// Next most likely (?): aligned objects.
counters().postWriteBarrierAligned.inc();
AlignedHeapChunk.dirtyCardForObjectOfAlignedHeapChunk(fixedObject);
return;
}
// Least likely (?): object needs a write-barrier and is unaligned.
counters().postWriteBarrierUnaligned.inc();
UnalignedHeapChunk.dirtyCardForObjectOfUnalignedHeapChunk(fixedObject);
return;
}
Aggregations