7272import com .oracle .truffle .api .dsl .ImportStatic ;
7373import com .oracle .truffle .api .dsl .Specialization ;
7474import com .oracle .truffle .api .library .CachedLibrary ;
75+ import com .oracle .truffle .api .object .DynamicObjectLibrary ;
7576import com .oracle .truffle .api .object .HiddenKey ;
7677import com .oracle .truffle .api .profiles .BranchProfile ;
7778
@@ -109,30 +110,35 @@ private static String castKey(CastToJavaStringNode castNode, Object value) {
109110 }
110111 }
111112
112- @ Specialization (guards = "isAttrWritable(object, key)" )
113+ @ Specialization (guards = "isAttrWritable(object, key)" , limit = "getAttributeAccessInlineCacheMaxDepth()" )
113114 static boolean writeHiddenKeyToDynamicStorage (PythonObject object , HiddenKey key , Object value ,
114- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
115+ @ CachedLibrary ( "object.getStorage()" ) DynamicObjectLibrary dylib ) {
115116 // HiddenKeys are always written to the storage and do not have any other special handling
116- return writeAttributeToDynamicObjectNode .execute (object .getStorage (), key , value );
117+ dylib .put (object .getStorage (), key , value );
118+ return true ;
117119 }
118120
119121 @ Specialization (guards = {"!isHiddenKey(key)" , "!lib.hasDict(object)" , "isAttrWritable(object, key)" , "!isManagedClass(object)" }, limit = "1" )
120122 static boolean writeToDynamicStorageNoType (PythonObject object , Object key , Object value ,
123+ @ Cached CastToJavaStringNode castToStrNode ,
121124 @ CachedLibrary ("object" ) @ SuppressWarnings ("unused" ) PythonObjectLibrary lib ,
122- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
125+ @ CachedLibrary ( limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
123126 // Objects w/o dict that are not classes do not have any special handling
124- return writeAttributeToDynamicObjectNode .execute (object .getStorage (), key , value );
127+ String strKey = castKey (castToStrNode , key );
128+ dylib .put (object .getStorage (), strKey , value );
129+ return true ;
125130 }
126131
127132 @ Specialization (guards = {"!isHiddenKey(key)" , "!lib.hasDict(klass)" , "isAttrWritable(klass, key)" }, limit = "1" )
128133 static boolean writeToDynamicStorageBuiltinType (PythonBuiltinClass klass , Object key , Object value ,
129134 @ CachedLibrary ("klass" ) @ SuppressWarnings ("unused" ) PythonObjectLibrary lib ,
130135 @ Cached CastToJavaStringNode castToStrNode ,
131136 @ Cached BranchProfile callAttrUpdate ,
132- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
137+ @ CachedLibrary ( limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
133138 String strKey = castKey (castToStrNode , key );
134139 try {
135- return writeAttributeToDynamicObjectNode .execute (klass , strKey , value );
140+ dylib .put (klass , strKey , value );
141+ return true ;
136142 } finally {
137143 if (!klass .canSkipOnAttributeUpdate (strKey , value )) {
138144 callAttrUpdate .enter ();
@@ -150,10 +156,11 @@ static boolean writeToDynamicStoragePythonClass(PythonClass klass, Object key, O
150156 @ CachedLibrary ("klass" ) @ SuppressWarnings ("unused" ) PythonObjectLibrary lib ,
151157 @ Cached CastToJavaStringNode castToStrNode ,
152158 @ Cached BranchProfile callAttrUpdate ,
153- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
159+ @ CachedLibrary ( limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
154160 String strKey = castKey (castToStrNode , key );
155161 try {
156- return writeAttributeToDynamicObjectNode .execute (klass , strKey , value );
162+ dylib .put (klass , strKey , value );
163+ return true ;
157164 } finally {
158165 if (!klass .canSkipOnAttributeUpdate (strKey , value )) {
159166 callAttrUpdate .enter ();
0 commit comments