# HG changeset patch # User Michael Van De Vanter # Date 1442880207 25200 # Node ID 959f658b918dc70930a005cca47fa812d0ffa6a9 # Parent 1f19e3cada3d0fffedf925737e954281fa616365 Truffle/Instrumentation: generify Instrumenter.install(Tool) in the type of the tool. diff -r 1f19e3cada3d -r 959f658b918d truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/LineBreakpointFactory.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/LineBreakpointFactory.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/LineBreakpointFactory.java Mon Sep 21 17:03:27 2015 -0700 @@ -138,8 +138,7 @@ this.warningLog = warningLog; final Instrumenter instrumenter = debugger.getInstrumenter(); - lineToProbesMap = new LineToProbesMap(); - instrumenter.install(lineToProbesMap); + lineToProbesMap = instrumenter.install(new LineToProbesMap()); instrumenter.addProbeListener(new DefaultProbeListener() { diff -r 1f19e3cada3d -r 959f658b918d truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/LineToProbesMap.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/LineToProbesMap.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/LineToProbesMap.java Mon Sep 21 17:03:27 2015 -0700 @@ -43,7 +43,7 @@ * An {@link InstrumentationTool} that builds a map of every {@link Probe} attached to some AST, * indexed by {@link Source} and line number. */ -final class LineToProbesMap extends Instrumenter.Tool { +final class LineToProbesMap extends Instrumenter.Tool { private static final boolean TRACE = false; private static final PrintStream OUT = System.out; diff -r 1f19e3cada3d -r 959f658b918d truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java --- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java Mon Sep 21 17:03:27 2015 -0700 @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -122,7 +123,7 @@ * language-agnostic management of individual execution environments is added to the platform, * installation will be (optionally) specific to a single execution environment. */ - public abstract static class Tool { + public abstract static class Tool> { // TODO (mlvdv) still thinking about the most appropriate name for this class of tools private ToolState toolState = ToolState.UNINSTALLED; @@ -234,7 +235,7 @@ private final Object vm; /** Tools that have been created, but not yet disposed. */ - private final Set tools = Collections.synchronizedSet(new LinkedHashSet()); + Set>> tools = new HashSet<>(); private final Set astProbers = Collections.synchronizedSet(new LinkedHashSet()); @@ -544,10 +545,12 @@ /** * Connects the tool to some part of the Truffle runtime, and enable data collection to start. * + * @return the tool * @throws IllegalStateException if the tool has previously been installed or has been disposed. */ - public void install(Tool tool) { + public > T install(T tool) { tool.install(this); + return tool; } @SuppressWarnings("unused") diff -r 1f19e3cada3d -r 959f658b918d truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/TruffleToolTest.java --- a/truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/TruffleToolTest.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/TruffleToolTest.java Mon Sep 21 17:03:27 2015 -0700 @@ -130,7 +130,7 @@ return instrumenter; } - private static final class DummyTruffleTool extends Instrumenter.Tool { + private static final class DummyTruffleTool extends Instrumenter.Tool { @Override protected boolean internalInstall() { diff -r 1f19e3cada3d -r 959f658b918d truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/CoverageTracker.java --- a/truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/CoverageTracker.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/CoverageTracker.java Mon Sep 21 17:03:27 2015 -0700 @@ -82,7 +82,7 @@ * @see Instrument * @see SyntaxTag */ -public final class CoverageTracker extends Instrumenter.Tool { +public final class CoverageTracker extends Instrumenter.Tool { /** Counting data. */ private final Map coverageMap = new HashMap<>(); diff -r 1f19e3cada3d -r 959f658b918d truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/LineToProbesMap.java --- a/truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/LineToProbesMap.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/LineToProbesMap.java Mon Sep 21 17:03:27 2015 -0700 @@ -43,7 +43,7 @@ * An {@link InstrumentationTool} that builds a map of every {@link Probe} attached to some AST, * indexed by {@link Source} and line number. */ -public final class LineToProbesMap extends Instrumenter.Tool { +public final class LineToProbesMap extends Instrumenter.Tool { private static final boolean TRACE = false; private static final PrintStream OUT = System.out; diff -r 1f19e3cada3d -r 959f658b918d truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/NodeExecCounter.java --- a/truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/NodeExecCounter.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.tools/src/com/oracle/truffle/tools/NodeExecCounter.java Mon Sep 21 17:03:27 2015 -0700 @@ -96,7 +96,7 @@ * @see SyntaxTag * @see ProbeFailure */ -public final class NodeExecCounter extends Instrumenter.Tool { +public final class NodeExecCounter extends Instrumenter.Tool { /** * Execution count for AST nodes of a particular type. @@ -119,7 +119,7 @@ /* * Everything up to here is inlined by Truffle compilation. Delegate the next part * to a method behind an inlining boundary. - * + * * Note that it is not permitted to pass a {@link VirtualFrame} across an inlining * boundary; they are truly virtual in inlined code. */