Skip to content

Commit

Permalink
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/hash/element_reference_tags.txt

This file was deleted.

16 changes: 11 additions & 5 deletions truffle/src/main/java/org/jruby/truffle/core/hash/HashNodes.java
Original file line number Diff line number Diff line change
@@ -263,8 +263,12 @@ protected int index(VirtualFrame frame, DynamicObject hash, Object key) {
return n;
}
} else {
if (hashed == PackedArrayStrategy.getHashed(store, n) && eql(frame, key, PackedArrayStrategy.getKey(store, n))) {
return n;
if (hashed == PackedArrayStrategy.getHashed(store, n)) {
final Object nKey = PackedArrayStrategy.getKey(store, n);
if(key == nKey || eql(frame, key, nKey)){

This comment has been minimized.

Copy link
@eregon

eregon Sep 21, 2016

Member

Java == won't work well on boxed primitives though.
A ReferenceEqualNode would be needed.
There is already SameOrEqualNode for the composition with ==, maybe we can have a SameOrEqlNode.

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Sep 21, 2016

Contributor

My comment is less useful. But the spacing here is different than the other 3 if statements in the diff.

This comment has been minimized.

Copy link
@bjfish

bjfish Sep 21, 2016

Contributor

@eregon Yes, it looks like Boxed Primitives need to be handled. For reference, here are the relevant comparisons:
https://github.com/ruby/ruby/blob/trunk/st.c#L89
https://github.com/ruby/ruby/blob/trunk/hash.c#L100

This comment has been minimized.

Copy link
@eregon

eregon Sep 22, 2016

Member

MRI doesn't need this special case because they mostly don't have boxed primitives (maybe just Float) but rather tagged pointers. The second code link is mostly just a fast path (although it also affects semantics).

This comment has been minimized.

Copy link
@eregon

eregon Nov 15, 2016

Member

Fixed in 6ef3980.

return n;
}

}
}
}
@@ -296,9 +300,11 @@ 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) &&
eql(frame, key, PackedArrayStrategy.getKey(store, n))) {
return PackedArrayStrategy.getValue(store, n);
if (hashed == PackedArrayStrategy.getHashed(store, n)) {
final Object nKey = PackedArrayStrategy.getKey(store, n);
if (key == nKey || eql(frame, key, nKey)) {
return PackedArrayStrategy.getValue(store, n);
}
}
}
}

0 comments on commit 457ca02

Please sign in to comment.