annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java @ 19869:1d6a7ea5de59

Truffle/Instrumentation: remove support for "probe-lite", an optimization for a particular use case that no longer seems worth the complexity.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Mon, 16 Mar 2015 15:59:57 -0700
parents 907128d02b31
children 2e3cc2a27711
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.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
38
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
39 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
40 * <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
41 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
42 * 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
43 * {@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
44 * {@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
45 * <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
46 * <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
47 * <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
48 * <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
49 * <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
50 * <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
51 * <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
52 * <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
53 * </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
54 * 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
55 * 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
56 */
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 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
58
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 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
60
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 @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
62 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
63 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
64 }
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 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
68 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
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
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 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
73
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 @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
75 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
76 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
77 }
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 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
81 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
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
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 @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
86 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
87 // 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
88 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
89 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
90 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
91 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
92
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 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
94 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
95 } 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
96 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
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 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
99
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 // 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
101 // 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
102 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
103
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 // 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115
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 // 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
117 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
118
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 // 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
120 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
121
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 // 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
123 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
124 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
125 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
126 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
127 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
128 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
129
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 // 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
131 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
132 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
133 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
134 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
135 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
136
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 // 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
138 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
139 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
140 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
141 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
142 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
143
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 // 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
145 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
146 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
147 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
148 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
149 } 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
150 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
151 }
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
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 // 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
154 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
155
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
156 }
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
157
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
158 @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
159 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
160
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 // 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
162 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
163 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
164 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
165 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
166 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
167
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 // 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
169 // 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
170 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
171 // 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
172 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
173
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 // 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
175 // 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
176 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
177
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 // 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
179 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
180
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 }
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 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
184
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
185 // 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
186 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
187
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
188 // 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
189 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
190
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 // 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
192 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
193 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
194 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
195 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
196 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
197
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
198 // 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
199 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
200
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
201 // 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
202 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
203 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
204 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
205 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
206 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
207
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
208 // 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
209 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
210 // 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
211 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
212 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
213 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
214 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
215 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
216
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
217 // 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
218 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
219 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
220 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
221 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
222 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
223
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
224 // 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
225 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
226
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
227 // 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
236 // 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
245 // 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
246 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
247
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
248 // 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
257 // 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
266 // 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
267 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
268
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
269 // 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
270 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
271 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
272 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
273 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
274 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
275 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
276 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
277 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
278
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
279 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
280
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
281 @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
282 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
283
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 // 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
285 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
286 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
287
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 // 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
289 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
290 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
291
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 // 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
293 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
294
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 // 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
296 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
297
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 // 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
299 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
300 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
301 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
302 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
303
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 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
305
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 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
307
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 // 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
309 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
310 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
311
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 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
313 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
314
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 // 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
316 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
317
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 // 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
319 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
320 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
321 }
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 // 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
323 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
324 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
325 }
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 // 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
328 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
329 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
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 // 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
332 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
333
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 // 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
335 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
336 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
337
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 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
339
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 }
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
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 private abstract class TestLanguageNode extends Node {
19518
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
343 public abstract Object execute(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
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 @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
346 public boolean isInstrumentable() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
347 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
348 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
349
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
350 @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
351 public WrapperNode createWrapperNode() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
352 return new TestLanguageWrapperNode(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
353 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
354 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
355
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
356 @NodeInfo(cost = NodeCost.NONE)
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
357 private class TestLanguageWrapperNode extends TestLanguageNode implements 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
358 @Child private TestLanguageNode child;
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 @Child private ProbeNode probeNode;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
360
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
361 public TestLanguageWrapperNode(TestLanguageNode child) {
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 assert !(child 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
363 this.child = child;
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
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 @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
367 public String instrumentationInfo() {
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 return "Wrapper node for testing";
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
369 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
370
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 @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
372 public boolean isInstrumentable() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
373 return false;
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 }
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 @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
377 public void insertProbe(ProbeNode newProbeNode) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
378 this.probeNode = newProbeNode;
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 }
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
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
381 @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
382 public Probe getProbe() {
19869
1d6a7ea5de59 Truffle/Instrumentation: remove support for "probe-lite", an optimization for a particular use case that no longer seems worth the complexity.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
383 return probeNode.getProbe();
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
384 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
385
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
386 @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
387 public Node getChild() {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
388 return child;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
389 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
390
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
391 @Override
19518
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
392 public Object execute(VirtualFrame vFrame) {
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
393 probeNode.enter(child, 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
394 Object result;
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
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 try {
19518
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
397 result = child.execute(vFrame);
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
398 probeNode.returnValue(child, vFrame, result);
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
399 } catch (KillException 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
400 throw (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
401 } catch (Exception e) {
19518
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
402 probeNode.returnExceptional(child, vFrame, e);
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
403 throw (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
404 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
405
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
406 return result;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
407 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
408 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
409
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
410 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
411 * A simple node for our test language to store a 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
412 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
413 private class TestValueNode extends 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
414 private final int 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
415
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
416 public TestValueNode(int 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
417 this.value = 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
418 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
419
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
420 @Override
19518
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
421 public Object execute(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
422 return new Integer(this.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
423 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
424 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
425
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
426 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
427 * A node for our test language that adds up two {@link TestValueNode}s.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
428 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
429 private class TestAdditionNode extends 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
430 @Child private TestLanguageNode leftChild;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
431 @Child private TestLanguageNode rightChild;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
432
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
433 public TestAdditionNode(TestValueNode leftChild, TestValueNode rightChild) {
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
434 this.leftChild = insert(leftChild);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
435 this.rightChild = insert(rightChild);
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
436 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
437
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
438 @Override
19518
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
439 public Object execute(VirtualFrame vFrame) {
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
440 return new Integer(((Integer) leftChild.execute(vFrame)).intValue() + ((Integer) rightChild.execute(vFrame)).intValue());
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
441 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
442 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
443
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
444 /**
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 * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any 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
446 * of the guest language. This is necessary since creating a {@link CallTarget} is how Truffle
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 * completes an AST. The root nodes serves as our entry point into a program.
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 */
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 private class TestRootNode extends 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
450 @Child private TestLanguageNode body;
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 /**
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 * This constructor emulates the global machinery that applies registered probers to every
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 * newly created AST. Global registry is not used, since that would interfere with other
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 * tests run in the same environment.
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 */
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 public TestRootNode(TestLanguageNode body) {
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 super(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
459 this.body = body;
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
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 @Override
19518
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
463 public Object execute(VirtualFrame vFrame) {
b5467bb34b24 Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
464 return body.execute(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
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
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 @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
468 public boolean isCloningAllowed() {
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 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
470 }
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
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 @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
473 public void applyInstrumentation() {
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 Probe.applyASTProbers(body);
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 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
476 }
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 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
479
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
480 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
481
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
482 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
483
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 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
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 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
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
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
490 /**
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
491 * 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
492 * 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
493 */
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
494 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
495
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
496 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
497 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
498 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
499
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
500 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
501 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
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 @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
504 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
505 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
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
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 @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
509 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
510 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
511 }
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
512
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
513 }, "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
514
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
515 }
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
516
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 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
518 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
519 }
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
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
521 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
522 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
523 }
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 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
526 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
527 }
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 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
530 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
531 }
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
532 }
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
533
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
534 /**
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
535 * 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
536 * 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
537 */
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
538 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
539
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
540 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
541 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
542 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
543
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
544 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
545 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
546
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
547 @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
548 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
549 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
550 }
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
551
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
552 @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
553 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
554 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
555 }
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
556
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
557 }, "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
558
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
559 }
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
560
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
561 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
562 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
563 }
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
564
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
565 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
566 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
567 }
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
568
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
569 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
570 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
571 }
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
572
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
573 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
574 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
575 }
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
576 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
577
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
578 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
579 * 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
580 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
581 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
582
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
583 @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
584 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
585 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
586
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
587 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
588
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
589 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
590 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
591
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
592 } 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
593 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
594
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
595 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
596 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
597 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
598 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
599
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
600 @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
601 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
602 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
603 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
604 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
605
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
606 /**
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
607 * 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
608 */
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
609 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
610
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
611 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
612
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
613 @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
614 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
615 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
616 }
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
617
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
618 }
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
619
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
620 /**
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
621 * 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
622 */
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
623 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
624
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
625 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
626
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
627 @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
628 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
629 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
630 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
631
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
632 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
633
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
634 /**
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
635 * 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
636 * 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
637 */
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
638 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
639
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
640 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
641
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
642 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
643
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
644 // 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
645 // 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
646 // 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
647 // 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
648 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
649
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
650 @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
651 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
652 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
653 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
654 }, "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
655 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
656 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
657
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
658 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
659
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
660 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
661 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
662
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
663 @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
664 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
665 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
666 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
667
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
668 @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
669 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
670 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
671 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
672 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
673
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
674 }