|
@@ -253,9 +253,8 @@ protected boolean equal(VirtualFrame frame, Object key1, Object key2) { |
|
|
} |
|
|
|
|
|
@ExplodeLoop |
|
|
@Specialization(guards = "isPackedHash(hash)", contains = "getConstantIndexPackedArray") |
|
|
@Specialization(guards = { "isPackedHash(hash)", "!isCompareByIdentity(hash)" }, contains = "getConstantIndexPackedArray") |
|
|
public Object getPackedArray(VirtualFrame frame, DynamicObject hash, Object key, |
|
|
@Cached("createBinaryProfile()") ConditionProfile byIdentityProfile, |
|
|
@Cached("create()") BranchProfile notInHashProfile, |
|
|
@Cached("create()") BranchProfile useDefaultProfile) { |
|
|
final int hashed = hashNode.hash(frame, key); |
|
@@ -265,24 +264,43 @@ public Object getPackedArray(VirtualFrame frame, DynamicObject hash, Object key, |
|
|
|
|
|
for (int n = 0; n < getContext().getOptions().HASH_PACKED_ARRAY_MAX; n++) { |
|
|
if (n < size) { |
|
|
if (hashed == PackedArrayStrategy.getHashed(store, n)) { |
|
|
final boolean equal; |
|
|
if (hashed == PackedArrayStrategy.getHashed(store, n) && |
|
|
eql(frame, key, PackedArrayStrategy.getKey(store, n))) { |
|
|
return PackedArrayStrategy.getValue(store, n); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (byIdentityProfile.profile(Layouts.HASH.getCompareByIdentity(hash))) { |
|
|
equal = equal(frame, key, PackedArrayStrategy.getKey(store, n)); |
|
|
} else { |
|
|
equal = eql(frame, key, PackedArrayStrategy.getKey(store, n)); |
|
|
} |
|
|
notInHashProfile.enter(); |
|
|
|
|
|
if (equal) { |
|
|
return PackedArrayStrategy.getValue(store, n); |
|
|
} |
|
|
if (undefinedValue != null) { |
|
|
return undefinedValue; |
|
|
} |
|
|
|
|
|
useDefaultProfile.enter(); |
|
|
return callDefaultNode.call(frame, hash, "default", null, key); |
|
|
|
|
|
} |
|
|
|
|
|
@ExplodeLoop |
|
|
@Specialization(guards = { "isPackedHash(hash)", "isCompareByIdentity(hash)" }, |
|
|
contains = "getConstantIndexPackedArray") |
|
|
public Object getPackedArrayByIdentity(VirtualFrame frame, DynamicObject hash, Object key, |
|
|
@Cached("create()") BranchProfile notInHashProfile, |
|
|
@Cached("create()") BranchProfile useDefaultProfile) { |
|
|
final Object[] store = (Object[]) Layouts.HASH.getStore(hash); |
|
|
final int size = Layouts.HASH.getSize(hash); |
|
|
|
|
|
for (int n = 0; n < getContext().getOptions().HASH_PACKED_ARRAY_MAX; n++) { |
|
|
if (n < size) { |
|
|
if (equal(frame, key, PackedArrayStrategy.getKey(store, n))) { |
|
|
return PackedArrayStrategy.getValue(store, n); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
notInHashProfile.enter(); |
|
|
|
|
|
|
|
|
if (undefinedValue != null) { |
|
|
return undefinedValue; |
|
|
} |
|
|