forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftl-polymorphic-bitor.js
52 lines (46 loc) · 1.19 KB
/
ftl-polymorphic-bitor.js
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
//@ runFTLNoCJIT
var o1 = {
i: 0,
valueOf: function() { return this.i; }
};
result = 0;
function foo(a, b) {
var result = 0;
for (var j = 0; j < 10; j++) {
var temp;
if (a > b)
temp = a | b;
else
temp = b | 1;
result += temp;
}
// Busy work just to allow the DFG and FTL to optimize this out. If the above causes
// us to speculation fail out to the baseline, this busy work will take a lot longer
// to run.
// This loop below also gets the DFG to compile this function sooner.
var origResult = result;
for (var i = 1; i < 1000; i++)
result = result | i;
result = origResult > result ? origResult : result;
return result;
}
noInline(foo);
var iterations;
var expectedResult;
if (this.window) {
// The layout test doesn't like too many iterations and may time out.
iterations = 10000;
expectedResult = 505700591;
} else {
iterations = 100000;
expectedResult = 50056912223;
}
for (var i = 0; i <= iterations; i++) {
o1.i = i;
if (i % 2)
result += foo(o1, 10);
else
result += foo(i, 10);
}
if (result != expectedResult)
throw "Bad result: " + result;