Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ priorities and future plans.

## Work in progress

- Avoid redundant modular masking of already unsigned 64-bit bitwise values,
improving general bitwise-heavy workloads such as Life.

- Restore `local` compatibility for tied hash and array elements, sparse
arrays, magic stashes, implicit `$_` foreach aliases (including early
return), and localized regex captures on both execution backends.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ public class BitwiseOperators {
private static final BigInteger UV_MASK = BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE);

private static BigInteger unsignedValue(RuntimeScalar scalar) {
return scalar.getBigint().and(UV_MASK);
BigInteger value = scalar.getBigint();
// Numeric bitwise operations are modulo 2^64. Their own results are
// already stored in that range, so avoid rebuilding BigInteger's
// backing array just to apply the same mask on the next operation.
if (value.signum() >= 0 && value.bitLength() <= 64) {
return value;
}
return value.and(UV_MASK);
}

private static RuntimeScalar unsignedResult(BigInteger value) {
if (value.signum() >= 0 && value.bitLength() <= 64) {
return new RuntimeScalar(value);
}
return new RuntimeScalar(value.and(UV_MASK));
}

Expand Down
Loading