@@ -1104,30 +1104,29 @@ static GetSolidBaseNode getUncached() {
11041104 protected Object getSolid (Object type ,
11051105 @ Cached GetBaseClassNode getBaseClassNode ,
11061106 @ Cached ("createForceType()" ) ReadAttributeFromObjectNode readAttr ,
1107- @ Cached GetInternalObjectArrayNode getArrayNode ,
11081107 @ Cached BranchProfile typeIsNotBase ,
11091108 @ Cached BranchProfile hasBase ,
11101109 @ Cached BranchProfile hasNoBase ) {
1111- return solidBase (type , getBaseClassNode , PythonContext .get (this ), readAttr , getArrayNode , typeIsNotBase , hasBase ,
1110+ return solidBase (type , getBaseClassNode , PythonContext .get (this ), readAttr , typeIsNotBase , hasBase ,
11121111 hasNoBase , 0 );
11131112 }
11141113
11151114 @ TruffleBoundary
1116- protected Object solidBaseTB (Object type , GetBaseClassNode getBaseClassNode , PythonContext context , GetInternalObjectArrayNode getArrayNode , int depth ) {
1117- return solidBase (type , getBaseClassNode , context , ReadAttributeFromObjectNode .getUncachedForceType (), getArrayNode , BranchProfile .getUncached (),
1115+ protected Object solidBaseTB (Object type , GetBaseClassNode getBaseClassNode , PythonContext context , int depth ) {
1116+ return solidBase (type , getBaseClassNode , context , ReadAttributeFromObjectNode .getUncachedForceType (), BranchProfile .getUncached (),
11181117 BranchProfile .getUncached (), BranchProfile .getUncached (), depth );
11191118 }
11201119
11211120 protected Object solidBase (Object type , GetBaseClassNode getBaseClassNode , PythonContext context , ReadAttributeFromObjectNode readAttr ,
1122- GetInternalObjectArrayNode getArrayNode , BranchProfile typeIsNotBase , BranchProfile hasBase , BranchProfile hasNoBase , int depth ) {
1121+ BranchProfile typeIsNotBase , BranchProfile hasBase , BranchProfile hasNoBase , int depth ) {
11231122 CompilerAsserts .partialEvaluationConstant (depth );
11241123 Object base = getBaseClassNode .execute (type );
11251124 if (base != null ) {
11261125 hasBase .enter ();
11271126 if (depth > 3 ) {
1128- base = solidBaseTB (base , getBaseClassNode , context , getArrayNode , depth );
1127+ base = solidBaseTB (base , getBaseClassNode , context , depth );
11291128 } else {
1130- base = solidBase (base , getBaseClassNode , context , readAttr , getArrayNode , typeIsNotBase , hasBase ,
1129+ base = solidBase (base , getBaseClassNode , context , readAttr , typeIsNotBase , hasBase ,
11311130 hasNoBase , depth + 1 );
11321131 }
11331132 } else {
@@ -1141,18 +1140,16 @@ protected Object solidBase(Object type, GetBaseClassNode getBaseClassNode, Pytho
11411140 typeIsNotBase .enter ();
11421141
11431142 Object typeSlots = getSlotsFromType (type , readAttr );
1144- Object baseSlots = getSlotsFromType (base , readAttr );
1145- if (extraivars (type , base , typeSlots , baseSlots , getArrayNode )) {
1143+ if (extraivars (type , base , typeSlots )) {
11461144 return type ;
11471145 } else {
11481146 return base ;
11491147 }
11501148 }
11511149
11521150 @ TruffleBoundary
1153- private static boolean extraivars (Object type , Object base , Object typeSlots , Object baseSlots , GetInternalObjectArrayNode getArrayNode ) {
1154- if (typeSlots == null && baseSlots != null && length (((PSequence ) baseSlots ).getSequenceStorage (), getArrayNode ) != 0 ||
1155- baseSlots == null && typeSlots != null && length (((PSequence ) typeSlots ).getSequenceStorage (), getArrayNode ) != 0 ) {
1151+ private static boolean extraivars (Object type , Object base , Object typeSlots ) {
1152+ if (typeSlots != null && length (typeSlots ) != 0 ) {
11561153 return true ;
11571154 }
11581155 Object typeNewMethod = LookupAttributeInMRONode .lookup (type , __NEW__ , GetMroStorageNode .getUncached (), ReadAttributeFromObjectNode .getUncached (), true );
@@ -1161,18 +1158,26 @@ private static boolean extraivars(Object type, Object base, Object typeSlots, Ob
11611158 }
11621159
11631160 @ TruffleBoundary
1164- private static int length (SequenceStorage storage , GetInternalObjectArrayNode getArrayNode ) {
1165- int result = 0 ;
1166- int length = storage .length ();
1167- Object [] slots = getArrayNode .execute (storage );
1168- for (int i = 0 ; i < length ; i ++) {
1169- // omit __DICT__ and __WEAKREF__, they cause no class layout conflict
1170- // see also test_slts.py#test_no_bases_have_class_layout_conflict
1171- if (!(slots [i ].equals (__DICT__ ) || slots [i ].equals (__WEAKREF__ ))) {
1172- result ++;
1161+ private static int length (Object slotsObject ) {
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 = GetInternalObjectArrayNode .getUncached ().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+ }
11731178 }
1179+ return count ;
11741180 }
1175- return result ;
11761181 }
11771182
11781183 private static Object getSlotsFromType (Object type , ReadAttributeFromObjectNode readAttr ) {
0 commit comments