mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 07:19:58 +00:00
b6276eb3d5
* Enable --limit-ints-to-64-bits for CFE when it is used to generate kernel for VM as CFE relies on int.parse being able to parse correct literals and reject incorrect. * Pass --limit-ints-to-64-bits to gen_kernel via environment variable to support batch mode compilation. Issue: https://github.com/dart-lang/sdk/issues/31339 Re-landing https://dart-review.googlesource.com/29941 with the fix: * Use checked-in SDK to avoid timeouts on SIMARM bots. Checked-in SDK was updated and now includes necessary fixes. Change-Id: I4a5a99455b60204572f3d619d7eb374035b03e40 Reviewed-on: https://dart-review.googlesource.com/30640 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
79 lines
2.8 KiB
Dart
79 lines
2.8 KiB
Dart
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
//
|
|
// Dart test program for testing left shifts of a constant.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
shiftLeft0(c) => 0 << c;
|
|
shiftLeft1(c) => 1 << c;
|
|
shiftLeft8448(c) => 8448 << c;
|
|
|
|
shiftLeftNeg1(c) => -1 << c;
|
|
shiftLeftNeg8448(c) => -8448 << c;
|
|
|
|
main() {
|
|
// Optimize shifts.
|
|
for (int i = 0; i < 6000; i++) {
|
|
shiftLeft1(2);
|
|
shiftLeft0(2);
|
|
shiftLeft8448(2);
|
|
shiftLeftNeg1(2);
|
|
shiftLeftNeg8448(2);
|
|
}
|
|
for (int i = 0; i < 80; i++) {
|
|
Expect.equals(0, shiftLeft0(i));
|
|
}
|
|
// Exceptions.
|
|
Expect.throws(() => shiftLeft0(-1));
|
|
|
|
Expect.equals(1, shiftLeft1(0));
|
|
Expect.equals(128, shiftLeft1(7));
|
|
Expect.equals(536870912, shiftLeft1(29));
|
|
// Deoptimize on 32-bit.
|
|
Expect.equals(1073741824, shiftLeft1(30));
|
|
Expect.equals(2147483648, shiftLeft1(31));
|
|
Expect.equals(1152921504606846976, shiftLeft1(60));
|
|
Expect.equals(2305843009213693952, shiftLeft1(61));
|
|
// Deoptimize on 64 bits.
|
|
Expect.equals(4611686018427387904, shiftLeft1(62));
|
|
Expect.equals(-9223372036854775808, shiftLeft1(63));
|
|
|
|
Expect.equals(8448, shiftLeft8448(0));
|
|
Expect.equals(1081344, shiftLeft8448(7));
|
|
Expect.equals(553648128, shiftLeft8448(16));
|
|
// Deoptimize on 32-bit.
|
|
Expect.equals(1107296256, shiftLeft8448(17));
|
|
Expect.equals(2214592512, shiftLeft8448(18));
|
|
Expect.equals(1188950301625810944, shiftLeft8448(47));
|
|
Expect.equals(2377900603251621888, shiftLeft8448(48));
|
|
// Deoptimize on 64 bits.
|
|
Expect.equals(4755801206503243776, shiftLeft8448(49));
|
|
Expect.equals(-8935141660703064064, shiftLeft8448(50));
|
|
|
|
Expect.equals(-1, shiftLeftNeg1(0));
|
|
Expect.equals(-128, shiftLeftNeg1(7));
|
|
Expect.equals(-536870912, shiftLeftNeg1(29));
|
|
// Deoptimize on 32-bit.
|
|
Expect.equals(-1073741824, shiftLeftNeg1(30));
|
|
Expect.equals(-2147483648, shiftLeftNeg1(31));
|
|
Expect.equals(-1152921504606846976, shiftLeftNeg1(60));
|
|
Expect.equals(-2305843009213693952, shiftLeftNeg1(61));
|
|
// Deoptimize on 64 bits.
|
|
Expect.equals(-4611686018427387904, shiftLeftNeg1(62));
|
|
Expect.equals(-9223372036854775808, shiftLeftNeg1(63));
|
|
|
|
Expect.equals(-8448, shiftLeftNeg8448(0));
|
|
Expect.equals(-1081344, shiftLeftNeg8448(7));
|
|
Expect.equals(-553648128, shiftLeftNeg8448(16));
|
|
// Deoptimize on 32-bit.
|
|
Expect.equals(-1107296256, shiftLeftNeg8448(17));
|
|
Expect.equals(-2214592512, shiftLeftNeg8448(18));
|
|
Expect.equals(-1188950301625810944, shiftLeftNeg8448(47));
|
|
Expect.equals(-2377900603251621888, shiftLeftNeg8448(48));
|
|
// Deoptimize on 64 bits.
|
|
Expect.equals(-4755801206503243776, shiftLeftNeg8448(49));
|
|
Expect.equals(8935141660703064064, shiftLeftNeg8448(50));
|
|
}
|