42
42
43
43
import java .util .Iterator ;
44
44
45
+ import com .oracle .graal .python .builtins .objects .function .PArguments ;
45
46
import com .oracle .graal .python .builtins .objects .function .PArguments .ThreadState ;
46
47
import com .oracle .truffle .api .CompilerDirectives ;
47
48
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
49
+ import com .oracle .truffle .api .frame .VirtualFrame ;
48
50
import com .oracle .truffle .api .library .GenerateLibrary ;
49
51
import com .oracle .truffle .api .library .Library ;
50
52
import com .oracle .truffle .api .library .LibraryFactory ;
51
53
import com .oracle .truffle .api .nodes .Node ;
54
+ import com .oracle .truffle .api .profiles .ConditionProfile ;
52
55
53
56
/*
54
57
* TODO:
@@ -92,6 +95,17 @@ public int length(HashingStorage self) {
92
95
return lengthWithState (self , null );
93
96
}
94
97
98
+ /**
99
+ * @see #lengthWithState(HashingStorage, ThreadState)
100
+ */
101
+ public final int lengthWithFrame (HashingStorage self , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
102
+ if (hasFrameProfile .profile (frame != null )) {
103
+ return lengthWithState (self , PArguments .getThreadState (frame ));
104
+ } else {
105
+ return length (self );
106
+ }
107
+ }
108
+
95
109
/**
96
110
* Implementers <i>must</i> call {@code __hash__} on the key if that could be visible, to comply
97
111
* with Python semantics.
@@ -110,6 +124,17 @@ public boolean hasKey(HashingStorage self, Object key) {
110
124
return getItem (self , key ) != null ;
111
125
}
112
126
127
+ /**
128
+ * @see #hasKeyWithState(HashingStorage, Object, ThreadState)
129
+ */
130
+ public final boolean hasKeyWithFrame (HashingStorage self , Object key , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
131
+ if (hasFrameProfile .profile (frame != null )) {
132
+ return hasKeyWithState (self , key , PArguments .getThreadState (frame ));
133
+ } else {
134
+ return hasKey (self , key );
135
+ }
136
+ }
137
+
113
138
/**
114
139
* Implementers <i>must</i> call {@code __hash__} on the key if that could be visible, to comply
115
140
* with Python semantics.
@@ -132,6 +157,17 @@ public Object getItem(HashingStorage self, Object key) {
132
157
return getItemWithState (self , key , null );
133
158
}
134
159
160
+ /**
161
+ * @see #getItemWithState(HashingStorage, Object, ThreadState)
162
+ */
163
+ public final Object getItemWithFrame (HashingStorage self , Object key , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
164
+ if (hasFrameProfile .profile (frame != null )) {
165
+ return getItemWithState (self , key , PArguments .getThreadState (frame ));
166
+ } else {
167
+ return getItem (self , key );
168
+ }
169
+ }
170
+
135
171
/**
136
172
* Implementers <i>must</i> call {@code __hash__} on the key if that could be visible, to comply
137
173
* with Python semantics.
@@ -155,6 +191,17 @@ public final HashingStorage setItem(HashingStorage self, Object key, Object valu
155
191
return setItemWithState (self , key , value , null );
156
192
}
157
193
194
+ /**
195
+ * @see #setItemWithState(HashingStorage, Object, Object, ThreadState)
196
+ */
197
+ public final HashingStorage setItemWithFrame (HashingStorage self , Object key , Object value , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
198
+ if (hasFrameProfile .profile (frame != null )) {
199
+ return setItemWithState (self , key , value , PArguments .getThreadState (frame ));
200
+ } else {
201
+ return setItem (self , key , value );
202
+ }
203
+ }
204
+
158
205
/**
159
206
* Implementers <i>must</i> call {@code __hash__} on the key if that could be visible, to comply
160
207
* with Python semantics.
@@ -174,6 +221,14 @@ public HashingStorage delItem(HashingStorage self, Object key) {
174
221
return delItemWithState (self , key , null );
175
222
}
176
223
224
+ public final HashingStorage delItemWithFrame (HashingStorage self , Object key , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
225
+ if (hasFrameProfile .profile (frame != null )) {
226
+ return delItemWithState (self , key , PArguments .getThreadState (frame ));
227
+ } else {
228
+ return delItem (self , key );
229
+ }
230
+ }
231
+
177
232
/**
178
233
* A node to be called in a loop with different keys to operate on {@code
179
234
* store}. It's execute method returns the new store to use for the next iteration.
@@ -275,6 +330,17 @@ public int compareKeys(HashingStorage self, HashingStorage other) {
275
330
return compareKeysWithState (self , other , null );
276
331
}
277
332
333
+ /**
334
+ * @see #compareKeysWithState(HashingStorage, HashingStorage, ThreadState)
335
+ */
336
+ public final int compareKeysWithFrame (HashingStorage self , HashingStorage other , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
337
+ if (hasFrameProfile .profile (frame != null )) {
338
+ return compareKeysWithState (self , other , PArguments .getThreadState (frame ));
339
+ } else {
340
+ return compareKeys (self , other );
341
+ }
342
+ }
343
+
278
344
/**
279
345
* @return {@code 0} if all entries are equal, {@code -1} if {@code self} is a subset, or
280
346
* {@code 1} if neither.
@@ -312,6 +378,17 @@ public HashingStorage intersect(HashingStorage self, HashingStorage other) {
312
378
return intersectWithState (self , other , null );
313
379
}
314
380
381
+ /**
382
+ * @see #intersectWithState(HashingStorage, HashingStorage, ThreadState)
383
+ */
384
+ public final HashingStorage intersectWithFrame (HashingStorage self , HashingStorage other , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
385
+ if (hasFrameProfile .profile (frame != null )) {
386
+ return intersectWithState (self , other , PArguments .getThreadState (frame ));
387
+ } else {
388
+ return intersect (self , other );
389
+ }
390
+ }
391
+
315
392
/**
316
393
* @return {@code true} iff the intersection of the two sets is empty.
317
394
*/
@@ -359,6 +436,17 @@ public HashingStorage diff(HashingStorage self, HashingStorage other) {
359
436
return diffWithState (self , other , null );
360
437
}
361
438
439
+ /**
440
+ * @see #getItemWithState(HashingStorage, Object, ThreadState)
441
+ */
442
+ public final HashingStorage diffWithFrame (HashingStorage self , HashingStorage other , ConditionProfile hasFrameProfile , VirtualFrame frame ) {
443
+ if (hasFrameProfile .profile (frame != null )) {
444
+ return diffWithState (self , other , PArguments .getThreadState (frame ));
445
+ } else {
446
+ return diff (self , other );
447
+ }
448
+ }
449
+
362
450
/**
363
451
* An iterable that does not need to be guarded separately with TruffleBoundary.
364
452
*/
0 commit comments