annotate graal/com.oracle.graal.truffle.test/sl/TestInlining.sl @ 18985:867058575979

Truffle: Improved support for "probing" AST nodes: - Node.isSafelyReplacaeableBy(Node) checks in advance if Node.replace(Node) would be unsafe (crash the VM). - Hoist Probe() from language imlementations into Node; now completely language agnostic. - Language implementations support probing by implementing Node.isInstrumentable() and Node.createWrapperNode() - Node.Probe() throws ProbeException (without side effects) if the probe fails. -- ProbeException contains an instance of ProbeFailure that diagnoses the failure in detail - Additional measures to prevent instrumentation from being applied to internal InstrumentationNodes. - Promote ProbeListener to top level interface and add a default implementation
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 27 Jan 2015 20:24:54 -0800
parents f735aa886cf6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17257
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * This tests that simple arithmetic gets inlined.
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 */
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 function add(a, b) {
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 return a + b;
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 }
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 function test() {
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 i = 0;
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 while (i < 100) {
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 i = add(i, 1);
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 }
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 return i;
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 }
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 function main() {
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 waitForOptimization(callUntilOptimized(test));
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 assertTrue(isInlined(test, test, add), "add is not inlined");
f735aa886cf6 Truffle: add new inlining tests; adapt tests for context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 }