use of org.graalvm.nativeimage.c.function.CodePointer 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.nativeimage.c.function.CodePointer in project graal by oracle.
the class Deoptimizer method deoptimizeFrameOperation.
private static void deoptimizeFrameOperation(Pointer sourceSp, boolean ignoreNonDeoptimizable, SpeculationReason speculation, IsolateThread currentThread) {
VMOperation.guaranteeInProgress("doDeoptimizeFrame");
CodePointer returnAddress = FrameAccess.readReturnAddress(sourceSp);
CodeInfoQueryResult info = CodeInfoTable.lookupCodeInfoQueryResult(returnAddress);
Deoptimizer deoptimizer = new Deoptimizer(sourceSp, info);
DeoptimizedFrame sourceFrame = deoptimizer.deoptSourceFrame(returnAddress, ignoreNonDeoptimizable, currentThread);
if (sourceFrame != null) {
registerSpeculationFailure(sourceFrame.getSourceInstalledCode(), speculation);
}
}
use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.
the class RuntimeCodeInfoMemoryWalkerAccessFeature method binarySearch.
/* Copied and adapted from Arrays.binarySearch. */
@Uninterruptible(reason = "called from uninterruptible code")
private static int binarySearch(RuntimeMethodInfo[] a, int fromIndex, int toIndex, CodePointer key) {
int low = fromIndex;
int high = toIndex - 1;
while (low <= high) {
int mid = (low + high) >>> 1;
CodePointer midVal = a[mid].getCodeStart();
if (((UnsignedWord) midVal).belowThan((UnsignedWord) key)) {
low = mid + 1;
} else if (((UnsignedWord) midVal).aboveThan((UnsignedWord) key)) {
high = mid - 1;
} else {
// key found
return mid;
}
}
// key not found.
return -(low + 1);
}
use of org.graalvm.nativeimage.c.function.CodePointer in project graal by oracle.
the class DeoptTester method deoptTest.
/**
* Scans the stack frames and if there are some new (= so far not seen) PCs inside deoptimizable
* methods, a deopt is done.
*
* Foreign call: {@link SnippetRuntime#DEOPTTEST}.
*/
@NeverInline("deoptTest must have a separate stack frame")
@SubstrateForeignCallTarget
public static void deoptTest() {
if (inDeoptTest > 0) {
return;
}
inDeoptTest++;
try {
if (Heap.getHeap().isAllocationDisallowed()) {
return;
}
if (VMOperationControl.TestingBackdoor.isLocked()) {
return;
}
if (VMOperation.isInProgress()) {
return;
}
Pointer startSp = KnownIntrinsics.readCallerStackPointer();
CodePointer startIp = KnownIntrinsics.readReturnAddress();
int numHandledPCs = handledPCs.size();
JavaStackWalker.walkCurrentThread(startSp, startIp, collectPcVisitor);
if (handledPCs.size() > numHandledPCs) {
Deoptimizer.deoptimizeAll();
}
} finally {
inDeoptTest--;
}
}
Aggregations