13
13
import org .truffleruby .RubyContext ;
14
14
import org .truffleruby .RubyLanguage ;
15
15
import org .truffleruby .core .inlined .InlinedDispatchNode ;
16
+ import org .truffleruby .core .inlined .InlinedMethodNode ;
17
+ import org .truffleruby .core .klass .RubyClass ;
16
18
import org .truffleruby .core .objectspace .ObjectSpaceManager ;
17
19
import org .truffleruby .core .string .RubyString ;
18
20
import org .truffleruby .core .string .StringOperations ;
@@ -48,6 +50,28 @@ public static void trace(RubyLanguage language, RubyContext context, RubyDynamic
48
50
traceObject (language , context , instance , node );
49
51
}
50
52
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
+
51
75
private static void traceObject (RubyLanguage language , RubyContext context , Object instance , Node currentNode ) {
52
76
CompilerAsserts .partialEvaluationConstant (language );
53
77
@@ -76,31 +100,9 @@ private static void traceBoundary(RubyLanguage language, RubyContext context, Ob
76
100
}
77
101
}
78
102
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
-
101
103
@ 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 ) {
104
106
final ObjectSpaceManager objectSpaceManager = context .getObjectSpaceManager ();
105
107
if (!objectSpaceManager .isTracingPaused ()) {
106
108
objectSpaceManager .setTracingPaused (true );
@@ -112,16 +114,6 @@ public static void traceInlineBoundary(RubyLanguage language, RubyContext contex
112
114
}
113
115
}
114
116
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
-
125
117
@ TruffleBoundary
126
118
private static void callTraceAllocation (RubyLanguage language , RubyContext context , Object object ,
127
119
Node currentNode ) {
@@ -139,8 +131,18 @@ private static void callTraceAllocation(RubyLanguage language, RubyContext conte
139
131
callAllocationTrace (language , context , object , allocatingSourceSection , allocatingMethod , className );
140
132
}
141
133
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
+
142
144
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 ) {
144
146
context .send (
145
147
context .getCoreLibrary ().objectSpaceModule ,
146
148
"trace_allocation" ,
0 commit comments