4343import static com .oracle .graal .python .runtime .exception .PythonErrorType .TypeError ;
4444
4545import com .oracle .graal .python .builtins .objects .PNone ;
46- import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .GetDictStorageNodeGen ;
4746import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .LenNodeGen ;
48- import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .SetDictStorageNodeGen ;
4947import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .SetItemNodeGen ;
50- import com .oracle .graal .python .builtins .objects .dict .PDict ;
5148import com .oracle .graal .python .builtins .objects .dict .PDictView ;
5249import com .oracle .graal .python .builtins .objects .function .PArguments ;
5350import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
54- import com .oracle .graal .python .builtins .objects .set .PBaseSet ;
5551import com .oracle .graal .python .builtins .objects .str .PString ;
5652import com .oracle .graal .python .nodes .ErrorMessages ;
5753import com .oracle .graal .python .nodes .PGuards ;
@@ -81,9 +77,8 @@ public abstract static class LenNode extends PNodeWithContext {
8177
8278 @ Specialization (limit = "4" )
8379 static int getLen (PHashingCollection c ,
84- @ Cached GetDictStorageNode getStorage ,
85- @ CachedLibrary ("getStorage.execute(c)" ) HashingStorageLibrary lib ) {
86- return lib .length (getStorage .execute (c ));
80+ @ CachedLibrary ("c.getDictStorage()" ) HashingStorageLibrary lib ) {
81+ return lib .length (c .getDictStorage ());
8782 }
8883
8984 public static LenNode create () {
@@ -98,69 +93,17 @@ public abstract static class SetItemNode extends PNodeWithContext {
9893 @ Specialization (limit = "4" )
9994 static void doSetItem (VirtualFrame frame , PHashingCollection c , Object key , Object value ,
10095 @ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
101- @ Cached GetDictStorageNode getStorage ,
102- @ Cached SetDictStorageNode setStorage ,
10396 @ CachedLibrary ("c.getDictStorage()" ) HashingStorageLibrary lib ) {
104- HashingStorage storage = getStorage . execute ( c );
97+ HashingStorage storage = c . getDictStorage ( );
10598 storage = lib .setItemWithFrame (storage , key , value , hasFrame , frame );
106- setStorage . execute ( c , storage );
99+ c . setDictStorage ( storage );
107100 }
108101
109102 public static SetItemNode create () {
110103 return SetItemNodeGen .create ();
111104 }
112105 }
113106
114- @ ImportStatic ({PGuards .class })
115- @ GenerateUncached
116- public abstract static class GetDictStorageNode extends PNodeWithContext {
117-
118- public abstract HashingStorage execute (PHashingCollection c );
119-
120- @ Specialization
121- static HashingStorage get (PBaseSet c ) {
122- return c .getDictStorage ();
123- }
124-
125- @ Specialization
126- static HashingStorage get (PDict c ) {
127- return c .getDictStorage ();
128- }
129-
130- public static GetDictStorageNode create () {
131- return GetDictStorageNodeGen .create ();
132- }
133-
134- public static GetDictStorageNode getUncached () {
135- return GetDictStorageNodeGen .getUncached ();
136- }
137- }
138-
139- @ ImportStatic ({PGuards .class })
140- @ GenerateUncached
141- public abstract static class SetDictStorageNode extends PNodeWithContext {
142-
143- public abstract void execute (PHashingCollection c , HashingStorage storage );
144-
145- @ Specialization
146- static void set (PBaseSet c , HashingStorage storage ) {
147- c .setDictStorage (storage );
148- }
149-
150- @ Specialization
151- static void set (PDict c , HashingStorage storage ) {
152- c .setDictStorage (storage );
153- }
154-
155- public static SetDictStorageNode create () {
156- return SetDictStorageNodeGen .create ();
157- }
158-
159- public static SetDictStorageNode getUncached () {
160- return SetDictStorageNodeGen .getUncached ();
161- }
162- }
163-
164107 @ ImportStatic ({PGuards .class })
165108 public abstract static class SetValueHashingStorageNode extends PNodeWithContext {
166109 public abstract void execute (VirtualFrame frame , HashingStorage iterator , Object value );
@@ -205,34 +148,30 @@ public final HashingStorage doNoValue(VirtualFrame frame, Object iterator) {
205148
206149 @ Specialization (guards = "isNoValue(value)" , limit = "1" )
207150 static HashingStorage doHashingCollectionNoValue (@ SuppressWarnings ("unused" ) VirtualFrame frame , PHashingCollection other , @ SuppressWarnings ("unused" ) Object value ,
208- @ Cached .Shared ("getStorage" ) @ Cached GetDictStorageNode getStorage ,
209- @ CachedLibrary ("getStorage.execute(other)" ) HashingStorageLibrary lib ) {
210- return lib .copy (getStorage .execute (other ));
151+ @ CachedLibrary ("other.getDictStorage()" ) HashingStorageLibrary lib ) {
152+ return lib .copy (other .getDictStorage ());
211153 }
212154
213155 @ Specialization (guards = "isNoValue(value)" , limit = "1" )
214156 static HashingStorage doPDictKeyViewNoValue (@ SuppressWarnings ("unused" ) VirtualFrame frame , PDictView .PDictKeysView other , Object value ,
215- @ Cached .Shared ("getStorage" ) @ Cached GetDictStorageNode getStorage ,
216- @ CachedLibrary ("getStorage.execute(other.getWrappedDict())" ) HashingStorageLibrary lib ) {
217- return doHashingCollectionNoValue (frame , other .getWrappedDict (), value , getStorage , lib );
157+ @ CachedLibrary ("other.getWrappedDict().getDictStorage()" ) HashingStorageLibrary lib ) {
158+ return doHashingCollectionNoValue (frame , other .getWrappedDict (), value , lib );
218159 }
219160
220161 @ Specialization (guards = "!isNoValue(value)" , limit = "1" )
221162 static HashingStorage doHashingCollection (@ SuppressWarnings ("unused" ) VirtualFrame frame , PHashingCollection other , Object value ,
222- @ Cached .Shared ("getStorage" ) @ Cached GetDictStorageNode getStorage ,
223163 @ Cached SetValueHashingStorageNode setValue ,
224- @ CachedLibrary ("getStorage.execute(other )" ) HashingStorageLibrary lib ) {
225- HashingStorage storage = lib .copy (getStorage . execute ( other ));
164+ @ CachedLibrary ("other.getDictStorage( )" ) HashingStorageLibrary lib ) {
165+ HashingStorage storage = lib .copy (other . getDictStorage ( ));
226166 setValue .execute (frame , storage , value );
227167 return storage ;
228168 }
229169
230170 @ Specialization (guards = "!isNoValue(value)" , limit = "1" )
231171 static HashingStorage doPDictView (@ SuppressWarnings ("unused" ) VirtualFrame frame , PDictView .PDictKeysView other , Object value ,
232- @ Cached .Shared ("getStorage" ) @ Cached GetDictStorageNode getStorage ,
233172 @ Cached SetValueHashingStorageNode setValue ,
234- @ CachedLibrary ("getStorage.execute( other.getWrappedDict())" ) HashingStorageLibrary lib ) {
235- return doHashingCollection (frame , other .getWrappedDict (), value , getStorage , setValue , lib );
173+ @ CachedLibrary ("other.getWrappedDict().getDictStorage( )" ) HashingStorageLibrary lib ) {
174+ return doHashingCollection (frame , other .getWrappedDict (), value , setValue , lib );
236175 }
237176
238177 @ Specialization
@@ -293,19 +232,17 @@ public abstract static class GetHashingStorageNode extends PNodeWithContext {
293232 public abstract HashingStorage execute (VirtualFrame frame , Object iterator );
294233
295234 @ Specialization
296- static HashingStorage doHashingCollection (@ SuppressWarnings ("unused" ) VirtualFrame frame , PHashingCollection other ,
297- @ Cached GetDictStorageNode getStorage ) {
298- return getStorage .execute (other );
235+ static HashingStorage doHashingCollection (PHashingCollection other ) {
236+ return other .getDictStorage ();
299237 }
300238
301239 @ Specialization
302- static HashingStorage doPDictView (@ SuppressWarnings ("unused" ) VirtualFrame frame , PDictView .PDictKeysView other ,
303- @ Cached GetDictStorageNode getStorage ) {
304- return getStorage .execute (other .getWrappedDict ());
240+ static HashingStorage doPDictView (PDictView .PDictKeysView other ) {
241+ return other .getWrappedDict ().getDictStorage ();
305242 }
306243
307244 @ Specialization (guards = {"!isPHashingCollection(other)" , "!isDictKeysView(other)" })
308- static HashingStorage doGeneric (@ SuppressWarnings ( "unused" ) VirtualFrame frame , Object other ,
245+ static HashingStorage doGeneric (VirtualFrame frame , Object other ,
309246 @ Cached GetClonedHashingStorageNode getHashingStorageNode ) {
310247 return getHashingStorageNode .doNoValue (frame , other );
311248 }
0 commit comments