|
Expand Up
|
@@ -125,7 +125,7 @@ private static int allocateFromStack(Continuation cont, Pointer baseSp, Pointer |
|
|
if (!yield) { |
|
|
PreemptVisitor visitor = new PreemptVisitor(baseSp); |
|
|
JavaStackWalker.walkThread(targetThread, visitor); |
|
|
if (visitor.preemptStatus != Continuation.YIELD_SUCCESS) { |
|
|
if (visitor.preemptStatus != Continuation.FREEZE_OK) { |
|
|
return visitor.preemptStatus; |
|
|
} |
|
|
startSp = visitor.leafSP; |
|
Expand All
|
@@ -138,7 +138,7 @@ private static int allocateFromStack(Continuation cont, Pointer baseSp, Pointer |
|
|
StoredContinuation instance = allocate(framesSize); |
|
|
fillUninterruptibly(instance, startIp, startSp, framesSize); |
|
|
cont.stored = instance; |
|
|
return Continuation.YIELD_SUCCESS; |
|
|
return Continuation.FREEZE_OK; |
|
|
} |
|
|
|
|
|
@Uninterruptible(reason = "Prevent modifications to the stack while initializing instance and copying frames.") |
|
Expand Down
Expand Up
|
@@ -187,39 +187,18 @@ public static boolean walkReferences(Pointer baseAddress, ObjectReferenceVisitor |
|
|
StoredContinuation s = (StoredContinuation) holderObject; |
|
|
assert baseAddress.equal(Word.objectToUntrackedPointer(holderObject)); |
|
|
|
|
|
CodePointer startIp = getIP(s); |
|
|
if (startIp.isNull()) { |
|
|
JavaStackWalk walk = StackValue.get(JavaStackWalk.class); |
|
|
if (!initWalk(s, walk)) { |
|
|
return true; // uninitialized, ignore |
|
|
} |
|
|
|
|
|
Pointer startSp = getFramesStart(s); |
|
|
Pointer endSp = arrayAddress(s).add(getSizeInBytes(s)); |
|
|
|
|
|
JavaStackWalk walk = StackValue.get(JavaStackWalk.class); |
|
|
JavaStackWalker.initWalk(walk, startSp, endSp, startIp); |
|
|
|
|
|
SimpleCodeInfoQueryResult queryResult = StackValue.get(SimpleCodeInfoQueryResult.class); |
|
|
do { |
|
|
Pointer sp = walk.getSP(); |
|
|
CodePointer ip = walk.getPossiblyStaleIP(); |
|
|
|
|
|
UntetheredCodeInfo untetheredCodeInfo = walk.getIPCodeInfo(); |
|
|
Object tether = CodeInfoAccess.acquireTether(untetheredCodeInfo); |
|
|
try { |
|
|
CodeInfo codeInfo = CodeInfoAccess.convert(untetheredCodeInfo); |
|
|
VMError.guarantee(codeInfo.equal(CodeInfoTable.getImageCodeInfo())); |
|
|
VMError.guarantee(Deoptimizer.checkDeoptimized(sp) == null); |
|
|
if (codeInfo.isNull()) { |
|
|
throw JavaStackWalker.reportUnknownFrameEncountered(sp, ip, null); |
|
|
} |
|
|
|
|
|
CodeInfoAccess.lookupCodeInfo(codeInfo, CodeInfoAccess.relativeIP(codeInfo, ip), queryResult); |
|
|
|
|
|
NonmovableArray<Byte> referenceMapEncoding = CodeInfoAccess.getStackReferenceMapEncoding(codeInfo); |
|
|
long referenceMapIndex = queryResult.getReferenceMapIndex(); |
|
|
if (referenceMapIndex != ReferenceMapIndex.NO_REFERENCE_MAP) { |
|
|
CodeReferenceMapDecoder.walkOffsetsFromPointer(sp, referenceMapEncoding, referenceMapIndex, visitor, holderObject); |
|
|
} |
|
|
CodeInfo codeInfo = CodeInfoAccess.convert(untetheredCodeInfo, tether); |
|
|
walkFrameReferences(walk, codeInfo, queryResult, visitor, holderObject); |
|
|
} finally { |
|
|
CodeInfoAccess.releaseTether(untetheredCodeInfo, tether); |
|
|
} |
|
Expand All
|
@@ -228,13 +207,52 @@ public static boolean walkReferences(Pointer baseAddress, ObjectReferenceVisitor |
|
|
return true; |
|
|
} |
|
|
|
|
|
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) |
|
|
public static boolean initWalk(StoredContinuation s, JavaStackWalk walk) { |
|
|
CodePointer startIp = getIP(s); |
|
|
if (startIp.isNull()) { |
|
|
return false; // uninitialized |
|
|
} |
|
|
|
|
|
initWalk(s, walk, startIp); |
|
|
return true; |
|
|
} |
|
|
|
|
|
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) |
|
|
public static void initWalk(StoredContinuation s, JavaStackWalk walk, CodePointer startIp) { |
|
|
Pointer startSp = getFramesStart(s); |
|
|
Pointer endSp = arrayAddress(s).add(getSizeInBytes(s)); |
|
|
|
|
|
JavaStackWalker.initWalk(walk, startSp, endSp, startIp); |
|
|
walk.setAnchor(WordFactory.nullPointer()); // never use an anchor of this platform thread |
|
|
} |
|
|
|
|
|
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) |
|
|
public static void walkFrameReferences(JavaStackWalk walk, CodeInfo codeInfo, SimpleCodeInfoQueryResult queryResult, ObjectReferenceVisitor visitor, Object holderObject) { |
|
|
Pointer sp = walk.getSP(); |
|
|
CodePointer ip = walk.getPossiblyStaleIP(); |
|
|
if (codeInfo.isNull()) { |
|
|
throw JavaStackWalker.reportUnknownFrameEncountered(sp, ip, null); |
|
|
} |
|
|
VMError.guarantee(codeInfo.equal(CodeInfoTable.getImageCodeInfo())); |
|
|
VMError.guarantee(Deoptimizer.checkDeoptimized(sp) == null); |
|
|
|
|
|
CodeInfoAccess.lookupCodeInfo(codeInfo, CodeInfoAccess.relativeIP(codeInfo, ip), queryResult); |
|
|
|
|
|
NonmovableArray<Byte> referenceMapEncoding = CodeInfoAccess.getStackReferenceMapEncoding(codeInfo); |
|
|
long referenceMapIndex = queryResult.getReferenceMapIndex(); |
|
|
if (referenceMapIndex != ReferenceMapIndex.NO_REFERENCE_MAP) { |
|
|
CodeReferenceMapDecoder.walkOffsetsFromPointer(sp, referenceMapEncoding, referenceMapIndex, visitor, holderObject); |
|
|
} |
|
|
} |
|
|
|
|
|
private static final class PreemptVisitor extends StackFrameVisitor { |
|
|
private final Pointer endSP; |
|
|
private boolean startFromNextFrame = false; |
|
|
|
|
|
Pointer leafSP; |
|
|
CodePointer leafIP; |
|
|
int preemptStatus = Continuation.YIELD_SUCCESS; |
|
|
int preemptStatus = Continuation.FREEZE_OK; |
|
|
|
|
|
PreemptVisitor(Pointer endSP) { |
|
|
this.endSP = endSP; |
|
Expand Down
|
|