annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java @ 20106:2e3cc2a27711

Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 31 Mar 2015 19:01:07 -0700
parents 1d6a7ea5de59
children e7ece52e1ff3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
1 /*
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
4 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
8 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
13 * accompanied this code).
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
14 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
18 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
21 * questions.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
22 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
23 package com.oracle.truffle.api.test.instrument;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
24
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
25 import static org.junit.Assert.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
26
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
27 import java.util.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
28
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
29 import org.junit.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
30
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
31 import com.oracle.truffle.api.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
32 import com.oracle.truffle.api.frame.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
33 import com.oracle.truffle.api.instrument.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
34 import com.oracle.truffle.api.instrument.ProbeFailure.Reason;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
35 import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
36 import com.oracle.truffle.api.instrument.impl.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
37 import com.oracle.truffle.api.nodes.*;
20106
2e3cc2a27711 Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19869
diff changeset
38 import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestAdditionNode;
2e3cc2a27711 Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19869
diff changeset
39 import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestLanguageNode;
2e3cc2a27711 Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19869
diff changeset
40 import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestLanguageWrapperNode;
2e3cc2a27711 Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19869
diff changeset
41 import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestRootNode;
2e3cc2a27711 Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19869
diff changeset
42 import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestValueNode;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
43
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
44 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
45 * <h3>AST Instrumentation</h3>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
46 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
47 * Instrumentation allows the insertion into Truffle ASTs language-specific instances of
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
48 * {@link WrapperNode} that propagate execution events through a {@link Probe} to any instances of
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
49 * {@link Instrument} that might be attached to the particular probe by tools.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
50 * <ol>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
51 * <li>Creates a simple add AST</li>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
52 * <li>Verifies its structure</li>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
53 * <li>"Probes" the add node by adding a {@link WrapperNode} and associated {@link Probe}</li>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
54 * <li>Attaches a simple {@link Instrument} to the node via the Probe's {@link ProbeNode}</li>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
55 * <li>Verifies the structure of the probed AST</li>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
56 * <li>Verifies the execution of the probed AST</li>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
57 * <li>Verifies the results observed by the instrument.</li>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
58 * </ol>
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
59 * To do these tests, several required classes have been implemented in their most basic form, only
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
60 * implementing the methods necessary for the tests to pass, with stubs elsewhere.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
61 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
62 public class InstrumentationTest {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
63
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
64 private static final SyntaxTag ADD_TAG = new SyntaxTag() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
65
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
66 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
67 public String name() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
68 return "Addition";
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
69 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
70
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
71 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
72 public String getDescription() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
73 return "Test Language Addition Node";
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
74 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
75 };
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
76
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
77 private static final SyntaxTag VALUE_TAG = new SyntaxTag() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
78
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
79 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
80 public String name() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
81 return "Value";
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
82 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
83
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
84 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
85 public String getDescription() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
86 return "Test Language Value Node";
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
87 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
88 };
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
89
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
90 @Test
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
91 public void testInstrumentationStructure() {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
92 // Create a simple addition AST
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
93 final TruffleRuntime runtime = Truffle.getRuntime();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
94 final TestValueNode leftValueNode = new TestValueNode(6);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
95 final TestValueNode rightValueNode = new TestValueNode(7);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
96 final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
97
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
98 try {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
99 addNode.probe();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
100 } catch (ProbeException e) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
101 assertEquals(e.getFailure().getReason(), Reason.NO_PARENT);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
102 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
103 final TestRootNode rootNode = new TestRootNode(addNode);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
104
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
105 // Creating a call target sets the parent pointers in this tree and is necessary prior to
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
106 // checking any parent/child relationships
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
107 final CallTarget callTarget1 = runtime.createCallTarget(rootNode);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
108
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
109 // Check the tree structure
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
110 assertEquals(addNode, leftValueNode.getParent());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
111 assertEquals(addNode, rightValueNode.getParent());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
112 Iterator<Node> iterator = addNode.getChildren().iterator();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
113 assertEquals(leftValueNode, iterator.next());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
114 assertEquals(rightValueNode, iterator.next());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
115 assertFalse(iterator.hasNext());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
116 assertEquals(rootNode, addNode.getParent());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
117 iterator = rootNode.getChildren().iterator();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
118 assertEquals(addNode, iterator.next());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
119 assertFalse(iterator.hasNext());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
120
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
121 // Ensure it executes correctly
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
122 assertEquals(13, callTarget1.call());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
123
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
124 // Probe the addition node
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
125 addNode.probe();
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
126
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
127 // Check the modified tree structure
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
128 assertEquals(addNode, leftValueNode.getParent());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
129 assertEquals(addNode, rightValueNode.getParent());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
130 iterator = addNode.getChildren().iterator();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
131 assertEquals(leftValueNode, iterator.next());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
132 assertEquals(rightValueNode, iterator.next());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
133 assertFalse(iterator.hasNext());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
134
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
135 // Ensure there's a WrapperNode correctly inserted into the AST
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
136 iterator = rootNode.getChildren().iterator();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
137 Node wrapperNode = iterator.next();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
138 assertTrue(wrapperNode instanceof TestLanguageWrapperNode);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
139 assertFalse(iterator.hasNext());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
140 assertEquals(rootNode, wrapperNode.getParent());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
141
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
142 // Check that the WrapperNode has both the probe and the wrapped node as children
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
143 iterator = wrapperNode.getChildren().iterator();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
144 assertEquals(addNode, iterator.next());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
145 ProbeNode probeNode = (ProbeNode) iterator.next();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
146 assertTrue(probeNode.getProbe() != null);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
147 assertFalse(iterator.hasNext());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
148
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
149 // Check that you can't probe the WrapperNodes
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
150 TestLanguageWrapperNode wrapper = (TestLanguageWrapperNode) wrapperNode;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
151 try {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
152 wrapper.probe();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
153 fail();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
154 } catch (ProbeException e) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
155 assertEquals(e.getFailure().getReason(), Reason.WRAPPER_NODE);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
156 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
157
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
158 // Check that the "probed" AST still executes correctly
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
159 assertEquals(13, callTarget1.call());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
160
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
161 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
162
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
163 @Test
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
164 public void testListeners() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
165
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
166 // Create a simple addition AST
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
167 final TruffleRuntime runtime = Truffle.getRuntime();
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
168 final TestValueNode leftValueNode = new TestValueNode(6);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
169 final TestValueNode rightValueNode = new TestValueNode(7);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
170 final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
171 final TestRootNode rootNode = new TestRootNode(addNode);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
172
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
173 // Creating a call target sets the parent pointers in this tree and is necessary prior to
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
174 // checking any parent/child relationships
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
175 final CallTarget callTarget = runtime.createCallTarget(rootNode);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
176 // Probe the addition node
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
177 final Probe probe = addNode.probe();
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
178
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
179 // Check instrumentation with the simplest kind of counters.
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
180 // They should all be removed when the check is finished.
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
181 checkCounters(probe, callTarget, rootNode, new TestInstrumentCounter(), new TestInstrumentCounter(), new TestInstrumentCounter());
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
182
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
183 // Now try with the more complex flavor of listener
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
184 checkCounters(probe, callTarget, rootNode, new TestASTInstrumentCounter(), new TestASTInstrumentCounter(), new TestASTInstrumentCounter());
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
185
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
186 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
187
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
188 private static void checkCounters(Probe probe, CallTarget callTarget, RootNode rootNode, TestCounter counterA, TestCounter counterB, TestCounter counterC) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
189
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
190 // Attach a counting instrument to the probe
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
191 counterA.attach(probe);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
192
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
193 // Attach a second counting instrument to the probe
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
194 counterB.attach(probe);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
195
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
196 // Run it again and check that the two instruments are working
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
197 assertEquals(13, callTarget.call());
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
198 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
199 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
200 assertEquals(counterB.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
201 assertEquals(counterB.leaveCount(), 1);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
202
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
203 // Remove counterA
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
204 counterA.dispose();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
205
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
206 // Run it again and check that instrument B is still working but not A
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
207 assertEquals(13, callTarget.call());
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
208 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
209 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
210 assertEquals(counterB.enterCount(), 2);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
211 assertEquals(counterB.leaveCount(), 2);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
212
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
213 // Simulate a split by cloning the AST
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
214 final CallTarget callTarget2 = Truffle.getRuntime().createCallTarget((TestRootNode) rootNode.copy());
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
215 // Run the clone and check that instrument B is still working but not A
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
216 assertEquals(13, callTarget2.call());
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
217 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
218 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
219 assertEquals(counterB.enterCount(), 3);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
220 assertEquals(counterB.leaveCount(), 3);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
221
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
222 // Run the original and check that instrument B is still working but not A
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
223 assertEquals(13, callTarget2.call());
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
224 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
225 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
226 assertEquals(counterB.enterCount(), 4);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
227 assertEquals(counterB.leaveCount(), 4);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
228
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
229 // Attach a second instrument to the probe
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
230 counterC.attach(probe);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
231
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
232 // Run the original and check that instruments B,C working but not A
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
233 assertEquals(13, callTarget.call());
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
234 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
235 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
236 assertEquals(counterB.enterCount(), 5);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
237 assertEquals(counterB.leaveCount(), 5);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
238 assertEquals(counterC.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
239 assertEquals(counterC.leaveCount(), 1);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
240
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
241 // Run the clone and check that instruments B,C working but not A
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
242 assertEquals(13, callTarget2.call());
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
243 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
244 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
245 assertEquals(counterB.enterCount(), 6);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
246 assertEquals(counterB.leaveCount(), 6);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
247 assertEquals(counterC.enterCount(), 2);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
248 assertEquals(counterC.leaveCount(), 2);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
249
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
250 // Remove instrumentC
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
251 counterC.dispose();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
252
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
253 // Run the original and check that instrument B working but not A,C
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
254 assertEquals(13, callTarget.call());
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
255 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
256 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
257 assertEquals(counterB.enterCount(), 7);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
258 assertEquals(counterB.leaveCount(), 7);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
259 assertEquals(counterC.enterCount(), 2);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
260 assertEquals(counterC.leaveCount(), 2);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
261
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
262 // Run the clone and check that instrument B working but not A,C
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
263 assertEquals(13, callTarget2.call());
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
264 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
265 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
266 assertEquals(counterB.enterCount(), 8);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
267 assertEquals(counterB.leaveCount(), 8);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
268 assertEquals(counterC.enterCount(), 2);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
269 assertEquals(counterC.leaveCount(), 2);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
270
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
271 // Remove instrumentB
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
272 counterB.dispose();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
273
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
274 // Run both the original and clone, check that no instruments working
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
275 assertEquals(13, callTarget.call());
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
276 assertEquals(13, callTarget2.call());
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
277 assertEquals(counterA.enterCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
278 assertEquals(counterA.leaveCount(), 1);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
279 assertEquals(counterB.enterCount(), 8);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
280 assertEquals(counterB.leaveCount(), 8);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
281 assertEquals(counterC.enterCount(), 2);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
282 assertEquals(counterC.leaveCount(), 2);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
283
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
284 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
285
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
286 @Test
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
287 public void testTagging() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
288
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
289 // Applies appropriate tags
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
290 final TestASTProber astProber = new TestASTProber();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
291 Probe.registerASTProber(astProber);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
292
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
293 // Listens for probes and tags being added
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
294 final TestProbeListener probeListener = new TestProbeListener();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
295 Probe.addProbeListener(probeListener);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
296
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
297 // Counts all entries to all instances of addition nodes
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
298 final TestMultiCounter additionCounter = new TestMultiCounter();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
299
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
300 // Counts all entries to all instances of value nodes
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
301 final TestMultiCounter valueCounter = new TestMultiCounter();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
302
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
303 // Create a simple addition AST
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
304 final TruffleRuntime runtime = Truffle.getRuntime();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
305 final TestValueNode leftValueNode = new TestValueNode(6);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
306 final TestValueNode rightValueNode = new TestValueNode(7);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
307 final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
308
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
309 final TestRootNode rootNode = new TestRootNode(addNode);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
310
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
311 final CallTarget callTarget = runtime.createCallTarget(rootNode);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
312
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
313 // Check that the prober added probes to the tree
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
314 assertEquals(probeListener.probeCount, 3);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
315 assertEquals(probeListener.tagCount, 3);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
316
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
317 assertEquals(Probe.findProbesTaggedAs(ADD_TAG).size(), 1);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
318 assertEquals(Probe.findProbesTaggedAs(VALUE_TAG).size(), 2);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
319
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
320 // Check that it executes correctly
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
321 assertEquals(13, callTarget.call());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
322
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
323 // Dynamically attach a counter for all executions of all Addition nodes
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
324 for (Probe probe : Probe.findProbesTaggedAs(ADD_TAG)) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
325 additionCounter.attachCounter(probe);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
326 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
327 // Dynamically attach a counter for all executions of all Value nodes
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
328 for (Probe probe : Probe.findProbesTaggedAs(VALUE_TAG)) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
329 valueCounter.attachCounter(probe);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
330 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
331
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
332 // Counters initialized at 0
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
333 assertEquals(additionCounter.count, 0);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
334 assertEquals(valueCounter.count, 0);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
335
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
336 // Execute again
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
337 assertEquals(13, callTarget.call());
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
338
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
339 // There are two value nodes in the AST, but only one addition node
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
340 assertEquals(additionCounter.count, 1);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
341 assertEquals(valueCounter.count, 2);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
342
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
343 Probe.unregisterASTProber(astProber);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
344
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
345 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
346
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
347 private interface TestCounter {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
348
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
349 int enterCount();
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
350
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
351 int leaveCount();
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
352
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
353 void attach(Probe probe);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
354
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
355 void dispose();
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
356
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
357 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
358
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
359 /**
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
360 * A counter for the number of times execution enters and leaves a probed AST node, using the
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
361 * simplest kind of listener.
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
362 */
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
363 private class TestInstrumentCounter implements TestCounter {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
364
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
365 public int enterCount = 0;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
366 public int leaveCount = 0;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
367 public final Instrument instrument;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
368
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
369 public TestInstrumentCounter() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
370 this.instrument = Instrument.create(new SimpleInstrumentListener() {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
371
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
372 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
373 public void enter(Probe probe) {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
374 enterCount++;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
375 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
376
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
377 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
378 public void returnAny(Probe probe) {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
379 leaveCount++;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
380 }
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
381
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
382 }, "Instrumentation Test Counter");
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
383
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
384 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
385
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
386 public int enterCount() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
387 return enterCount;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
388 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
389
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
390 public int leaveCount() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
391 return leaveCount;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
392 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
393
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
394 public void attach(Probe probe) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
395 probe.attach(instrument);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
396 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
397
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
398 public void dispose() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
399 instrument.dispose();
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
400 }
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
401 }
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
402
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
403 /**
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
404 * A counter for the number of times execution enters and leaves a probed AST node, using the
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
405 * simplest kind of listener.
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
406 */
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
407 private class TestASTInstrumentCounter implements TestCounter {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
408
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
409 public int enterCount = 0;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
410 public int leaveCount = 0;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
411 public final Instrument instrument;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
412
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
413 public TestASTInstrumentCounter() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
414 this.instrument = Instrument.create(new SimpleASTInstrumentListener() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
415
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
416 @Override
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
417 public void enter(Probe probe, Node node, VirtualFrame vFrame) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
418 enterCount++;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
419 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
420
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
421 @Override
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
422 public void returnAny(Probe probe, Node node, VirtualFrame vFrame) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
423 leaveCount++;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
424 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
425
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
426 }, "Instrumentation Test Counter");
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
427
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
428 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
429
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
430 public int enterCount() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
431 return enterCount;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
432 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
433
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
434 public int leaveCount() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
435 return leaveCount;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
436 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
437
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
438 public void attach(Probe probe) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
439 probe.attach(instrument);
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
440 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
441
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
442 public void dispose() {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
443 instrument.dispose();
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
444 }
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
445 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
446
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
447 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
448 * Tags selected nodes on newly constructed ASTs.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
449 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
450 private static final class TestASTProber implements NodeVisitor, ASTProber {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
451
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
452 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
453 public boolean visit(Node node) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
454 if (node instanceof TestLanguageNode) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
455
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
456 final TestLanguageNode testNode = (TestLanguageNode) node;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
457
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
458 if (node instanceof TestValueNode) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
459 testNode.probe().tagAs(VALUE_TAG, null);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
460
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
461 } else if (node instanceof TestAdditionNode) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
462 testNode.probe().tagAs(ADD_TAG, null);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
463
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
464 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
465 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
466 return true;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
467 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
468
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
469 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
470 public void probeAST(Node node) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
471 node.accept(this);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
472 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
473 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
474
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
475 /**
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
476 * Counts the number of "enter" events at probed nodes using the simplest AST listener.
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
477 */
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
478 static final class TestInstrumentListener extends DefaultInstrumentListener {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
479
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
480 public int counter = 0;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
481
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
482 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
483 public void enter(Probe probe) {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
484 counter++;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
485 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
486
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
487 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
488
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
489 /**
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
490 * Counts the number of "enter" events at probed nodes using the AST listener.
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
491 */
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
492 static final class TestASTInstrumentListener extends DefaultASTInstrumentListener {
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
493
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
494 public int counter = 0;
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
495
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
496 @Override
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
497 public void enter(Probe probe, Node node, VirtualFrame vFrame) {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
498 counter++;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
499 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
500
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
501 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
502
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
503 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
504 * A counter that can count executions at multiple nodes; it attaches a separate instrument at
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
505 * each Probe, but keeps a total count.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
506 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
507 private static final class TestMultiCounter {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
508
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
509 public int count = 0;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
510
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
511 public void attachCounter(Probe probe) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
512
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
513 // Attach a new instrument for every Probe
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
514 // where we want to count executions.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
515 // it will get copied when ASTs cloned, so
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
516 // keep the count in this outer class.
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
517 probe.attach(Instrument.create(new DefaultInstrumentListener() {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
518
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
519 @Override
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
520 public void enter(Probe p) {
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
521 count++;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
522 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
523 }, "Instrumentation Test MultiCounter"));
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
524 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
525 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
526
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
527 private static final class TestProbeListener extends DefaultProbeListener {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
528
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
529 public int probeCount = 0;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
530 public int tagCount = 0;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
531
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
532 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
533 public void newProbeInserted(Probe probe) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
534 probeCount++;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
535 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
536
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
537 @Override
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
538 public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
539 tagCount++;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
540 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
541 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
542
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
543 }