Skip to content

Commit 699c732

Browse files
committed
Merge branch 'labs-numpy-hpy-port'
2 parents 1a7d36e + bed8573 commit 699c732

File tree

1 file changed

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

1 file changed

+8
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static final class HPyProperty {
490490
this(key, value, null);
491491
}
492492

493-
public void write(WriteAttributeToObjectNode writeAttributeToObjectNode, ReadAttributeFromObjectNode readAttributeFromObjectNode, Object enclosingType) {
493+
void write(WriteAttributeToObjectNode writeAttributeToObjectNode, ReadAttributeFromObjectNode readAttributeFromObjectNode, Object enclosingType) {
494494
for (HPyProperty prop = this; prop != null; prop = prop.next) {
495495
/*
496496
* Do not overwrite existing attributes. Reason: Different slots may map to the same
@@ -502,11 +502,15 @@ public void write(WriteAttributeToObjectNode writeAttributeToObjectNode, ReadAtt
502502
* that we cannot easily do the same since we have two separate sets of slots: HPy
503503
* slots and legacy slots. Right now, the HPy slots have precedence.
504504
*/
505-
if (readAttributeFromObjectNode.execute(enclosingType, prop.key) == PNone.NO_VALUE) {
506-
writeAttributeToObjectNode.execute(enclosingType, prop.key, prop.value);
505+
if (!keyExists(readAttributeFromObjectNode, enclosingType, key)) {
506+
writeAttributeToObjectNode.execute(enclosingType, key, value);
507507
}
508508
}
509509
}
510+
511+
static boolean keyExists(ReadAttributeFromObjectNode readAttributeFromObjectNode, Object enclosingType, Object key) {
512+
return readAttributeFromObjectNode.execute(enclosingType, key) != PNone.NO_VALUE;
513+
}
510514
}
511515

512516
@GenerateUncached
@@ -944,7 +948,7 @@ static HPyProperty doIt(GraalHPyContext context, Object enclosingType, Object sl
944948
default:
945949
// this is the generic slot case
946950
String attributeKey = slot.getAttributeKey();
947-
if (attributeKey != null) {
951+
if (attributeKey != null && !HPyProperty.keyExists(readAttributeToObjectNode, enclosingType, attributeKey)) {
948952
Object pfuncPtr = callHelperFunctionNode.call(context, GraalHPyNativeSymbol.GRAAL_HPY_LEGACY_SLOT_GET_PFUNC, slotDef);
949953
/*
950954
* TODO(fa): Properly determine if 'pfuncPtr' is a native function pointer

0 commit comments

Comments
 (0)