Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.graal.truffle.test/sl/TestIsCompilationConstant1.sl @ 17444:2834b4432586
Truffle: introduce CompilerDirectives.isCompilationConstant.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 14 Oct 2014 20:02:44 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17443:90c6a996f9cd | 17444:2834b4432586 |
---|---|
1 | |
2 | |
3 function testConstantValue1() { | |
4 return isCompilationConstant(42); | |
5 } | |
6 | |
7 function testConstantValue2() { | |
8 return isCompilationConstant(21 + 21); | |
9 } | |
10 | |
11 function testConstantSequence() { | |
12 40; | |
13 return isCompilationConstant(42); | |
14 } | |
15 | |
16 function testConstantLocalVariable() { | |
17 x = 42; | |
18 return isCompilationConstant(x); | |
19 } | |
20 | |
21 function testNonConstantAdd() { | |
22 return isCompilationConstant(42 + "42"); | |
23 } | |
24 | |
25 | |
26 function main() { | |
27 callFunctionsWith("testConstant", harnessTrue); | |
28 callFunctionsWith("testNonConstant", harnessFalse); | |
29 } | |
30 | |
31 function harnessTrue(testFunction) { | |
32 callUntilOptimized(testFunction); | |
33 assertTrue(testFunction(), "test function " + testFunction + " is not constant"); | |
34 } | |
35 | |
36 | |
37 function harnessFalse(testFunction) { | |
38 callUntilOptimized(testFunction); | |
39 assertFalse(testFunction(), "test function " + testFunction + " is constant"); | |
40 } |