summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/jaeger/recompile/incdec.js
blob: 93786ba34971ac670310c8f72c5deb825ea0c5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* Handle recompilation on overflow of inc/dec operations. */

function local()
{
  var j = 0x7ffffff0;
  for (var i = 0; i < 100; i++)
    j++;
  assertEq(j, 2147483732);
}
local();

function olocal()
{
  var j = 0x7ffffff0;
  for (var i = 0; i < 100; i++) {
    if (j++ == 5000)
      break;
  }
  assertEq(j, 2147483732);
}
olocal();

function arg(j)
{
  for (var i = 0; i < 100; i++)
    j++;
  assertEq(j, 2147483732);
}
arg(0x7ffffff0);

function oarg(j)
{
  for (var i = 0; i < 100; i++) {
    if (j++ == 5000)
      break;
  }
  assertEq(j, 2147483732);
}
oarg(0x7ffffff0);

// basic global inc/dec correctness
var x = 1.23;
x = x--;
x = x++;
x = ++x;
x = --x;
assertEq(x, 1.23);

var g = 0x7ffffff0;
function glob()
{
  for (var i = 0; i < 100; i++)
    g++;
  assertEq(g, 2147483732);
}
glob();

function gname()
{
  n = 0x7ffffff0;
  for (var i = 0; i < 100; i++)
    n++;
  assertEq(n, 2147483732);
}
gname();

function prop()
{
  var v = {f: 0x7ffffff0};
  for (var i = 0; i < 100; i++)
    v.f++;
  assertEq(v.f, 2147483732);
}
prop();

function elem(v, f)
{
  for (var i = 0; i < 100; i++)
    v[f]++;
  assertEq(v.f, 2147483732);
}
elem({f: 0x7ffffff0}, "f");

function name()
{
  var v = 0x7ffffff0;
  var i;
  eval("for (i = 0; i < 100; i++) v++");
  assertEq(v + 10, 2147483742);
}
name();