Mercurial > hg > truffle
annotate graal/com.oracle.graal.truffle.test/sl/TestInliningRecursive1.sl @ 18913:51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 20 Jan 2015 16:40:45 +0100 |
parents | 04d6bb76cfb3 |
children | e66a6f8d63e3 |
rev | line source |
---|---|
17257
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Test recursive calls do not get inlined and do not crash. |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 */ |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 function fib(a) { |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 if (a == 2 || a == 1) { |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 return 1; |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 } |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 return fib(a-1) + fib(a-2); |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 } |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 function test() { |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 i = 0; |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 sum = 0; |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 while (i < 100) { |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 sum = sum + fib(7); |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 i = i + 1; |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 } |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 return sum; |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 } |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 function main() { |
17405
04d6bb76cfb3
Truffle: update callUntilOptimized to wait for the compilation and call it once optimized.
Christian Humer <christian.humer@gmail.com>
parents:
17257
diff
changeset
|
22 callUntilOptimized(test); |
17257
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 assertTrue(isInlined(test, test, fib), "fib is not inlined"); |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 assertFalse(isInlined(test, fib, fib), "fib -> fib is not inlined"); |
f735aa886cf6
Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 } |