@@ -452,6 +452,30 @@ public abstract static class VMHashStart extends PrimitiveArrayArgumentsNode {
452
452
public long startHash (long salt ) {
453
453
return getContext ().getHashing (this ).start (salt );
454
454
}
455
+
456
+ @ Specialization (guards = "isRubyBignum(salt)" )
457
+ public long startHashBigNum (DynamicObject salt ) {
458
+ return getContext ().getHashing (this ).start (Layouts .BIGNUM .getValue (salt ).hashCode ());
459
+ }
460
+
461
+ @ Specialization (guards = "!isRubyNumber(salt)" )
462
+ public Object startHashNotNumber (Object salt ,
463
+ @ Cached ("createPrivate()" ) CallDispatchHeadNode coerceToIntNode ,
464
+ @ Cached ("createBinaryProfile()" ) ConditionProfile isIntegerProfile ,
465
+ @ Cached ("createBinaryProfile()" ) ConditionProfile isLongProfile ,
466
+ @ Cached ("createBinaryProfile()" ) ConditionProfile isBignumProfile ) {
467
+ Object result = coerceToIntNode .call (coreLibrary ().getTruffleTypeModule (), "coerce_to_int" , salt );
468
+ if (isIntegerProfile .profile (result instanceof Integer )) {
469
+ return getContext ().getHashing (this ).start ((int ) result );
470
+ } else if (isLongProfile .profile (result instanceof Long )) {
471
+ return getContext ().getHashing (this ).start ((long ) result );
472
+ } else if (isBignumProfile .profile (Layouts .BIGNUM .isBignum (result ))) {
473
+ return getContext ().getHashing (this ).start (Layouts .BIGNUM .getValue ((DynamicObject ) result ).hashCode ());
474
+ } else {
475
+ throw new UnsupportedOperationException ();
476
+ }
477
+
478
+ }
455
479
}
456
480
457
481
@ Primitive (name = "vm_hash_update" , needsSelf = false )
0 commit comments