view graal/com.oracle.graal.truffle.test/sl/TestIsCompilationConstant1.sl @ 19345:0d85421cb5d6

Truffle/Instrumentation: add missing support method for InstrumentationPartialEvaluatinoTest
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Thu, 12 Feb 2015 17:25:50 -0800
parents 2834b4432586
children
line wrap: on
line source



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");
}