14
14
import org .truffleruby .RubyLanguage ;
15
15
import org .truffleruby .core .inlined .InlinedDispatchNode ;
16
16
import org .truffleruby .core .inlined .InlinedMethodNode ;
17
- import org .truffleruby .core .klass .RubyClass ;
18
17
import org .truffleruby .core .objectspace .ObjectSpaceManager ;
19
18
import org .truffleruby .core .string .RubyString ;
20
19
import org .truffleruby .core .string .StringOperations ;
@@ -50,45 +49,42 @@ public static void trace(RubyLanguage language, RubyContext context, RubyDynamic
50
49
traceObject (language , context , instance , node );
51
50
}
52
51
53
- public static void traceBasicObjectAllocation (RubyDynamicObject instance , RubyClass rubyClass ,
52
+ private static void traceObject (RubyLanguage language , RubyContext context , Object instance , Node currentNode ) {
53
+ truffleTracing (language , instance );
54
+
55
+ if (context .getObjectSpaceManager ().isTracing (language )) {
56
+ traceBoundary (language , context , instance , currentNode );
57
+ }
58
+ }
59
+
60
+ public static void traceInlined (RubyDynamicObject instance , String className , String allocatingMethod ,
54
61
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
- }
62
+ final RubyLanguage language = node .getLanguage ();
63
+ final RubyContext context = node .getContext ();
64
+
65
+ truffleTracing (language , instance );
68
66
69
- if (context .getObjectSpaceManager ().isTracing (language )) {
70
- traceInlineBoundary (language , context , instance , rubyClass , node );
67
+ if (context .getObjectSpaceManager ().isTracing (language )) {
68
+ if (!(node .getParent () instanceof InlinedDispatchNode )) {
69
+ traceBoundary (language , context , instance , node );
70
+ } else {
71
+ traceInlineBoundary (language , context , instance , className , allocatingMethod , node );
71
72
}
72
73
}
73
74
}
74
75
75
- private static void traceObject (RubyLanguage language , RubyContext context , Object instance , Node currentNode ) {
76
+ private static void truffleTracing (RubyLanguage language , Object instance ) {
76
77
CompilerAsserts .partialEvaluationConstant (language );
77
78
78
79
final AllocationReporter allocationReporter = language .getAllocationReporter ();
79
80
if (allocationReporter .isActive ()) {
80
81
allocationReporter .onEnter (null , 0 , AllocationReporter .SIZE_UNKNOWN );
81
82
allocationReporter .onReturnValue (instance , 0 , AllocationReporter .SIZE_UNKNOWN );
82
83
}
83
-
84
- if (context .getObjectSpaceManager ().isTracing (language )) {
85
- traceBoundary (language , context , instance , currentNode );
86
- }
87
84
}
88
85
89
86
@ TruffleBoundary
90
- private static void traceBoundary (RubyLanguage language , RubyContext context , Object object ,
91
- Node currentNode ) {
87
+ private static void traceBoundary (RubyLanguage language , RubyContext context , Object object , Node currentNode ) {
92
88
final ObjectSpaceManager objectSpaceManager = context .getObjectSpaceManager ();
93
89
if (!objectSpaceManager .isTracingPaused ()) {
94
90
objectSpaceManager .setTracingPaused (true );
@@ -102,12 +98,12 @@ private static void traceBoundary(RubyLanguage language, RubyContext context, Ob
102
98
103
99
@ TruffleBoundary
104
100
private static void traceInlineBoundary (RubyLanguage language , RubyContext context , RubyDynamicObject instance ,
105
- RubyClass klass , RubyContextSourceNode node ) {
101
+ String className , String allocatingMethod , RubyContextSourceNode node ) {
106
102
final ObjectSpaceManager objectSpaceManager = context .getObjectSpaceManager ();
107
103
if (!objectSpaceManager .isTracingPaused ()) {
108
104
objectSpaceManager .setTracingPaused (true );
109
105
try {
110
- callTraceInlineAllocation (language , context , instance , klass , node );
106
+ callTraceInlineAllocation (language , context , instance , className , allocatingMethod , node );
111
107
} finally {
112
108
objectSpaceManager .setTracingPaused (false );
113
109
}
@@ -125,24 +121,22 @@ private static void callTraceAllocation(RubyLanguage language, RubyContext conte
125
121
126
122
final Object allocatingSelf = RubyArguments .getSelf (allocatingFrame );
127
123
final String allocatingMethod = RubyArguments .getMethod (allocatingFrame ).getName ();
128
- final String className = LogicalClassNode .getUncached ().execute (allocatingSelf ).fields
129
- .getName ();
124
+ final String className = LogicalClassNode .getUncached ().execute (allocatingSelf ).fields .getName ();
130
125
131
- callAllocationTrace (language , context , object , allocatingSourceSection , allocatingMethod , className );
126
+ callAllocationTrace (language , context , object , allocatingSourceSection , className , allocatingMethod );
132
127
}
133
128
134
129
@ TruffleBoundary
135
130
private static void callTraceInlineAllocation (RubyLanguage language , RubyContext context ,
136
- RubyDynamicObject instance , RubyClass klass , RubyContextSourceNode node ) {
131
+ RubyDynamicObject instance , String className , String allocatingMethod , RubyContextSourceNode node ) {
137
132
final SourceSection allocatingSourceSection = context
138
133
.getCallStack ()
139
134
.getTopMostUserSourceSection (node .getEncapsulatingSourceSection ());
140
-
141
- callAllocationTrace (language , context , instance , allocatingSourceSection , "__allocate__" , "Class" );
135
+ callAllocationTrace (language , context , instance , allocatingSourceSection , className , allocatingMethod );
142
136
}
143
137
144
138
private static void callAllocationTrace (RubyLanguage language , RubyContext context , Object object ,
145
- SourceSection allocatingSourceSection , String allocatingMethod , String className ) {
139
+ SourceSection allocatingSourceSection , String className , String allocatingMethod ) {
146
140
context .send (
147
141
context .getCoreLibrary ().objectSpaceModule ,
148
142
"trace_allocation" ,
0 commit comments