File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 172
172
import com .oracle .truffle .api .profiles .BranchProfile ;
173
173
import com .oracle .truffle .api .profiles .ConditionProfile ;
174
174
import com .oracle .truffle .api .profiles .ValueProfile ;
175
+ import com .oracle .truffle .api .utilities .TriState ;
175
176
import com .oracle .truffle .llvm .spi .NativeTypeLibrary ;
176
177
import com .oracle .truffle .llvm .spi .ReferenceLibrary ;
177
178
@@ -1703,6 +1704,31 @@ protected static boolean isObType(String key) {
1703
1704
}
1704
1705
}
1705
1706
1707
+ @ ExportMessage
1708
+ @ TruffleBoundary
1709
+ int identityHashCode () {
1710
+ int val = Byte .hashCode (state ) ^ Long .hashCode (value );
1711
+ if (Double .isNaN (dvalue )) {
1712
+ return val ;
1713
+ } else {
1714
+ return val ^ Double .hashCode (dvalue );
1715
+ }
1716
+ }
1717
+
1718
+ @ ExportMessage
1719
+ TriState isIdenticalOrUndefined (Object obj ) {
1720
+ if (obj instanceof PrimitiveNativeWrapper ) {
1721
+ // This basically emulates singletons for boxed values. However, we need to do so to
1722
+ // preserve the invariant that storing an object into a list and getting it out (in
1723
+ // the same critical region) returns the same object.
1724
+ PrimitiveNativeWrapper other = (PrimitiveNativeWrapper ) obj ;
1725
+ return TriState .valueOf (other .state == state && other .value == value &&
1726
+ (other .dvalue == dvalue || Double .isNaN (dvalue ) && Double .isNaN (other .dvalue )));
1727
+ } else {
1728
+ return TriState .UNDEFINED ;
1729
+ }
1730
+ }
1731
+
1706
1732
@ ExportMessage
1707
1733
static class IsSame {
1708
1734
You can’t perform that action at this time.
0 commit comments