23
23
import org .jruby .truffle .nodes .dispatch .CallDispatchHeadNode ;
24
24
import org .jruby .truffle .nodes .dispatch .DispatchHeadNodeFactory ;
25
25
import org .jruby .truffle .nodes .hash .FindEntryNode ;
26
+ import org .jruby .truffle .nodes .hash .HashNode ;
26
27
import org .jruby .truffle .nodes .yield .YieldDispatchHeadNode ;
27
28
import org .jruby .truffle .runtime .RubyArguments ;
28
29
import org .jruby .truffle .runtime .RubyContext ;
@@ -118,7 +119,7 @@ public static boolean isSmallArrayOfPairs(RubyClass hashClass, Object[] args) {
118
119
@ ImportStatic (HashGuards .class )
119
120
public abstract static class GetIndexNode extends CoreMethodArrayArgumentsNode {
120
121
121
- @ Child private CallDispatchHeadNode hashNode ;
122
+ @ Child private HashNode hashNode ;
122
123
@ Child private CallDispatchHeadNode eqlNode ;
123
124
@ Child private BasicObjectNodes .ReferenceEqualNode equalNode ;
124
125
@ Child private CallDispatchHeadNode callDefaultNode ;
@@ -132,7 +133,7 @@ public abstract static class GetIndexNode extends CoreMethodArrayArgumentsNode {
132
133
133
134
public GetIndexNode (RubyContext context , SourceSection sourceSection ) {
134
135
super (context , sourceSection );
135
- hashNode = DispatchHeadNodeFactory . createMethodCall (context , true );
136
+ hashNode = new HashNode (context , sourceSection );
136
137
eqlNode = DispatchHeadNodeFactory .createMethodCall (context , false , false , null );
137
138
equalNode = BasicObjectNodesFactory .ReferenceEqualNodeFactory .create (context , sourceSection , null , null );
138
139
callDefaultNode = DispatchHeadNodeFactory .createMethodCall (context );
@@ -143,7 +144,7 @@ public GetIndexNode(RubyContext context, SourceSection sourceSection) {
143
144
144
145
@ Specialization (guards = "isNullStorage(hash)" )
145
146
public Object getNull (VirtualFrame frame , RubyHash hash , Object key ) {
146
- hashNode .call (frame , key , "hash" , null );
147
+ hashNode .hash (frame , key );
147
148
148
149
if (undefinedValue != null ) {
149
150
return undefinedValue ;
@@ -155,7 +156,7 @@ public Object getNull(VirtualFrame frame, RubyHash hash, Object key) {
155
156
@ ExplodeLoop
156
157
@ Specialization (guards = "isPackedArrayStorage(hash)" )
157
158
public Object getPackedArray (VirtualFrame frame , RubyHash hash , Object key ) {
158
- hashNode .call (frame , key , "hash" , null );
159
+ hashNode .hash (frame , key );
159
160
160
161
final Object [] store = (Object []) hash .getStore ();
161
162
final int size = hash .getSize ();
@@ -233,7 +234,7 @@ public Object getOrUndefined(VirtualFrame frame, RubyHash hash, Object key) {
233
234
@ ImportStatic (HashGuards .class )
234
235
public abstract static class SetIndexNode extends CoreMethodArrayArgumentsNode {
235
236
236
- @ Child private CallDispatchHeadNode hashNode ;
237
+ @ Child private HashNode hashNode ;
237
238
@ Child private CallDispatchHeadNode eqlNode ;
238
239
@ Child private BasicObjectNodes .ReferenceEqualNode equalNode ;
239
240
@@ -243,15 +244,15 @@ public abstract static class SetIndexNode extends CoreMethodArrayArgumentsNode {
243
244
244
245
public SetIndexNode (RubyContext context , SourceSection sourceSection ) {
245
246
super (context , sourceSection );
246
- hashNode = DispatchHeadNodeFactory . createMethodCall (context , true );
247
+ hashNode = new HashNode (context , sourceSection );
247
248
eqlNode = DispatchHeadNodeFactory .createMethodCall (context , false , false , null );
248
249
equalNode = BasicObjectNodesFactory .ReferenceEqualNodeFactory .create (context , sourceSection , null , null );
249
250
}
250
251
251
252
@ Specialization (guards = { "isNullStorage(hash)" , "!isRubyString(key)" })
252
253
public Object setNull (VirtualFrame frame , RubyHash hash , Object key , Object value ) {
253
254
final Object [] store = new Object [PackedArrayStrategy .TRUFFLE_HASH_PACKED_ARRAY_MAX * 2 ];
254
- hashNode .call (frame , key , "hash" , null );
255
+ hashNode .hash (frame , key );
255
256
store [0 ] = key ;
256
257
store [1 ] = value ;
257
258
hash .setStore (store , 1 , null , null );
@@ -271,7 +272,7 @@ public Object setNull(VirtualFrame frame, RubyHash hash, RubyString key, Object
271
272
@ ExplodeLoop
272
273
@ Specialization (guards = {"isPackedArrayStorage(hash)" , "!isRubyString(key)" })
273
274
public Object setPackedArray (VirtualFrame frame , RubyHash hash , Object key , Object value ) {
274
- hashNode .call (frame , key , "hash" , null );
275
+ hashNode .hash (frame , key );
275
276
276
277
final Object [] store = (Object []) hash .getStore ();
277
278
final int size = hash .getSize ();
@@ -1211,7 +1212,7 @@ public static boolean isNullStorage(RubyHash hash) {
1211
1212
}
1212
1213
1213
1214
public static boolean isPackedArrayStorage (RubyHash hash ) {
1214
- // Can't do instanceof Object[] due to cavariance
1215
+ // Can't do instanceof Object[] due to covariance
1215
1216
return !(isNullStorage (hash ) || isBucketsStorage (hash ));
1216
1217
}
1217
1218
0 commit comments