41
41
import com .oracle .truffle .api .RootCallTarget ;
42
42
import com .oracle .truffle .api .Truffle ;
43
43
import com .oracle .truffle .api .dsl .Cached ;
44
- import com .oracle .truffle .api .dsl .ReportPolymorphism ;
45
44
import com .oracle .truffle .api .dsl .Specialization ;
46
45
import com .oracle .truffle .api .frame .FrameDescriptor ;
47
46
import com .oracle .truffle .api .frame .MaterializedFrame ;
@@ -96,12 +95,17 @@ protected boolean isPreInitializing() {
96
95
97
96
}
98
97
99
- @ ReportPolymorphism
100
98
@ CoreMethod (names = "to_proc" )
101
99
public abstract static class ToProcNode extends CoreMethodArrayArgumentsNode {
102
100
103
101
public static final Arity ARITY = new Arity (0 , 0 , true );
104
102
103
+ public static ToProcNode create () {
104
+ return SymbolNodesFactory .ToProcNodeFactory .create (null );
105
+ }
106
+
107
+ public abstract RubyProc execute (VirtualFrame frame , RubySymbol symbol );
108
+
105
109
@ Child private ReadCallerFrameNode readCallerFrame = ReadCallerFrameNode .create ();
106
110
107
111
@ Specialization (
@@ -110,27 +114,29 @@ public abstract static class ToProcNode extends CoreMethodArrayArgumentsNode {
110
114
protected RubyProc toProcCached (VirtualFrame frame , RubySymbol symbol ,
111
115
@ Cached ("symbol" ) RubySymbol cachedSymbol ,
112
116
@ Cached ("getRefinements(frame)" ) Map <RubyModule , RubyModule []> cachedRefinements ,
113
- @ Cached ("getOrCreateProc(cachedRefinements, symbol)" ) RubyProc cachedProc ) {
117
+ @ Cached ("getOrCreateProc(getContext(), cachedRefinements, symbol)" ) RubyProc cachedProc ) {
114
118
return cachedProc ;
115
119
}
116
120
117
- @ Specialization
121
+ @ Specialization ( replaces = "toProcCached" )
118
122
protected RubyProc toProcUncached (VirtualFrame frame , RubySymbol symbol ) {
119
123
final Map <RubyModule , RubyModule []> refinements = getRefinements (frame );
120
- return getOrCreateProc (refinements , symbol );
124
+ return getOrCreateProc (getContext (), refinements , symbol );
121
125
}
122
126
123
127
@ TruffleBoundary
124
- protected RubyProc getOrCreateProc (Map <RubyModule , RubyModule []> refinements , RubySymbol symbol ) {
128
+ public static RubyProc getOrCreateProc (RubyContext context ,
129
+ Map <RubyModule , RubyModule []> refinements ,
130
+ RubySymbol symbol ) {
125
131
// TODO (eregon, 23 Sep 2020): this should ideally cache on the refinements by comparing classes, and not by identity.
126
132
return ConcurrentOperations .getOrCompute (
127
133
symbol .getCachedProcs (),
128
134
refinements ,
129
- key -> createProc (getContext () , key , symbol ));
135
+ key -> createProc (context , key , symbol ));
130
136
}
131
137
132
138
@ TruffleBoundary
133
- protected static RubyProc createProc (RubyContext context , Map <RubyModule , RubyModule []> refinements ,
139
+ private static RubyProc createProc (RubyContext context , Map <RubyModule , RubyModule []> refinements ,
134
140
RubySymbol symbol ) {
135
141
final InternalMethod method = context .getCoreMethods ().SYMBOL_TO_PROC ;
136
142
final SourceSection sourceSection = CoreLibrary .UNAVAILABLE_SOURCE_SECTION ;
0 commit comments