blob: b3161be497040e07caaaeca194829c887de21b67 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7// -----------------------------------------------------------------------------
8
9function SmiTaggingCanOverflow(x) {
10 x = x | 0;
11 if (x == 0) return;
12 return x;
13}
14
15SmiTaggingCanOverflow(2147483647);
16SmiTaggingCanOverflow(2147483647);
17%OptimizeFunctionOnNextCall(SmiTaggingCanOverflow);
18assertEquals(2147483647, SmiTaggingCanOverflow(2147483647));
19
20// -----------------------------------------------------------------------------
21
22function ModILeftCanBeNegative() {
23 var x = 0;
24 for (var i = -1; i < 0; ++i) x = i % 2;
25 return x;
26}
27
28ModILeftCanBeNegative();
29%OptimizeFunctionOnNextCall(ModILeftCanBeNegative);
30assertEquals(-1, ModILeftCanBeNegative());
31
32// -----------------------------------------------------------------------------
33
34function ModIRightCanBeZero() {
35 var x = 0;
36 for (var i = -1; i <= 0; ++i) x = (2 % i) | 0;
37 return x;
38}
39
40ModIRightCanBeZero();
41%OptimizeFunctionOnNextCall(ModIRightCanBeZero);
42ModIRightCanBeZero();