use of org.graalvm.word.Pointer in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method usedObjectMemoryOfUnalignedHeapChunk.
/**
* How much space is used for the objects in an UnalignedHeapChunk?
*/
public static UnsignedWord usedObjectMemoryOfUnalignedHeapChunk(UnalignedHeader that) {
final Pointer start = getUnalignedHeapChunkStart(that);
final Pointer top = that.getTop();
return top.subtract(start);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method committedObjectMemoryOfUnalignedHeapChunk.
/**
* The committed object memory is the space between start and end.
*/
public static UnsignedWord committedObjectMemoryOfUnalignedHeapChunk(UnalignedHeader that) {
final Pointer start = getUnalignedHeapChunkStart(that);
final Pointer end = that.getEnd();
final UnsignedWord result = end.subtract(start);
return result;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AllocationSnippets method newPinnedInstanceSnippet.
@Snippet
public static Object newPinnedInstanceSnippet(PinnedAllocatorImpl pinnedAllocator, DynamicHub hub, @ConstantParameter int encoding, @ConstantParameter boolean fillContents, AllocationCounter counter) {
pinnedAllocator.ensureOpen();
UnsignedWord size = LayoutEncoding.getInstanceSize(encoding);
profileAllocation(size, counter);
Pointer memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.pinnedTLAB.getAddress(), size);
Object result;
if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, memory.isNonNull())) {
result = formatObjectImpl(memory, hub, size, true, fillContents, false);
} else {
result = callSlowNewPinnedInstance(SLOW_NEW_PINNED_INSTANCE, pinnedAllocator, hub.asClass());
}
return PiNode.piCastToSnippetReplaceeStamp(result);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AllocationSnippets method newMultiArraySnippet.
@Snippet
public static Object newMultiArraySnippet(DynamicHub hub, @ConstantParameter int rank, @VarargsParameter int[] dimensions, AllocationCounter counter) {
Pointer dims = DimensionsNode.allocaDimsArray(rank);
ExplodeLoopNode.explodeLoop();
for (int i = 0; i < rank; i++) {
dims.writeInt(i * sizeOfDimensionElement, dimensions[i], LocationIdentity.INIT_LOCATION);
}
return callNewMultiArray(NEW_MULTI_ARRAY, hub.asClass(), rank, dims, counter);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AllocationSnippets method doCloneSnippet.
/**
* The actual implementation of {@link Object#clone}.
*/
@Snippet
private static Object doCloneSnippet(Object thisObj, AllocationCounter counter) throws CloneNotSupportedException {
if (!(thisObj instanceof Cloneable)) {
throw CLONE_NOT_SUPPORTED_EXCEPTION;
}
DynamicHub hub = KnownIntrinsics.readHub(thisObj);
int layoutEncoding = hub.getLayoutEncoding();
UnsignedWord size = LayoutEncoding.getSizeFromObject(thisObj);
profileAllocation(size, counter);
/*
* The size of the clone is the same as the size of the original object. On the fast path we
* try to allocate aligned memory, i.e., a block inside an aligned chunks, for the clone and
* don't need to distinguish instance objects from arrays. If we fail, i.e., the returned
* memory is null, then either the instance object or small array didn't fit in the
* available space or it is a large array. In either case we go on the slow path.
*/
Pointer memory = ThreadLocalAllocation.allocateMemory(ThreadLocalAllocation.regularTLAB.getAddress(), size);
Object thatObject = null;
if (BranchProbabilityNode.probability(BranchProbabilityNode.FAST_PATH_PROBABILITY, memory.isNonNull())) {
WordBase header = ObjectHeaderImpl.getObjectHeaderImpl().formatHub(hub, false, false);
memory.writeWord(ConfigurationValues.getObjectLayout().getHubOffset(), header, LocationIdentity.INIT_LOCATION);
/*
* For arrays the length initialization is handled by doCloneUninterruptibly since the
* array length offset is the same as the first field offset.
*/
thatObject = memory.toObjectNonNull();
} else {
if (LayoutEncoding.isArray(layoutEncoding)) {
int length = KnownIntrinsics.readArrayLength(thisObj);
thatObject = callSlowNewArray(SLOW_NEW_ARRAY, hub.asClass(), length);
} else {
thatObject = callSlowNewInstance(SLOW_NEW_INSTANCE, hub.asClass());
}
}
if (LayoutEncoding.isArray(layoutEncoding)) {
int length = KnownIntrinsics.readArrayLength(thisObj);
thatObject = PiArrayNode.piArrayCastToSnippetReplaceeStamp(thatObject, length);
} else {
thatObject = PiNode.piCastToSnippetReplaceeStamp(thatObject);
}
UnsignedWord firstFieldOffset = WordFactory.signed(ConfigurationValues.getObjectLayout().getFirstFieldOffset());
return doCloneUninterruptibly(thisObj, thatObject, firstFieldOffset, size);
}
Aggregations