Skip to content

Commit ec73039

Browse files
committed
Fix calculation of basicsize/weaklistoffset
1 parent 8f853c3 commit ec73039

File tree

1 file changed

+12
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+12
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,15 @@ public static long lookupNativeI64MemberInMRO(Object cls, CFields nativeMemberNa
953953
attr = ReadAttributeFromObjectNode.getUncachedForceType().execute(mroCls, CompilerDirectives.castExact(managedMemberName, TruffleString.class));
954954
}
955955
if (attr != NO_VALUE) {
956-
return indexedSlotsSize + PyNumberAsSizeNode.executeExactUncached(attr);
956+
return PyNumberAsSizeNode.executeExactUncached(attr);
957+
} else if (indexedSlotsSize != 0) {
958+
// managed class with __slots__, but no precomputed
959+
// basicsize/dictoffset/weaklistoffset
960+
break;
957961
}
958962
} else {
959963
assert PGuards.isNativeClass(mroCls) : "invalid class inheritance structure; expected native class";
960-
return indexedSlotsSize + CStructAccess.ReadI64Node.getUncached().readFromObj((PythonNativeClass) mroCls, nativeMemberName);
964+
return CStructAccess.ReadI64Node.getUncached().readFromObj((PythonNativeClass) mroCls, nativeMemberName);
961965
}
962966
}
963967
// return the value from PyBaseObject - assumed to be 0 for vectorcall_offset
@@ -1000,11 +1004,15 @@ static long doSingleContext(Object cls, CFields nativeMember, HiddenAttr managed
10001004
} else if (PGuards.isManagedClass(current)) {
10011005
Object attr = readAttrNode.execute(inliningTarget, (PythonObject) current, managedMemberName, null);
10021006
if (attr != null) {
1003-
return indexedSlotsSize + asSizeNode.executeExact(null, inliningTarget, attr);
1007+
return asSizeNode.executeExact(null, inliningTarget, attr);
1008+
} else if (indexedSlotsSize != 0) {
1009+
// managed class with __slots__, but no precomputed
1010+
// basicsize/dictoffset/weaklistoffset
1011+
break;
10041012
}
10051013
} else {
10061014
assert PGuards.isNativeClass(current) : "invalid class inheritance structure; expected native class";
1007-
return indexedSlotsSize + getTypeMemberNode.readFromObj((PythonNativeClass) current, nativeMember);
1015+
return getTypeMemberNode.readFromObj((PythonNativeClass) current, nativeMember);
10081016
}
10091017
current = getBaseClassNode.execute(inliningTarget, current);
10101018
} while (current != null);

0 commit comments

Comments
 (0)