Skip to content

Commit 296485e

Browse files
committed
Remove exported message PInt#hash, implement EconomicMapStorage#xor
1 parent 85c2ec7 commit 296485e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/EconomicMapStorage.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,15 @@ static HashingStorage diffGeneric(EconomicMapStorage self, HashingStorage other,
587587
}
588588
}
589589

590+
@ExportMessage
591+
public HashingStorage xor(HashingStorage other,
592+
@CachedLibrary("this") HashingStorageLibrary selfLib,
593+
@CachedLibrary(limit = "2") HashingStorageLibrary otherLib) {
594+
HashingStorage a = selfLib.diff(this, other);
595+
HashingStorage b = otherLib.diff(other, this);
596+
return selfLib.union(a, b);
597+
}
598+
590599
@Override
591600
@ExportMessage
592601
public HashingStorageIterable<Object> keys() {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ public HashingStorage union(HashingStorage other,
560560
}
561561

562562
@ExportMessage
563-
public HashingStorage diff(HashingStorage other,
563+
public HashingStorage diffWithState(HashingStorage other, @SuppressWarnings("unused") ThreadState state,
564564
@CachedLibrary("this") HashingStorageLibrary libSelf,
565565
@Exclusive @Cached DiffInjectNode diffNode) {
566566
HashingStorage newStore = EconomicMapStorage.create();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import com.oracle.truffle.api.library.CachedLibrary;
5656
import com.oracle.truffle.api.library.ExportLibrary;
5757
import com.oracle.truffle.api.library.ExportMessage;
58+
import com.oracle.truffle.api.library.ExportMessage.Ignore;
5859
import com.oracle.truffle.api.object.Shape;
5960

6061
@ExportLibrary(InteropLibrary.class)
@@ -563,16 +564,12 @@ public BigInteger add(PInt other) {
563564
return add(other.value);
564565
}
565566

566-
@ExportMessage
567+
// We cannot export it as a message, because it can be overridden!
568+
@Ignore
567569
public long hash() {
568570
return hashBigInteger(value);
569571
}
570572

571-
@ExportMessage
572-
public long hashWithState(@SuppressWarnings("unused") ThreadState state) {
573-
return hash();
574-
}
575-
576573
@TruffleBoundary
577574
public static long hashBigInteger(BigInteger i) {
578575
long h = i.remainder(BigInteger.valueOf(SysModuleBuiltins.HASH_MODULUS)).longValue();

0 commit comments

Comments
 (0)