annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/InstrumentationTest.java @ 18236:6a05fba906be

igv: fix coloring for 'Param' nodes (formerly 'Local')
author Bernhard Urban <bernhard.urban@jku.at>
date Tue, 04 Nov 2014 13:03:21 +0100
parents 5d16da2ca0c8
children e3c95cbbb50c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
1 /*
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
4 *
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
8 *
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
13 * accompanied this code).
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
14 *
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
18 *
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
21 * questions.
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
22 */
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
23 package com.oracle.truffle.api.test;
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
24
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
25 import java.util.*;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
26
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
27 import org.junit.*;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
28
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
29 import com.oracle.truffle.api.*;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
30 import com.oracle.truffle.api.frame.*;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
31 import com.oracle.truffle.api.instrument.*;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
32 import com.oracle.truffle.api.nodes.*;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
33 import com.oracle.truffle.api.source.*;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
34
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
35 /**
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
36 * <h3>AST Instrumentation</h3>
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
37 *
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
38 * Instrumentation allows the insertion into Truffle ASTs language-specific instances of
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
39 * {@link Wrapper} that propagate {@link ExecutionEvents} through a {@link Probe} to any instances
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
40 * of {@link Instrument} that might be attached to the particular probe by tools.
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
41 * <ol>
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
42 * <li>Creates a simple add AST</li>
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
43 * <li>Verifies its structure</li>
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
44 * <li>"Probes" the add node by adding a {@link Wrapper} and associated {@link Probe}</li>
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
45 * <li>Attaches a simple {@link Instrument} to the node via its {@link Probe}</li>
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
46 * <li>Verifies the structure of the probed AST</li>
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
47 * <li>Verifies the execution of the probed AST</li>
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
48 * <li>Verifies the results observed by the instrument.</li>
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
49 * </ol>
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
50 * To do these tests, several required classes have been implemented in their most basic form, only
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
51 * implementing the methods necessary for the tests to pass, with stubs elsewhere.
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
52 */
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
53 public class InstrumentationTest {
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
54
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
55 @Test
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
56 public void test() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
57 // Build a tree
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
58 TruffleRuntime runtime = Truffle.getRuntime();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
59 TestChildNode leftChild = new TestChildNode();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
60 TestChildNode rightChild = new TestChildNode();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
61 TestSourceSection sourceSection = new TestSourceSection();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
62 TestAddNode addNode = new TestAddNode(leftChild, rightChild, sourceSection);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
63 TestRootNode rootNode = new TestRootNode(addNode);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
64
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
65 // Have to create a call target before checking parent/child relationships
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
66 CallTarget target = runtime.createCallTarget(rootNode);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
67
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
68 // Check tree structure
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
69 Assert.assertEquals(addNode, leftChild.getParent());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
70 Assert.assertEquals(addNode, rightChild.getParent());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
71 Iterator<Node> iterator = addNode.getChildren().iterator();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
72 Assert.assertEquals(leftChild, iterator.next());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
73 Assert.assertEquals(rightChild, iterator.next());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
74 Assert.assertFalse(iterator.hasNext());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
75 Assert.assertEquals(rootNode, addNode.getParent());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
76 iterator = rootNode.getChildren().iterator();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
77 Assert.assertEquals(addNode, iterator.next());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
78 Assert.assertFalse(iterator.hasNext());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
79 Object result = target.call();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
80 Assert.assertEquals(42, result);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
81
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
82 // Create another call target, this time with the "probed" add node
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
83 TestExecutionContext context = new TestExecutionContext();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
84 TestWrapper wrapper = new TestWrapper(addNode, context);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
85 rootNode = new TestRootNode(wrapper);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
86 target = runtime.createCallTarget(rootNode);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
87
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
88 // Check the new tree structure
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
89 Assert.assertEquals(addNode, leftChild.getParent());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
90 Assert.assertEquals(addNode, rightChild.getParent());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
91 iterator = addNode.getChildren().iterator();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
92 Assert.assertEquals(leftChild, iterator.next());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
93 Assert.assertEquals(rightChild, iterator.next());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
94 Assert.assertFalse(iterator.hasNext());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
95 Assert.assertEquals(wrapper, addNode.getParent());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
96 iterator = wrapper.getChildren().iterator();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
97 Assert.assertEquals(addNode, iterator.next());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
98 Assert.assertFalse(iterator.hasNext());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
99 Assert.assertEquals(rootNode, wrapper.getParent());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
100 iterator = rootNode.getChildren().iterator();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
101 Assert.assertEquals(wrapper, iterator.next());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
102 Assert.assertFalse(iterator.hasNext());
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
103 result = target.call();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
104 Assert.assertEquals(42, result);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
105
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
106 // Create some instruments
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
107 final TestInstrument instrumentA = new TestInstrument();
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
108 final TestInstrument instrumentB = new TestInstrument();
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
109
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
110 wrapper.getProbe().addInstrument(instrumentA);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
111
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
112 result = target.call();
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
113 Assert.assertEquals(instrumentA.numInstrumentEnter, 1);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
114 Assert.assertEquals(instrumentA.numInstrumentLeave, 1);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
115 Assert.assertEquals(instrumentB.numInstrumentEnter, 0);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
116 Assert.assertEquals(instrumentB.numInstrumentLeave, 0);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
117 Assert.assertEquals(42, result);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
118
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
119 wrapper.getProbe().addInstrument(instrumentB);
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
120
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
121 result = target.call();
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
122 Assert.assertEquals(instrumentA.numInstrumentEnter, 2);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
123 Assert.assertEquals(instrumentA.numInstrumentLeave, 2);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
124 Assert.assertEquals(instrumentB.numInstrumentEnter, 1);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
125 Assert.assertEquals(instrumentB.numInstrumentLeave, 1);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
126 Assert.assertEquals(42, result);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
127
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
128 wrapper.getProbe().removeInstrument(instrumentA);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
129
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
130 result = target.call();
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
131 Assert.assertEquals(instrumentA.numInstrumentEnter, 2);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
132 Assert.assertEquals(instrumentA.numInstrumentLeave, 2);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
133 Assert.assertEquals(instrumentB.numInstrumentEnter, 2);
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
134 Assert.assertEquals(instrumentB.numInstrumentLeave, 2);
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
135 Assert.assertEquals(42, result);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
136
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
137 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
138
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
139 private class TestRootNode extends RootNode {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
140 @Child private RootNode child;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
141
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
142 public TestRootNode(RootNode child) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
143 super(null);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
144 this.child = child;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
145 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
146
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
147 @Override
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
148 public Object execute(VirtualFrame frame) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
149 return child.execute(frame);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
150 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
151 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
152
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
153 private class TestAddNode extends RootNode {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
154
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
155 @Child private TestChildNode left;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
156 @Child private TestChildNode right;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
157
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
158 public TestAddNode(TestChildNode left, TestChildNode right, TestSourceSection sourceSection) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
159 super(sourceSection);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
160 this.left = left;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
161 this.right = right;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
162 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
163
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
164 @Override
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
165 public Object execute(VirtualFrame frame) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
166 return left.execute() + right.execute();
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
167 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
168 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
169
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
170 private class TestChildNode extends Node {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
171
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
172 public TestChildNode() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
173 super(null);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
174 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
175
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
176 public int execute() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
177 return 21;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
178 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
179 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
180
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
181 /**
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
182 * The wrapper node class is usually language-specific and inherits from the language-specific
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
183 * subclass of {@link Node}, not {@RootNode}.
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
184 */
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
185 private class TestWrapper extends RootNode implements Wrapper {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
186 @Child private RootNode child;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
187 private Probe probe;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
188
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
189 public TestWrapper(RootNode child, ExecutionContext context) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
190 this.child = insert(child);
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16775
diff changeset
191 this.probe = context.createProbe(child.getSourceSection());
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
192 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
193
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
194 public Node getChild() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
195 return child;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
196 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
197
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
198 public Probe getProbe() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
199 return probe;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
200 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
201
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
202 @Override
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
203 public Object execute(VirtualFrame frame) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
204 probe.enter(child, frame);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
205 Object result;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
206
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
207 try {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
208 result = child.execute(frame);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
209 probe.leave(child, frame, result);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
210 } catch (Exception e) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
211 probe.leaveExceptional(child, frame, e);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
212 throw (e);
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
213 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
214 return result;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
215 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
216 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
217
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
218 /**
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
219 * An "empty" description of the source code that might correspond to a particular AST node. The
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
220 * instrumentation framework tracks probes that have been inserted by their source location,
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
221 * using this as a key.
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
222 */
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
223 private class TestSourceSection implements SourceSection {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
224
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
225 public Source getSource() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
226 return null;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
227 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
228
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
229 public int getStartLine() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
230 return 0;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
231 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
232
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
233 public LineLocation getLineLocation() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
234 return null;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
235 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
236
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
237 public int getStartColumn() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
238 return 0;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
239 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
240
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
241 public int getCharIndex() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
242 return 0;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
243 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
244
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
245 public int getCharLength() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
246 return 0;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
247 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
248
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
249 public int getCharEndIndex() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
250 return 0;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
251 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
252
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
253 public String getIdentifier() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
254 return null;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
255 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
256
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
257 public String getCode() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
258 return null;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
259 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
260
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
261 public String getShortDescription() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
262 return null;
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
263 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
264
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
265 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
266
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
267 private class TestExecutionContext extends ExecutionContext {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
268
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
269 @Override
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
270 public String getLanguageShortName() {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
271 return "test";
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
272 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
273
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
274 @Override
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
275 protected void setSourceCallback(SourceCallback sourceCallback) {
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
276 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
277
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
278 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
279
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
280 private class TestInstrument extends Instrument {
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
281
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
282 public int numInstrumentEnter = 0;
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
283 public int numInstrumentLeave = 0;
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
284
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
285 @Override
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
286 public void enter(Node astNode, VirtualFrame frame) {
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
287 numInstrumentEnter++;
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
288 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
289
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
290 @Override
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
291 public void leave(Node astNode, VirtualFrame frame, Object result) {
16775
8c606e8053b8 Truffle/API test: additional documentation on the new instrumentation tests; move into project with other tests and add an entry in package-info.java
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16702
diff changeset
292 numInstrumentLeave++;
16702
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
293 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
294 }
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
295
2a5ec181dad4 SL: Added instrumentation testing
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff changeset
296 }