@@ -1104,30 +1104,29 @@ static GetSolidBaseNode getUncached() {
1104
1104
protected Object getSolid (Object type ,
1105
1105
@ Cached GetBaseClassNode getBaseClassNode ,
1106
1106
@ Cached ("createForceType()" ) ReadAttributeFromObjectNode readAttr ,
1107
- @ Cached GetInternalObjectArrayNode getArrayNode ,
1108
1107
@ Cached BranchProfile typeIsNotBase ,
1109
1108
@ Cached BranchProfile hasBase ,
1110
1109
@ 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 ,
1112
1111
hasNoBase , 0 );
1113
1112
}
1114
1113
1115
1114
@ 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 (),
1118
1117
BranchProfile .getUncached (), BranchProfile .getUncached (), depth );
1119
1118
}
1120
1119
1121
1120
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 ) {
1123
1122
CompilerAsserts .partialEvaluationConstant (depth );
1124
1123
Object base = getBaseClassNode .execute (type );
1125
1124
if (base != null ) {
1126
1125
hasBase .enter ();
1127
1126
if (depth > 3 ) {
1128
- base = solidBaseTB (base , getBaseClassNode , context , getArrayNode , depth );
1127
+ base = solidBaseTB (base , getBaseClassNode , context , depth );
1129
1128
} else {
1130
- base = solidBase (base , getBaseClassNode , context , readAttr , getArrayNode , typeIsNotBase , hasBase ,
1129
+ base = solidBase (base , getBaseClassNode , context , readAttr , typeIsNotBase , hasBase ,
1131
1130
hasNoBase , depth + 1 );
1132
1131
}
1133
1132
} else {
@@ -1141,18 +1140,16 @@ protected Object solidBase(Object type, GetBaseClassNode getBaseClassNode, Pytho
1141
1140
typeIsNotBase .enter ();
1142
1141
1143
1142
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 )) {
1146
1144
return type ;
1147
1145
} else {
1148
1146
return base ;
1149
1147
}
1150
1148
}
1151
1149
1152
1150
@ 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 ) {
1156
1153
return true ;
1157
1154
}
1158
1155
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
1161
1158
}
1162
1159
1163
1160
@ 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
+ }
1173
1178
}
1179
+ return count ;
1174
1180
}
1175
- return result ;
1176
1181
}
1177
1182
1178
1183
private static Object getSlotsFromType (Object type , ReadAttributeFromObjectNode readAttr ) {
0 commit comments