Skip to content

Commit

Permalink
For JIT compiled code that is on the stack, only walk the tether.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhaeubl committed Dec 14, 2023
1 parent 5fb4028 commit 450e48c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -875,14 +875,11 @@ private void walkStack(JavaStackWalk walk) {

if (RuntimeCompilation.isEnabled() && codeInfo != CodeInfoTable.getImageCodeInfo()) {
/*
* For runtime-compiled code that is currently on the stack, we need to treat all
* the references to Java heap objects as strong references. It is important that we
* really walk *all* those references here. Otherwise, RuntimeCodeCacheWalker might
* decide to invalidate too much code, depending on the order in which the CodeInfo
* objects are visited.
* Runtime-compiled code that is currently on the stack must be kept alive. So, we
* mark the tether as strongly reachable. The RuntimeCodeCacheWalker will handle all
* other object references later on.
*/
RuntimeCodeInfoAccess.walkStrongReferences(codeInfo, greyToBlackObjRefVisitor);
RuntimeCodeInfoAccess.walkWeakReferences(codeInfo, greyToBlackObjRefVisitor);
RuntimeCodeInfoAccess.walkTether(codeInfo, greyToBlackObjRefVisitor);
}

if (!JavaStackWalker.continueWalk(walk, queryResult, deoptFrame)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,21 @@ public static boolean walkWeakReferences(CodeInfo info, ObjectReferenceVisitor v
return continueVisiting;
}

/**
* This method only walks the tether. You typically want to use {@link #walkStrongReferences}
* and/or {@link #walkWeakReferences} instead.
*/
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static boolean walkTether(CodeInfo info, ObjectReferenceVisitor visitor) {
Pointer address = NonmovableArrays.addressOf(cast(info).getObjectFields(), CodeInfoImpl.TETHER_OBJFIELD);
return callVisitor(visitor, address);
}

@Uninterruptible(reason = "Bridge between uninterruptible and potentially interruptible code.", mayBeInlined = true, calleeMustBe = false)
private static boolean callVisitor(ObjectReferenceVisitor visitor, Pointer address) {
return visitor.visitObjectReference(address, true, null);
}

/**
* This method only visits a very specific subset of all the references, so you typically want
* to use {@link #walkStrongReferences} and/or {@link #walkWeakReferences} instead.
Expand Down

0 comments on commit 450e48c

Please sign in to comment.