use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class ThreadLocalAllocation method allocateMemory.
/**
* The implementation of the AllocationSnippets.fastAllocateImpl(Unsigned).
* <p>
* This is bump-pointer allocation for the young generation, using a cached "top" and "end".
* <p>
* Since this is called from a snippet, it and all the methods it calls, must be able to be
* inlined. The easy way to do that is to make this method, and all the methods it calls, final
* or static.
* <p>
* This allocates *memory*, not an Object. The rest of the allocation path takes care of turning
* the memory into an Object.
* <p>
* See also
* {@linkplain AlignedHeapChunk#allocateMemory(AlignedHeapChunk.AlignedHeader, UnsignedWord)}.
*/
@Uninterruptible(reason = "returns uninitialized memory, modifies TLAB", callerMustBe = true)
public static Pointer allocateMemory(Descriptor allocator, UnsignedWord size) {
Pointer top = KnownIntrinsics.nonNullPointer(allocator.getAllocationTop(TOP_IDENTITY));
Pointer end = KnownIntrinsics.nonNullPointer(allocator.getAllocationEnd(END_IDENTITY));
UnsignedWord available = end.subtract(top);
if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, size.belowOrEqual(available))) {
allocator.setAllocationTop(top.add(size), TOP_IDENTITY);
return top;
} else {
return WordFactory.nullPointer();
}
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class ThreadLocalAllocation method pushToThreadLocalFreeList.
/**
* Push an aligned chunk on the thread-local list of free chunks.
*/
@Uninterruptible(reason = "Pushes the free list that is drained, at a safepoint, by garbage collections.")
private static void pushToThreadLocalFreeList(AlignedHeader alignedChunk) {
log().string("[ThreadLocalAllocation.pushToThreadLocalFreeList: alignedChunk: ").hex(alignedChunk).newline();
log().string(" before freeList: ").hex(freeList.get()).newline();
assert alignedChunk.isNonNull() : "Should not push a null chunk on the free list.";
final AlignedHeader head = freeList.get();
alignedChunk.setNext(head);
freeList.set(alignedChunk);
log().string(" after freeList: ").hex(freeList.get()).string("]").newline();
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method allocateMemory.
/*
* Methods on UnalignedHeapChunk.
*/
/**
* Allocate memory within this AlignedHeapChunk. No initialization of the memory happens here.
*/
@Uninterruptible(reason = "Returns uninitialized memory.", callerMustBe = true)
public static Pointer allocateMemory(UnalignedHeader that, UnsignedWord size) {
final UnsignedWord available = availableObjectMemory(that);
// Is memory available for the requested size?
Pointer result = WordFactory.nullPointer();
if (size.belowOrEqual(available)) {
// Returned memory is at the start,
result = that.getTop();
final Pointer newTop = result.add(size);
setTopCarefully(that, newTop);
}
return result;
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class AllocationSnippets method formatArrayImpl.
@Uninterruptible(reason = "Manipulates Objects via Pointers", callerMustBe = true)
private static Object formatArrayImpl(Pointer memory, DynamicHub hub, int length, int layoutEncoding, UnsignedWord size, boolean fillContents, boolean rememberedSet, boolean unaligned) {
WordBase header = ObjectHeaderImpl.getObjectHeaderImpl().formatHub(hub, rememberedSet, unaligned);
memory.writeWord(ConfigurationValues.getObjectLayout().getHubOffset(), header, LocationIdentity.INIT_LOCATION);
memory.writeInt(ConfigurationValues.getObjectLayout().getArrayLengthOffset(), length, LocationIdentity.INIT_LOCATION);
if (fillContents) {
UnsignedWord offset = LayoutEncoding.getArrayBaseOffset(layoutEncoding);
if ((!isWordAligned(offset)) && offset.belowThan(size)) {
/*
* The first array element offset can be 4-byte aligned. Write an int in this case
* to zero any bytes before the Word writes below.
*/
memory.writeInt(offset, 0, LocationIdentity.INIT_LOCATION);
offset = offset.add(4);
}
/* Assert that offset is now Word aligned, or past the end of the elements. */
assert isWordAligned(offset) : "offset should be Word aligned";
while (offset.belowThan(size)) {
memory.writeWord(offset, WordFactory.zero(), LocationIdentity.INIT_LOCATION);
offset = offset.add(ConfigurationValues.getTarget().wordSize);
}
}
return memory.toObjectNonNull();
}
use of com.oracle.svm.core.annotate.Uninterruptible in project graal by oracle.
the class AllocationSnippets method fastNewArrayUninterruptibly.
@Uninterruptible(reason = "Holds uninitialized memory from allocateMemory through formatArryImpl")
private static Object fastNewArrayUninterruptibly(DynamicHub hub, int length, int layoutEncoding, boolean fillContents, UnsignedWord size) {
Pointer memory = WordFactory.nullPointer();
if (size.belowOrEqual(HeapPolicy.getLargeArrayThreshold()) && length >= 0) {
memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.regularTLAB.getAddress(), size);
}
Object result = null;
if (memory.isNonNull()) {
result = formatArrayImpl(memory, hub, length, layoutEncoding, size, fillContents, false, false);
}
return result;
}
Aggregations