view graal/com.oracle.graal.truffle.test/sl/TestInliningRecursive2.sl @ 19001:5a79fa76b489

Run eclipse format.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 28 Jan 2015 04:05:07 +0100
parents 04d6bb76cfb3
children e66a6f8d63e3
line wrap: on
line source

/* 
 * Tests that indirect recursions are not inlined.
 */
function fib(a) { 
    if (a == 2 || a == 1) {
        return 1;
    }
    return call(fib, a-1) + call(fib, a-2) + call(void, 0);
}

function call(f, a) {
    return f(a);
}

function void(a) {
    return a;
}

function test() {
    i = 0;
    sum = 0;
    while (i < 100) {
        sum = sum + fib(7);
        i = i + 1;
    }
    return sum;
}

function main() {
    callUntilOptimized(test);
    assertTrue(isInlined(test, test, fib), "not inlined: test -> fib");
    
    assertTrue(isInlined(test, fib, call), "not inlined: fib -> call");
    assertFalse(isInlined(test, call, fib), "inlined: call -> fib"); 
    assertTrue(isInlined(test, call, void), "inlined: call -> void");
    
}