46
46
import com .oracle .graal .python .builtins .CoreFunctions ;
47
47
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
48
48
import com .oracle .graal .python .builtins .PythonBuiltins ;
49
- import com .oracle .graal .python .builtins .modules .BuiltinFunctions ;
50
49
import com .oracle .graal .python .builtins .objects .PNone ;
51
50
import com .oracle .graal .python .builtins .objects .PNotImplemented ;
52
51
import com .oracle .graal .python .builtins .objects .common .EconomicMapStorage ;
56
55
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .PythonEquivalence ;
57
56
import com .oracle .graal .python .builtins .objects .common .PHashingCollection ;
58
57
import com .oracle .graal .python .builtins .objects .dict .PDictView ;
58
+ import com .oracle .graal .python .builtins .objects .function .PArguments ;
59
+ import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
59
60
import com .oracle .graal .python .builtins .objects .set .FrozenSetBuiltinsFactory .BinaryUnionNodeGen ;
60
61
import com .oracle .graal .python .builtins .objects .str .PString ;
61
62
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
62
63
import com .oracle .graal .python .nodes .IndirectCallNode ;
63
64
import com .oracle .graal .python .nodes .PNodeWithContext ;
64
65
import com .oracle .graal .python .nodes .call .special .LookupAndCallBinaryNode ;
65
- import com .oracle .graal .python .nodes .call .special .LookupAndCallUnaryNode ;
66
66
import com .oracle .graal .python .nodes .control .GetIteratorExpressionNode .GetIteratorNode ;
67
67
import com .oracle .graal .python .nodes .control .GetNextNode ;
68
68
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
71
71
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
72
72
import com .oracle .graal .python .nodes .object .GetLazyClassNode ;
73
73
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
74
- import com .oracle .graal .python .nodes .util .CoerceToJavaLongNode ;
75
74
import com .oracle .graal .python .runtime .ExecutionContext .IndirectCallContext ;
76
75
import com .oracle .graal .python .runtime .PythonContext ;
77
76
import com .oracle .graal .python .runtime .exception .PException ;
87
86
import com .oracle .truffle .api .dsl .NodeFactory ;
88
87
import com .oracle .truffle .api .dsl .Specialization ;
89
88
import com .oracle .truffle .api .frame .VirtualFrame ;
89
+ import com .oracle .truffle .api .library .CachedLibrary ;
90
90
import com .oracle .truffle .api .nodes .Node ;
91
91
import com .oracle .truffle .api .profiles .ConditionProfile ;
92
92
import com .oracle .truffle .api .profiles .ValueProfile ;
@@ -624,9 +624,7 @@ public long getHash(@SuppressWarnings("unused") VirtualFrame frame, PFrozenSet s
624
624
public long computeHash (VirtualFrame frame , PFrozenSet self ,
625
625
@ Cached HashingStorageNodes .LenNode getLen ,
626
626
@ Cached HashingStorageNodes .GetItemNode getItemNode ,
627
- @ Cached ("create(__HASH__)" ) LookupAndCallUnaryNode lookupHashAttributeNode ,
628
- @ Cached BuiltinFunctions .IsInstanceNode isInstanceNode ,
629
- @ Cached ("createLossy()" ) CoerceToJavaLongNode castToLongNode ) {
627
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary lib ) {
630
628
// adapted from https://github.com/python/cpython/blob/master/Objects/setobject.c#L758
631
629
HashingStorage storage = self .getDictStorage ();
632
630
int len = getLen .execute (storage );
@@ -635,15 +633,10 @@ public long computeHash(VirtualFrame frame, PFrozenSet self,
635
633
long c1 = 0x3611c3e3 ;
636
634
long c2 = 0x2338c7c1 ;
637
635
long hash = 0 ;
638
- long tmp ;
639
636
640
637
for (Object key : storage .keys ()) {
641
638
Object value = getItemNode .execute (frame , storage , key );
642
- Object hashValue = lookupHashAttributeNode .executeObject (frame , value );
643
- if (!isInstanceNode .executeWith (frame , hashValue , getBuiltinPythonClass (PythonBuiltinClassType .PInt ))) {
644
- throw raise (PythonErrorType .TypeError , "__hash__ method should return an integer" );
645
- }
646
- tmp = castToLongNode .execute (hashValue );
639
+ long tmp = lib .hashWithState (value , PArguments .getThreadState (frame ));
647
640
hash ^= shuffleBits (tmp );
648
641
}
649
642
0 commit comments