72
72
import com .oracle .truffle .api .dsl .ImportStatic ;
73
73
import com .oracle .truffle .api .dsl .Specialization ;
74
74
import com .oracle .truffle .api .library .CachedLibrary ;
75
+ import com .oracle .truffle .api .object .DynamicObjectLibrary ;
75
76
import com .oracle .truffle .api .object .HiddenKey ;
76
77
import com .oracle .truffle .api .profiles .BranchProfile ;
77
78
@@ -109,30 +110,35 @@ private static String castKey(CastToJavaStringNode castNode, Object value) {
109
110
}
110
111
}
111
112
112
- @ Specialization (guards = "isAttrWritable(object, key)" )
113
+ @ Specialization (guards = "isAttrWritable(object, key)" , limit = "getAttributeAccessInlineCacheMaxDepth()" )
113
114
static boolean writeHiddenKeyToDynamicStorage (PythonObject object , HiddenKey key , Object value ,
114
- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
115
+ @ CachedLibrary ( "object.getStorage()" ) DynamicObjectLibrary dylib ) {
115
116
// 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 ;
117
119
}
118
120
119
121
@ Specialization (guards = {"!isHiddenKey(key)" , "!lib.hasDict(object)" , "isAttrWritable(object, key)" , "!isManagedClass(object)" }, limit = "1" )
120
122
static boolean writeToDynamicStorageNoType (PythonObject object , Object key , Object value ,
123
+ @ Cached CastToJavaStringNode castToStrNode ,
121
124
@ CachedLibrary ("object" ) @ SuppressWarnings ("unused" ) PythonObjectLibrary lib ,
122
- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
125
+ @ CachedLibrary ( limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
123
126
// 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 ;
125
130
}
126
131
127
132
@ Specialization (guards = {"!isHiddenKey(key)" , "!lib.hasDict(klass)" , "isAttrWritable(klass, key)" }, limit = "1" )
128
133
static boolean writeToDynamicStorageBuiltinType (PythonBuiltinClass klass , Object key , Object value ,
129
134
@ CachedLibrary ("klass" ) @ SuppressWarnings ("unused" ) PythonObjectLibrary lib ,
130
135
@ Cached CastToJavaStringNode castToStrNode ,
131
136
@ Cached BranchProfile callAttrUpdate ,
132
- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
137
+ @ CachedLibrary ( limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
133
138
String strKey = castKey (castToStrNode , key );
134
139
try {
135
- return writeAttributeToDynamicObjectNode .execute (klass , strKey , value );
140
+ dylib .put (klass , strKey , value );
141
+ return true ;
136
142
} finally {
137
143
if (!klass .canSkipOnAttributeUpdate (strKey , value )) {
138
144
callAttrUpdate .enter ();
@@ -150,10 +156,11 @@ static boolean writeToDynamicStoragePythonClass(PythonClass klass, Object key, O
150
156
@ CachedLibrary ("klass" ) @ SuppressWarnings ("unused" ) PythonObjectLibrary lib ,
151
157
@ Cached CastToJavaStringNode castToStrNode ,
152
158
@ Cached BranchProfile callAttrUpdate ,
153
- @ Cached WriteAttributeToDynamicObjectNode writeAttributeToDynamicObjectNode ) {
159
+ @ CachedLibrary ( limit = "getAttributeAccessInlineCacheMaxDepth()" ) DynamicObjectLibrary dylib ) {
154
160
String strKey = castKey (castToStrNode , key );
155
161
try {
156
- return writeAttributeToDynamicObjectNode .execute (klass , strKey , value );
162
+ dylib .put (klass , strKey , value );
163
+ return true ;
157
164
} finally {
158
165
if (!klass .canSkipOnAttributeUpdate (strKey , value )) {
159
166
callAttrUpdate .enter ();
0 commit comments