43
43
import static com .oracle .graal .python .runtime .exception .PythonErrorType .TypeError ;
44
44
45
45
import com .oracle .graal .python .builtins .objects .PNone ;
46
- import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .GetDictStorageNodeGen ;
47
46
import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .LenNodeGen ;
48
- import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .SetDictStorageNodeGen ;
49
47
import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodesFactory .SetItemNodeGen ;
50
- import com .oracle .graal .python .builtins .objects .dict .PDict ;
51
48
import com .oracle .graal .python .builtins .objects .dict .PDictView ;
52
49
import com .oracle .graal .python .builtins .objects .function .PArguments ;
53
50
import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
54
- import com .oracle .graal .python .builtins .objects .set .PBaseSet ;
55
51
import com .oracle .graal .python .builtins .objects .str .PString ;
56
52
import com .oracle .graal .python .nodes .ErrorMessages ;
57
53
import com .oracle .graal .python .nodes .PGuards ;
@@ -81,9 +77,8 @@ public abstract static class LenNode extends PNodeWithContext {
81
77
82
78
@ Specialization (limit = "4" )
83
79
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 ());
87
82
}
88
83
89
84
public static LenNode create () {
@@ -98,69 +93,17 @@ public abstract static class SetItemNode extends PNodeWithContext {
98
93
@ Specialization (limit = "4" )
99
94
static void doSetItem (VirtualFrame frame , PHashingCollection c , Object key , Object value ,
100
95
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
101
- @ Cached GetDictStorageNode getStorage ,
102
- @ Cached SetDictStorageNode setStorage ,
103
96
@ CachedLibrary ("c.getDictStorage()" ) HashingStorageLibrary lib ) {
104
- HashingStorage storage = getStorage . execute ( c );
97
+ HashingStorage storage = c . getDictStorage ( );
105
98
storage = lib .setItemWithFrame (storage , key , value , hasFrame , frame );
106
- setStorage . execute ( c , storage );
99
+ c . setDictStorage ( storage );
107
100
}
108
101
109
102
public static SetItemNode create () {
110
103
return SetItemNodeGen .create ();
111
104
}
112
105
}
113
106
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
-
164
107
@ ImportStatic ({PGuards .class })
165
108
public abstract static class SetValueHashingStorageNode extends PNodeWithContext {
166
109
public abstract void execute (VirtualFrame frame , HashingStorage iterator , Object value );
@@ -205,34 +148,30 @@ public final HashingStorage doNoValue(VirtualFrame frame, Object iterator) {
205
148
206
149
@ Specialization (guards = "isNoValue(value)" , limit = "1" )
207
150
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 ());
211
153
}
212
154
213
155
@ Specialization (guards = "isNoValue(value)" , limit = "1" )
214
156
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 );
218
159
}
219
160
220
161
@ Specialization (guards = "!isNoValue(value)" , limit = "1" )
221
162
static HashingStorage doHashingCollection (@ SuppressWarnings ("unused" ) VirtualFrame frame , PHashingCollection other , Object value ,
222
- @ Cached .Shared ("getStorage" ) @ Cached GetDictStorageNode getStorage ,
223
163
@ 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 ( ));
226
166
setValue .execute (frame , storage , value );
227
167
return storage ;
228
168
}
229
169
230
170
@ Specialization (guards = "!isNoValue(value)" , limit = "1" )
231
171
static HashingStorage doPDictView (@ SuppressWarnings ("unused" ) VirtualFrame frame , PDictView .PDictKeysView other , Object value ,
232
- @ Cached .Shared ("getStorage" ) @ Cached GetDictStorageNode getStorage ,
233
172
@ 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 );
236
175
}
237
176
238
177
@ Specialization
@@ -293,19 +232,17 @@ public abstract static class GetHashingStorageNode extends PNodeWithContext {
293
232
public abstract HashingStorage execute (VirtualFrame frame , Object iterator );
294
233
295
234
@ 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 ();
299
237
}
300
238
301
239
@ 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 ();
305
242
}
306
243
307
244
@ Specialization (guards = {"!isPHashingCollection(other)" , "!isDictKeysView(other)" })
308
- static HashingStorage doGeneric (@ SuppressWarnings ( "unused" ) VirtualFrame frame , Object other ,
245
+ static HashingStorage doGeneric (VirtualFrame frame , Object other ,
309
246
@ Cached GetClonedHashingStorageNode getHashingStorageNode ) {
310
247
return getHashingStorageNode .doNoValue (frame , other );
311
248
}
0 commit comments