@@ -1148,8 +1148,8 @@ protected Object solidBase(Object type, GetBaseClassNode getBaseClassNode, Pytho
11481148
11491149 @ TruffleBoundary
11501150 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 ) {
11531153 return true ;
11541154 }
11551155 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
11581158 }
11591159
11601160 @ 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+ }
11701178 }
1179+ return count ;
11711180 }
1172- return result ;
11731181 }
11741182
11751183 private static Object getSlotsFromType (Object type , ReadAttributeFromObjectNode readAttr ) {
0 commit comments