Mercurial > hg > graal-jvmci-8
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle.test/sl/TestIsCompilationConstant1.sl Tue Oct 14 20:02:44 2014 +0200 @@ -0,0 +1,40 @@ + + +function testConstantValue1() { + return isCompilationConstant(42); +} + +function testConstantValue2() { + return isCompilationConstant(21 + 21); +} + +function testConstantSequence() { + 40; + return isCompilationConstant(42); +} + +function testConstantLocalVariable() { + x = 42; + return isCompilationConstant(x); +} + +function testNonConstantAdd() { + return isCompilationConstant(42 + "42"); +} + + +function main() { + callFunctionsWith("testConstant", harnessTrue); + callFunctionsWith("testNonConstant", harnessFalse); +} + +function harnessTrue(testFunction) { + callUntilOptimized(testFunction); + assertTrue(testFunction(), "test function " + testFunction + " is not constant"); +} + + +function harnessFalse(testFunction) { + callUntilOptimized(testFunction); + assertFalse(testFunction(), "test function " + testFunction + " is constant"); +} \ No newline at end of file