2828import org .graalvm .nativeimage .Platforms ;
2929
3030import com .oracle .svm .core .code .CodeInfo ;
31- import com .oracle .svm .core .code .CodeInfoAccess ;
3231import com .oracle .svm .core .code .RuntimeCodeCache .CodeInfoVisitor ;
3332import com .oracle .svm .core .code .RuntimeCodeInfoAccess ;
34- import com .oracle .svm .core .heap . ObjectReferenceVisitor ;
33+ import com .oracle .svm .core .genscavenge . compacting . ObjectRefFixupVisitor ;
3534
36- /**
37- * Before compaction, updates the same references that were visited by
38- * {@link RuntimeCodeCacheWalker} during the mark phase.
39- */
35+ /** Before compaction, updates references from {@link CodeInfo} structures. */
4036final class RuntimeCodeCacheFixupWalker implements CodeInfoVisitor {
4137
42- private final ObjectReferenceVisitor visitor ;
38+ private final ObjectRefFixupVisitor visitor ;
4339
4440 @ Platforms (Platform .HOSTED_ONLY .class )
45- RuntimeCodeCacheFixupWalker (ObjectReferenceVisitor visitor ) {
41+ RuntimeCodeCacheFixupWalker (ObjectRefFixupVisitor visitor ) {
4642 this .visitor = visitor ;
4743 }
4844
@@ -52,18 +48,10 @@ public boolean visitCode(CodeInfo codeInfo) {
5248 return true ;
5349 }
5450
55- int state = CodeInfoAccess .getState (codeInfo );
56- if (state == CodeInfo .STATE_UNREACHABLE || state == CodeInfo .STATE_READY_FOR_INVALIDATION ) {
57- /*
58- * The code will be freed during this collection, but we need to make sure that all the
59- * objects that are accessed during the invalidation remain accessible. Those objects
60- * can only be collected in a subsequent garbage collection.
61- */
62- RuntimeCodeInfoAccess .walkObjectFields (codeInfo , visitor );
63- return true ;
64- }
65-
66- /* The CodeInfo remains valid, so we need to fix up all references. */
51+ /*
52+ * Whether this CodeInfo remains valid or will be invalidated or freed during this GC, we
53+ * update all references, including clearing those to objects that do not survive.
54+ */
6755 RuntimeCodeInfoAccess .walkStrongReferences (codeInfo , visitor );
6856 RuntimeCodeInfoAccess .walkWeakReferences (codeInfo , visitor );
6957 return true ;
0 commit comments