annotate truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/CoverageTracker.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 0d36601f233e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
1 /*
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
4 *
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
10 *
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
15 * accompanied this code).
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
16 *
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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,
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
20 *
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
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
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
23 * questions.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
24 */
21568
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20907
diff changeset
25 package com.oracle.truffle.tools;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
26
22219
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
27 import java.io.PrintStream;
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
28 import java.util.ArrayList;
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
29 import java.util.Comparator;
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
30 import java.util.HashMap;
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
31 import java.util.List;
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
32 import java.util.Map;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
33 import java.util.Map.Entry;
22219
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
34 import java.util.TreeSet;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
35
22221
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
36 import com.oracle.truffle.api.instrument.Instrumenter;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
37 import com.oracle.truffle.api.instrument.Probe;
22259
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
38 import com.oracle.truffle.api.instrument.ProbeInstrument;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
39 import com.oracle.truffle.api.instrument.ProbeListener;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
40 import com.oracle.truffle.api.instrument.SimpleInstrumentListener;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
41 import com.oracle.truffle.api.instrument.StandardSyntaxTag;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
42 import com.oracle.truffle.api.instrument.SyntaxTag;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
43 import com.oracle.truffle.api.instrument.impl.DefaultProbeListener;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
44 import com.oracle.truffle.api.instrument.impl.DefaultSimpleInstrumentListener;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
45 import com.oracle.truffle.api.nodes.Node;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
46 import com.oracle.truffle.api.source.LineLocation;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
47 import com.oracle.truffle.api.source.Source;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22093
diff changeset
48 import com.oracle.truffle.api.source.SourceSection;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
49
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
50 /**
22259
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
51 * An {@linkplain Instrumenter.Tool Instrumentation Tool} that counts interpreter
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
52 * <em>execution calls</em> to AST nodes that hold a specified {@linkplain SyntaxTag syntax tag},
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
53 * tabulated by source and line number associated with each node. Syntax tags are presumed to be
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
54 * applied external to the tool. If no tag is specified, {@linkplain StandardSyntaxTag#STATEMENT
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
55 * STATEMENT} is used, corresponding to conventional behavior for code coverage tools.
20907
06b0a2fb20a1 Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20889
diff changeset
56 * <p>
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
57 * <b>Tool Life Cycle</b>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
58 * <p>
22259
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
59 * See {@linkplain Instrumenter.Tool Instrumentation Tool} for the life cycle common to all such
1348cc2e084e Truffle/Instrumentation: javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22255
diff changeset
60 * tools.
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
61 * <p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
62 * <b>Execution Counts</b>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
63 * <p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
64 * <ul>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
65 * <li>"Execution call" on a node is is defined as invocation of a node method that is instrumented
22230
3f2052afcb6d Truffle/Instrumentation: rename the methods in the Instrument listener classes to use the "on" convention, e.g. onEnter(), add Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22225
diff changeset
66 * to produce the event {@link SimpleInstrumentListener#onEnter(Probe)};</li>
22247
c1c9c6d79f40 Truffle/Instrumentation: remove method Instrumenter.isInstrumentable()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22234
diff changeset
67 * <li>Execution calls are tabulated only at nodes where the guest languages supports
c1c9c6d79f40 Truffle/Instrumentation: remove method Instrumenter.isInstrumentable()
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22234
diff changeset
68 * {@linkplain Instrumenter#probe(Node) probing}.</li>
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
69 * <li>Execution calls are tabulated only at nodes present in the AST when originally created;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
70 * dynamically added nodes will not be instrumented.</li>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
71 * </ul>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
72 * </p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
73 * <b>Results</b>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
74 * <p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
75 * A modification-safe copy of the {@linkplain #getCounts() counts} can be retrieved at any time,
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
76 * without effect on the state of the tool.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
77 * </p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
78 * <p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
79 * A "default" {@linkplain #print(PrintStream) print()} method can summarizes the current counts at
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
80 * any time in a simple textual format, with no other effect on the state of the tool.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
81 * </p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
82 *
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: 22247
diff changeset
83 * @see ProbeInstrument
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
84 * @see SyntaxTag
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
85 */
22266
0d36601f233e Merge revised Instrumentation framework into the Polyglot API
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22259
diff changeset
86 public final class CoverageTracker extends Instrumenter.Tool {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
87
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
88 /** Counting data. */
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
89 private final Map<LineLocation, CoverageRecord> coverageMap = new HashMap<>();
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
90
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
91 /** Needed for disposal. */
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: 22247
diff changeset
92 private final List<ProbeInstrument> instruments = new ArrayList<>();
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
93
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
94 /**
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
95 * Coverage counting is restricted to nodes holding this tag.
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
96 */
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
97 private final SyntaxTag countingTag;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
98
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
99 private final ProbeListener probeListener;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
100
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
101 /**
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
102 * Create a per-line coverage tool for nodes tagged as {@linkplain StandardSyntaxTag#STATEMENT
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
103 * statements} in subsequently created ASTs.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
104 */
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
105 public CoverageTracker() {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
106 this(StandardSyntaxTag.STATEMENT);
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
107 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
108
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
109 /**
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
110 * Create a per-line coverage tool for nodes tagged as specified, presuming that tags applied
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
111 * outside this tool.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
112 */
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
113 public CoverageTracker(SyntaxTag tag) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
114 this.probeListener = new CoverageProbeListener();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
115 this.countingTag = tag;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
116 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
117
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
118 @Override
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
119 protected boolean internalInstall() {
22221
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
120 final Instrumenter instrumenter = getInstrumenter();
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
121 for (Probe probe : instrumenter.findProbesTaggedAs(countingTag)) {
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
122 addCoverageCounter(probe);
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
123 }
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
124 instrumenter.addProbeListener(probeListener);
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
125 return true;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
126 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
127
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
128 @Override
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
129 protected void internalReset() {
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
130 coverageMap.clear();
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
131 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
132
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
133 @Override
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
134 protected void internalDispose() {
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: 22093
diff changeset
135 getInstrumenter().removeProbeListener(probeListener);
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: 22247
diff changeset
136 for (ProbeInstrument instrument : instruments) {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
137 instrument.dispose();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
138 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
139 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
140
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
141 /**
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
142 * Gets a modification-safe summary of the current per-type node execution counts; does not
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
143 * affect the counts.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
144 * <p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
145 * The map holds an array for each source, and elements of the a array corresponding to the
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
146 * textual lines of that source. An array entry contains null if the corresponding line of
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
147 * source is associated with no nodes of the relevant type, i.e. where no count was made. A
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
148 * numeric entry represents the execution count at the corresponding line of source.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
149 * <p>
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
150 * <b>Note:</b> source line numbers are 1-based, so array index {@code i} corresponds to source
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
151 * line number {@code i + 1}
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
152 */
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
153 public Map<Source, Long[]> getCounts() {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
154
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
155 /**
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
156 * Counters for every {Source, line number} for which a counter was installed, i.e. for
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
157 * every line associated with an appropriately tagged AST node; iterable in order of source
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
158 * name, then line number.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
159 */
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
160 final TreeSet<Entry<LineLocation, CoverageRecord>> entries = new TreeSet<>(new LineLocationEntryComparator());
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
161
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
162 for (Entry<LineLocation, CoverageRecord> entry : coverageMap.entrySet()) {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
163 entries.add(entry);
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
164 }
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
165 final Map<Source, Long[]> result = new HashMap<>();
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
166 Source curSource = null;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
167 Long[] curLineTable = null;
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
168 for (Entry<LineLocation, CoverageRecord> entry : entries) {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
169 final LineLocation key = entry.getKey();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
170 final Source source = key.getSource();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
171 final int lineNo = key.getLineNumber();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
172 if (source != curSource) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
173 if (curSource != null) {
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
174 result.put(curSource, curLineTable);
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
175 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
176 curSource = source;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
177 curLineTable = new Long[source.getLineCount()];
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
178 }
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
179 curLineTable[lineNo - 1] = entry.getValue().count;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
180 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
181 if (curSource != null) {
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
182 result.put(curSource, curLineTable);
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
183 }
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
184 return result;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
185 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
186
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
187 /**
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
188 * A default printer for the current line counts, producing lines of the form " (<count>) <line
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
189 * number> : <text of line>", grouped by source.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
190 */
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
191 public void print(PrintStream out) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
192 out.println();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
193 out.println(countingTag.name() + " coverage:");
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
194
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
195 /**
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
196 * Counters for every {Source, line number} for which a counter was installed, i.e. for
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
197 * every line associated with an appropriately tagged AST node; iterable in order of source
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
198 * name, then line number.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
199 */
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
200 final TreeSet<Entry<LineLocation, CoverageRecord>> entries = new TreeSet<>(new LineLocationEntryComparator());
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
201
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
202 for (Entry<LineLocation, CoverageRecord> entry : coverageMap.entrySet()) {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
203 entries.add(entry);
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
204 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
205 Source curSource = null;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
206 int curLineNo = 1;
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
207 for (Entry<LineLocation, CoverageRecord> entry : entries) {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
208 final LineLocation key = entry.getKey();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
209 final Source source = key.getSource();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
210 final int lineNo = key.getLineNumber();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
211 if (source != curSource) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
212 if (curSource != null) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
213 while (curLineNo <= curSource.getLineCount()) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
214 displayLine(out, null, curSource, curLineNo++);
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
215 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
216 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
217 curSource = source;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
218 curLineNo = 1;
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
219 out.println();
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
220 out.println(source.getPath());
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
221 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
222 while (curLineNo < lineNo) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
223 displayLine(out, null, curSource, curLineNo++);
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
224 }
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
225 displayLine(out, entry.getValue(), curSource, curLineNo++);
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
226 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
227 if (curSource != null) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
228 while (curLineNo <= curSource.getLineCount()) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
229 displayLine(out, null, curSource, curLineNo++);
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
230 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
231 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
232 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
233
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
234 private static void displayLine(PrintStream out, CoverageRecord record, Source source, int lineNo) {
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
235 if (record == null) {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
236 out.format("%14s", " ");
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
237 } else {
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
238 out.format("(%12d)", record.count);
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
239 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
240 out.format(" %3d: ", lineNo);
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
241 out.println(source.getCode(lineNo));
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
242 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
243
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
244 /**
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
245 * A listener for events at each instrumented AST location. This listener counts
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
246 * "execution calls" to the instrumented node.
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
247 */
20889
73b1844b5b14 Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19818
diff changeset
248 private final class CoverageRecord extends DefaultSimpleInstrumentListener {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
249
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
250 private final SourceSection srcSection; // The text of the code being counted
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: 22247
diff changeset
251 private ProbeInstrument instrument; // The attached Instrument, in case need to remove.
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
252 private long count = 0;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
253
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
254 CoverageRecord(SourceSection srcSection) {
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
255 this.srcSection = srcSection;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
256 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
257
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
258 @Override
22230
3f2052afcb6d Truffle/Instrumentation: rename the methods in the Instrument listener classes to use the "on" convention, e.g. onEnter(), add Javadoc
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22225
diff changeset
259 public void onEnter(Probe probe) {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
260 if (isEnabled()) {
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
261 count++;
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
262 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
263 }
19593
6d895b028a44 Truffle/InstrumentationTools: clean up some misleading code and commentary in CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
264
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
265 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
266
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
267 private static final class LineLocationEntryComparator implements Comparator<Entry<LineLocation, CoverageRecord>> {
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
268
19248
a2ff253c458f Truffle/Instrumentation: code cleanups in tools CoverageTracker and NodeExecCounter, especially for tutorial value
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19187
diff changeset
269 public int compare(Entry<LineLocation, CoverageRecord> e1, Entry<LineLocation, CoverageRecord> e2) {
21987
b2d1c8ff592a Less classes in the source API package. Merging interfaces and their only implementation into final classes. Hiding NullSourceSection behind factory method. Using JDK's standard CharsetDecoder instead of proprietary BytesDecoder.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
270 return e1.getKey().compareTo(e2.getKey());
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
271 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
272 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
273
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
274 /**
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
275 * Attach a counting instrument to each node that is assigned a specified tag.
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
276 */
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
277 private class CoverageProbeListener extends DefaultProbeListener {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
278
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
279 @Override
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
280 public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
281 if (countingTag == tag) {
22221
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
282 addCoverageCounter(probe);
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
283 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
284 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
285 }
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
286
22221
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
287 private void addCoverageCounter(Probe probe) {
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
288 final SourceSection srcSection = probe.getProbedSourceSection();
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
289 if (srcSection == null) {
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
290 // TODO (mlvdv) report this?
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
291 return;
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
292 }
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
293 // Get the source line where the
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
294 final LineLocation lineLocation = srcSection.getLineLocation();
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
295 CoverageRecord record = coverageMap.get(lineLocation);
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
296 if (record != null) {
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
297 // Another node starts on same line; count only the first (textually)
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
298 if (srcSection.getCharIndex() > record.srcSection.getCharIndex()) {
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
299 // Existing record, corresponds to code earlier on line
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
300 return;
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
301 } else {
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
302 // Existing record, corresponds to code at a later position; replace it
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
303 record.instrument.dispose();
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
304 }
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
305 }
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
306
22225
a0fa69e3e60e Truffle/Instrumentation: remove static Instrument factory methods, now supported by Instrumenter
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22221
diff changeset
307 final CoverageRecord coverageRecord = new CoverageRecord(srcSection);
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: 22247
diff changeset
308 final ProbeInstrument instrument = getInstrumenter().attach(probe, coverageRecord, CoverageTracker.class.getSimpleName());
22225
a0fa69e3e60e Truffle/Instrumentation: remove static Instrument factory methods, now supported by Instrumenter
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22221
diff changeset
309 coverageRecord.instrument = instrument;
22221
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
310 instruments.add(instrument);
22225
a0fa69e3e60e Truffle/Instrumentation: remove static Instrument factory methods, now supported by Instrumenter
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22221
diff changeset
311 coverageMap.put(lineLocation, coverageRecord);
22221
c92d6117696f Truffle/Instrumentation: modify behavior of CoverageTracker and LineToProbesMap so that they will work on ASTs created before installation (as long as correct probes are in place)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22220
diff changeset
312 }
18987
ac114ad31cdd Truffle/Tools: a new framework for pluggable tools that gather Truffle execution data
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
313 }