11
11
12
12
import com .oracle .truffle .api .dsl .GenerateUncached ;
13
13
import com .oracle .truffle .api .dsl .ImportStatic ;
14
+ import com .oracle .truffle .api .frame .Frame ;
14
15
import org .graalvm .collections .Pair ;
15
16
import org .truffleruby .RubyContext ;
16
17
import org .truffleruby .RubyLanguage ;
21
22
import org .truffleruby .collections .ConcurrentOperations ;
22
23
import org .truffleruby .core .CoreLibrary ;
23
24
import org .truffleruby .core .array .RubyArray ;
25
+ import org .truffleruby .core .inlined .AlwaysInlinedMethodNode ;
24
26
import org .truffleruby .core .klass .RubyClass ;
25
27
import org .truffleruby .core .module .RubyModule ;
26
28
import org .truffleruby .core .proc .ProcCallTargets ;
35
37
import org .truffleruby .language .RubyRootNode ;
36
38
import org .truffleruby .language .Visibility ;
37
39
import org .truffleruby .language .arguments .EmptyArgumentsDescriptor ;
38
- import org .truffleruby .language .arguments .ReadCallerFrameNode ;
39
40
import org .truffleruby .language .arguments .RubyArguments ;
40
41
import org .truffleruby .language .control .BreakID ;
41
42
import org .truffleruby .language .control .RaiseException ;
55
56
import com .oracle .truffle .api .dsl .Specialization ;
56
57
import com .oracle .truffle .api .frame .FrameDescriptor ;
57
58
import com .oracle .truffle .api .frame .MaterializedFrame ;
58
- import com .oracle .truffle .api .frame .VirtualFrame ;
59
59
import com .oracle .truffle .api .source .SourceSection ;
60
60
61
61
import java .util .Map ;
@@ -126,29 +126,26 @@ protected long hash(RubySymbol symbol,
126
126
}
127
127
}
128
128
129
- @ CoreMethod (names = "to_proc" )
129
+ @ GenerateUncached
130
+ @ CoreMethod (names = "to_proc" , alwaysInlined = true )
130
131
@ ImportStatic (DeclarationContext .class )
131
- public abstract static class ToProcNode extends CoreMethodArrayArgumentsNode {
132
+ public abstract static class ToProcNode extends AlwaysInlinedMethodNode {
132
133
133
134
public static final Arity ARITY = new Arity (1 , 0 , true );
134
135
135
136
public static ToProcNode create () {
136
- return SymbolNodesFactory .ToProcNodeFactory .create (null );
137
+ return SymbolNodesFactory .ToProcNodeFactory .create ();
137
138
}
138
139
139
- public abstract RubyProc execute (VirtualFrame frame , RubySymbol symbol );
140
-
141
- @ Child private ReadCallerFrameNode readCallerFrame = ReadCallerFrameNode .create ();
142
-
143
140
@ Specialization (
144
141
guards = {
145
142
"isSingleContext()" ,
146
143
"symbol == cachedSymbol" ,
147
- "getRefinements(frame ) == cachedRefinements" },
144
+ "getRefinements(callerFrame ) == cachedRefinements" },
148
145
limit = "getIdentityCacheLimit()" )
149
- protected RubyProc toProcCached (VirtualFrame frame , RubySymbol symbol ,
146
+ protected RubyProc toProcCached (Frame callerFrame , RubySymbol symbol , Object [] rubyArgs , RootCallTarget target ,
150
147
@ Cached ("symbol" ) RubySymbol cachedSymbol ,
151
- @ Cached ("getRefinements(frame )" ) Map <RubyModule , RubyModule []> cachedRefinements ,
148
+ @ Cached ("getRefinements(callerFrame )" ) Map <RubyModule , RubyModule []> cachedRefinements ,
152
149
@ Cached ("getOrCreateCallTarget(getContext(), getLanguage(), cachedSymbol, cachedRefinements)" ) RootCallTarget callTarget ,
153
150
@ Cached ("createProc(getContext(), getLanguage(), cachedRefinements, callTarget)" ) RubyProc cachedProc ) {
154
151
return cachedProc ;
@@ -157,17 +154,19 @@ protected RubyProc toProcCached(VirtualFrame frame, RubySymbol symbol,
157
154
@ Specialization (
158
155
guards = {
159
156
"symbol == cachedSymbol" ,
160
- "getRefinements(frame ) == NO_REFINEMENTS" },
157
+ "getRefinements(callerFrame ) == NO_REFINEMENTS" },
161
158
limit = "getIdentityCacheLimit()" )
162
- protected RubyProc toProcCachedNoRefinements (VirtualFrame frame , RubySymbol symbol ,
159
+ protected RubyProc toProcCachedNoRefinements (
160
+ Frame callerFrame , RubySymbol symbol , Object [] rubyArgs , RootCallTarget target ,
163
161
@ Cached ("symbol" ) RubySymbol cachedSymbol ,
164
162
@ Cached ("getOrCreateCallTarget(getContext(), getLanguage(), cachedSymbol, NO_REFINEMENTS)" ) RootCallTarget callTarget ) {
165
163
return createProc (getContext (), getLanguage (), DeclarationContext .NO_REFINEMENTS , callTarget );
166
164
}
167
165
168
166
@ Specialization (replaces = { "toProcCached" , "toProcCachedNoRefinements" })
169
- protected RubyProc toProcUncached (VirtualFrame frame , RubySymbol symbol ) {
170
- final Map <RubyModule , RubyModule []> refinements = getRefinements (frame );
167
+ protected RubyProc toProcUncached (
168
+ Frame callerFrame , RubySymbol symbol , Object [] rubyArgs , RootCallTarget target ) {
169
+ final Map <RubyModule , RubyModule []> refinements = getRefinements (callerFrame );
171
170
final RootCallTarget callTarget = getOrCreateCallTarget (getContext (), getLanguage (), symbol , refinements );
172
171
return createProc (getContext (), getLanguage (), refinements , callTarget );
173
172
}
@@ -246,12 +245,7 @@ public static RootCallTarget createCallTarget(RubyLanguage language, RubySymbol
246
245
return rootNode .getCallTarget ();
247
246
}
248
247
249
- protected InternalMethod getMethod (VirtualFrame frame ) {
250
- return RubyArguments .getMethod (frame );
251
- }
252
-
253
- protected Map <RubyModule , RubyModule []> getRefinements (VirtualFrame frame ) {
254
- final MaterializedFrame callerFrame = readCallerFrame .execute (frame );
248
+ protected Map <RubyModule , RubyModule []> getRefinements (Frame callerFrame ) {
255
249
final DeclarationContext declarationContext = RubyArguments .tryGetDeclarationContext (callerFrame );
256
250
return declarationContext != null
257
251
? declarationContext .getRefinements ()
0 commit comments