Skip to content

Commit 8710ef2

Browse files
committed
Reorganize AllocationTracing a bit
1 parent 172a517 commit 8710ef2

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

src/main/java/org/truffleruby/language/objects/AllocationTracing.java

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.truffleruby.RubyContext;
1414
import org.truffleruby.RubyLanguage;
1515
import org.truffleruby.core.inlined.InlinedDispatchNode;
16+
import org.truffleruby.core.inlined.InlinedMethodNode;
17+
import org.truffleruby.core.klass.RubyClass;
1618
import org.truffleruby.core.objectspace.ObjectSpaceManager;
1719
import org.truffleruby.core.string.RubyString;
1820
import org.truffleruby.core.string.StringOperations;
@@ -48,6 +50,28 @@ public static void trace(RubyLanguage language, RubyContext context, RubyDynamic
4850
traceObject(language, context, instance, node);
4951
}
5052

53+
public static void traceBasicObjectAllocation(RubyDynamicObject instance, RubyClass rubyClass,
54+
InlinedMethodNode node) {
55+
RubyLanguage language = node.getLanguage();
56+
RubyContext context = node.getContext();
57+
58+
if (!(node.getParent() instanceof InlinedDispatchNode)) {
59+
traceObject(language, context, instance, node);
60+
} else {
61+
CompilerAsserts.partialEvaluationConstant(language);
62+
63+
final AllocationReporter allocationReporter = language.getAllocationReporter();
64+
if (allocationReporter.isActive()) {
65+
allocationReporter.onEnter(null, 0, AllocationReporter.SIZE_UNKNOWN);
66+
allocationReporter.onReturnValue(instance, 0, AllocationReporter.SIZE_UNKNOWN);
67+
}
68+
69+
if (context.getObjectSpaceManager().isTracing(language)) {
70+
traceInlineBoundary(language, context, instance, rubyClass, node);
71+
}
72+
}
73+
}
74+
5175
private static void traceObject(RubyLanguage language, RubyContext context, Object instance, Node currentNode) {
5276
CompilerAsserts.partialEvaluationConstant(language);
5377

@@ -76,31 +100,9 @@ private static void traceBoundary(RubyLanguage language, RubyContext context, Ob
76100
}
77101
}
78102

79-
public static void traceBasicObjectAllocation(RubyDynamicObject instance, RubyDynamicObject rubyClass,
80-
RubyContextSourceNode node) {
81-
RubyLanguage language = node.getLanguage();
82-
RubyContext context = node.getContext();
83-
84-
if (!(node.getParent() instanceof InlinedDispatchNode)) {
85-
traceObject(language, context, instance, node);
86-
} else {
87-
CompilerAsserts.partialEvaluationConstant(language);
88-
89-
final AllocationReporter allocationReporter = language.getAllocationReporter();
90-
if (allocationReporter.isActive()) {
91-
allocationReporter.onEnter(null, 0, AllocationReporter.SIZE_UNKNOWN);
92-
allocationReporter.onReturnValue(instance, 0, AllocationReporter.SIZE_UNKNOWN);
93-
}
94-
95-
if (context.getObjectSpaceManager().isTracing(language)) {
96-
traceInlineBoundary(language, context, instance, rubyClass, node);
97-
}
98-
}
99-
}
100-
101103
@TruffleBoundary
102-
public static void traceInlineBoundary(RubyLanguage language, RubyContext context, RubyDynamicObject instance,
103-
RubyDynamicObject klass, RubyContextSourceNode node) {
104+
private static void traceInlineBoundary(RubyLanguage language, RubyContext context, RubyDynamicObject instance,
105+
RubyClass klass, RubyContextSourceNode node) {
104106
final ObjectSpaceManager objectSpaceManager = context.getObjectSpaceManager();
105107
if (!objectSpaceManager.isTracingPaused()) {
106108
objectSpaceManager.setTracingPaused(true);
@@ -112,16 +114,6 @@ public static void traceInlineBoundary(RubyLanguage language, RubyContext contex
112114
}
113115
}
114116

115-
@TruffleBoundary
116-
public static void callTraceInlineAllocation(RubyLanguage language, RubyContext context, RubyDynamicObject instance,
117-
RubyDynamicObject klass, RubyContextSourceNode node) {
118-
final SourceSection allocatingSourceSection = context
119-
.getCallStack()
120-
.getTopMostUserSourceSection(node.getEncapsulatingSourceSection());
121-
122-
callAllocationTrace(language, context, instance, allocatingSourceSection, "__allocate__", "Class");
123-
}
124-
125117
@TruffleBoundary
126118
private static void callTraceAllocation(RubyLanguage language, RubyContext context, Object object,
127119
Node currentNode) {
@@ -139,8 +131,18 @@ private static void callTraceAllocation(RubyLanguage language, RubyContext conte
139131
callAllocationTrace(language, context, object, allocatingSourceSection, allocatingMethod, className);
140132
}
141133

134+
@TruffleBoundary
135+
private static void callTraceInlineAllocation(RubyLanguage language, RubyContext context,
136+
RubyDynamicObject instance, RubyClass klass, RubyContextSourceNode node) {
137+
final SourceSection allocatingSourceSection = context
138+
.getCallStack()
139+
.getTopMostUserSourceSection(node.getEncapsulatingSourceSection());
140+
141+
callAllocationTrace(language, context, instance, allocatingSourceSection, "__allocate__", "Class");
142+
}
143+
142144
private static void callAllocationTrace(RubyLanguage language, RubyContext context, Object object,
143-
final SourceSection allocatingSourceSection, final String allocatingMethod, final String className) {
145+
SourceSection allocatingSourceSection, String allocatingMethod, String className) {
144146
context.send(
145147
context.getCoreLibrary().objectSpaceModule,
146148
"trace_allocation",

0 commit comments

Comments
 (0)