@@ -1148,8 +1148,8 @@ protected Object solidBase(Object type, GetBaseClassNode getBaseClassNode, Pytho
1148
1148
1149
1149
@ TruffleBoundary
1150
1150
private static boolean extraivars (Object type , Object base , Object typeSlots , Object baseSlots , GetInternalObjectArrayNode getArrayNode ) {
1151
- if (typeSlots == null && baseSlots != null && length ((( PSequence ) baseSlots ). getSequenceStorage () , getArrayNode ) != 0 ||
1152
- baseSlots == null && typeSlots != null && length ((( PSequence ) typeSlots ). getSequenceStorage () , getArrayNode ) != 0 ) {
1151
+ if (typeSlots == null && baseSlots != null && length (baseSlots , getArrayNode ) != 0 ||
1152
+ baseSlots == null && typeSlots != null && length (typeSlots , getArrayNode ) != 0 ) {
1153
1153
return true ;
1154
1154
}
1155
1155
Object typeNewMethod = LookupAttributeInMRONode .lookup (type , __NEW__ , GetMroStorageNode .getUncached (), ReadAttributeFromObjectNode .getUncached (), true );
@@ -1158,18 +1158,26 @@ private static boolean extraivars(Object type, Object base, Object typeSlots, Ob
1158
1158
}
1159
1159
1160
1160
@ TruffleBoundary
1161
- private static int length (SequenceStorage storage , GetInternalObjectArrayNode getArrayNode ) {
1162
- int result = 0 ;
1163
- int length = storage .length ();
1164
- Object [] slots = getArrayNode .execute (storage );
1165
- for (int i = 0 ; i < length ; i ++) {
1166
- // omit __DICT__ and __WEAKREF__, they cause no class layout conflict
1167
- // see also test_slts.py#test_no_bases_have_class_layout_conflict
1168
- if (!(slots [i ].equals (__DICT__ ) || slots [i ].equals (__WEAKREF__ ))) {
1169
- result ++;
1161
+ private static int length (Object slotsObject , GetInternalObjectArrayNode getArrayNode ) {
1162
+ assert PGuards .isString (slotsObject ) || PGuards .isPSequence (slotsObject ): "slotsObject must be either a String or a PSequence" ;
1163
+
1164
+ if (PGuards .isString (slotsObject )) {
1165
+ return (slotsObject .equals (__DICT__ ) || slotsObject .equals (__WEAKREF__ )) ? 0 : 1 ;
1166
+ } else {
1167
+ SequenceStorage storage = ((PSequence ) slotsObject ).getSequenceStorage ();
1168
+
1169
+ int count = 0 ;
1170
+ int length = storage .length ();
1171
+ Object [] slots = getArrayNode .execute (storage );
1172
+ for (int i = 0 ; i < length ; i ++) {
1173
+ // omit __DICT__ and __WEAKREF__, they cause no class layout conflict
1174
+ // see also test_slts.py#test_no_bases_have_class_layout_conflict
1175
+ if (!(slots [i ].equals (__DICT__ ) || slots [i ].equals (__WEAKREF__ ))) {
1176
+ count ++;
1177
+ }
1170
1178
}
1179
+ return count ;
1171
1180
}
1172
- return result ;
1173
1181
}
1174
1182
1175
1183
private static Object getSlotsFromType (Object type , ReadAttributeFromObjectNode readAttr ) {
0 commit comments