Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // | |
| 5 // Test that type tests are not misoptimized. | |
| 6 // VMOptions=--optimization-counter-threshold=1000 --optimization-filter=IsAnInt | |
| 7 | |
| 8 main() { | |
| 9 train(); | |
| 10 if (IsAnInt("This is not an int")) throw "oops"; | |
| 11 } | |
| 12 | |
| 13 // Prime the IC with things that are and are not ints. | |
| 14 void train() { | |
| 15 int sum = 0; | |
| 16 for (int i = 0; i < 10000; i++) { | |
| 17 IsAnInt(42); // Smi - always goes first in the generated code. | |
| 18 IsAnInt(1 << 62); // Mint | |
|
Vyacheslav Egorov (Google)
2017/05/23 16:00:32
this is only mint on x64.
erikcorry
2017/05/24 13:37:16
Comment fixed.
| |
| 19 IsAnInt(1 << 62); | |
| 20 IsAnInt(4200000000000000000000000000000000000); // BigInt | |
| 21 IsAnInt(4200000000000000000000000000000000000); | |
| 22 // This one that is not an int goes last in the IC because it is called | |
| 23 // less frequently. | |
| 24 IsAnInt(4.2); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 int IsAnInt(Foo f) => f is int; | |
| OLD | NEW |