annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java @ 22157:dc83cc1f94f2

Using fully qualified imports
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 16 Sep 2015 11:33:22 +0200
parents 78c3d3d8d86e
children 1c0f490984d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
1 /*
18985
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
4 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
10 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
15 * accompanied this code).
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
16 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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,
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
20 *
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
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
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
23 * questions.
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
24 */
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.instrument;
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
26
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
27 import com.oracle.truffle.api.Assumption;
19488
2f676c3ca430 Truffle/Instrumentation: fix some optimization bugs; instrumentation PE tests now succeed after recent compiler work
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19247
diff changeset
28 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
29 import com.oracle.truffle.api.TruffleLanguage;
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
30 import com.oracle.truffle.api.impl.Accessor;
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: 19696
diff changeset
31 import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
32 import com.oracle.truffle.api.nodes.InvalidAssumptionException;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
33 import com.oracle.truffle.api.nodes.Node;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
34 import com.oracle.truffle.api.nodes.NodeVisitor;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
35 import com.oracle.truffle.api.nodes.RootNode;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
36 import com.oracle.truffle.api.source.Source;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
37 import com.oracle.truffle.api.source.SourceSection;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
38 import com.oracle.truffle.api.utilities.CyclicAssumption;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
39 import java.io.PrintStream;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
40 import java.lang.ref.WeakReference;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
41 import java.util.ArrayList;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
42 import java.util.Collection;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
43 import java.util.Collections;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
44 import java.util.List;
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
45
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
46 //TODO (mlvdv) these statics should not be global. Move them to some kind of context.
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
47
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
48 /**
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
49 * A <em>binding</em> between:
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
50 * <ol>
21130
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
51 * <li>A program location in an executing Truffle AST (corresponding to a {@link SourceSection}),
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
52 * and</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
53 * <li>A dynamically managed collection of "attached" {@linkplain Instrument Instruments} that
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
54 * receive event notifications on behalf of external clients.</li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
55 * </ol>
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
56 * <p>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
57 * Client-oriented documentation for the use of Probes is available online at <a
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
58 * HREF="https://wiki.openjdk.java.net/display/Graal/Finding+Probes" >https://wiki.openjdk.java.
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
59 * net/display/Graal/Finding+Probes</a>
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
60 * <p>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
61 * <h4>Implementation notes:</h4>
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
62 * <p>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
63 * <ul>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
64 * <li>A Probe must be permanently associated with a <em>program location</em>, defined by a
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
65 * particular {@link SourceSection}, even though:
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
66 * <ul>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
67 * <li>that location is represented in an AST as a {@link Node}, which might be replaced through
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
68 * optimizations such as specialization, and</li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
69 * <li>Truffle may <em>clone</em> the AST so that the location is actually represented by multiple
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
70 * Nodes in multiple ASTs.</li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
71 * </ul>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
72 * </li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
73 *
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
74 * <li>The effect of the binding is to intercept {@linkplain TruffleEvents execution events}
20961
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
75 * arriving at the "probed" AST Node and notify each attached {@link Instrument} before execution is
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
76 * allowed to proceed to the child and again after execution completes.</li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
77 *
20961
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
78 * <li>The method {@link Node#probe()} creates a Probe on an AST Node; redundant calls return the
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
79 * same Probe.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
80 *
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
81 * <li>The "probing" of a Truffle AST must be done after the AST is complete (i.e. parent pointers
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
82 * correctly assigned), but before any cloning or executions. This is done by creating an instance
20961
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
83 * of {@link ASTProber} and registering it via {@link #registerASTProber(ASTProber)}. Once
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
84 * registered, it will be applied automatically to every newly created AST.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
85 *
20961
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
86 * <li>The "probing" of an AST Node is implemented by insertion of a {@link ProbeNode.WrapperNode}
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
87 * into the AST (as new parent of the Node being probed), together with an associated
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
88 * {@link ProbeNode} that routes execution events at the probed Node to all the
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
89 * {@linkplain Instrument Instruments} attached to the Probe's <em>instrument chain</em>.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
90 *
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
91 * <li>When Truffle clones an AST, any attached WrapperNodes and ProbeNodes are cloned as well,
20961
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
92 * together with their attached instrument chains. Each Probe instance intercepts cloning events and
21298b90a6bf Truffle/Instrumentation: Javadoc cleanup
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20908
diff changeset
93 * keeps track of all AST copies.</li>
20908
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
94 *
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
95 * <li>All attached {@link InstrumentationNode}s effectively become part of the running program:
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
96 * <ul>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
97 * <li>Good News: instrumentation code implicitly benefits from every kind of Truffle optimization.</li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
98 * <li>Bad News: instrumentation code must be implemented carefully to avoid interfering with any
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
99 * Truffle optimizations.</li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
100 * </ul>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
101 * </li>
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
102 *
f166d264af9f Truflfe/Instrumentaion: migrate client-oriented notes on Probes to a newly written documentation page at https://wiki.openjdk.java.net/display/Graal/Finding+Probes. Replace Probe's Javadoc with implementation notes oriented to implementors.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20105
diff changeset
103 * </ul>
15605
bb9473723904 Truffle/Instrumentation:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
104 *
bb9473723904 Truffle/Instrumentation:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 15279
diff changeset
105 * @see Instrument
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
106 * @see ASTProber
18985
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
107 * @see ProbeListener
19696
27fe86a6fb49 Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19517
diff changeset
108 * @see SyntaxTag
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
109 */
22066
78c3d3d8d86e Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
110 @SuppressWarnings("rawtypes")
21130
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
111 public final class Probe {
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
112 private final Class<? extends TruffleLanguage> language;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
113
21684
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
114 private static final boolean TRACE = false;
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
115 private static final String TRACE_PREFIX = "PROBE: ";
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
116 private static final PrintStream OUT = System.out;
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
117
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
118 private static void trace(String format, Object... args) {
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
119 if (TRACE) {
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
120 OUT.println(TRACE_PREFIX + String.format(format, args));
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
121 }
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
122 }
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
123
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
124 private static final List<ASTProber> astProbers = new ArrayList<>();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
125
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
126 private static final List<ProbeListener> probeListeners = new ArrayList<>();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
127
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
128 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
129 * All Probes that have been created.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
130 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
131 private static final List<WeakReference<Probe>> probes = new ArrayList<>();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
132
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
133 /**
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
134 * A global trap that triggers notification just before executing any Node that is Probed with a
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
135 * matching tag.
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
136 */
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
137 @CompilationFinal private static SyntaxTagTrap beforeTagTrap = null;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
138
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
139 /**
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
140 * A global trap that triggers notification just after executing any Node that is Probed with a
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
141 * matching tag.
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
142 */
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
143 @CompilationFinal private static SyntaxTagTrap afterTagTrap = null;
19491
4d66c000d253 Truffle/Instrumentation: more cleanup in Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19490
diff changeset
144
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
145 private static final class FindSourceVisitor implements NodeVisitor {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
146
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
147 Source source = null;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
148
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
149 public boolean visit(Node node) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
150 final SourceSection sourceSection = node.getSourceSection();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
151 if (sourceSection != null) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
152 source = sourceSection.getSource();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
153 return false;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
154 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
155 return true;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
156 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
157 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
158
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
159 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
160 * Walks an AST, looking for the first node with an assigned {@link SourceSection} and returning
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
161 * the {@link Source}.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
162 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
163 private static Source findSource(Node node) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
164 final FindSourceVisitor visitor = new FindSourceVisitor();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
165 node.accept(visitor);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
166 return visitor.source;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
167 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
168
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
169 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
170 * Enables instrumentation at selected nodes in all subsequently constructed ASTs.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
171 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
172 public static void registerASTProber(ASTProber prober) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
173 astProbers.add(prober);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
174 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
175
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
176 public static void unregisterASTProber(ASTProber prober) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
177 astProbers.remove(prober);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
178 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
179
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
180 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
181 * Enables instrumentation in a newly created AST by applying all registered instances of
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
182 * {@link ASTProber}.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
183 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
184 public static void applyASTProbers(Node node) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
185
21685
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
186 String name = "<?>";
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
187 final Source source = findSource(node);
21685
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
188 if (source != null) {
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
189 name = source.getShortName();
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
190 } else {
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
191 final SourceSection sourceSection = node.getEncapsulatingSourceSection();
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
192 if (sourceSection != null) {
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
193 name = sourceSection.getShortDescription();
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
194 }
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
195 }
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
196 trace("START %s", name);
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
197 for (ProbeListener listener : probeListeners) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
198 listener.startASTProbing(source);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
199 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
200 for (ASTProber prober : astProbers) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
201 prober.probeAST(node);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
202 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
203 for (ProbeListener listener : probeListeners) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
204 listener.endASTProbing(source);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
205 }
21685
fd8a92655fbd Truffle/Instrumentation: improve Probe trace output for builtins
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21684
diff changeset
206 trace("FINISHED %s", name);
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
207 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
208
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
209 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
210 * Adds a {@link ProbeListener} to receive events.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
211 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
212 public static void addProbeListener(ProbeListener listener) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
213 assert listener != null;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
214 probeListeners.add(listener);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
215 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
216
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
217 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
218 * Removes a {@link ProbeListener}. Ignored if listener not found.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
219 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
220 public static void removeProbeListener(ProbeListener listener) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
221 probeListeners.remove(listener);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
222 }
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
223
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
224 /**
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
225 * Returns all {@link Probe}s holding a particular {@link SyntaxTag}, or the whole collection of
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
226 * probes if the specified tag is {@code null}.
16856
7833417c8172 Changes to Instrumentation
David Piorkowski <david.piorkowski@oracle.com>
parents: 16391
diff changeset
227 *
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
228 * @return A collection of probes containing the given tag.
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
229 */
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
230 public static Collection<Probe> findProbesTaggedAs(SyntaxTag tag) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
231 final List<Probe> taggedProbes = new ArrayList<>();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
232 for (WeakReference<Probe> ref : probes) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
233 Probe probe = ref.get();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
234 if (probe != null) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
235 if (tag == null || probe.isTaggedAs(tag)) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
236 taggedProbes.add(ref.get());
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
237 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
238 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
239 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
240 return taggedProbes;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
241 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
242
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
243 // TODO (mlvdv) generalize to permit multiple "before traps" without a performance hit?
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
244 /**
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
245 * Sets the current "<em>before</em> tag trap"; there can be no more than one in effect.
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
246 * <ul>
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
247 * <li>The before-trap triggers a callback just <strong><em>before</em></strong> execution
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
248 * reaches <strong><em>any</em></strong> {@link Probe} (either existing or subsequently created)
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
249 * with the specified {@link SyntaxTag}.</li>
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
250 * <li>Setting the before-trap to {@code null} clears an existing before-trap.</li>
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
251 * <li>Setting a non{@code -null} before-trap when one is already set clears the previously set
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
252 * before-trap.</li>
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
253 * </ul>
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
254 *
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
255 * @param newBeforeTagTrap The new "before" {@link SyntaxTagTrap} to set.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
256 */
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
257 public static void setBeforeTagTrap(SyntaxTagTrap newBeforeTagTrap) {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
258 beforeTagTrap = newBeforeTagTrap;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
259 for (WeakReference<Probe> ref : probes) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
260 final Probe probe = ref.get();
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
261 if (probe != null) {
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
262 probe.notifyTrapsChanged();
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
263 }
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
264 }
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
265 }
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
266
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
267 // TODO (mlvdv) generalize to permit multiple "after traps" without a performance hit?
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
268 /**
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
269 * Sets the current "<em>after</em> tag trap"; there can be no more than one in effect.
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
270 * <ul>
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
271 * <li>The after-trap triggers a callback just <strong><em>after</em></strong> execution leaves
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
272 * <strong><em>any</em></strong> {@link Probe} (either existing or subsequently created) with
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
273 * the specified {@link SyntaxTag}.</li>
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
274 * <li>Setting the after-trap to {@code null} clears an existing after-trap.</li>
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
275 * <li>Setting a non{@code -null} after-trap when one is already set clears the previously set
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
276 * after-trap.</li>
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
277 * </ul>
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
278 *
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
279 * @param newAfterTagTrap The new "after" {@link SyntaxTagTrap} to set.
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
280 */
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
281 public static void setAfterTagTrap(SyntaxTagTrap newAfterTagTrap) {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
282 afterTagTrap = newAfterTagTrap;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
283 for (WeakReference<Probe> ref : probes) {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
284 final Probe probe = ref.get();
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
285 if (probe != null) {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
286 probe.notifyTrapsChanged();
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
287 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
288 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
289 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
290
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
291 private final SourceSection sourceSection;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
292 private final ArrayList<SyntaxTag> tags = new ArrayList<>();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
293 private final List<WeakReference<ProbeNode>> probeNodeClones = new ArrayList<>();
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
294
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
295 /*
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
296 * Invalidated whenever something changes in the Probe and its Instrument chain, so need deopt
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
297 */
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
298 private final CyclicAssumption probeStateUnchangedCyclic = new CyclicAssumption("Probe state unchanged");
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
299
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
300 /*
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
301 * The assumption that nothing had changed in this probe, the last time anybody checked (when
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
302 * there may have been a deopt). Every time a check fails, gets replaced by a new unchanged
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
303 * assumption.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
304 */
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
305 @CompilationFinal private Assumption probeStateUnchangedAssumption = probeStateUnchangedCyclic.getAssumption();
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
306
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
307 // Must invalidate whenever changed
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
308 @CompilationFinal private boolean isBeforeTrapActive = false;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
309
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
310 // Must invalidate whenever changed
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
311 @CompilationFinal private boolean isAfterTrapActive = false;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
312
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
313 /**
18985
867058575979 Truffle: Improved support for "probing" AST nodes:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18485
diff changeset
314 * Intended for use only by {@link ProbeNode}.
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
315 */
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
316 Probe(Class<? extends TruffleLanguage> l, ProbeNode probeNode, SourceSection sourceSection) {
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
317 this.sourceSection = sourceSection;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
318 probes.add(new WeakReference<>(this));
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
319 registerProbeNodeClone(probeNode);
21684
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
320 if (TRACE) {
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
321 final String location = this.sourceSection == null ? "<unknown>" : sourceSection.getShortDescription();
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
322 trace("ADDED %s %s %s", "Probe@", location, getTagsDescription());
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
323 }
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
324 for (ProbeListener listener : probeListeners) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
325 listener.newProbeInserted(this);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
326 }
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
327 this.language = l;
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
328 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
329
21130
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
330 /**
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
331 * Is this node tagged as belonging to a particular human-sensible category of language
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
332 * constructs?
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
333 */
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
334 public boolean isTaggedAs(SyntaxTag tag) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
335 assert tag != null;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
336 return tags.contains(tag);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
337 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
338
21130
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
339 /**
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
340 * In which user-sensible categories has this node been tagged (<em>empty set</em> if none).
7d21cdb15e54 Truffle/Instrumentation: remove an interface that no longer adds value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20961
diff changeset
341 */
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
342 public Collection<SyntaxTag> getSyntaxTags() {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
343 return Collections.unmodifiableCollection(tags);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
344 }
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
345
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
346 /**
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
347 * Adds a {@linkplain SyntaxTag tag} to the set of tags associated with this {@link Probe};
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
348 * {@code no-op} if already in the set.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
349 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
350 public void tagAs(SyntaxTag tag, Object tagValue) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
351 assert tag != null;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
352 if (!tags.contains(tag)) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
353 tags.add(tag);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
354 for (ProbeListener listener : probeListeners) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
355 listener.probeTaggedAs(this, tag, tagValue);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
356 }
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
357
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
358 // Update the status of this Probe with respect to global tag traps
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
359 boolean tagTrapsChanged = false;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
360 if (beforeTagTrap != null && tag == beforeTagTrap.getTag()) {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
361 this.isBeforeTrapActive = true;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
362 tagTrapsChanged = true;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
363 }
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
364 if (afterTagTrap != null && tag == afterTagTrap.getTag()) {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
365 this.isAfterTrapActive = true;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
366 tagTrapsChanged = true;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
367 }
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
368 if (tagTrapsChanged) {
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
369 invalidateProbeUnchanged();
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
370 }
21684
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
371 if (TRACE) {
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
372 trace("TAGGED as %s: %s", tag, getShortDescription());
c072fbce5756 Truffle/Instrumentation: move Probe tracing out of DebugEngine and into Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21131
diff changeset
373 }
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
374 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
375 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
376
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
377 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
378 * Adds instrumentation at this Probe.
16857
7bfbad29d331 Truffle/Instrumentation: Javadoc cleanups and minor corrections.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16856
diff changeset
379 *
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
380 * @param instrument an instrument not yet attached to a probe
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
381 * @throws IllegalStateException if the instrument has ever been attached before
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
382 */
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
383 public void attach(Instrument instrument) throws IllegalStateException {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
384 if (instrument.isDisposed()) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
385 throw new IllegalStateException("Attempt to attach disposed instrument");
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
386 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
387 if (instrument.getProbe() != null) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
388 throw new IllegalStateException("Attampt to attach an already attached instrument");
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
389 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
390 instrument.setAttachedTo(this);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
391 for (WeakReference<ProbeNode> ref : probeNodeClones) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
392 final ProbeNode probeNode = ref.get();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
393 if (probeNode != null) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
394 probeNode.addInstrument(instrument);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
395 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
396 }
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
397 invalidateProbeUnchanged();
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
398 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
399
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
400 /**
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
401 * Gets the {@link SourceSection} associated with the Guest Language AST node being
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
402 * instrumented, possibly {@code null}.
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
403 */
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
404 public SourceSection getProbedSourceSection() {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
405 return sourceSection;
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
406 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
407
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
408 public String getShortDescription() {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
409 final String location = sourceSection == null ? "<unknown>" : sourceSection.getShortDescription();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
410 return "Probe@" + location + getTagsDescription();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
411 }
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
412
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
413 /**
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
414 * Internal method for removing and rendering inert a specific instrument previously attached at
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
415 * this Probe.
16857
7bfbad29d331 Truffle/Instrumentation: Javadoc cleanups and minor corrections.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16856
diff changeset
416 *
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
417 * @param instrument an instrument already attached
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
418 * @throws IllegalStateException if instrument not attached at this Probe
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
419 * @see Instrument#dispose()
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
420 */
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
421 void disposeInstrument(Instrument instrument) throws IllegalStateException {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
422 for (WeakReference<ProbeNode> ref : probeNodeClones) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
423 final ProbeNode probeNode = ref.get();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
424 if (probeNode != null) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
425 probeNode.removeInstrument(instrument);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
426 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
427 }
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
428 invalidateProbeUnchanged();
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
429 }
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
430
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
431 /**
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
432 * Receives notification that a new clone of the instrument chain associated with this
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
433 * {@link Probe} has been created as a side-effect of AST cloning.
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
434 */
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
435 void registerProbeNodeClone(ProbeNode probeNode) {
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
436 probeNodeClones.add(new WeakReference<>(probeNode));
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
437 }
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
438
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
439 /**
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
440 * Gets the currently active <strong><em>before</em></strong> {@linkplain SyntaxTagTrap Tag
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
441 * Trap} at this Probe. Non{@code -null} if the global
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
442 * {@linkplain Probe#setBeforeTagTrap(SyntaxTagTrap) Before Tag Trap} is set and if this Probe
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
443 * holds the {@link SyntaxTag} specified in the trap.
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
444 */
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
445 SyntaxTagTrap getBeforeTrap() {
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
446 checkProbeUnchanged();
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
447 return isBeforeTrapActive ? beforeTagTrap : null;
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
448 }
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
449
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
450 /**
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
451 * Gets the currently active <strong><em>after</em></strong> {@linkplain SyntaxTagTrap Tag Trap}
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
452 * at this Probe. Non{@code -null} if the global
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
453 * {@linkplain Probe#setAfterTagTrap(SyntaxTagTrap) After Tag Trap} is set and if this Probe
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
454 * holds the {@link SyntaxTag} specified in the trap.
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
455 */
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
456 SyntaxTagTrap getAfterTrap() {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
457 checkProbeUnchanged();
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
458 return isAfterTrapActive ? afterTagTrap : null;
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
459 }
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
460
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
461 /**
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
462 * To be called wherever in the Probe/Instrument chain there are dependencies on the probe
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
463 * state's @CompilatonFinal fields.
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
464 */
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
465 void checkProbeUnchanged() {
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
466 try {
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
467 probeStateUnchangedAssumption.check();
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
468 } catch (InvalidAssumptionException ex) {
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
469 // Failure creates an implicit deoptimization
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
470 // Get the assumption associated with the new probe state
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
471 this.probeStateUnchangedAssumption = probeStateUnchangedCyclic.getAssumption();
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
472 }
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
473 }
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
474
20105
e73096245a4c Truffle/Instrumentation: the Instrument code now has access to Probe.invalidateProbeUnchanged, needed for attaching AST instrumentation.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
475 void invalidateProbeUnchanged() {
19490
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
476 probeStateUnchangedCyclic.invalidate();
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
477 }
745ecef4c9cd Truffle/Instrumentation: clean up the use of Assumptions in the Probe (and attached Instruments)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19488
diff changeset
478
21131
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
479 private void notifyTrapsChanged() {
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
480 this.isBeforeTrapActive = beforeTagTrap != null && this.isTaggedAs(beforeTagTrap.getTag());
d6d9631eb057 TruffleInstrumentation: rename Probe.setTagTrap() to Probe.setBeforeTagTrap() and add Probe.setAfterTagTrap()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21130
diff changeset
481 this.isAfterTrapActive = afterTagTrap != null && this.isTaggedAs(afterTagTrap.getTag());
19491
4d66c000d253 Truffle/Instrumentation: more cleanup in Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19490
diff changeset
482 invalidateProbeUnchanged();
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
483 }
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
484
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
485 private String getTagsDescription() {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
486 final StringBuilder sb = new StringBuilder();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
487 sb.append("[");
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
488 String prefix = "";
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
489 for (SyntaxTag tag : tags) {
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
490 sb.append(prefix);
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
491 prefix = ",";
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
492 sb.append(tag.toString());
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
493 }
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
494 sb.append("]");
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
495 return sb.toString();
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18338
diff changeset
496 }
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
497
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
498 static final class AccessorInstrument extends Accessor {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
499 @Override
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
500 protected Class<? extends TruffleLanguage> findLanguage(RootNode n) {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
501 return super.findLanguage(n);
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
502 }
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
503
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
504 @Override
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
505 protected Class<? extends TruffleLanguage> findLanguage(Probe probe) {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
506 return probe.language;
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
507 }
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
508 }
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
509
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
510 static final AccessorInstrument ACCESSOR = new AccessorInstrument();
15279
0c6d8a08e31b Truffle: Major cleanup and extension of the Truffle Instrumentation framework in com.oracle.truffle.api
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
511 }