-
-
Notifications
You must be signed in to change notification settings - Fork 921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Truffle] New implementation of non-small hashes #2328
Changes from 7 commits
9810a50
0eee052
3e82545
579881f
4b6b34a
3c5c26d
18593e6
35c1350
96c8da6
b2a89e6
639ecf6
2bb0e15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,7 @@ | |
package org.jruby.truffle.nodes.core; | ||
|
||
import org.jruby.truffle.runtime.core.RubyHash; | ||
|
||
import java.util.LinkedHashMap; | ||
import org.jruby.truffle.runtime.hash.Bucket; | ||
|
||
public class HashGuards { | ||
|
||
|
@@ -20,23 +19,12 @@ public static boolean isNull(RubyHash hash) { | |
} | ||
|
||
public static boolean isObjectArray(RubyHash hash) { | ||
return hash.getStore() instanceof Object[]; | ||
} | ||
|
||
public static boolean isObjectLinkedHashMap(RubyHash hash) { | ||
return hash.getStore() instanceof LinkedHashMap<?, ?>; | ||
} | ||
|
||
public static boolean isOtherNull(RubyHash hash, RubyHash other) { | ||
return other.getStore() == null; | ||
} | ||
|
||
public static boolean isOtherObjectArray(RubyHash hash, RubyHash other) { | ||
return other.getStore() instanceof Object[]; | ||
// Arrays are covariant in Java! | ||
return hash.getStore() instanceof Object[] && !(hash.getStore() instanceof Bucket[]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this means there is no good way to check that the ObjectArray strategy is actually only using |
||
} | ||
|
||
public static boolean isOtherObjectLinkedHashMap(RubyHash hash, RubyHash other) { | ||
return other.getStore() instanceof LinkedHashMap<?, ?>; | ||
public static boolean isBucketArray(RubyHash hash) { | ||
return hash.getStore() instanceof Bucket[]; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MRI uses a temporary Hash to avoid O(n2) here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe we could have an overload of
notDesignedForCompilation()
mapping toCompilerAsserts.neverPartOfCompilation(String message)
so to keep track of what is not compilation ready when not obvious.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea - we can go through and add a reason for all the
notDesigned
s when we do a spring clean after 0.6 is released.