4444import static com .oracle .graal .python .util .PythonUtils .TS_ENCODING ;
4545
4646import 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 ;
4949import 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 ;
5151import com .oracle .graal .python .builtins .objects .str .PString ;
5252import com .oracle .graal .python .builtins .objects .str .StringNodes ;
5353import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
6262import com .oracle .graal .python .runtime .exception .PException ;
6363import com .oracle .truffle .api .HostCompilerDirectives .InliningCutoff ;
6464import com .oracle .truffle .api .dsl .Cached ;
65+ import com .oracle .truffle .api .dsl .Cached .Exclusive ;
6566import com .oracle .truffle .api .dsl .Cached .Shared ;
6667import com .oracle .truffle .api .dsl .Fallback ;
6768import com .oracle .truffle .api .dsl .GenerateCached ;
7273import com .oracle .truffle .api .frame .Frame ;
7374import com .oracle .truffle .api .frame .VirtualFrame ;
7475import com .oracle .truffle .api .nodes .Node ;
75- import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
7676import com .oracle .truffle .api .strings .TruffleString ;
7777
7878/**
@@ -106,16 +106,16 @@ static int doTuple(PTuple object) {
106106 return object .getSequenceStorage ().length ();
107107 }
108108
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 );
113113 }
114114
115115 @ Specialization (guards = "cannotBeOverridden(object, inliningTarget, getClassNode)" )
116- static int doSet (Node inliningTarget , PSet object ,
116+ static int doSet (Node inliningTarget , PBaseSet object ,
117117 @ Shared ("getClass" ) @ SuppressWarnings ("unused" ) @ Cached GetPythonObjectClassNode getClassNode ,
118- @ Shared ( "hashingStorageLen" ) @ Cached HashingStorageLen lenNode ) {
118+ @ Cached HashingStorageNodes . HashingStorageLen lenNode ) {
119119 return lenNode .execute (inliningTarget , object .getDictStorage ());
120120 }
121121
@@ -137,8 +137,7 @@ static int doPBytes(Node inliningTarget, PBytesLike object,
137137 static int doOthers (Frame frame , Node inliningTarget , Object object ,
138138 @ Cached GetObjectSlotsNode getTpSlotsNode ,
139139 @ Cached TpSlotLen .CallSlotLenNode callSlotLenNode ,
140- @ Cached InlinedBranchProfile hasNoSqLenBranch ,
141- @ Cached PRaiseNode .Lazy raiseNode ) {
140+ @ Exclusive @ Cached PRaiseNode .Lazy raiseNode ) {
142141 TpSlots slots = getTpSlotsNode .execute (inliningTarget , object );
143142 if (slots .sq_length () != null ) {
144143 return callSlotLenNode .execute ((VirtualFrame ) frame , inliningTarget , slots .sq_length (), object );
0 commit comments