annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/ProbeManager.java @ 16856:7833417c8172

Changes to Instrumentation
author David Piorkowski <david.piorkowski@oracle.com>
date Mon, 18 Aug 2014 14:36:12 -0700
parents 50d79ad439f1
children 7bfbad29d331
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
1 /*
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
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.
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
4 *
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
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
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
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
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
10 *
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
15 * accompanied this code).
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
16 *
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
20 *
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
23 * questions.
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
24 */
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.instrument.impl;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
26
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
27 import java.util.*;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
28
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
29 import com.oracle.truffle.api.instrument.*;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
30 import com.oracle.truffle.api.instrument.impl.InstrumentationNode.ProbeCallback;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
31 import com.oracle.truffle.api.instrument.impl.InstrumentationNode.ProbeImpl;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
32 import com.oracle.truffle.api.source.*;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
33
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
34 /**
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
35 * Factory and services for AST {@link Probe}s
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
36 */
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
37 public final class ProbeManager {
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
38
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
39 /**
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
40 * The collection of {@link ProbeListener}s to call.
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
41 */
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
42 private final List<ProbeListener> probeListeners = new ArrayList<>();
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
43
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
44 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
45 * The collection of all probes added.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
46 */
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
47 private final List<ProbeImpl> probeList = new ArrayList<>();
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
48
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
49 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
50 * The callback to be triggered by the {@link #tagTrap}.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
51 *
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
52 */
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
53 private final ProbeCallback probeCallback;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
54
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
55 /**
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
56 * When non-null, "enter" events with matching tags will trigger a callback.
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
57 */
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
58 private SyntaxTagTrap tagTrap = null;
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
59
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
60 public ProbeManager() {
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
61 this.probeCallback = new ProbeCallback() {
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
62 /**
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
63 * Receives (from the {@link Probe} implementation) and distributes notification that a
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
64 * {@link Probe} has acquired a new {@linkplain SyntaxTag tag}.
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
65 */
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
66 public void newTagAdded(ProbeImpl probe, SyntaxTag tag) {
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
67 for (ProbeListener listener : probeListeners) {
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
68 listener.probeTaggedAs(probe, tag);
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
69 }
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
70 if (tagTrap != null && tag == tagTrap.getTag()) {
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
71 probe.setTrap(tagTrap);
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
72 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
73 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
74 };
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
75 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
76
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
77 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
78 * Add a {@link ProbeListener} to receive events.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
79 *
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
80 * @param listener The listener to be added.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
81 */
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
82 public void addProbeListener(ProbeListener listener) {
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
83 assert listener != null;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
84 probeListeners.add(listener);
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
85 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
86
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
87 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
88 * Remove a {@link ProbeListener}. If no matching probe listener is found, nothing happens.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
89 *
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
90 * @param removeListener
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
91 */
15944
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
92 public void removeProbeListener(ProbeListener removeListener) {
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
93 final List<ProbeListener> listeners = new ArrayList<>(probeListeners);
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
94 for (ProbeListener listener : listeners) {
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
95 if (listener == removeListener) {
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
96 probeListeners.remove(listener);
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
97 }
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
98 }
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
99 }
eedf6c293639 Truffle: additional methods on ExecutionContext
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15779
diff changeset
100
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
101 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
102 * Creates a {@link Probe} for the given {@link SourceSection} and informs all
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
103 * {@link ProbeListener}s stored in this manager of its creation.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
104 *
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
105 * @param source The source section to associate with this probe.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
106 * @return The probe that was created.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
107 */
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
108 public Probe createProbe(SourceSection source) {
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
109 assert source != null;
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
110
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
111 ProbeImpl probe = InstrumentationNode.createProbe(source, probeCallback);
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
112 probeList.add(probe);
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
113
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
114 for (ProbeListener listener : probeListeners) {
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
115 listener.newProbeInserted(source, probe);
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
116 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
117
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
118 return probe;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
119 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
120
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
121 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
122 * Returns a collection of {@link Probe}s created by this manager that have the given
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
123 * {@link SyntaxTag}.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
124 *
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
125 * @param tag The tag to search for.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
126 * @return An iterable collection of probes containing the given tag.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
127 */
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
128 public Collection<Probe> findProbesTaggedAs(SyntaxTag tag) {
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
129 final List<Probe> probes = new ArrayList<>();
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
130 for (Probe probe : probeList) {
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
131 if (tag == null || probe.isTaggedAs(tag)) {
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
132 probes.add(probe);
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
133 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
134 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
135 return probes;
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
136 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
137
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
138 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
139 * Calls {@link ProbeImpl#setTrap(SyntaxTagTrap)} for all probes with the given
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
140 * {@link SyntaxTag} . There can only be one tag trap set at a time. An
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
141 * {@link IllegalStateException} is thrown if this is called and a tag trap has already been
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
142 * set.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
143 *
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
144 * @param tagTrap The {@link SyntaxTagTrap} to set.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
145 */
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
146 public void setTagTrap(SyntaxTagTrap tagTrap) {
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
147 assert tagTrap != null;
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
148 if (this.tagTrap != null) {
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
149 throw new IllegalStateException("trap already set");
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
150 }
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
151 this.tagTrap = tagTrap;
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
152
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
153 SyntaxTag tag = tagTrap.getTag();
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
154 for (ProbeImpl probe : probeList) {
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
155 if (probe.isTaggedAs(tag)) {
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
156 probe.setTrap(tagTrap);
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
157 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
158 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
159 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
160
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
161 /**
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
162 * Clears the current {@link SyntaxTagTrap}. If no trap has been set, an
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
163 * {@link IllegalStateException} is thrown.
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
164 */
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
165 public void clearTagTrap() {
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
166 if (this.tagTrap == null) {
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
167 throw new IllegalStateException("no trap set");
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
168 }
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
169 for (ProbeImpl probe : probeList) {
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
170 if (probe.isTaggedAs(tagTrap.getTag())) {
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
171 probe.setTrap(null);
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
172 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
173 }
16391
50d79ad439f1 Truffle/Instrumentation: rename PhylumTag to SyntaxTag (along with related classes/methods)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16181
diff changeset
174 tagTrap = null;
15779
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
175 }
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
176
8c34e2cc4add Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
177 }