mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:58:05 +00:00
[dart2wasm] Add intrinsics for bitwise operations on booleans.
Change-Id: Ic09545535c954d72615ca035ed1b133fada5d733 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275080 Reviewed-by: Aske Simon Christensen <askesc@google.com> Commit-Queue: Jackson Gardner <jacksongardner@google.com>
This commit is contained in:
parent
c15f248840
commit
1306a4c284
|
@ -26,6 +26,13 @@ class Intrinsifier {
|
|||
|
||||
static final Map<w.ValueType, Map<w.ValueType, Map<String, CodeGenCallback>>>
|
||||
binaryOperatorMap = {
|
||||
boolType: {
|
||||
boolType: {
|
||||
'|': (b) => b.i32_or(),
|
||||
'^': (b) => b.i32_xor(),
|
||||
'&': (b) => b.i32_and(),
|
||||
}
|
||||
},
|
||||
intType: {
|
||||
intType: {
|
||||
'+': (b) => b.i64_add(),
|
||||
|
|
|
@ -50,6 +50,23 @@ void test() {
|
|||
Expect.equals(0x00000000000000F0, 0xF00000000000000F << 4);
|
||||
Expect.equals(0xF00000000, 15 << 32);
|
||||
|
||||
// Test bitwise operations on booleans
|
||||
// This avoids frontend optimizations
|
||||
final trueValue = int.parse("1") == 1;
|
||||
final falseValue = int.parse("2") == 1;
|
||||
Expect.equals(trueValue, trueValue & trueValue);
|
||||
Expect.equals(falseValue, trueValue & falseValue);
|
||||
Expect.equals(falseValue, falseValue & trueValue);
|
||||
Expect.equals(falseValue, falseValue & falseValue);
|
||||
Expect.equals(trueValue, trueValue | trueValue);
|
||||
Expect.equals(trueValue, trueValue | falseValue);
|
||||
Expect.equals(trueValue, falseValue | trueValue);
|
||||
Expect.equals(falseValue, falseValue | falseValue);
|
||||
Expect.equals(falseValue, trueValue ^ trueValue);
|
||||
Expect.equals(trueValue, trueValue ^ falseValue);
|
||||
Expect.equals(trueValue, falseValue ^ trueValue);
|
||||
Expect.equals(falseValue, falseValue ^ falseValue);
|
||||
|
||||
testNegativeValueShifts();
|
||||
testPositiveValueShifts();
|
||||
testNoMaskingOfShiftCount();
|
||||
|
|
|
@ -52,6 +52,23 @@ void test() {
|
|||
Expect.equals(0x00000000000000F0, 0xF00000000000000F << 4);
|
||||
Expect.equals(0xF00000000, 15 << 32);
|
||||
|
||||
// Test bitwise operations on booleans
|
||||
// This avoids frontend optimizations
|
||||
final trueValue = int.parse("1") == 1;
|
||||
final falseValue = int.parse("2") == 1;
|
||||
Expect.equals(trueValue, trueValue & trueValue);
|
||||
Expect.equals(falseValue, trueValue & falseValue);
|
||||
Expect.equals(falseValue, falseValue & trueValue);
|
||||
Expect.equals(falseValue, falseValue & falseValue);
|
||||
Expect.equals(trueValue, trueValue | trueValue);
|
||||
Expect.equals(trueValue, trueValue | falseValue);
|
||||
Expect.equals(trueValue, falseValue | trueValue);
|
||||
Expect.equals(falseValue, falseValue | falseValue);
|
||||
Expect.equals(falseValue, trueValue ^ trueValue);
|
||||
Expect.equals(trueValue, trueValue ^ falseValue);
|
||||
Expect.equals(trueValue, falseValue ^ trueValue);
|
||||
Expect.equals(falseValue, falseValue ^ falseValue);
|
||||
|
||||
testNegativeValueShifts();
|
||||
testPositiveValueShifts();
|
||||
testNoMaskingOfShiftCount();
|
||||
|
|
Loading…
Reference in a new issue