Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java @ 22548:6b76a24fffbd default tip
Use all variables: a, b, u,v and x, y
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Thu, 14 Jan 2016 14:20:57 +0100 |
parents | 260e3cdf11ec |
children |
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 |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
27 import java.io.PrintStream; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
28 import java.lang.ref.WeakReference; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
29 import java.util.ArrayList; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
30 import java.util.Collection; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
31 import java.util.Collections; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
32 import java.util.List; |
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
|
33 |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
34 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
|
35 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
36 import com.oracle.truffle.api.TruffleLanguage; |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
37 import com.oracle.truffle.api.instrument.TagInstrument.AfterTagInstrument; |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
38 import com.oracle.truffle.api.instrument.TagInstrument.BeforeTagInstrument; |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
39 import com.oracle.truffle.api.nodes.InvalidAssumptionException; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
40 import com.oracle.truffle.api.nodes.Node; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
41 import com.oracle.truffle.api.source.SourceSection; |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
42 import com.oracle.truffle.api.utilities.CyclicAssumption; |
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
|
43 |
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
|
44 /** |
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
|
45 * 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
|
46 * <ol> |
22262
0df2f06977fa
Truffle/Instrumentation: the new Instrument class is now public; minor Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22257
diff
changeset
|
47 * <li>a <em>guest language program location</em> in an executing Truffle AST (corresponding to a |
22224
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
48 * {@link SourceSection}), and</li> |
22262
0df2f06977fa
Truffle/Instrumentation: the new Instrument class is now public; minor Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22257
diff
changeset
|
49 * <li>a dynamically managed collection of <em>attached</em> {@linkplain Instrument Instruments} |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
50 * that receive event notifications on behalf of external clients.</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
|
51 * </ol> |
22257
3168715cb34d
Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22256
diff
changeset
|
52 * <strong>Note</strong>:The relationship for {@link ProbeInstrument} must be with an AST |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
53 * <em>location</em>, not a specific {@link Node}, because ASTs are routinely <em>cloned</em> at |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
54 * runtime. An AST <em>location</em> is best represented as the {@link SourceSection} from which the |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
55 * original AST Node was created. |
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 * |
22224
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
62 * @see Instrumenter |
22255
e7643754d982
Truffle/Instrumentation: rename Instrument to ProbeInstrument to distinguish from another kind to be added.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22226
diff
changeset
|
63 * @see ProbeInstrument |
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
|
64 * @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
|
65 * @see ProbeListener |
19696
27fe86a6fb49
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19517
diff
changeset
|
66 * @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
|
67 */ |
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
|
68 @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
|
69 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
|
70 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
|
71 |
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
|
72 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
|
73 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
|
74 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
|
75 |
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
|
76 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
|
77 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
|
78 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
|
79 } |
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
|
80 } |
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
|
81 |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
82 private final Instrumenter instrumenter; |
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
|
83 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
|
84 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
|
85 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
|
86 |
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
|
87 /* |
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
|
88 * 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
|
89 */ |
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
|
90 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
|
91 |
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
|
92 /* |
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
|
93 * 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
|
94 * 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
|
95 * 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
|
96 */ |
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
|
97 @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
|
98 |
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
|
99 // Must invalidate whenever changed |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
100 @CompilationFinal private boolean isBeforeTagInstrumentActive = false; |
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
|
101 |
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
|
102 // Must invalidate whenever changed |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
103 @CompilationFinal private boolean isAfterTagInstrumentActive = 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
|
104 |
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
|
105 /** |
22224
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
106 * Constructor for use only by {@link ProbeNode}. |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
107 * <p> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
108 * <h4>Probe Implementation notes:</h4> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
109 * <p> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
110 * <ul> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
111 * <li>A Probe must be permanently associated with a <em>program location</em>, defined by a |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
112 * particular {@link SourceSection}, even though: |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
113 * <ul> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
114 * <li>that location is represented in an AST as a {@link Node}, which might be replaced through |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
115 * optimizations such as specialization, and</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
116 * <li>Truffle may <em>clone</em> the AST so that the location is actually represented by |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
117 * multiple Nodes in multiple ASTs.</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
118 * </ul> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
119 * </li> |
22226
c896a8e70777
Truffle/Instrumentation:
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22225
diff
changeset
|
120 * <li>The effect of the binding is to intercept {@linkplain EventHandlerNode execution events} |
22255
e7643754d982
Truffle/Instrumentation: rename Instrument to ProbeInstrument to distinguish from another kind to be added.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22226
diff
changeset
|
121 * arriving at the "probed" AST Node and notify each attached {@link ProbeInstrument} before |
22224
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
122 * execution is allowed to proceed to the child and again after execution completes.</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
123 * |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
124 * <li>The method {@link Instrumenter#probe(Node)} creates a Probe on an AST Node; redundant |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
125 * calls return the same Probe.</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
126 * |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
127 * <li>The "probing" of a Truffle AST must be done after the AST is complete (i.e. parent |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
128 * pointers correctly assigned), but before any cloning or executions. This is done by applying |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
129 * instances of {@link ASTProber} provided by each language implementation, combined with any |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
130 * instances registered by tools via {@link Instrumenter#registerASTProber(ASTProber)}. Once |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
131 * registered, these will be applied automatically to every newly created AST.</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
132 * |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
133 * <li>The "probing" of an AST Node is implemented by insertion of a |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
134 * {@link ProbeNode.WrapperNode} into the AST (as new parent of the Node being probed), together |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
135 * with an associated {@link ProbeNode} that routes execution events at the probed Node to all |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
136 * the {@linkplain ProbeInstrument Instruments} attached to the Probe's |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
137 * <em>instrument chain</em>.</li> |
22224
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
138 * |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
139 * <li>When Truffle clones an AST, any attached WrapperNodes and ProbeNodes are cloned as well, |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
140 * together with their attached instrument chains. Each Probe instance intercepts cloning events |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
141 * and keeps track of all AST copies.</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
142 * |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
143 * <li>All attached {@link InstrumentationNode}s effectively become part of the running program: |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
144 * <ul> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
145 * <li>Good News: instrumentation code implicitly benefits from every kind of Truffle |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
146 * optimization.</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
147 * <li>Bad News: instrumentation code must be implemented carefully to avoid interfering with |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
148 * any Truffle optimizations.</li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
149 * </ul> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
150 * </li> |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
151 * </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
|
152 */ |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
153 Probe(Instrumenter instrumenter, Class<? extends TruffleLanguage> l, ProbeNode probeNode, SourceSection sourceSection) { |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
154 this.instrumenter = instrumenter; |
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
|
155 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
|
156 registerProbeNodeClone(probeNode); |
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
|
157 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
|
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 |
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
|
160 /** |
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
|
161 * 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
|
162 * {@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
|
163 */ |
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 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
|
165 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
|
166 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
|
167 tags.add(tag); |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
168 instrumenter.tagAdded(this, tag, tagValue); |
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
|
169 |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
170 // Update the status of this Probe with respect to global TagInstruments |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
171 boolean tagInstrumentsChanged = false; |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
172 final BeforeTagInstrument beforeTagInstrument = instrumenter.getBeforeTagInstrument(); |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
173 if (beforeTagInstrument != null && tag == beforeTagInstrument.getTag()) { |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
174 this.isBeforeTagInstrumentActive = true; |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
175 tagInstrumentsChanged = true; |
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
|
176 } |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
177 final AfterTagInstrument afterTagInstrument = instrumenter.getAfterTagInstrument(); |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
178 if (afterTagInstrument != null && tag == afterTagInstrument.getTag()) { |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
179 this.isAfterTagInstrumentActive = true; |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
180 tagInstrumentsChanged = true; |
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
|
181 } |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
182 if (tagInstrumentsChanged) { |
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
|
183 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
|
184 } |
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
|
185 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
|
186 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
|
187 } |
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
|
188 } |
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
|
189 } |
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
|
190 |
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
|
191 /** |
22224
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
192 * Is the <em>Probed node</em> tagged as belonging to a particular human-sensible category of |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
193 * language constructs? |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
194 */ |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
195 public boolean isTaggedAs(SyntaxTag tag) { |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
196 assert tag != null; |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
197 return tags.contains(tag); |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
198 } |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
199 |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
200 /** |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
201 * In which user-sensible categories has the <em>Probed node</em> been tagged ( |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
202 * <em>empty set</em> if none). |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
203 */ |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
204 public Collection<SyntaxTag> getSyntaxTags() { |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
205 return Collections.unmodifiableCollection(tags); |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
206 } |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
207 |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
208 /** |
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
|
209 * 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
|
210 * |
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
|
211 * @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
|
212 * @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
|
213 */ |
22255
e7643754d982
Truffle/Instrumentation: rename Instrument to ProbeInstrument to distinguish from another kind to be added.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22226
diff
changeset
|
214 void attach(ProbeInstrument instrument) throws IllegalStateException { |
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
|
215 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
|
216 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
|
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 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
|
219 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
|
220 } |
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 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 } |
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
|
227 } |
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
|
228 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
|
229 } |
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 |
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 /** |
22224
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
232 * Gets the {@link SourceSection} associated with the <en>Probed AST node</em>, possibly |
776dc0a09749
Truffle/Instrumentation: Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
233 * {@code null}. |
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
|
234 */ |
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 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
|
236 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
|
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 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
|
240 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
|
241 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
|
242 } |
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
|
243 |
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
|
244 /** |
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
|
245 * 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
|
246 * 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
|
247 * |
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
|
248 * @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
|
249 * @throws IllegalStateException if instrument not attached at this Probe |
22255
e7643754d982
Truffle/Instrumentation: rename Instrument to ProbeInstrument to distinguish from another kind to be added.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22226
diff
changeset
|
250 * @see ProbeInstrument#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
|
251 */ |
22255
e7643754d982
Truffle/Instrumentation: rename Instrument to ProbeInstrument to distinguish from another kind to be added.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22226
diff
changeset
|
252 void disposeInstrument(ProbeInstrument instrument) throws IllegalStateException { |
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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 } |
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
|
258 } |
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
|
259 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
|
260 } |
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 |
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
|
262 /** |
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
|
263 * 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
|
264 * {@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
|
265 */ |
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
|
266 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
|
267 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
|
268 } |
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
|
269 |
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
|
270 /** |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
271 * Gets the currently active {@linkplain BeforeTagInstrument} at this Probe. Non{@code -null} if |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
272 * the global {@linkplain BeforeTagInstrument} is set and if this Probe holds the |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
273 * {@link SyntaxTag} specified in the instrument. |
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
|
274 */ |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
275 BeforeTagInstrument getBeforeTagInstrument() { |
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
|
276 checkProbeUnchanged(); |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
277 return isBeforeTagInstrumentActive ? instrumenter.getBeforeTagInstrument() : 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
|
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 |
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 /** |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
281 * Gets the currently active {@linkplain AfterTagInstrument} at this Probe. Non{@code -null} if |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
282 * the global {@linkplain BeforeTagInstrument} is set and if this Probe holds the |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
283 * {@link SyntaxTag} specified in the instrument. |
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
|
284 */ |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
285 AfterTagInstrument getAfterTagInstrument() { |
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
|
286 checkProbeUnchanged(); |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
287 return isAfterTagInstrumentActive ? instrumenter.getAfterTagInstrument() : null; |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
288 } |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
289 |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
290 Class<? extends TruffleLanguage> getLanguage() { |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
291 return language; |
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
|
292 } |
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
|
293 |
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 * 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
|
296 * 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
|
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 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
|
299 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
|
300 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
|
301 } 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
|
302 // 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
|
303 // 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
|
304 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
|
305 } |
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 } |
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
|
307 |
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
|
308 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
|
309 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
|
310 } |
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
|
311 |
22256
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
312 void notifyTagInstrumentsChanged() { |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
313 final BeforeTagInstrument beforeTagInstrument = instrumenter.getBeforeTagInstrument(); |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
314 this.isBeforeTagInstrumentActive = beforeTagInstrument != null && this.isTaggedAs(beforeTagInstrument.getTag()); |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
315 final AfterTagInstrument afterTagInstrument = instrumenter.getAfterTagInstrument(); |
75e5db92973a
TruffleInstrumentation: fold the "TagTrap" mechanism into the general framework of Instruments, Listeners, and management via Instrumenter.attach() methods.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22255
diff
changeset
|
316 this.isAfterTagInstrumentActive = afterTagInstrument != null && this.isTaggedAs(afterTagInstrument.getTag()); |
19491
4d66c000d253
Truffle/Instrumentation: more cleanup in Probe
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19490
diff
changeset
|
317 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
|
318 } |
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
|
319 |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22066
diff
changeset
|
320 String getTagsDescription() { |
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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 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
|
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 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
|
330 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
|
331 } |
22293
260e3cdf11ec
Truffle/Instrumentation: replace (non-functional) AdvancedInstrument kind with new EvalInstrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22262
diff
changeset
|
332 |
260e3cdf11ec
Truffle/Instrumentation: replace (non-functional) AdvancedInstrument kind with new EvalInstrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22262
diff
changeset
|
333 Instrumenter getInstrumenter() { |
260e3cdf11ec
Truffle/Instrumentation: replace (non-functional) AdvancedInstrument kind with new EvalInstrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22262
diff
changeset
|
334 return instrumenter; |
260e3cdf11ec
Truffle/Instrumentation: replace (non-functional) AdvancedInstrument kind with new EvalInstrument
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22262
diff
changeset
|
335 } |
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
|
336 } |