55
55
import org .truffleruby .core .kernel .KernelNodesFactory ;
56
56
import org .truffleruby .core .proc .ProcOperations ;
57
57
import org .truffleruby .core .rope .CodeRange ;
58
- import org .truffleruby .core .string .StringNodes ;
58
+ import org .truffleruby .core .string .StringNodes . MakeStringNode ;
59
59
import org .truffleruby .core .string .StringOperations ;
60
60
import org .truffleruby .language .backtrace .Backtrace ;
61
61
import org .truffleruby .language .control .ExitException ;
@@ -84,13 +84,12 @@ public abstract class VMPrimitiveNodes {
84
84
@ Primitive (name = "vm_catch" , needsSelf = false )
85
85
public abstract static class CatchNode extends PrimitiveArrayArgumentsNode {
86
86
87
- @ Child private YieldNode dispatchNode = YieldNode .create ();
88
-
89
87
@ Specialization
90
- protected Object doCatch (VirtualFrame frame , Object tag , DynamicObject block ,
88
+ protected Object doCatch (Object tag , DynamicObject block ,
91
89
@ Cached BranchProfile catchProfile ,
92
90
@ Cached ("createBinaryProfile()" ) ConditionProfile matchProfile ,
93
- @ Cached ReferenceEqualNode referenceEqualNode ) {
91
+ @ Cached ReferenceEqualNode referenceEqualNode ,
92
+ @ Cached YieldNode dispatchNode ) {
94
93
try {
95
94
return dispatchNode .executeDispatch (block , tag );
96
95
} catch (ThrowException e ) {
@@ -106,7 +105,7 @@ protected Object doCatch(VirtualFrame frame, Object tag, DynamicObject block,
106
105
107
106
// The hard #exit!
108
107
@ Primitive (name = "vm_exit" , needsSelf = false , lowerFixnum = 1 )
109
- public static abstract class VMExitPrimitiveNode extends PrimitiveArrayArgumentsNode {
108
+ public static abstract class VMExitNode extends PrimitiveArrayArgumentsNode {
110
109
111
110
@ Specialization
112
111
protected Object vmExit (int status ) {
@@ -149,16 +148,10 @@ protected boolean vmMethodIsBasic(VirtualFrame frame, DynamicObject method) {
149
148
@ Primitive (name = "vm_method_lookup" , needsSelf = false )
150
149
public static abstract class VMMethodLookupNode extends PrimitiveArrayArgumentsNode {
151
150
152
- @ Child private NameToJavaStringNode nameToJavaStringNode ;
153
- @ Child private LookupMethodNode lookupMethodNode ;
154
-
155
- public VMMethodLookupNode () {
156
- nameToJavaStringNode = NameToJavaStringNode .create ();
157
- lookupMethodNode = LookupMethodNode .create ();
158
- }
159
-
160
151
@ Specialization
161
- protected DynamicObject vmMethodLookup (VirtualFrame frame , Object receiver , Object name ) {
152
+ protected DynamicObject vmMethodLookup (VirtualFrame frame , Object receiver , Object name ,
153
+ @ Cached NameToJavaStringNode nameToJavaStringNode ,
154
+ @ Cached LookupMethodNode lookupMethodNode ) {
162
155
// TODO BJF Sep 14, 2016 Handle private
163
156
final String normalizedName = nameToJavaStringNode .executeToJavaString (name );
164
157
InternalMethod method = lookupMethodNode .lookupIgnoringVisibility (frame , receiver , normalizedName );
@@ -171,7 +164,7 @@ protected DynamicObject vmMethodLookup(VirtualFrame frame, Object receiver, Obje
171
164
}
172
165
173
166
@ Primitive (name = "vm_object_respond_to" , needsSelf = false )
174
- public static abstract class VMObjectRespondToPrimitiveNode extends PrimitiveArrayArgumentsNode {
167
+ public static abstract class VMObjectRespondToNode extends PrimitiveArrayArgumentsNode {
175
168
176
169
@ Child private KernelNodes .RespondToNode respondToNode = KernelNodesFactory .RespondToNodeFactory
177
170
.create (null , null , null );
@@ -185,7 +178,7 @@ protected boolean vmObjectRespondTo(VirtualFrame frame, Object object, Object na
185
178
186
179
187
180
@ Primitive (name = "vm_object_singleton_class" , needsSelf = false )
188
- public static abstract class VMObjectSingletonClassPrimitiveNode extends PrimitiveArrayArgumentsNode {
181
+ public static abstract class VMObjectSingletonClassNode extends PrimitiveArrayArgumentsNode {
189
182
190
183
@ Child private KernelNodes .SingletonClassMethodNode singletonClassNode = KernelNodesFactory .SingletonClassMethodNodeFactory
191
184
.create (null );
@@ -228,7 +221,7 @@ public static void reRaiseException(RubyContext context, DynamicObject exception
228
221
}
229
222
230
223
@ Primitive (name = "vm_set_module_name" , needsSelf = false )
231
- public static abstract class VMSetModuleNamePrimitiveNode extends PrimitiveArrayArgumentsNode {
224
+ public static abstract class VMSetModuleNameNode extends PrimitiveArrayArgumentsNode {
232
225
233
226
@ Specialization
234
227
protected Object vmSetModuleName (Object object ) {
@@ -248,7 +241,7 @@ protected Object doThrow(Object tag, Object value) {
248
241
}
249
242
250
243
@ Primitive (name = "vm_watch_signal" , needsSelf = false )
251
- public static abstract class VMWatchSignalPrimitiveNode extends PrimitiveArrayArgumentsNode {
244
+ public static abstract class VMWatchSignalNode extends PrimitiveArrayArgumentsNode {
252
245
253
246
@ TruffleBoundary
254
247
@ Specialization (guards = { "isRubyString(signalName)" , "isRubyString(action)" })
@@ -386,7 +379,7 @@ private boolean registerHandler(String signalName, Runnable newHandler) {
386
379
}
387
380
388
381
@ Primitive (name = "vm_get_config_item" , needsSelf = false )
389
- public abstract static class VMGetConfigItemPrimitiveNode extends PrimitiveArrayArgumentsNode {
382
+ public abstract static class VMGetConfigItemNode extends PrimitiveArrayArgumentsNode {
390
383
391
384
@ TruffleBoundary
392
385
@ Specialization (guards = "isRubyString(key)" )
@@ -403,14 +396,13 @@ protected Object get(DynamicObject key) {
403
396
}
404
397
405
398
@ Primitive (name = "vm_get_config_section" , needsSelf = false )
406
- public abstract static class VMGetConfigSectionPrimitiveNode extends PrimitiveArrayArgumentsNode {
407
-
408
- @ Child private StringNodes .MakeStringNode makeStringNode = StringNodes .MakeStringNode .create ();
409
- @ Child private YieldNode yieldNode = YieldNode .create ();
399
+ public abstract static class VMGetConfigSectionNode extends PrimitiveArrayArgumentsNode {
410
400
411
401
@ TruffleBoundary
412
402
@ Specialization (guards = { "isRubyString(section)" , "isRubyProc(block)" })
413
- protected DynamicObject getSection (DynamicObject section , DynamicObject block ) {
403
+ protected DynamicObject getSection (DynamicObject section , DynamicObject block ,
404
+ @ Cached MakeStringNode makeStringNode ,
405
+ @ Cached YieldNode yieldNode ) {
414
406
for (Entry <String , Object > entry : getContext ()
415
407
.getNativeConfiguration ()
416
408
.getSection (StringOperations .getString (section ))) {
@@ -425,7 +417,7 @@ protected DynamicObject getSection(DynamicObject section, DynamicObject block) {
425
417
}
426
418
427
419
@ Primitive (name = "vm_set_class" , needsSelf = false )
428
- public abstract static class VMSetClassPrimitiveNode extends PrimitiveArrayArgumentsNode {
420
+ public abstract static class VMSetClassNode extends PrimitiveArrayArgumentsNode {
429
421
430
422
@ Specialization (guards = "isRubyClass(newClass)" )
431
423
protected DynamicObject setClass (DynamicObject object , DynamicObject newClass ) {
@@ -444,7 +436,7 @@ public abstract static class VMDevUrandomBytes extends PrimitiveArrayArgumentsNo
444
436
445
437
@ Specialization (guards = "count >= 0" )
446
438
protected DynamicObject readRandomBytes (int count ,
447
- @ Cached StringNodes . MakeStringNode makeStringNode ) {
439
+ @ Cached MakeStringNode makeStringNode ) {
448
440
final byte [] bytes = getContext ().getRandomSeedBytes (count );
449
441
450
442
return makeStringNode .executeMake (bytes , ASCIIEncoding .INSTANCE , CodeRange .CR_UNKNOWN );
@@ -462,7 +454,7 @@ protected DynamicObject negativeCount(int count) {
462
454
}
463
455
464
456
@ Primitive (name = "vm_hash_start" , needsSelf = false )
465
- public abstract static class VMHashStart extends PrimitiveArrayArgumentsNode {
457
+ public abstract static class VMHashStartNode extends PrimitiveArrayArgumentsNode {
466
458
467
459
@ Specialization
468
460
protected long startHash (long salt ) {
@@ -495,7 +487,7 @@ protected Object startHashNotNumber(Object salt,
495
487
}
496
488
497
489
@ Primitive (name = "vm_hash_update" , needsSelf = false )
498
- public abstract static class VMHashUpdate extends PrimitiveArrayArgumentsNode {
490
+ public abstract static class VMHashUpdateNode extends PrimitiveArrayArgumentsNode {
499
491
500
492
@ Specialization
501
493
protected long updateHash (long hash , long value ) {
@@ -507,7 +499,6 @@ protected long updateHash(long hash, DynamicObject value) {
507
499
return Hashing .update (hash , Layouts .BIGNUM .getValue (value ).hashCode ());
508
500
}
509
501
510
-
511
502
@ Specialization (guards = "!isRubyNumber(value)" )
512
503
protected Object updateHash (long hash , Object value ,
513
504
@ Cached ("createPrivate()" ) CallDispatchHeadNode coerceToIntNode ,
@@ -529,11 +520,13 @@ protected Object updateHash(long hash, Object value,
529
520
}
530
521
531
522
@ Primitive (name = "vm_hash_end" , needsSelf = false )
532
- public abstract static class VMHashEnd extends PrimitiveArrayArgumentsNode {
523
+ public abstract static class VMHashEndNode extends PrimitiveArrayArgumentsNode {
533
524
534
525
@ Specialization
535
526
protected long endHash (long hash ) {
536
527
return Hashing .end (hash );
537
528
}
529
+
538
530
}
531
+
539
532
}
0 commit comments