Skip to content

Commit b3bfc9d

Browse files
committed
[Truffle] Do not visit singleton classes with ObjectSpace.each_object.
1 parent ac26614 commit b3bfc9d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

truffle/src/main/java/org/jruby/truffle/runtime/core/RubyClass.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import com.oracle.truffle.api.CompilerAsserts;
1313
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
1414
import com.oracle.truffle.api.nodes.Node;
15+
1516
import org.jruby.truffle.nodes.RubyNode;
1617
import org.jruby.truffle.nodes.objects.Allocator;
1718
import org.jruby.truffle.runtime.RubyContext;
19+
import org.jruby.truffle.runtime.subsystems.ObjectSpaceManager.ObjectGraphVisitor;
1820

1921
import java.util.Collections;
2022
import java.util.Set;
@@ -149,6 +151,14 @@ public Allocator getAllocator() {
149151
return allocator;
150152
}
151153

154+
@Override
155+
public void visitObjectGraph(ObjectGraphVisitor visitor) {
156+
// MRI consider all singleton classes as internal objects.
157+
if (!isSingleton) {
158+
super.visitObjectGraph(visitor);
159+
}
160+
}
161+
152162
public static class ClassAllocator implements Allocator {
153163

154164
@Override

0 commit comments

Comments
 (0)