18
18
import com .oracle .truffle .api .profiles .BranchProfile ;
19
19
import com .oracle .truffle .api .profiles .ConditionProfile ;
20
20
import org .truffleruby .core .array .ArrayUtils ;
21
- import org .truffleruby .core .cast .NameToJavaStringNode ;
22
21
import org .truffleruby .core .cast .ToSymbolNode ;
23
22
import org .truffleruby .core .exception .ExceptionOperations ;
24
23
import org .truffleruby .core .klass .RubyClass ;
@@ -77,7 +76,6 @@ public static DispatchNode getUncached() {
77
76
@ Child protected MetaClassNode metaclassNode ;
78
77
@ Child protected LookupMethodNode methodLookup ;
79
78
@ Child protected CallInternalMethodNode callNode ;
80
- @ Child protected NameToJavaStringNode nameToString ;
81
79
@ Child protected CallForeignMethodNode callForeign ;
82
80
@ Child protected DispatchNode callMethodMissing ;
83
81
@ Child protected ToSymbolNode toSymbol ;
@@ -126,29 +124,25 @@ public Object callWithBlock(Object receiver, String method, RubyProc block, Obje
126
124
return execute (null , receiver , method , block , arguments );
127
125
}
128
126
129
- public Object dispatch (VirtualFrame frame , Object receiver , Object methodName , RubyProc block , Object [] arguments ) {
127
+ public Object dispatch (VirtualFrame frame , Object receiver , String methodName , RubyProc block , Object [] arguments ) {
130
128
return execute (frame , receiver , methodName , block , arguments );
131
129
}
132
130
133
- public boolean doesRespondTo (VirtualFrame frame , Object methodName , Object receiver ) {
131
+ public boolean doesRespondTo (VirtualFrame frame , String methodName , Object receiver ) {
134
132
assert config == PRIVATE_DOES_RESPOND || config == PUBLIC_DOES_RESPOND ;
135
133
return (boolean ) execute (frame , receiver , methodName , null , EMPTY_ARGUMENTS );
136
134
}
137
135
138
- public Object execute (VirtualFrame frame , Object receiver , Object methodName , RubyProc block , Object [] arguments ) {
139
-
140
- final String stringName = nameIsString .profile (methodName instanceof String )
141
- ? (String ) methodName
142
- : nameToString (methodName );
136
+ public Object execute (VirtualFrame frame , Object receiver , String methodName , RubyProc block , Object [] arguments ) {
143
137
144
138
final RubyClass metaclass = metaclassNode .execute (receiver );
145
139
146
140
if (isForeignCall .profile (metaclass == getContext ().getCoreLibrary ().truffleInteropForeignClass )) {
147
141
assert config .dispatchAction == DispatchAction .CALL_METHOD ;
148
- return callForeign (receiver , stringName , block , arguments );
142
+ return callForeign (receiver , methodName , block , arguments );
149
143
}
150
144
151
- final InternalMethod method = methodLookup .execute (frame , metaclass , stringName , config );
145
+ final InternalMethod method = methodLookup .execute (frame , metaclass , methodName , config );
152
146
153
147
if (methodMissing .profile (method == null || method .isUndefined ())) {
154
148
switch (config .dispatchAction ) {
@@ -159,7 +153,7 @@ public Object execute(VirtualFrame frame, Object receiver, Object methodName, Ru
159
153
case RETURN_MISSING :
160
154
return MISSING ;
161
155
case CALL_METHOD_MISSING :
162
- return callMethodMissing (frame , receiver , methodName , stringName , block , arguments );
156
+ return callMethodMissing (frame , receiver , methodName , block , arguments );
163
157
}
164
158
}
165
159
}
@@ -176,7 +170,7 @@ public Object execute(VirtualFrame frame, Object receiver, Object methodName, Ru
176
170
}
177
171
178
172
private Object callMethodMissing (
179
- VirtualFrame frame , Object receiver , Object methodName , String stringName , RubyProc block ,
173
+ VirtualFrame frame , Object receiver , String methodName , RubyProc block ,
180
174
Object [] arguments ) {
181
175
182
176
final RubySymbol symbolName = nameToSymbol (methodName );
@@ -190,22 +184,14 @@ private Object callMethodMissing(
190
184
throw new RaiseException (getContext (), coreExceptions ().noMethodErrorFromMethodMissing (
191
185
formatter ,
192
186
receiver ,
193
- stringName ,
187
+ methodName ,
194
188
arguments ,
195
189
this ));
196
190
}
197
191
198
192
return result ;
199
193
}
200
194
201
- protected String nameToString (Object methodName ) {
202
- if (nameToString == null ) {
203
- CompilerDirectives .transferToInterpreterAndInvalidate ();
204
- nameToString = insert (NameToJavaStringNode .create ());
205
- }
206
- return nameToString .execute (methodName );
207
- }
208
-
209
195
protected Object callForeign (Object receiver , String methodName , RubyProc block , Object [] arguments ) {
210
196
if (callForeign == null ) {
211
197
CompilerDirectives .transferToInterpreterAndInvalidate ();
@@ -226,7 +212,7 @@ protected Object callMethodMissingNode(
226
212
return callMethodMissing .execute (null , receiver , "method_missing" , block , arguments );
227
213
}
228
214
229
- protected RubySymbol nameToSymbol (Object methodName ) {
215
+ protected RubySymbol nameToSymbol (String methodName ) {
230
216
if (toSymbol == null ) {
231
217
CompilerDirectives .transferToInterpreterAndInvalidate ();
232
218
toSymbol = insert (ToSymbolNode .create ());
@@ -280,21 +266,11 @@ protected Uncached(DispatchConfiguration config) {
280
266
}
281
267
282
268
@ Override
283
- public Object execute (VirtualFrame frame , Object receiver , Object methodName , RubyProc block ,
269
+ public Object execute (VirtualFrame frame , Object receiver , String methodName , RubyProc block ,
284
270
Object [] arguments ) {
285
271
return super .execute (null , receiver , methodName , block , arguments );
286
272
}
287
273
288
- @ Override
289
- protected String nameToString (Object methodName ) {
290
- if (nameToString == null ) {
291
- CompilerDirectives .transferToInterpreterAndInvalidate ();
292
- nameToString = insert (NameToJavaStringNode .getUncached ());
293
- }
294
-
295
- return nameToString .execute (methodName );
296
- }
297
-
298
274
@ Override
299
275
protected Object callForeign (Object receiver , String methodName , RubyProc block , Object [] arguments ) {
300
276
if (callForeign == null ) {
@@ -319,7 +295,7 @@ protected Object callMethodMissingNode(
319
295
}
320
296
321
297
@ Override
322
- protected RubySymbol nameToSymbol (Object methodName ) {
298
+ protected RubySymbol nameToSymbol (String methodName ) {
323
299
if (toSymbol == null ) {
324
300
CompilerDirectives .transferToInterpreterAndInvalidate ();
325
301
toSymbol = insert (ToSymbolNode .getUncached ());
0 commit comments