Mercurial > hg > truffle
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/CoverageTracker.java @ 19518:b5467bb34b24
Truffle/Instrumentation: some variable renaming for clarity
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Thu, 19 Feb 2015 11:42:03 -0800 |
parents | a2ff253c458f |
children | 6d895b028a44 |
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 */ |
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
|
25 package com.oracle.truffle.api.tools; |
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 |
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
|
27 import java.io.*; |
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
|
28 import java.util.*; |
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
|
29 import java.util.Map.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
|
30 import java.util.concurrent.atomic.*; |
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
|
31 |
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
|
32 import com.oracle.truffle.api.frame.*; |
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 com.oracle.truffle.api.instrument.*; |
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
|
34 import com.oracle.truffle.api.instrument.impl.*; |
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 import com.oracle.truffle.api.nodes.*; |
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
|
36 import com.oracle.truffle.api.nodes.Node.Child; |
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
|
37 import com.oracle.truffle.api.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
|
38 |
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
|
39 /** |
19187
c5b20395a8bf
Truffle/Instrumentation: eclipseformat
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19186
diff
changeset
|
40 * An {@link InstrumentationTool} that counts interpreter <em>execution calls</em> to AST nodes that |
c5b20395a8bf
Truffle/Instrumentation: eclipseformat
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19186
diff
changeset
|
41 * hold a specified {@linkplain SyntaxTag tag}, tabulated by source and line number associated with |
c5b20395a8bf
Truffle/Instrumentation: eclipseformat
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19186
diff
changeset
|
42 * each node. Tags are presumed to be applied external to the tool. If no tag is specified, |
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
|
43 * {@linkplain StandardSyntaxTag#STATEMENT STATEMENT} is used, corresponding to conventional |
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
|
44 * behavior for code coverage tools. |
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
|
45 * <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
|
46 * <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
|
47 * <p> |
19186
3d2296dbace9
Truffle/Instrumentation: TruffleTool renamed to InstrumentationTool (the base class for a group of tools that collect information during program execution)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18987
diff
changeset
|
48 * See {@link InstrumentationTool} for the life cycle common to all such 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
|
49 * <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
|
50 * <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
|
51 * <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
|
52 * <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
|
53 * <li>"Execution call" on a node is is defined as invocation of a node method that is instrumented |
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
|
54 * to produce the event {@link TruffleEventListener#enter(Node, VirtualFrame)};</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
|
55 * <li>Execution calls are tabulated only at <em>instrumented</em> nodes, i.e. those for which |
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
|
56 * {@linkplain Node#isInstrumentable() isInstrumentable() == true};</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
|
57 * <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
|
58 * 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
|
59 * </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
|
60 * </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
|
61 * <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
|
62 * <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
|
63 * 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
|
64 * 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
|
65 * </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
|
66 * <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
|
67 * 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
|
68 * 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
|
69 * </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
|
70 * |
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 * @see Instrument |
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 * @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
|
73 */ |
19186
3d2296dbace9
Truffle/Instrumentation: TruffleTool renamed to InstrumentationTool (the base class for a group of tools that collect information during program execution)
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18987
diff
changeset
|
74 public final class CoverageTracker extends InstrumentationTool { |
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
|
75 |
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 /** 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
|
77 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
|
78 |
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
|
79 /** Needed for disposal. */ |
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
|
80 private final List<Instrument> instruments = new ArrayList<>(); |
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 |
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 /** |
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
|
83 * 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
|
84 */ |
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 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
|
86 |
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 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
|
88 |
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
|
89 /** |
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 * 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
|
91 * 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
|
92 */ |
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 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
|
94 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
|
95 } |
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 /** |
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 * 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
|
99 * 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
|
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 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
|
102 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
|
103 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
|
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 |
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 @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
|
107 protected boolean internalInstall() { |
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 Probe.addProbeListener(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
|
109 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
|
110 } |
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 |
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 @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
|
113 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
|
114 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
|
115 } |
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 @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
|
118 protected void internalDispose() { |
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 Probe.removeProbeListener(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
|
120 for (Instrument instrument : instruments) { |
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
|
121 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
|
122 } |
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
|
123 } |
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
|
124 |
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 /** |
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 * 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
|
127 * 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
|
128 * <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
|
129 * 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
|
130 * 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
|
131 * 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
|
132 * 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
|
133 * <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
|
134 * <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
|
135 * 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
|
136 */ |
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 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
|
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 * 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
|
141 * 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
|
142 * 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
|
143 */ |
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
|
144 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
|
145 |
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
|
146 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
|
147 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
|
148 } |
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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 } |
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
|
160 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
|
161 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
|
162 } |
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 curLineTable[lineNo - 1] = entry.getValue().count.longValue(); |
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 } |
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
|
165 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
|
166 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
|
167 } |
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 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
|
169 } |
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 |
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 /** |
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 * 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
|
173 * 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
|
174 */ |
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 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
|
176 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
|
177 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
|
178 |
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
|
179 /** |
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 * 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
|
181 * 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
|
182 * 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
|
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 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
|
185 |
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
|
186 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
|
187 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
|
188 } |
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 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 } |
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
|
200 } |
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 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
|
202 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
|
203 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
|
204 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
|
205 } |
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 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
|
207 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
|
208 } |
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 displayLine(out, entry.getValue().count, 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
|
210 } |
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 (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
|
212 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
|
213 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
|
214 } |
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 |
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 private static void displayLine(PrintStream out, AtomicLong value, Source source, int 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
|
219 if (value == 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
|
220 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
|
221 } else { |
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 out.format("(%12d)", value.longValue()); |
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 } |
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 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
|
225 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
|
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 |
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 /** |
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
|
229 * A listener for events at each instrumented AST location. This listener counts |
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
|
230 * "execution calls" to the instrumented node and is <em>stateful</em>. State in listeners must |
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
|
231 * be considered carefully since ASTs, along with all instrumentation (including event listener |
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
|
232 * such as this) are routinely cloned by the Truffle runtime. AST cloning is <em>shallow</em> |
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 * (for non- {@link Child} nodes), so in this case the actual count <em>is shared</em> among all |
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
|
234 * the clones; the count is also held in a table indexed by source 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
|
235 * <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
|
236 * In contrast, a primitive field would <em>not</em> be shared among clones and resulting 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
|
237 * would not be accurate. |
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
|
238 */ |
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
|
239 private final class CoverageEventListener extends DefaultEventListener { |
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
|
240 |
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 /** |
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 * Shared by all clones of the associated instrument and by the table of counters for 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
|
243 * 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
|
244 */ |
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
|
245 private final AtomicLong count; |
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
|
246 |
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
|
247 CoverageEventListener(AtomicLong 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
|
248 this.count = count; |
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 } |
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
|
250 |
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
|
251 @Override |
19518
b5467bb34b24
Truffle/Instrumentation: some variable renaming for clarity
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19248
diff
changeset
|
252 public void enter(Node node, VirtualFrame vFrame) { |
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 if (isEnabled()) { |
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
|
254 count.getAndIncrement(); |
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
|
255 } |
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 |
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
|
259 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
|
260 |
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
|
261 public int compare(Entry<LineLocation, CoverageRecord> e1, Entry<LineLocation, CoverageRecord> e2) { |
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 return LineLocation.COMPARATOR.compare(e1.getKey(), e2.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
|
263 } |
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
|
264 } |
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 /** |
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
|
267 * 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
|
268 */ |
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
|
269 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
|
270 |
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 @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
|
272 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
|
273 if (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
|
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 final SourceSection srcSection = probe.getProbedSourceSection(); |
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 if (srcSection == 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
|
277 // TODO (mlvdv) report 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
|
278 } else { |
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
|
279 // Get the source line where the |
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
|
280 final LineLocation lineLocation = srcSection.getLineLocation(); |
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
|
281 CoverageRecord record = coverageMap.get(lineLocation); |
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
|
282 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
|
283 // Another node starts on same line; count only the first (textually) |
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
|
284 if (srcSection.getCharIndex() > record.srcSection.getCharIndex()) { |
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
|
285 // Record already in place, corresponds to code earlier on line |
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
|
286 return; |
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
|
287 } else { |
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
|
288 // Record already in place, corresponds to later code; replace it |
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
|
289 record.instrument.dispose(); |
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
|
290 } |
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
|
291 } |
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
|
292 final AtomicLong count = new AtomicLong(); |
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
|
293 final CoverageEventListener eventListener = new CoverageEventListener(count); |
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
|
294 final Instrument instrument = Instrument.create(eventListener, CoverageTracker.class.getSimpleName()); |
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
|
295 instruments.add(instrument); |
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
|
296 probe.attach(instrument); |
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
|
297 coverageMap.put(lineLocation, new CoverageRecord(srcSection, instrument, 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
|
298 } |
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
|
299 } |
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
|
300 } |
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
|
301 } |
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
|
302 |
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
|
303 private class CoverageRecord { |
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
|
304 |
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
|
305 final SourceSection srcSection; // The text of the code being counted |
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
|
306 final Instrument instrument; // The attached Instrument, in case need to remove. |
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
|
307 final AtomicLong count; |
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
|
308 |
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
|
309 CoverageRecord(SourceSection srcSection, Instrument instrument, AtomicLong 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
|
310 this.srcSection = srcSection; |
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
|
311 this.instrument = instrument; |
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
|
312 this.count = count; |
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 } |
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
|
314 } |
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
|
315 |
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
|
316 } |