44
44
import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING ;
45
45
46
46
import com .oracle .graal .python .builtins .objects .bytes .PBytesLike ;
47
- import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes . HashingStorageLen ;
48
- import com .oracle .graal .python .builtins .objects .dict . PDict ;
47
+ import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes ;
48
+ import com .oracle .graal .python .builtins .objects .common . PHashingCollection ;
49
49
import com .oracle .graal .python .builtins .objects .list .PList ;
50
- import com .oracle .graal .python .builtins .objects .set .PSet ;
50
+ import com .oracle .graal .python .builtins .objects .set .PBaseSet ;
51
51
import com .oracle .graal .python .builtins .objects .str .PString ;
52
52
import com .oracle .graal .python .builtins .objects .str .StringNodes ;
53
53
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
62
62
import com .oracle .graal .python .runtime .exception .PException ;
63
63
import com .oracle .truffle .api .HostCompilerDirectives .InliningCutoff ;
64
64
import com .oracle .truffle .api .dsl .Cached ;
65
+ import com .oracle .truffle .api .dsl .Cached .Exclusive ;
65
66
import com .oracle .truffle .api .dsl .Cached .Shared ;
66
67
import com .oracle .truffle .api .dsl .Fallback ;
67
68
import com .oracle .truffle .api .dsl .GenerateCached ;
72
73
import com .oracle .truffle .api .frame .Frame ;
73
74
import com .oracle .truffle .api .frame .VirtualFrame ;
74
75
import com .oracle .truffle .api .nodes .Node ;
75
- import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
76
76
import com .oracle .truffle .api .strings .TruffleString ;
77
77
78
78
/**
@@ -106,16 +106,16 @@ static int doTuple(PTuple object) {
106
106
return object .getSequenceStorage ().length ();
107
107
}
108
108
109
- @ Specialization (guards = "cannotBeOverriddenForImmutableType (object)" )
110
- static int doDict (Node inliningTarget , PDict object ,
111
- @ Shared ( "hashingStorageLen" ) @ Cached HashingStorageLen lenNode ) {
112
- return lenNode . execute (inliningTarget , object . getDictStorage () );
109
+ @ Specialization (guards = "!isAnySet (object)" )
110
+ static int doPHashingCollection (Node inliningTarget , PHashingCollection object ,
111
+ @ Exclusive @ Cached PRaiseNode . Lazy raise ) {
112
+ throw raise . get (inliningTarget ). raise ( TypeError , ErrorMessages . IS_NOT_A_SEQUENCE , object );
113
113
}
114
114
115
115
@ Specialization (guards = "cannotBeOverridden(object, inliningTarget, getClassNode)" )
116
- static int doSet (Node inliningTarget , PSet object ,
116
+ static int doSet (Node inliningTarget , PBaseSet object ,
117
117
@ Shared ("getClass" ) @ SuppressWarnings ("unused" ) @ Cached GetPythonObjectClassNode getClassNode ,
118
- @ Shared ( "hashingStorageLen" ) @ Cached HashingStorageLen lenNode ) {
118
+ @ Cached HashingStorageNodes . HashingStorageLen lenNode ) {
119
119
return lenNode .execute (inliningTarget , object .getDictStorage ());
120
120
}
121
121
@@ -137,8 +137,7 @@ static int doPBytes(Node inliningTarget, PBytesLike object,
137
137
static int doOthers (Frame frame , Node inliningTarget , Object object ,
138
138
@ Cached GetObjectSlotsNode getTpSlotsNode ,
139
139
@ Cached TpSlotLen .CallSlotLenNode callSlotLenNode ,
140
- @ Cached InlinedBranchProfile hasNoSqLenBranch ,
141
- @ Cached PRaiseNode .Lazy raiseNode ) {
140
+ @ Exclusive @ Cached PRaiseNode .Lazy raiseNode ) {
142
141
TpSlots slots = getTpSlotsNode .execute (inliningTarget , object );
143
142
if (slots .sq_length () != null ) {
144
143
return callSlotLenNode .execute ((VirtualFrame ) frame , inliningTarget , slots .sq_length (), object );
0 commit comments