74
74
import com .oracle .graal .python .builtins .objects .type .PythonAbstractClass ;
75
75
import com .oracle .graal .python .builtins .objects .type .PythonBuiltinClass ;
76
76
import com .oracle .graal .python .builtins .objects .type .TypeNodes ;
77
- import com .oracle .graal .python .builtins .objects .type .TypeNodes .GetSuperClassNode ;
78
- import com .oracle .graal .python .builtins .objects .type .TypeNodesFactory .GetSuperClassNodeGen ;
77
+ import com .oracle .graal .python .builtins .objects .type .TypeNodes .GetBaseClassNode ;
78
+ import com .oracle .graal .python .builtins .objects .type .TypeNodesFactory .GetBaseClassNodeGen ;
79
79
import com .oracle .graal .python .nodes .BuiltinNames ;
80
80
import com .oracle .graal .python .nodes .ErrorMessages ;
81
81
import com .oracle .graal .python .nodes .PGuards ;
115
115
import com .oracle .truffle .api .nodes .UnexpectedResultException ;
116
116
import com .oracle .truffle .api .profiles .BranchProfile ;
117
117
import com .oracle .truffle .api .profiles .ConditionProfile ;
118
- import java .util .Arrays ;
119
118
120
119
@ CoreFunctions (extendClasses = PythonBuiltinClassType .PythonObject )
121
120
public class ObjectBuiltins extends PythonBuiltins {
@@ -133,7 +132,7 @@ abstract static class ClassNode extends PythonBinaryBuiltinNode {
133
132
@ Child private TypeNodes .GetNameNode getTypeNameNode ;
134
133
135
134
@ Child private LookupAttributeInMRONode lookupNewNode ;
136
- @ Child private GetSuperClassNode getBaseClassNode ;
135
+ @ Child private GetBaseClassNode getBaseClassNode ;
137
136
@ Child private GetDictStorageNode getDictStorageNode ;
138
137
@ Child private LookupAndCallBinaryNode getDictNode ;
139
138
@ Child private HashingStorageLibrary hashingStorageLib ;
@@ -189,17 +188,16 @@ private boolean compatibleForAssignment(VirtualFrame frame, Object self, PythonA
189
188
Object newBase = other ;
190
189
Object oldBase = self ;
191
190
192
- // TODO getBaseClassNode tends to fail with "get bestBase case not yet implemented"
193
- Object newParent = getSuperClassNode ().execute (newBase );
191
+ Object newParent = getBaseClassNode ().execute (frame , newBase );
194
192
while (newParent != null && compatibleWithBase (frame , newBase , newParent )) {
195
193
newBase = newParent ;
196
- newParent = getSuperClassNode ().execute (newBase );
194
+ newParent = getBaseClassNode ().execute (frame , newBase );
197
195
}
198
196
199
- Object oldParent = getSuperClassNode ().execute (oldBase );
197
+ Object oldParent = getBaseClassNode ().execute (frame , oldBase );
200
198
while (oldParent != null && compatibleWithBase (frame , oldBase , oldParent )) {
201
199
oldBase = oldParent ;
202
- oldParent = getSuperClassNode ().execute (oldBase );
200
+ oldParent = getBaseClassNode ().execute (frame , oldBase );
203
201
}
204
202
205
203
if (newBase != oldBase && (newParent != oldParent || !compareSlotsFromDict (frame , newBase , oldBase ))) {
@@ -257,7 +255,6 @@ private boolean compareSlotsFromDict(VirtualFrame frame, Object a, Object b) {
257
255
return compareSlots (a , b , aSlots , bSlots );
258
256
}
259
257
260
- @ TruffleBoundary
261
258
private boolean compareSlots (Object aType , Object bType , Object aSlotsArg , Object bSlotsArg ) {
262
259
Object aSlots = aSlotsArg ;
263
260
Object bSlots = bSlotsArg ;
@@ -267,24 +264,7 @@ private boolean compareSlots(Object aType, Object bType, Object aSlotsArg, Objec
267
264
}
268
265
269
266
if (aSlots != null && bSlots != null ) {
270
- Object [] aArray = getObjectArrayNode ().execute (aSlots );
271
- Object [] bArray = getObjectArrayNode ().execute (bSlots );
272
- if (bArray .length != aArray .length ) {
273
- return false ;
274
- }
275
- aArray = Arrays .copyOf (aArray , aArray .length );
276
- bArray = Arrays .copyOf (bArray , bArray .length );
277
- // what cpython does in same_slots_added() is a compare on a sorted slots list
278
- // ((PyHeapTypeObject *)a)->ht_slots which is populated in type_new() and
279
- // NOT the same like the unsorted __slots__ attribute.
280
- Arrays .sort (bArray );
281
- Arrays .sort (aArray );
282
- for (int i = 0 ; i < aArray .length ; i ++) {
283
- if (!aArray [i ].equals (bArray [i ])) {
284
- return false ;
285
- }
286
- }
287
- return true ;
267
+ return TypeNodes .compareSortedSlots (aSlots , bSlots , getObjectArrayNode ());
288
268
}
289
269
290
270
aSlots = getLookupSlots ().execute (aType );
@@ -355,10 +335,10 @@ private LookupAttributeInMRONode getLookupSlots() {
355
335
return lookupSlotsNode ;
356
336
}
357
337
358
- private GetSuperClassNode getSuperClassNode () {
338
+ private GetBaseClassNode getBaseClassNode () {
359
339
if (getBaseClassNode == null ) {
360
340
CompilerDirectives .transferToInterpreterAndInvalidate ();
361
- getBaseClassNode = insert (GetSuperClassNodeGen .create ());
341
+ getBaseClassNode = insert (GetBaseClassNodeGen .create ());
362
342
}
363
343
return getBaseClassNode ;
364
344
}
0 commit comments