48
48
import com .oracle .graal .python .builtins .objects .common .HashingStorageLibrary .HashingStorageIterable ;
49
49
import com .oracle .graal .python .builtins .objects .common .ObjectHashMap .DictKey ;
50
50
import com .oracle .graal .python .builtins .objects .common .ObjectHashMap .MapCursor ;
51
- import com .oracle .graal .python .builtins .objects .common .ObjectHashMap .PutProfiles ;
51
+ import com .oracle .graal .python .builtins .objects .common .ObjectHashMap .PutNode ;
52
52
import com .oracle .graal .python .builtins .objects .function .PArguments ;
53
53
import com .oracle .graal .python .builtins .objects .function .PArguments .ThreadState ;
54
54
import com .oracle .graal .python .builtins .objects .object .PythonObject ;
71
71
import com .oracle .truffle .api .library .ExportLibrary ;
72
72
import com .oracle .truffle .api .library .ExportMessage ;
73
73
import com .oracle .truffle .api .nodes .LoopNode ;
74
- import com .oracle .truffle .api .nodes .Node ;
75
74
import com .oracle .truffle .api .profiles .ConditionProfile ;
76
75
import com .oracle .truffle .api .profiles .LoopConditionProfile ;
77
76
import com .oracle .truffle .api .strings .TruffleString ;
@@ -163,7 +162,7 @@ static boolean maySideEffect(PythonObject o, LookupInheritedAttributeNode.Dynami
163
162
@ Specialization
164
163
static HashingStorage setItemTruffleString (EconomicMapStorage self , TruffleString key , Object value , ThreadState state ,
165
164
@ Shared ("tsHash" ) @ Cached TruffleString .HashCodeNode hashCodeNode ,
166
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
165
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
167
166
@ Shared ("gotState" ) @ Cached ConditionProfile gotState ) {
168
167
VirtualFrame frame = gotState .profile (state == null ) ? null : PArguments .frameForCall (state );
169
168
putNode .put (state , self .map , key , PyObjectHashNode .hash (key , hashCodeNode ), assertNoJavaString (value ));
@@ -174,7 +173,7 @@ static HashingStorage setItemTruffleString(EconomicMapStorage self, TruffleStrin
174
173
static HashingStorage setItemPString (EconomicMapStorage self , PString key , Object value , ThreadState state ,
175
174
@ Shared ("stringMaterialize" ) @ Cached StringMaterializeNode stringMaterializeNode ,
176
175
@ Shared ("tsHash" ) @ Cached TruffleString .HashCodeNode hashCodeNode ,
177
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
176
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
178
177
@ Shared ("gotState" ) @ Cached ConditionProfile gotState ,
179
178
@ Shared ("builtinProfile" ) @ Cached IsBuiltinClassProfile isBuiltinClassProfile ) {
180
179
final TruffleString k = stringMaterializeNode .execute (key );
@@ -184,7 +183,7 @@ static HashingStorage setItemPString(EconomicMapStorage self, PString key, Objec
184
183
@ Specialization (guards = {"!hasSideEffect(self)" , "!isBuiltin(key,builtinProfile) || !isBuiltin(value,builtinProfile)" ,
185
184
"maySideEffect(key, lookup) || maySideEffect(value, lookup)" }, limit = "1" )
186
185
static HashingStorage setItemPythonObjectWithSideEffect (EconomicMapStorage self , PythonObject key , PythonObject value , ThreadState state ,
187
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
186
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
188
187
@ Shared ("hashNode" ) @ Cached PyObjectHashNode hashNode ,
189
188
@ Shared ("lookup" ) @ Cached LookupInheritedAttributeNode .Dynamic lookup ,
190
189
@ Shared ("builtinProfile" ) @ Cached IsBuiltinClassProfile builtinProfile ,
@@ -195,7 +194,7 @@ static HashingStorage setItemPythonObjectWithSideEffect(EconomicMapStorage self,
195
194
196
195
@ Specialization (guards = {"!hasSideEffect(self)" , "!isBuiltin(key,builtinProfile)" , "maySideEffect(key, lookup)" }, limit = "1" )
197
196
static HashingStorage setItemPythonObjectWithSideEffect (EconomicMapStorage self , PythonObject key , Object value , ThreadState state ,
198
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
197
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
199
198
@ Shared ("hashNode" ) @ Cached PyObjectHashNode hashNode ,
200
199
@ Shared ("lookup" ) @ Cached LookupInheritedAttributeNode .Dynamic lookup ,
201
200
@ Shared ("builtinProfile" ) @ Cached IsBuiltinClassProfile builtinProfile ,
@@ -206,7 +205,7 @@ static HashingStorage setItemPythonObjectWithSideEffect(EconomicMapStorage self,
206
205
207
206
@ Specialization (guards = {"!hasSideEffect(self)" , "!isBuiltin(value,builtinProfile)" , "maySideEffect(value, lookup)" }, limit = "1" )
208
207
static HashingStorage setItemPythonObjectWithSideEffect (EconomicMapStorage self , Object key , PythonObject value , ThreadState state ,
209
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
208
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
210
209
@ Shared ("hashNode" ) @ Cached PyObjectHashNode hashNode ,
211
210
@ Shared ("lookup" ) @ Cached LookupInheritedAttributeNode .Dynamic lookup ,
212
211
@ Shared ("builtinProfile" ) @ Cached IsBuiltinClassProfile builtinProfile ,
@@ -217,7 +216,7 @@ static HashingStorage setItemPythonObjectWithSideEffect(EconomicMapStorage self,
217
216
218
217
@ Specialization (replaces = {"setItemPString" , "setItemTruffleString" })
219
218
static HashingStorage setItemGeneric (EconomicMapStorage self , Object key , Object value , ThreadState state ,
220
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
219
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
221
220
@ Shared ("hashNode" ) @ Cached PyObjectHashNode hashNode ,
222
221
@ Shared ("gotState" ) @ Cached ConditionProfile gotState ) {
223
222
VirtualFrame frame = gotState .profile (state == null ) ? null : PArguments .frameForCall (state );
@@ -260,23 +259,23 @@ protected static boolean hasSideEffect(EconomicMapStorage self, EconomicMapStora
260
259
static HashingStorage toSameTypeSideEffect (EconomicMapStorage self , EconomicMapStorage other ,
261
260
@ CachedLibrary ("self" ) HashingStorageLibrary thisLib ,
262
261
@ Shared ("selfEntriesLoop" ) @ Cached LoopConditionProfile loopProfile ,
263
- @ Shared ("putProfiles " ) @ Cached ObjectHashMap .PutProfiles profiles ) {
262
+ @ Shared ("putNode " ) @ Cached ObjectHashMap .PutNode putNode ) {
264
263
convertToSideEffectMap (other );
265
- return toSameType (self , other , thisLib , loopProfile , profiles );
264
+ return toSameType (self , other , thisLib , loopProfile , putNode );
266
265
}
267
266
268
267
@ Specialization (guards = "!hasSideEffect(self, other)" )
269
268
static HashingStorage toSameType (EconomicMapStorage self , EconomicMapStorage other ,
270
269
@ CachedLibrary ("self" ) HashingStorageLibrary thisLib ,
271
270
@ Shared ("selfEntriesLoop" ) @ Cached LoopConditionProfile loopProfile ,
272
- @ Shared ("putProfiles " ) @ Cached ObjectHashMap .PutProfiles profiles ) {
271
+ @ Shared ("putNode " ) @ Cached ObjectHashMap .PutNode putNode ) {
273
272
MapCursor cursor = self .map .getEntries ();
274
273
// get/put may throw, but we ignore that small inaccuracy
275
274
final int size = self .map .size ();
276
275
loopProfile .profileCounted (size );
277
276
LoopNode .reportLoopCount (thisLib , size );
278
277
while (loopProfile .inject (advance (cursor ))) {
279
- other . map . put (null , cursor .getKey ().getValue (), cursor .getKey ().getPythonHash (), cursor .getValue (), profiles );
278
+ putNode . put (null , other . map , cursor .getKey ().getValue (), cursor .getKey ().getPythonHash (), cursor .getValue ());
280
279
}
281
280
return other ;
282
281
}
@@ -522,7 +521,7 @@ public static class DiffWithState {
522
521
@ Specialization
523
522
static HashingStorage diffSameType (EconomicMapStorage self , EconomicMapStorage other , ThreadState state ,
524
523
@ CachedLibrary ("self" ) HashingStorageLibrary thisLib ,
525
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
524
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
526
525
@ Shared ("getNode" ) @ Cached ObjectHashMap .GetNode getNode ,
527
526
@ Shared ("selfEntriesLoop" ) @ Cached LoopConditionProfile loopProfile ,
528
527
@ Shared ("gotState" ) @ Cached ConditionProfile gotState ) {
@@ -544,7 +543,7 @@ static HashingStorage diffSameType(EconomicMapStorage self, EconomicMapStorage o
544
543
@ Specialization
545
544
static HashingStorage diffGeneric (EconomicMapStorage self , HashingStorage other , @ SuppressWarnings ("unused" ) ThreadState state ,
546
545
@ CachedLibrary ("self" ) HashingStorageLibrary thisLib ,
547
- @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
546
+ @ Shared ("putNode" ) @ Cached ObjectHashMap .PutNode putNode ,
548
547
@ Shared ("selfEntriesLoop" ) @ Cached LoopConditionProfile loopProfile ,
549
548
@ Shared ("otherHLib" ) @ CachedLibrary (limit = "2" ) HashingStorageLibrary hlib ,
550
549
@ Shared ("gotState" ) @ Cached ConditionProfile gotState ) {
@@ -585,19 +584,20 @@ public HashingStorageIterable<Object> reverseKeys() {
585
584
return map .reverseKeys ();
586
585
}
587
586
588
- protected void setValueForAllKeys (VirtualFrame frame , Object value , ObjectHashMap . PutProfiles profiles , Node node , LoopConditionProfile loopProfile ) {
587
+ protected void setValueForAllKeys (VirtualFrame frame , Object value , PutNode putNode , ConditionProfile hasFrame , LoopConditionProfile loopProfile ) {
589
588
MapCursor cursor = map .getEntries ();
590
589
final int size = map .size ();
591
590
loopProfile .profileCounted (size );
592
- LoopNode .reportLoopCount (node , size );
591
+ LoopNode .reportLoopCount (putNode , size );
592
+ ThreadState state = PArguments .getThreadStateOrNull (frame , hasFrame );
593
593
while (loopProfile .inject (advance (cursor ))) {
594
- map .put (frame , getDictKey (cursor ), value , profiles );
594
+ putNode .put (state , map , getDictKey (cursor ), value );
595
595
}
596
596
}
597
597
598
598
@ TruffleBoundary
599
599
public void putUncached (TruffleString key , Object value ) {
600
- map . put (null , key , PyObjectHashNode .hash (key , HashCodeNode .getUncached ()), value , PutProfiles . getUncached () );
600
+ ObjectHashMapFactory . PutNodeGen . getUncached (). put (null , this . map , key , PyObjectHashNode .hash (key , HashCodeNode .getUncached ()), value );
601
601
}
602
602
603
603
@ Override
0 commit comments