@@ -153,9 +153,9 @@ static boolean writeToDynamicStorageNoType(PythonObject object, Object key, Obje
153
153
@ Specialization (guards = {"isAttrWritable(klass, key)" , "!isHiddenKey(key)" , "getDict.execute(klass) == null" }, limit = "1" )
154
154
boolean writeToDynamicStorageBuiltinType (PythonBuiltinClass klass , Object key , Object value ,
155
155
@ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
156
- @ Cached CastToJavaStringNode castToStrNode ,
157
- @ Cached BranchProfile callAttrUpdate ,
158
- @ CachedLibrary (limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
156
+ @ Shared ( "castToStr" ) @ Cached CastToJavaStringNode castToStrNode ,
157
+ @ Shared ( "callAttrUpdate" ) @ Cached BranchProfile callAttrUpdate ,
158
+ @ Shared ( "dylib" ) @ CachedLibrary (limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
159
159
if (PythonContext .get (this ).isInitialized ()) {
160
160
throw PRaiseNode .raiseUncached (this , TypeError , ErrorMessages .CANT_SET_ATTRIBUTES_OF_TYPE_S , klass );
161
161
} else {
@@ -166,10 +166,10 @@ boolean writeToDynamicStorageBuiltinType(PythonBuiltinClass klass, Object key, O
166
166
@ Specialization (guards = {"isAttrWritable(klass, key)" , "!isHiddenKey(key)" , "getDict.execute(klass) == null" }, limit = "1" )
167
167
static boolean writeToDynamicStoragePythonClass (PythonClass klass , Object key , Object value ,
168
168
@ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
169
- @ Cached CastToJavaStringNode castToStrNode ,
170
- @ Cached BranchProfile callAttrUpdate ,
169
+ @ Shared ( "castToStr" ) @ Cached CastToJavaStringNode castToStrNode ,
170
+ @ Shared ( "callAttrUpdate" ) @ Cached BranchProfile callAttrUpdate ,
171
171
@ Cached BranchProfile updateFlags ,
172
- @ CachedLibrary (limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
172
+ @ Shared ( "dylib" ) @ CachedLibrary (limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
173
173
if (value == PNone .NO_VALUE ) {
174
174
updateFlags .enter ();
175
175
dylib .setShapeFlags (klass , dylib .getShapeFlags (klass ) | HAS_NO_VALUE_PROPERTIES );
@@ -197,8 +197,8 @@ private static boolean writeToDynamicStorageManagedClass(PythonManagedClass klas
197
197
static boolean writeToDictNoType (@ SuppressWarnings ("unused" ) PythonObject object , Object key , Object value ,
198
198
@ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
199
199
@ Bind ("getDict.execute(object)" ) PDict dict ,
200
- @ Cached BranchProfile updateStorage ,
201
- @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ) {
200
+ @ Shared ( "updateStorage" ) @ Cached BranchProfile updateStorage ,
201
+ @ Shared ( "hlib" ) @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ) {
202
202
return writeToDict (dict , key , value , updateStorage , hlib );
203
203
}
204
204
@@ -207,10 +207,10 @@ static boolean writeToDictNoType(@SuppressWarnings("unused") PythonObject object
207
207
boolean writeToDictBuiltinType (PythonBuiltinClass klass , Object key , Object value ,
208
208
@ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
209
209
@ Bind ("getDict.execute(klass)" ) PDict dict ,
210
- @ Cached CastToJavaStringNode castToStrNode ,
211
- @ Cached BranchProfile callAttrUpdate ,
212
- @ Cached BranchProfile updateStorage ,
213
- @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ) {
210
+ @ Shared ( "castToStr" ) @ Cached CastToJavaStringNode castToStrNode ,
211
+ @ Shared ( "callAttrUpdate" ) @ Cached BranchProfile callAttrUpdate ,
212
+ @ Shared ( "updateStorage" ) @ Cached BranchProfile updateStorage ,
213
+ @ Shared ( "hlib" ) @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ) {
214
214
if (PythonContext .get (this ).isInitialized ()) {
215
215
throw PRaiseNode .raiseUncached (this , TypeError , ErrorMessages .CANT_SET_ATTRIBUTES_OF_TYPE_S , klass );
216
216
} else {
@@ -222,10 +222,10 @@ boolean writeToDictBuiltinType(PythonBuiltinClass klass, Object key, Object valu
222
222
static boolean writeToDictClass (PythonClass klass , Object key , Object value ,
223
223
@ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
224
224
@ Bind ("getDict.execute(klass)" ) PDict dict ,
225
- @ Cached CastToJavaStringNode castToStrNode ,
226
- @ Cached BranchProfile callAttrUpdate ,
227
- @ Cached BranchProfile updateStorage ,
228
- @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ) {
225
+ @ Shared ( "castToStr" ) @ Cached CastToJavaStringNode castToStrNode ,
226
+ @ Shared ( "callAttrUpdate" ) @ Cached BranchProfile callAttrUpdate ,
227
+ @ Shared ( "updateStorage" ) @ Cached BranchProfile updateStorage ,
228
+ @ Shared ( "hlib" ) @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ) {
229
229
return writeToDictManagedClass (klass , dict , key , value , castToStrNode , callAttrUpdate , updateStorage , hlib );
230
230
}
231
231
@@ -256,13 +256,6 @@ static boolean writeToDict(PDict dict, Object key, Object value,
256
256
return true ;
257
257
}
258
258
259
- @ Specialization (guards = "isErrorCase(getDict, object, key)" , limit = "1" )
260
- static boolean doError (Object object , Object key , @ SuppressWarnings ("unused" ) Object value ,
261
- @ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
262
- @ Cached PRaiseNode raiseNode ) {
263
- throw raiseNode .raise (PythonBuiltinClassType .AttributeError , ErrorMessages .OBJ_P_HAS_NO_ATTR_S , object , key );
264
- }
265
-
266
259
@ Specialization
267
260
static boolean doPBCT (PythonBuiltinClassType object , Object key , Object value ,
268
261
@ Cached WriteAttributeToObjectNode recursive ) {
@@ -292,10 +285,10 @@ protected static boolean isErrorCase(GetDictIfExistsNode getDict, Object object,
292
285
protected abstract static class WriteAttributeToObjectNotTypeNode extends WriteAttributeToObjectNode {
293
286
@ Specialization (guards = {"!isHiddenKey(key)" })
294
287
static boolean writeNativeObject (PythonAbstractNativeObject object , Object key , Object value ,
295
- @ Cached GetDictIfExistsNode getDict ,
296
- @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ,
297
- @ Cached BranchProfile updateStorage ,
298
- @ Cached PRaiseNode raiseNode ) {
288
+ @ Shared ( "getDict" ) @ Cached GetDictIfExistsNode getDict ,
289
+ @ Shared ( "hlib" ) @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ,
290
+ @ Shared ( "updateStorage" ) @ Cached BranchProfile updateStorage ,
291
+ @ Shared ( "raiseNode" ) @ Cached PRaiseNode raiseNode ) {
299
292
/*
300
293
* The dict of native objects that stores the object attributes is located at 'objectPtr
301
294
* + Py_TYPE(objectPtr)->tp_dictoffset'. 'PythonObjectLibrary.getDict' will exactly load
@@ -307,6 +300,13 @@ static boolean writeNativeObject(PythonAbstractNativeObject object, Object key,
307
300
}
308
301
throw raiseNode .raise (PythonBuiltinClassType .AttributeError , ErrorMessages .OBJ_P_HAS_NO_ATTR_S , object , key );
309
302
}
303
+
304
+ @ Specialization (guards = "isErrorCase(getDict, object, key)" , limit = "1" )
305
+ static boolean doError (Object object , Object key , @ SuppressWarnings ("unused" ) Object value ,
306
+ @ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
307
+ @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ) {
308
+ throw raiseNode .raise (PythonBuiltinClassType .AttributeError , ErrorMessages .OBJ_P_HAS_NO_ATTR_S , object , key );
309
+ }
310
310
}
311
311
312
312
@ GenerateUncached
@@ -342,7 +342,7 @@ static boolean writeNativeClassGeneric(PythonAbstractNativeObject object, Object
342
342
@ Shared ("hlib" ) @ CachedLibrary (limit = "1" ) HashingStorageLibrary hlib ,
343
343
@ Shared ("updateStorage" ) @ Cached BranchProfile updateStorage ,
344
344
@ Cached BranchProfile canBeSpecialSlot ,
345
- @ Cached CastToJavaStringNode castKeyNode ,
345
+ @ Shared ( "castToStr" ) @ Cached CastToJavaStringNode castKeyNode ,
346
346
@ Cached IsTypeNode isTypeNode ,
347
347
@ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ) {
348
348
try {
@@ -372,5 +372,12 @@ static boolean writeNativeClassGeneric(PythonAbstractNativeObject object, Object
372
372
}
373
373
}
374
374
}
375
+
376
+ @ Specialization (guards = "isErrorCase(getDict, object, key)" , limit = "1" )
377
+ static boolean doError (Object object , Object key , @ SuppressWarnings ("unused" ) Object value ,
378
+ @ SuppressWarnings ("unused" ) @ Shared ("getDict" ) @ Cached GetDictIfExistsNode getDict ,
379
+ @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ) {
380
+ throw raiseNode .raise (PythonBuiltinClassType .AttributeError , ErrorMessages .OBJ_P_HAS_NO_ATTR_S , object , key );
381
+ }
375
382
}
376
383
}
0 commit comments