annotate graal/com.oracle.graal.truffle.test/sl/TestIsCompilationConstant1.sl @ 21400:33d3be2548d6

removed cache for intermediate graphs in ReplacementsImpl since graph building inlining is now used
author Doug Simon <doug.simon@oracle.com>
date Fri, 15 May 2015 13:45:06 +0200
parents 2834b4432586
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17444
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 function testConstantValue1() {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 return isCompilationConstant(42);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 }
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 function testConstantValue2() {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 return isCompilationConstant(21 + 21);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 }
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 function testConstantSequence() {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 40;
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 return isCompilationConstant(42);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 }
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 function testConstantLocalVariable() {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 x = 42;
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 return isCompilationConstant(x);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 }
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 function testNonConstantAdd() {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 return isCompilationConstant(42 + "42");
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 }
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26 function main() {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 callFunctionsWith("testConstant", harnessTrue);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 callFunctionsWith("testNonConstant", harnessFalse);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 }
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31 function harnessTrue(testFunction) {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32 callUntilOptimized(testFunction);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33 assertTrue(testFunction(), "test function " + testFunction + " is not constant");
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 }
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 function harnessFalse(testFunction) {
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 callUntilOptimized(testFunction);
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 assertFalse(testFunction(), "test function " + testFunction + " is constant");
2834b4432586 Truffle: introduce CompilerDirectives.isCompilationConstant.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40 }