@@ -1100,18 +1100,21 @@ Object doEmptyStorage(VirtualFrame frame, EmptyStorage storage, Object key) {
1100
1100
return null ;
1101
1101
}
1102
1102
1103
+ // this is just a minor performance optimization
1103
1104
@ Specialization
1104
1105
static Object doPythonObjectString (PythonObjectDictStorage storage , String key ,
1105
1106
@ Shared ("readKey" ) @ Cached ReadAttributeFromDynamicObjectNode readKey ) {
1106
1107
return doDynamicObjectString (storage , key , readKey );
1107
1108
}
1108
1109
1110
+ // this is just a minor performance optimization
1109
1111
@ Specialization
1110
1112
static Object doPythonObjectPString (PythonObjectDictStorage storage , PString key ,
1111
1113
@ Shared ("readKey" ) @ Cached ReadAttributeFromDynamicObjectNode readKey ) {
1112
1114
return doDynamicObjectPString (storage , key , readKey );
1113
1115
}
1114
1116
1117
+ // this will read from the dynamic object
1115
1118
@ Specialization
1116
1119
static Object doDynamicObjectString (DynamicObjectStorage storage , String key ,
1117
1120
@ Shared ("readKey" ) @ Cached ReadAttributeFromDynamicObjectNode readKey ) {
@@ -1126,10 +1129,22 @@ static Object doDynamicObjectPString(DynamicObjectStorage storage, PString key,
1126
1129
return result == PNone .NO_VALUE ? null : result ;
1127
1130
}
1128
1131
1129
- @ Specialization (guards = {"!isString(key)" , "isHashable(frame, key)" , "s.getClass() == cachedClass" }, limit = "MAX_DYNAMIC_STORAGES" )
1130
- Object doDynamicStorage (@ SuppressWarnings ("unused" ) VirtualFrame frame , DynamicObjectStorage s , Object key ,
1131
- @ Cached ("s.getClass()" ) Class <? extends DynamicObjectStorage > cachedClass ) {
1132
- return cachedClass .cast (s ).getItem (key , getEquivalence ());
1132
+ // this must read from the non-dynamic object storage
1133
+ @ Specialization (guards = {"!isString(key)" , "isHashable(frame, key)" })
1134
+ Object doDynamicStorage (@ SuppressWarnings ("unused" ) VirtualFrame frame , PythonObjectHybridDictStorage s , Object key ) {
1135
+ return s .getItem (key , getEquivalence ());
1136
+ }
1137
+
1138
+ protected static boolean isPythonObjectHybridStorage (DynamicObjectStorage s ) {
1139
+ return s instanceof PythonObjectHybridDictStorage ;
1140
+ }
1141
+
1142
+ // any dynamic object storage that isn't hybridized cannot store
1143
+ // non-string keys
1144
+ @ Specialization (guards = {"!isString(key)" , "isHashable(frame, key)" , "!isPythonObjectHybridStorage(s)" })
1145
+ @ SuppressWarnings ("unused" )
1146
+ Object doDynamicStorage (VirtualFrame frame , DynamicObjectStorage s , Object key ) {
1147
+ return null ;
1133
1148
}
1134
1149
1135
1150
@ Specialization
0 commit comments