use of org.graalvm.word.Pointer in project graal by oracle.
the class HeapChunkProvider method zap.
/**
* Write the given value over all the Object memory in the chunk.
*/
private static void zap(Header<?> chunk, WordBase value) {
Pointer start = chunk.getTop();
Pointer limit = chunk.getEnd();
log().string(" zap chunk: ").hex(chunk).string(" start: ").hex(start).string(" limit: ").hex(limit).string(" value: ").hex(value).newline();
for (Pointer p = start; p.belowThan(limit); p = p.add(FrameAccess.wordSize())) {
p.writeWord(0, value);
}
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class Deoptimizer method deoptimizeInRangeOperation.
/**
* Deoptimize a specific method on all thread stacks.
*/
private static void deoptimizeInRangeOperation(CodePointer fromIp, CodePointer toIp, boolean deoptAll) {
VMOperation.guaranteeInProgress("Deoptimizer.deoptimizeInRangeOperation, but not in VMOperation.");
/* Handle my own thread specially, because I do not have a JavaFrameAnchor. */
StackFrameVisitor currentThreadDeoptVisitor = getStackFrameVisitor((Pointer) fromIp, (Pointer) toIp, deoptAll, CEntryPointContext.getCurrentIsolateThread());
Pointer sp = KnownIntrinsics.readCallerStackPointer();
CodePointer ip = KnownIntrinsics.readReturnAddress();
JavaStackWalker.walkCurrentThread(sp, ip, currentThreadDeoptVisitor);
/* If I am multi-threaded, deoptimize this method on all the other stacks. */
if (SubstrateOptions.MultiThreaded.getValue()) {
for (IsolateThread vmThread = VMThreads.firstThread(); VMThreads.isNonNullThread(vmThread); vmThread = VMThreads.nextThread(vmThread)) {
if (vmThread == CEntryPointContext.getCurrentIsolateThread()) {
continue;
}
StackFrameVisitor deoptVisitor = getStackFrameVisitor((Pointer) fromIp, (Pointer) toIp, deoptAll, vmThread);
JavaStackWalker.walkThread(vmThread, deoptVisitor);
}
}
if (testGCinDeoptimizer) {
Heap.getHeap().getGC().collect("from Deoptimizer.deoptimizeInRange because of testGCinDeoptimizer");
}
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class Deoptimizer method rewriteStackAndJumpToTarget.
/**
* Performs the actual stack rewriting. When this method is called the sp is already at the
* bottom of the deopt target method.
*
* @param newSp Points to the bottom of the deopt target method (but above the return address
* slot).
* @param frame The deopt frame handle.
* @return The epilog of this method restores the return value registers from the returned frame
* handle. The instructions for restoring the return value registers must be generated
* in this method's epilog by a backend-specific FrameContext class.
*/
@DeoptStub(stubType = StubType.ExitStub)
@NeverInline("don't provoke the writeStackPointer devil with a non-trivial method")
@Uninterruptible(reason = "Frame holds Objects in unmanaged storage.")
private static DeoptimizedFrame rewriteStackAndJumpToTarget(Pointer newSp, DeoptimizedFrame frame) {
/*
* The first word of the new stack content is already the return address into the caller of
* deoptimizeInRange(). So when this method returns we are inside the caller of
* deoptimizeInRange().
*/
Pointer bottomSp = newSp.subtract(FrameAccess.returnAddressSize());
frame.getTargetContent().copyToPointer(bottomSp);
if (DeoptimizationCounters.Options.ProfileDeoptimization.getValue()) {
DeoptimizationCounters.counters().timeSpentInDeopt.add(System.nanoTime() - DeoptimizationCounters.startTime.get());
}
return frame;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class Deoptimizer method deoptStub.
/**
* Performs the second step of deoptimization: the actual rewriting of a deoptimized method's
* frame.
* <p>
* The pointer to the deopt stub code was installed in the return address slot by
* {@link #deoptimizeInRange}. Therefore the stub is "called" when a method wants to return to a
* deoptimized method.
* <p>
* When {@link #deoptStub} is "called", the stack looks like this:
*
* <pre>
* : :
* | |
* | | frame of the
* +--------------------------------+ deoptimized method
* | pointer to DeoptimizedFrame |
* +--------------------------------+--------- no return address between the frames!
* | |
* | | frame of
* | | {@link #deoptStub}
* : ... :
* </pre>
*
* @param frame This is the handle which was created in {@link #deoptimizeInRange}. It is
* fetched from the stack (the slot above the original return address) and passed as
* parameter. The instructions for fetching the frame handle must be generated in
* this method's prolog by a backend-specific FrameContext class. The prolog also
* stores the original return value registers in the {@code frame}.
*/
@DeoptStub(stubType = StubType.EntryStub)
@Uninterruptible(reason = "Frame holds Objects in unmanaged storage.")
public static void deoptStub(DeoptimizedFrame frame) {
DeoptimizationCounters.counters().deoptCount.inc();
if (DeoptimizationCounters.Options.ProfileDeoptimization.getValue()) {
DeoptimizationCounters.startTime.set(System.nanoTime());
}
/* Build the content of the deopt target stack frames. */
frame.buildContent();
/*
* The frame was pinned to keep it from moving during construction. I can unpin it now that
* I am uninterruptible. (And I have to unpin it.)
*/
frame.getPin().close();
recentDeoptimizationEvents.append(frame.getCompletedMessage());
Pointer sp = KnownIntrinsics.readStackPointer();
/* Do the stack rewriting. Return directly to the deopt target. */
final Pointer newSp = sp.add(WordFactory.unsigned(deoptStubFrameSize)).add(WordFactory.unsigned(frame.getSourceTotalFrameSize()).subtract(frame.getTargetContent().getSize()).subtract(FrameAccess.returnAddressSize()));
rewriteStackStub(newSp, frame);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class InteriorObjRefWalker method walkObjectInline.
@AlwaysInline("Performance critical version")
public static boolean walkObjectInline(final Object obj, final ObjectReferenceVisitor visitor) {
final DynamicHub objHub = ObjectHeader.readDynamicHubFromObject(obj);
final int layoutEncoding = objHub.getLayoutEncoding();
final Pointer objPointer = Word.objectToUntrackedPointer(obj);
// Visit each Object reference in the array part of the Object.
if (LayoutEncoding.isObjectArray(layoutEncoding)) {
int length = KnownIntrinsics.readArrayLength(obj);
for (int index = 0; index < length; index++) {
final UnsignedWord elementOffset = LayoutEncoding.getArrayElementOffset(layoutEncoding, index);
final Pointer elementPointer = objPointer.add(elementOffset);
boolean isCompressed = ReferenceAccess.singleton().haveCompressedReferences();
final boolean visitResult = visitor.visitObjectReferenceInline(elementPointer, isCompressed);
if (!visitResult) {
return false;
}
}
}
// Visit Object reference in the fields of the Object.
byte[] referenceMapEncoding = DynamicHubSupport.getReferenceMapEncoding();
long referenceMapIndex = objHub.getReferenceMapIndex();
return ReferenceMapDecoder.walkOffsetsFromPointer(objPointer, referenceMapEncoding, referenceMapIndex, visitor);
}
Aggregations