Mercurial > hg > truffle
changeset 4409:9f8e4aeec1a9
Merge
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Sun, 29 Jan 2012 11:40:04 +0100 |
parents | b197bbb58d2f (current diff) 3b776fb6ffd9 (diff) |
children | 646a6bfecf73 c8de52cc672a |
files | graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiResult.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalContext.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalTimers.java graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterObserver.java mx.bat src/share/tools/IdealGraphVisualizer/ControlFlow/build.xml src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/platform.properties src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.properties src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentSettings.xml src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentWstcref.xml src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/layer.xml src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/NullScriptEngine.java src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ScriptEngineAbstraction.java src/share/tools/IdealGraphVisualizer/Graal/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/GraalGraphToTextConverter.java src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java src/share/tools/IdealGraphVisualizer/GraphTextEditor/build.xml src/share/tools/IdealGraphVisualizer/GraphTextEditor/manifest.mf src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.properties src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.xml src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml src/share/tools/IdealGraphVisualizer/GraphToText/build.xml src/share/tools/IdealGraphVisualizer/GraphToText/manifest.mf src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/platform.properties src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.properties src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.xml src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterEdge.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterIngoingConnection.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterInputSlotNode.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutgoingConnection.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/InterClusterConnection.java src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/build.xml src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/manifest.mf src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.properties src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.xml src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java src/share/tools/IdealGraphVisualizer/NetworkConnection/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupReceiver src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/build.xml src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/manifest.mf src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.properties src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.xml src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerGraphToTextConverter.java src/share/tools/IdealGraphVisualizer/StructuredText/build.xml src/share/tools/IdealGraphVisualizer/StructuredText/manifest.mf src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/platform.properties src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.properties src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.xml src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java src/share/tools/IdealGraphVisualizer/TextEditor/build.xml src/share/tools/IdealGraphVisualizer/TextEditor/manifest.mf src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/platform.properties src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.properties src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.xml src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/suite.properties src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditor.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditorKit.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManager.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManagerFactory.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextHighlightsLayerFactory.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextSideBarFactory.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/layer.xml src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/org-netbeans-modules-editor-preferences.xml src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/EnableBlockLayoutAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/BlockWidget.java src/share/vm/graal/graal_paths.hpp |
diffstat | 373 files changed, 3694 insertions(+), 12692 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiResult.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.max.cri.ci; - -/** - * Represents the result of compiling a method. The result can include a target method with machine code and metadata, - * and/or statistics. If the compiler bailed out due to malformed bytecode, an internal error, or other cause, it will - * supply the bailout object. - */ -public class CiResult { - private final CiTargetMethod targetMethod; - private final CiBailout bailout; - - /** - * Creates a new compilation result. - * @param targetMethod the method that was produced, if any - * @param bailout the bailout condition that occurred - * @param stats statistics about the compilation - */ - public CiResult(CiTargetMethod targetMethod, CiBailout bailout) { - this.targetMethod = targetMethod; - this.bailout = bailout; - } - - /** - * Gets the target method that was produced by this compilation. If no target method was - * produced, but a bailout occured, then the bailout exception will be thrown at this point. - * @return the target method produced - * @throws {@link CiBailout} if a bailout occurred - */ - public CiTargetMethod targetMethod() { - if (bailout != null) { - throw bailout; - } - return targetMethod; - } - - /** - * Returns the bailout condition that occurred for this compilation, if any. - * @return the bailout - */ - public CiBailout bailout() { - return bailout; - } -}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/LinearScanAllocator.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/LinearScanAllocator.java Sun Jan 29 11:40:04 2012 +0100 @@ -39,16 +39,15 @@ import com.oracle.max.graal.compiler.lir.LIRPhiMapping.PhiValueProcedure; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; public class LinearScanAllocator { - private final GraalContext context; private final LIR lir; private final FrameMap frameMap; private final DataFlowAnalysis dataFlow; - public LinearScanAllocator(GraalContext context, LIR lir, FrameMap frameMap) { - this.context = context; + public LinearScanAllocator(LIR lir, FrameMap frameMap) { this.lir = lir; this.frameMap = frameMap; @@ -159,23 +158,23 @@ assert LIRVerifier.verify(true, lir, frameMap); dataFlow.execute(); - IntervalPrinter.printBeforeAllocation("Before register allocation", context, lir, frameMap.registerConfig, dataFlow); + IntervalPrinter.printBeforeAllocation("Before register allocation", lir, frameMap.registerConfig, dataFlow); allocate(); - IntervalPrinter.printAfterAllocation("After linear scan allocation", context, lir, frameMap.registerConfig, dataFlow, blockEndLocations); + IntervalPrinter.printAfterAllocation("After linear scan allocation", lir, frameMap.registerConfig, dataFlow, blockEndLocations); ResolveDataFlow resolveDataFlow = new ResolveDataFlowImpl(lir, moveResolver, dataFlow); resolveDataFlow.execute(); frameMap.finish(); - IntervalPrinter.printAfterAllocation("After resolve data flow", context, lir, frameMap.registerConfig, dataFlow, blockEndLocations); + IntervalPrinter.printAfterAllocation("After resolve data flow", lir, frameMap.registerConfig, dataFlow, blockEndLocations); assert RegisterVerifier.verify(lir, frameMap); AssignRegisters assignRegisters = new AssignRegistersImpl(lir, frameMap); assignRegisters.execute(); - context.observable.fireCompilationEvent("After register asignment", lir); + Debug.dump(lir, "After register asignment"); assert LIRVerifier.verify(false, lir, frameMap); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java Sun Jan 29 11:40:04 2012 +0100 @@ -39,16 +39,15 @@ import com.oracle.max.graal.compiler.lir.LIRPhiMapping.PhiValueProcedure; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; public class SpillAllAllocator { - private final GraalContext context; private final LIR lir; private final FrameMap frameMap; private final DataFlowAnalysis dataFlow; - public SpillAllAllocator(GraalContext context, LIR lir, FrameMap frameMap) { - this.context = context; + public SpillAllAllocator(LIR lir, FrameMap frameMap) { this.lir = lir; this.frameMap = frameMap; @@ -134,23 +133,23 @@ assert LIRVerifier.verify(true, lir, frameMap); dataFlow.execute(); - IntervalPrinter.printBeforeAllocation("Before register allocation", context, lir, frameMap.registerConfig, dataFlow); + IntervalPrinter.printBeforeAllocation("Before register allocation", lir, frameMap.registerConfig, dataFlow); allocate(); - IntervalPrinter.printAfterAllocation("After spill all allocation", context, lir, frameMap.registerConfig, dataFlow, blockLocations); + IntervalPrinter.printAfterAllocation("After spill all allocation", lir, frameMap.registerConfig, dataFlow, blockLocations); ResolveDataFlow resolveDataFlow = new ResolveDataFlowImpl(lir, moveResolver, dataFlow); resolveDataFlow.execute(); frameMap.finish(); - IntervalPrinter.printAfterAllocation("After resolve data flow", context, lir, frameMap.registerConfig, dataFlow, blockLocations); + IntervalPrinter.printAfterAllocation("After resolve data flow", lir, frameMap.registerConfig, dataFlow, blockLocations); assert RegisterVerifier.verify(lir, frameMap); AssignRegisters assignRegisters = new AssignRegistersImpl(lir, frameMap); assignRegisters.execute(); - context.observable.fireCompilationEvent("After register asignment", lir); + Debug.dump(lir, "After register asignment"); assert LIRVerifier.verify(false, lir, frameMap); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/IntervalPrinter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/IntervalPrinter.java Sun Jan 29 11:40:04 2012 +0100 @@ -30,7 +30,6 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.max.graal.alloc.simple.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandFlag; import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandMode; @@ -39,18 +38,22 @@ public final class IntervalPrinter { - public static void printBeforeAllocation(String label, GraalContext context, LIR lir, RiRegisterConfig registerConfig, DataFlowAnalysis dataFlow) { - if (context.isObserved()) { - IntervalPrinter printer = new IntervalPrinter(lir, registerConfig, dataFlow, null); - context.observable.fireCompilationEvent(label, lir, printer.execute()); - } + @SuppressWarnings("unused") + public static void printBeforeAllocation(String label, LIR lir, RiRegisterConfig registerConfig, DataFlowAnalysis dataFlow) { + // TODO(tw): Fix printing. +// if (context.isObserved()) { +// IntervalPrinter printer = new IntervalPrinter(lir, registerConfig, dataFlow, null); +// context.observable.fireCompilationEvent(label, lir, printer.execute()); +// } } - public static void printAfterAllocation(String label, GraalContext context, LIR lir, RiRegisterConfig registerConfig, DataFlowAnalysis dataFlow, LocationMap[] blockEndLocations) { - if (context.isObserved()) { - IntervalPrinter printer = new IntervalPrinter(lir, registerConfig, dataFlow, blockEndLocations); - context.observable.fireCompilationEvent(label, lir, printer.execute()); - } + @SuppressWarnings("unused") + public static void printAfterAllocation(String label, LIR lir, RiRegisterConfig registerConfig, DataFlowAnalysis dataFlow, LocationMap[] blockEndLocations) { + // TODO(tw): Fix printing. +// if (context.isObserved()) { +// IntervalPrinter printer = new IntervalPrinter(lir, registerConfig, dataFlow, blockEndLocations); +// context.observable.fireCompilationEvent(label, lir, printer.execute()); +// } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,6 +23,7 @@ package com.oracle.max.graal.compiler; import java.util.*; +import java.util.concurrent.*; import com.oracle.max.asm.*; import com.oracle.max.cri.ci.*; @@ -34,19 +35,17 @@ import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.gen.*; import com.oracle.max.graal.compiler.lir.*; -import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.target.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; public class GraalCompiler { - public final GraalContext context; - /** * The target that this compiler has been configured for. */ @@ -67,8 +66,7 @@ */ public final Backend backend; - public GraalCompiler(GraalContext context, GraalRuntime runtime, CiTarget target, Backend backend, RiXirGenerator xirGen) { - this.context = context; + public GraalCompiler(GraalRuntime runtime, CiTarget target, Backend backend, RiXirGenerator xirGen) { this.runtime = runtime; this.target = target; this.xir = xirGen; @@ -79,169 +77,135 @@ return compileMethod(method, new StructuredGraph(method), osrBCI, plan); } - public CiTargetMethod compileMethod(RiResolvedMethod method, StructuredGraph graph, int osrBCI, PhasePlan plan) { + public CiTargetMethod compileMethod(final RiResolvedMethod method, final StructuredGraph graph, int osrBCI, final PhasePlan plan) { if (osrBCI != -1) { throw new CiBailout("No OSR supported"); } - context.timers.startScope(getClass()); - try { - long startTime = 0; - int index = context.metrics.CompiledMethods++; - final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); - if (printCompilation) { - TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", - index, - method.holder().name(), - method.name(), - method.signature().asString())); - startTime = System.nanoTime(); - } - TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); - - CiTargetMethod result = null; - context.observable.fireCompilationStarted(runtime, target, method); - try { - try { - CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null; - LIR lir = emitHIR(graph, assumptions, plan); - FrameMap frameMap = emitLIR(lir, graph, method); - result = emitCode(assumptions, method, lir, frameMap); - - if (GraalOptions.Meter) { - context.metrics.BytecodesCompiled += method.codeSize(); + return Debug.scope(createScopeName(method), method, new Callable<CiTargetMethod>() { + public CiTargetMethod call() { + final CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null; + final LIR lir = Debug.scope("FrontEnd", graph, new Callable<LIR>() { + public LIR call() { + return emitHIR(graph, assumptions, plan); + } + }); + final FrameMap frameMap = Debug.scope("BackEnd", lir, new Callable<FrameMap>() { + public FrameMap call() { + return emitLIR(lir, graph, method); + } + }); + return Debug.scope("CodeGen", frameMap, new Callable<CiTargetMethod>() { + public CiTargetMethod call() { + return emitCode(assumptions, method, lir, frameMap); } - } catch (CiBailout | GraalInternalError exception) { - throw exception; - } catch (Throwable t) { - throw new GraalInternalError(t); - } - } catch (GraalInternalError error) { - error.addContext("method", CiUtil.format("%H.%n(%p):%r", method)); - if (context.isObserved()) { - if (error.node() != null) { - context.observable.fireCompilationEvent("VerificationError on Node " + error.node(), CompilationEvent.ERROR, this, error.node().graph()); - } else if (error.graph() != null) { - context.observable.fireCompilationEvent("VerificationError on Graph " + error.graph(), CompilationEvent.ERROR, this, error.graph()); - } - } - throw error; - } finally { - context.observable.fireCompilationFinished(runtime, target, method); - filter.remove(); - if (printCompilation) { - long time = (System.nanoTime() - startTime) / 100000; - TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", - index, - "", - "", - "", - time / 10, - time % 10, - graph.getNodeCount(), - (result != null ? result.targetCodeSize() : -1))); - } + }); } + }); + } - return result; - } finally { - context.timers.endScope(); + private static String createScopeName(RiResolvedMethod method) { + if (Debug.isEnabled()) { + return String.format("[%s::%s]", createSimpleName(method.holder()), method.name()); + } else { + return null; } } + private static String createSimpleName(RiResolvedType holder) { + String base = holder.name(); + int slashIndex = base.lastIndexOf('/'); + if (slashIndex == -1) { + slashIndex = 0; + } + return base.substring(slashIndex + 1, base.length() - 1); + } + /** * Builds the graph, optimizes it. */ public LIR emitHIR(StructuredGraph graph, CiAssumptions assumptions, PhasePlan plan) { - try { - context.timers.startScope("HIR"); + + if (graph.start().next() == null) { + plan.runPhases(PhasePosition.AFTER_PARSING, graph); + new DeadCodeEliminationPhase().apply(graph); + } else { + Debug.dump(graph, "initial state"); + } + + new PhiStampPhase().apply(graph); - if (graph.start().next() == null) { - plan.runPhases(PhasePosition.AFTER_PARSING, graph, context); - new DeadCodeEliminationPhase().apply(graph, context); - } else { - if (context.isObserved()) { - context.observable.fireCompilationEvent("initial state", graph); - } - } + if (GraalOptions.ProbabilityAnalysis && graph.start().probability() == 0) { + new ComputeProbabilityPhase().apply(graph); + } - new PhiStampPhase().apply(graph); + if (GraalOptions.Intrinsify) { + new IntrinsificationPhase(runtime).apply(graph); + } - if (GraalOptions.ProbabilityAnalysis && graph.start().probability() == 0) { - new ComputeProbabilityPhase().apply(graph, context); - } - - if (GraalOptions.Intrinsify) { - new IntrinsificationPhase(runtime).apply(graph, context); - } + if (GraalOptions.Inline && !plan.isPhaseDisabled(InliningPhase.class)) { + new InliningPhase(target, runtime, null, assumptions, plan).apply(graph); + new DeadCodeEliminationPhase().apply(graph); + new PhiStampPhase().apply(graph); + } - if (GraalOptions.Inline && !plan.isPhaseDisabled(InliningPhase.class)) { - new InliningPhase(target, runtime, null, assumptions, plan).apply(graph, context); - new DeadCodeEliminationPhase().apply(graph, context); - new PhiStampPhase().apply(graph); - } + if (GraalOptions.OptCanonicalizer) { + new CanonicalizerPhase(target, runtime, assumptions).apply(graph); + } - if (GraalOptions.OptCanonicalizer) { - new CanonicalizerPhase(target, runtime, assumptions).apply(graph, context); - } + plan.runPhases(PhasePosition.HIGH_LEVEL, graph); + + if (GraalOptions.OptLoops) { + new SafepointPollingEliminationPhase().apply(graph); + } - plan.runPhases(PhasePosition.HIGH_LEVEL, graph, context); - - if (GraalOptions.OptLoops) { - new SafepointPollingEliminationPhase().apply(graph, context); - } + if (GraalOptions.EscapeAnalysis && !plan.isPhaseDisabled(EscapeAnalysisPhase.class)) { + new EscapeAnalysisPhase(target, runtime, assumptions, plan).apply(graph); + new PhiStampPhase().apply(graph); + new CanonicalizerPhase(target, runtime, assumptions).apply(graph); + } - if (GraalOptions.EscapeAnalysis && !plan.isPhaseDisabled(EscapeAnalysisPhase.class)) { - new EscapeAnalysisPhase(target, runtime, assumptions, plan).apply(graph, context); - new PhiStampPhase().apply(graph); - new CanonicalizerPhase(target, runtime, assumptions).apply(graph, context); - } + if (GraalOptions.OptGVN) { + new GlobalValueNumberingPhase().apply(graph); + } + graph.mark(); + new LoweringPhase(runtime).apply(graph); + new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph); + + if (GraalOptions.Lower) { + new FloatingReadPhase().apply(graph); if (GraalOptions.OptGVN) { - new GlobalValueNumberingPhase().apply(graph, context); + new GlobalValueNumberingPhase().apply(graph); } - - graph.mark(); - new LoweringPhase(runtime).apply(graph, context); - new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph, context); - - if (GraalOptions.Lower) { - new FloatingReadPhase().apply(graph, context); + if (GraalOptions.OptReadElimination) { + new ReadEliminationPhase().apply(graph); + } + } + new RemovePlaceholderPhase().apply(graph); + new DeadCodeEliminationPhase().apply(graph); - if (GraalOptions.OptGVN) { - new GlobalValueNumberingPhase().apply(graph, context); - } + plan.runPhases(PhasePosition.MID_LEVEL, graph); - if (GraalOptions.OptReadElimination) { - new ReadEliminationPhase().apply(graph, context); - } - } - new RemovePlaceholderPhase().apply(graph, context); - new DeadCodeEliminationPhase().apply(graph, context); + plan.runPhases(PhasePosition.LOW_LEVEL, graph); - plan.runPhases(PhasePosition.MID_LEVEL, graph, context); + final IdentifyBlocksPhase schedule = new IdentifyBlocksPhase(true, LIRBlock.FACTORY); + schedule.apply(graph); - plan.runPhases(PhasePosition.LOW_LEVEL, graph, context); - - IdentifyBlocksPhase schedule = new IdentifyBlocksPhase(true, LIRBlock.FACTORY); - schedule.apply(graph, context); - - if (context.isObserved()) { - context.observable.fireCompilationEvent("After IdentifyBlocksPhase", graph, schedule); + final List<Block> blocks = schedule.getBlocks(); + final NodeMap<LIRBlock> valueToBlock = new NodeMap<>(graph); + for (Block b : blocks) { + for (Node i : b.getInstructions()) { + valueToBlock.set(i, (LIRBlock) b); } + } + final LIRBlock startBlock = valueToBlock.get(graph.start()); + assert startBlock != null; + assert startBlock.numberOfPreds() == 0; - List<Block> blocks = schedule.getBlocks(); - NodeMap<LIRBlock> valueToBlock = new NodeMap<>(graph); - for (Block b : blocks) { - for (Node i : b.getInstructions()) { - valueToBlock.set(i, (LIRBlock) b); - } - } - LIRBlock startBlock = valueToBlock.get(graph.start()); - assert startBlock != null; - assert startBlock.numberOfPreds() == 0; + return Debug.scope("Compute Linear Scan Order", new Callable<LIR>() { - context.timers.startScope("Compute Linear Scan Order"); - try { + @Override + public LIR call() { ComputeLinearScanOrder clso = new ComputeLinearScanOrder(blocks.size(), schedule.loopCount(), startBlock); List<LIRBlock> linearScanOrder = clso.linearScanOrder(); List<LIRBlock> codeEmittingOrder = clso.codeEmittingOrder(); @@ -252,111 +216,67 @@ } LIR lir = new LIR(startBlock, linearScanOrder, codeEmittingOrder, valueToBlock, schedule.loopCount()); - - if (context.isObserved()) { - context.observable.fireCompilationEvent("After linear scan order", graph, lir); - } + Debug.dump(lir, "After linear scan order"); return lir; - } catch (AssertionError t) { - context.observable.fireCompilationEvent("AssertionError in ComputeLinearScanOrder", CompilationEvent.ERROR, graph); - throw t; - } catch (RuntimeException t) { - context.observable.fireCompilationEvent("RuntimeException in ComputeLinearScanOrder", CompilationEvent.ERROR, graph); - throw t; - } finally { - context.timers.endScope(); + } - } finally { - context.timers.endScope(); - } + }); } - public FrameMap emitLIR(LIR lir, StructuredGraph graph, RiResolvedMethod method) { - context.timers.startScope("LIR"); - try { - if (GraalOptions.GenLIR) { - context.timers.startScope("Create LIR"); - LIRGenerator lirGenerator = null; - FrameMap frameMap; - try { - frameMap = backend.newFrameMap(runtime.getRegisterConfig(method)); - - lirGenerator = backend.newLIRGenerator(context, graph, frameMap, method, lir, xir); + public FrameMap emitLIR(final LIR lir, StructuredGraph graph, final RiResolvedMethod method) { + final FrameMap frameMap = backend.newFrameMap(runtime.getRegisterConfig(method)); + final LIRGenerator lirGenerator = backend.newLIRGenerator(graph, frameMap, method, lir, xir); - for (LIRBlock b : lir.linearScanOrder()) { - lirGenerator.doBlock(b); - } - - for (LIRBlock b : lir.linearScanOrder()) { - if (b.phis != null) { - b.phis.fillInputs(lirGenerator); - } - } - } finally { - context.timers.endScope(); + Debug.scope("LIRGen", new Runnable() { + public void run() { + for (LIRBlock b : lir.linearScanOrder()) { + lirGenerator.doBlock(b); } - if (context.isObserved()) { - context.observable.fireCompilationEvent("After LIR generation", graph, lir, lirGenerator); + for (LIRBlock b : lir.linearScanOrder()) { + if (b.phis != null) { + b.phis.fillInputs(lirGenerator); + } } + + Debug.dump(lirGenerator, "After LIR generation"); if (GraalOptions.PrintLIR && !TTY.isSuppressed()) { LIR.printLIR(lir.linearScanOrder()); } - - if (GraalOptions.AllocSSA) { - new LinearScanAllocator(context, lir, frameMap).execute(); -// new SpillAllAllocator(context, lir, frameMap).execute(); - } else { - new LinearScan(context, target, method, graph, lir, lirGenerator, frameMap).allocate(); - } - return frameMap; - } else { - return null; } - } catch (Error e) { - if (context.isObserved() && GraalOptions.PlotOnError) { - context.observable.fireCompilationEvent(e.getClass().getSimpleName() + " in emitLIR", CompilationEvent.ERROR, graph); + }); + + Debug.scope("Allocator", new Runnable() { + public void run() { + if (GraalOptions.AllocSSA) { + new LinearScanAllocator(lir, frameMap).execute(); + // new SpillAllAllocator(context, lir, frameMap).execute(); + } else { + new LinearScan(target, method, lir, lirGenerator, frameMap).allocate(); + } } - throw e; - } catch (RuntimeException e) { - if (context.isObserved() && GraalOptions.PlotOnError) { - context.observable.fireCompilationEvent(e.getClass().getSimpleName() + " in emitLIR", CompilationEvent.ERROR, graph); - } - throw e; - } finally { - context.timers.endScope(); - } + }); + return frameMap; } private TargetMethodAssembler createAssembler(FrameMap frameMap, LIR lir) { AbstractAssembler masm = backend.newAssembler(frameMap.registerConfig); - TargetMethodAssembler tasm = new TargetMethodAssembler(context, target, runtime, frameMap, lir.slowPaths, masm); + TargetMethodAssembler tasm = new TargetMethodAssembler(target, runtime, frameMap, lir.slowPaths, masm); tasm.setFrameSize(frameMap.frameSize()); tasm.targetMethod.setCustomStackAreaOffset(frameMap.offsetToCustomArea()); return tasm; } public CiTargetMethod emitCode(CiAssumptions assumptions, RiResolvedMethod method, LIR lir, FrameMap frameMap) { - if (GraalOptions.GenLIR && GraalOptions.GenCode) { - context.timers.startScope("Create Code"); - try { - TargetMethodAssembler tasm = createAssembler(frameMap, lir); - lir.emitCode(tasm); + TargetMethodAssembler tasm = createAssembler(frameMap, lir); + lir.emitCode(tasm); - CiTargetMethod targetMethod = tasm.finishTargetMethod(method, false); - if (assumptions != null && !assumptions.isEmpty()) { - targetMethod.setAssumptions(assumptions); - } - - if (context.isObserved()) { - context.observable.fireCompilationEvent("After code generation", lir, targetMethod); - } - return targetMethod; - } finally { - context.timers.endScope(); - } + CiTargetMethod targetMethod = tasm.finishTargetMethod(method, false); + if (assumptions != null && !assumptions.isEmpty()) { + targetMethod.setAssumptions(assumptions); } - return null; + Debug.dump(targetMethod, "After code generation"); + return targetMethod; } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalContext.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.max.graal.compiler; - -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.observer.*; - -/** - * This class is intended for non-essential stuff like statistics, observing, etc. It should not be used for anything - * that has a direct influence on the result of a compilation! - */ -public class GraalContext { - - public static final GraalContext EMPTY_CONTEXT = new GraalContext("silent context"); - - public final ObservableContext observable = new ObservableContext(); - public final GraalTimers timers = new GraalTimers(); - public final GraalMetrics metrics = new GraalMetrics(); - - private final String name; - - public GraalContext(String name) { - this.name = name; - } - - public boolean isObserved() { - return observable.isObserved(); - } - - public void addCompilationObserver(CompilationObserver observer) { - observable.addCompilationObserver(observer); - } - - public void print() { - if (GraalOptions.Meter || GraalOptions.Time) { - for (int i = 0; i < 22 + name.length(); i++) { - TTY.print('='); - } - TTY.println("\n========== " + name + " =========="); - if (GraalOptions.Meter) { - metrics.print(); - } - if (GraalOptions.Time) { - timers.print(); - } - } - } -}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.max.graal.compiler; - -import java.lang.reflect.*; -import java.util.*; -import java.util.Map.Entry; - -import com.oracle.max.criutils.*; - - -/** - * This class contains a number of fields that collect metrics about compilation, particularly - * the number of times certain optimizations are performed. - */ -public final class GraalMetrics { - // Checkstyle: stop - public int CompiledMethods; - public int TargetMethods; - public int LocalValueNumberHits; - public int ValueMapResizes; - public int InlinedFinalizerChecks; - public int InlineForcedMethods; - public int InlineForbiddenMethods; - public int InlineConsidered; - public int InlinePerformed; - public int InlineUncompiledConsidered; - public int InlineUncompiledPerformed; - public int BlocksDeleted; - public int BytecodesCompiled; - public int CodeBytesEmitted; - public int SafepointsEmitted; - public int ExceptionHandlersEmitted; - public int DataPatches; - public int DirectCallSitesEmitted; - public int IndirectCallSitesEmitted; - public int LiveHIRInstructions; - public int LIRInstructions; - public int LIRVariables; - public int LIRXIRInstructions; - public int LIRMoveInstructions; - public int LSRAIntervalsCreated; - public int LSRASpills; - public int LoadConstantIterations; - public int CodeBufferCopies; - public int UniqueValueIdsAssigned; - public int FrameStatesCreated; - public int FrameStateValuesCreated; - public int LoopsPeeled; - public int LoopsInverted; - public int PartialUsageProbability; - public int FullUsageProbability; - public int Rematerializations; - public int GlobalValueNumberingHits; - public int ExplicitExceptions; - public int GuardsHoisted; - - - - /** - * The total number of bytes of bytecode parsed during this compilation, including any inlined methods. - */ - public int bytecodeCount; - - /** - * The number of internal graph nodes created during this compilation. - */ - public int nodeCount; - - /** - * The number of basic blocks created during this compilation. - */ - public int blockCount; - - /** - * The number of loops in the compiled method. - */ - public int loopCount; - - /** - * The number of methods inlined. - */ - public int inlineCount; - - /** - * The number of methods folded (i.e. evaluated). - */ - public int foldCount; - - /** - * The number of intrinsics inlined in this compilation. - */ - public int intrinsicCount; - - - // Checkstyle: resume - - public void print() { - for (Entry<String, MetricsEntry> m : map.entrySet()) { - printField(m.getKey(), m.getValue().value); - } - printFields(GraalMetrics.class); - } - - public static class MetricsEntry { - public int value; - - public void increment() { - increment(1); - } - - public void increment(int val) { - value += val; - } - } - - private LinkedHashMap<String, MetricsEntry> map = new LinkedHashMap<>(); - - public MetricsEntry get(String name) { - if (!map.containsKey(name)) { - map.put(name, new MetricsEntry()); - } - return map.get(name); - } - - public void printFields(Class<?> javaClass) { - final String className = javaClass.getSimpleName(); - TTY.println(className + " {"); - for (final Field field : javaClass.getFields()) { - printField(field, false); - } - TTY.println("}"); - } - - public void printField(final Field field, boolean tabbed) { - final String fieldName = String.format("%35s", field.getName()); - try { - String prefix = tabbed ? "" : " " + fieldName + " = "; - String postfix = tabbed ? "\t" : "\n"; - if (field.getType() == int.class) { - TTY.print(prefix + field.getInt(this) + postfix); - } else if (field.getType() == boolean.class) { - TTY.print(prefix + field.getBoolean(this) + postfix); - } else if (field.getType() == float.class) { - TTY.print(prefix + field.getFloat(this) + postfix); - } else if (field.getType() == String.class) { - TTY.print(prefix + field.get(this) + postfix); - } else if (field.getType() == Map.class) { - Map<?, ?> m = (Map<?, ?>) field.get(this); - TTY.print(prefix + printMap(m) + postfix); - } else { - TTY.print(prefix + field.get(this) + postfix); - } - } catch (IllegalAccessException e) { - // do nothing. - } - } - - private static String printMap(Map<?, ?> m) { - StringBuilder sb = new StringBuilder(); - - List<String> keys = new ArrayList<>(); - for (Object key : m.keySet()) { - keys.add((String) key); - } - Collections.sort(keys); - - for (String key : keys) { - sb.append(key); - sb.append("\t"); - sb.append(m.get(key)); - sb.append("\n"); - } - - return sb.toString(); - } - - private static void printField(String fieldName, long value) { - TTY.print(" " + fieldName + " = " + value + "\n"); - } -} -
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Sun Jan 29 11:40:04 2012 +0100 @@ -82,21 +82,24 @@ public static boolean PrintLIR = ____; public static boolean PrintCFGToFile = ____; + // Debug settings: + public static boolean Debug = true; + public static String Dump = null; + public static String Meter = null; + public static String Time = null; + public static String Log = null; + public static String MethodFilter = null; + // Ideal graph visualizer output settings - public static boolean Plot = ____; - public static boolean PlotVerbose = ____; public static boolean PlotOnError = ____; public static int PlotLevel = 3; public static boolean PlotSnippets = ____; - public static boolean PrintIdealGraphBytecodes = true; public static int PrintIdealGraphLevel = 0; public static boolean PrintIdealGraphFile = ____; public static String PrintIdealGraphAddress = "127.0.0.1"; public static int PrintIdealGraphPort = 4444; // Other printing settings - public static boolean Meter = ____; - public static boolean Time = ____; public static boolean PrintQueue = ____; public static boolean PrintCompilation = ____; public static boolean PrintXirTemplates = ____; @@ -107,17 +110,7 @@ public static int TraceLinearScanLevel = 0; public static boolean TraceRegisterAllocation = false; public static int TraceLIRGeneratorLevel = 0; - public static boolean TraceRelocation = ____; - public static boolean TraceLIRVisit = ____; - public static boolean TraceAssembler = ____; - public static boolean TraceInlining = ____; - public static boolean TraceDeadCodeElimination = ____; public static boolean TraceEscapeAnalysis = ____; - public static boolean TraceCanonicalizer = ____; - public static boolean TraceMemoryMaps = ____; - public static boolean TraceProbability = ____; - public static boolean TraceReadElimination = ____; - public static boolean TraceGVN = ____; public static int TraceBytecodeParserLevel = 0; public static boolean ExitVMOnBailout = ____; public static boolean ExitVMOnException = true; @@ -126,8 +119,6 @@ public static boolean AssumeVerifiedBytecode = true; // Code generator settings - public static boolean GenLIR = true; - public static boolean GenCode = true; public static boolean UseBranchPrediction = true; public static boolean UseExceptionProbability = true; public static boolean AllowExplicitExceptionChecks = true;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalTimers.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.max.graal.compiler; - -import java.util.*; - -import com.oracle.max.criutils.*; - -/** - * This class contains timers that record the amount of time spent in various parts of the compiler. It builds a - * hierarchical and a flat representation of the timing. In order to reliably create the hierarchy the following code - * pattern should be used: - * - * <pre> - * GraalTimers.startScope("name"); - * try { - * ... - * } finally { - * GraalTimers.endScope(); - * } - * </pre> - */ -public final class GraalTimers { - - private static class TimingScope { - - public final TimingScope parent; - public final int level; - public long time; - public long count; - public long subTime; - public long startTime; - - public final ArrayList<String> subNames = new ArrayList<>(); - public final ArrayList<TimingScope> subScopes = new ArrayList<>(); - - public TimingScope(TimingScope parent) { - this.parent = parent; - this.level = parent == null ? 0 : parent.level + 1; - } - - private static final String PREFIX = " | | | | | | | | | +"; - - public static void treeIndent(int i) { - assert i < PREFIX.length() / 8; - TTY.print(PREFIX.substring(PREFIX.length() - i * 8)); - } - - private void printScope(int indent) { - TTY.println("%3.0f%% %6.2fs %5d", time * 100.0 / parent.time, time / 1000000000.0, count); - if (!subNames.isEmpty() && (time - subTime) > 0) { - treeIndent(indent + 1); - TTY.print("%-40s", "self:"); - TTY.println("%3.0f%% %6.2fs %5d", (time - subTime) * 100.0 / time, (time - subTime) / 1000000000.0, count); - } - printSub(indent + 1); - } - - public void printSub(int indent) { - for (int i = 0; i < subNames.size(); i++) { - String name = subNames.get(i); - TimingScope scope = subScopes.get(i); - treeIndent(indent); - TTY.print("%-40s", name + ":"); - scope.printScope(indent); - } - } - - public long accumulateSub(Map<String, Long> times, Map<String, Long> counts) { - long result = 0; - for (int i = 0; i < subNames.size(); i++) { - String name = subNames.get(i); - TimingScope scope = subScopes.get(i); - long totalTime = times.containsKey(name) ? times.get(name) : 0; - long totalCount = counts.containsKey(name) ? counts.get(name) : 0; - long myTime = scope.time - scope.subTime; - times.put(name, totalTime + myTime); - counts.put(name, totalCount + scope.count); - result += myTime + scope.accumulateSub(times, counts); - } - return result; - } - } - - private final TimingScope rootScope = new TimingScope(null); - - private ThreadLocal<TimingScope> currentScope = new ThreadLocal<TimingScope>() { - - @Override - protected TimingScope initialValue() { - TimingScope scope = new TimingScope(rootScope); - rootScope.subNames.add(Thread.currentThread().getName()); - rootScope.subScopes.add(scope); - return scope; - } - }; - - private ThreadLocal<Integer> currentLevel = new ThreadLocal<Integer>() { - @Override - protected Integer initialValue() { - return 0; - } - }; - - public void startScope(Class< ? > clazz) { - if (GraalOptions.Time) { - startScope(clazz.getSimpleName()); - } else { - currentLevel.set(currentLevel.get() + 1); - } - } - - public int currentLevel() { - if (GraalOptions.Time) { - return currentScope.get().level; - } else { - return currentLevel.get(); - } - } - - public void startScope(String name) { - if (GraalOptions.Time) { - TimingScope current = currentScope.get(); - int index = current.subNames.indexOf(name); - TimingScope sub; - if (index == -1) { - sub = new TimingScope(current); - current.subNames.add(name); - current.subScopes.add(sub); - } else { - sub = current.subScopes.get(index); - } - currentScope.set(sub); - sub.startTime = System.nanoTime(); - sub.count++; - } else { - currentLevel.set(currentLevel.get() + 1); - } - } - - public void endScope() { - if (GraalOptions.Time) { - TimingScope current = currentScope.get(); - long time = System.nanoTime() - current.startTime; - current.time += time; - current.parent.subTime += time; - currentScope.set(current.parent); - } else { - currentLevel.set(currentLevel.get() - 1); - } - } - - public void print() { - if (GraalOptions.Time) { - rootScope.time = 0; - for (TimingScope scope : rootScope.subScopes) { - scope.time = scope.subTime; - rootScope.time += scope.subTime; - } - - TTY.println("==============================="); - TTY.println("Total Compilation Time: %6.2fs", rootScope.time / 1000000000.0); - TTY.println(); - - rootScope.printSub(0); - - TreeMap<String, Long> times = new TreeMap<>(); - TreeMap<String, Long> counts = new TreeMap<>(); - long total = rootScope.accumulateSub(times, counts); - - TTY.println(); - for (String name : times.keySet()) { - if (times.get(name) > 0) { - TTY.println("%-30s: %7.4f s (%5.2f%%) %5d", name, times.get(name) / 1000000000.0, times.get(name) * 100.0 / total, counts.get(name)); - } - } - } - } -}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,10 +24,10 @@ import java.util.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; /** * This class performs basic optimizations on the control flow graph after LIR generation. @@ -38,8 +38,8 @@ * Performs control flow optimizations on the given LIR graph. * @param ir the LIR graph that should be optimized */ - public static void optimize(LIR ir, GraalContext context) { - ControlFlowOptimizer optimizer = new ControlFlowOptimizer(ir, context); + public static void optimize(LIR ir) { + ControlFlowOptimizer optimizer = new ControlFlowOptimizer(ir); List<LIRBlock> code = ir.codeEmittingOrder(); //optimizer.reorderShortLoops(code); optimizer.deleteEmptyBlocks(code); @@ -48,11 +48,9 @@ } private final LIR ir; - private final GraalContext context; - private ControlFlowOptimizer(LIR ir, GraalContext context) { + private ControlFlowOptimizer(LIR ir) { this.ir = ir; - this.context = context; } /* private void reorderShortLoop(List<LIRBlock> code, LIRBlock headerBlock, int headerIdx) { @@ -123,7 +121,7 @@ if (canDeleteBlock(block)) { // adjust successor and predecessor lists block.replaceWith(block.suxAt(0)); - context.metrics.BlocksDeleted++; + Debug.metric("BlocksDeleted").increment(); } else { // adjust position of this block in the block list if blocks before // have been deleted
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java Sun Jan 29 11:40:04 2012 +0100 @@ -657,12 +657,9 @@ /** * Sentinel interval to denote the end of an interval list. */ - static final Interval EndMarker = new Interval(null, CiValue.IllegalValue, -1); + static final Interval EndMarker = new Interval(CiValue.IllegalValue, -1); - Interval(GraalContext context, CiValue operand, int operandNumber) { - if (GraalOptions.Meter && context != null) { - context.metrics.LSRAIntervalsCreated++; - } + Interval(CiValue operand, int operandNumber) { assert operand != null; this.operand = operand; this.operandNumber = operandNumber;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Sun Jan 29 11:40:04 2012 +0100 @@ -41,8 +41,8 @@ import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandMode; import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; -import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.compiler.lir.StandardOp.*; /** @@ -52,7 +52,6 @@ */ public final class LinearScan { - final GraalContext context; final CiTarget target; final RiMethod method; final LIR ir; @@ -120,14 +119,10 @@ */ private final int firstVariableNumber; - private final StructuredGraph graph; - - public LinearScan(GraalContext context, CiTarget target, RiResolvedMethod method, StructuredGraph graph, LIR ir, LIRGenerator gen, FrameMap frameMap) { - this.context = context; + public LinearScan(CiTarget target, RiResolvedMethod method, LIR ir, LIRGenerator gen, FrameMap frameMap) { this.target = target; this.method = method; - this.graph = graph; this.ir = ir; this.gen = gen; this.frameMap = frameMap; @@ -238,7 +233,7 @@ assert isProcessed(operand); assert isLegal(operand); int operandNumber = operandNumber(operand); - Interval interval = new Interval(context, operand, operandNumber); + Interval interval = new Interval(operand, operandNumber); assert operandNumber < intervalsSize; assert intervals[operandNumber] == null; intervals[operandNumber] = interval; @@ -289,7 +284,7 @@ } int numLoops() { - return ir.loopCount(); + return ir.numLoops(); } boolean isIntervalInLoop(int interval, int loop) { @@ -1617,7 +1612,7 @@ // intervals that have no oops inside need not to be processed. // to ensure a walking until the last instruction id, add a dummy interval // with a high operation id - nonOopIntervals = new Interval(context, CiValue.IllegalValue, -1); + nonOopIntervals = new Interval(CiValue.IllegalValue, -1); nonOopIntervals.addRange(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1); return new IntervalWalker(this, oopIntervals, nonOopIntervals); @@ -1785,70 +1780,65 @@ } public void allocate() { - context.timers.startScope("Lifetime Analysis"); - try { - numberInstructions(); - printLir("Before register allocation", true); + Debug.scope("LifetimeAnalysis", new Runnable() { - computeLocalLiveSets(); - computeGlobalLiveSets(); - - buildIntervals(); - sortIntervalsBeforeAllocation(); - } finally { - context.timers.endScope(); - } + public void run() { + numberInstructions(); + printLir("Before register allocation", true); + computeLocalLiveSets(); + computeGlobalLiveSets(); + buildIntervals(); + sortIntervalsBeforeAllocation(); + } + }); - context.timers.startScope("Linear Scan"); - try { - printIntervals("Before register allocation"); + Debug.scope("RegisterAllocation", new Runnable() { - allocateRegisters(); + public void run() { + printIntervals("Before register allocation"); + allocateRegisters(); + } + }); - } finally { - context.timers.endScope(); - } + Debug.scope("ResolveDataFlow", new Runnable() { + public void run() { + resolveDataFlow(); + } + }); - context.timers.startScope("Resolution"); - try { - resolveDataFlow(); - } finally { - context.timers.endScope(); - } + Debug.scope("DebugInfo", new Runnable() { - context.timers.startScope("Create Debug Info"); - try { - frameMap.finish(); + public void run() { + frameMap.finish(); - printIntervals("After register allocation"); - printLir("After register allocation", true); + printIntervals("After register allocation"); + printLir("After register allocation", true); - sortIntervalsAfterAllocation(); + sortIntervalsAfterAllocation(); - if (GraalOptions.DetailedAsserts) { - verify(); - } + if (GraalOptions.DetailedAsserts) { + verify(); + } - eliminateSpillMoves(); - assignLocations(); + eliminateSpillMoves(); + assignLocations(); - if (GraalOptions.DetailedAsserts) { - verifyIntervals(); + if (GraalOptions.DetailedAsserts) { + verifyIntervals(); + } } - } finally { - context.timers.endScope(); - } + }); + + Debug.scope("ControlFlowOptimizations", new Runnable() { - context.timers.startScope("Control Flow Optimizations"); - try { - printLir("After register number assignment", true); - EdgeMoveOptimizer.optimize(ir.linearScanOrder()); - ControlFlowOptimizer.optimize(ir, context); - printLir("After control flow optimization", false); - } finally { - context.timers.endScope(); - } + public void run() { + printLir("After register number assignment", true); + EdgeMoveOptimizer.optimize(ir.linearScanOrder()); + ControlFlowOptimizer.optimize(ir); + printLir("After control flow optimization", false); + } + }); } void printIntervals(String label) { @@ -1873,12 +1863,11 @@ TTY.println(); } - if (context.isObserved()) { - context.observable.fireCompilationEvent(label, graph, this, Arrays.copyOf(intervals, intervalsSize)); - } + Debug.dump(Arrays.copyOf(intervals, intervalsSize), label); } - void printLir(String label, boolean hirValid) { + void printLir(String label, @SuppressWarnings("unused") boolean hirValid) { + // TODO(tw): Fix printing. if (GraalOptions.TraceLinearScanLevel >= 1 && !TTY.isSuppressed()) { TTY.println(); TTY.println(label); @@ -1886,9 +1875,7 @@ TTY.println(); } - if (context.isObserved()) { - context.observable.fireCompilationEvent(label, hirValid ? graph : null, ir); - } + Debug.dump(ir, label); } boolean verify() { @@ -2025,7 +2012,7 @@ fixedIntervals = createUnhandledLists(IS_PRECOLORED_INTERVAL, null).first; // to ensure a walking until the last instruction id, add a dummy interval // with a high operation id - otherIntervals = new Interval(context, CiValue.IllegalValue, -1); + otherIntervals = new Interval(CiValue.IllegalValue, -1); otherIntervals.addRange(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1); IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Sun Jan 29 11:40:04 2012 +0100 @@ -34,6 +34,7 @@ import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.lir.LIR.SlowPath; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; public class TargetMethodAssembler { @@ -46,10 +47,7 @@ private List<ExceptionInfo> exceptionInfoList; private int lastSafepointPos; - private final GraalContext context; - - public TargetMethodAssembler(GraalContext context, CiTarget target, RiRuntime runtime, FrameMap frameMap, List<SlowPath> slowPaths, AbstractAssembler asm) { - this.context = context; + public TargetMethodAssembler(CiTarget target, RiRuntime runtime, FrameMap frameMap, List<SlowPath> slowPaths, AbstractAssembler asm) { this.target = target; this.runtime = runtime; this.frameMap = frameMap; @@ -84,13 +82,11 @@ } } - if (GraalOptions.Meter) { - context.metrics.TargetMethods++; - context.metrics.CodeBytesEmitted += targetMethod.targetCodeSize(); - context.metrics.SafepointsEmitted += targetMethod.safepoints.size(); - context.metrics.DataPatches += targetMethod.dataReferences.size(); - context.metrics.ExceptionHandlersEmitted += targetMethod.exceptionHandlers.size(); - } + Debug.metric("TargetMethods").increment(); + Debug.metric("CodeBytesEmitted").add(targetMethod.targetCodeSize()); + Debug.metric("SafepointsEmitted").add(targetMethod.safepoints.size()); + Debug.metric("DataPatches").add(targetMethod.dataReferences.size()); + Debug.metric("ExceptionHandlersEmitted").add(targetMethod.exceptionHandlers.size()); if (GraalOptions.PrintAssembly && !TTY.isSuppressed() && !isStub) { Util.printSection("Target Method", Util.SECTION_CHARACTER); @@ -181,13 +177,8 @@ public CiAddress recordDataReferenceInCode(CiConstant data, int alignment) { assert data != null; - int pos = asm.codeBuffer.position(); - - if (GraalOptions.TraceRelocation) { - TTY.print("Data reference in code: pos = %d, data = %s", pos, data.toString()); - } - + Debug.log("Data reference in code: pos = %d, data = %s", pos, data.toString()); targetMethod.recordDataReference(pos, data, alignment); return CiAddress.Placeholder; }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Sun Jan 29 11:40:04 2012 +0100 @@ -50,6 +50,7 @@ import com.oracle.max.graal.compiler.lir.StandardOp.ParametersOp; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; @@ -64,8 +65,6 @@ * This class traverses the HIR instructions and generates LIR instructions from them. */ public abstract class LIRGenerator extends LIRGeneratorTool { - public final GraalContext context; - protected final Graph graph; protected final RiRuntime runtime; protected final CiTarget target; @@ -139,8 +138,7 @@ private LockScope curLocks; - public LIRGenerator(GraalContext context, Graph graph, RiRuntime runtime, CiTarget target, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) { - this.context = context; + public LIRGenerator(Graph graph, RiRuntime runtime, CiTarget target, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) { this.graph = graph; this.runtime = runtime; this.target = target; @@ -418,15 +416,9 @@ } currentInstruction = instr; - if (GraalOptions.TraceLIRVisit) { - TTY.println("Visiting " + instr); - } - + Debug.log("Visiting %s", instr); emitNode(instr); - - if (GraalOptions.TraceLIRVisit) { - TTY.println("Operand for " + instr + " = " + operand(instr)); - } + Debug.log("Operand for %s = %s", instr, operand(instr)); } protected void emitNode(ValueNode node) { @@ -1304,9 +1296,7 @@ inputOperandArray, tempOperandArray, inputOperandIndicesArray, tempOperandIndicesArray, (allocatedResultOperand == IllegalValue) ? -1 : resultOperand.index, info, infoAfter, trueSuccessor, falseSuccessor); - if (GraalOptions.Meter) { - context.metrics.LIRXIRInstructions++; - } + Debug.metric("LIRXIRInstructions").increment(); } return operandsArray[resultOperand.index];
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java Sun Jan 29 11:40:04 2012 +0100 @@ -65,8 +65,7 @@ public SlowPath methodEndMarker; private int numVariables; - - private final int loopCount; + private final int numLoops; public SpillMoveFactory spillMoveFactory; @@ -81,15 +80,15 @@ /** * Creates a new LIR instance for the specified compilation. - * @param loopCount number of loops + * @param numLoops number of loops * @param compilation the compilation */ - public LIR(LIRBlock startBlock, List<LIRBlock> linearScanOrder, List<LIRBlock> codeEmittingOrder, NodeMap<LIRBlock> valueToBlock, int loopCount) { + public LIR(LIRBlock startBlock, List<LIRBlock> linearScanOrder, List<LIRBlock> codeEmittingOrder, NodeMap<LIRBlock> valueToBlock, int numLoops) { this.codeEmittingOrder = codeEmittingOrder; this.linearScanOrder = linearScanOrder; this.startBlock = startBlock; this.valueToBlock = valueToBlock; - this.loopCount = loopCount; + this.numLoops = numLoops; slowPaths = new ArrayList<>(); deoptimizationStubs = new ArrayList<>(); @@ -115,10 +114,6 @@ return valueToBlock; } - public int loopCount() { - return loopCount; - } - public int numVariables() { return numVariables; } @@ -263,4 +258,8 @@ TTY.println(); } } + + public int numLoops() { + return numLoops; + } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/CanonicalizerPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/CanonicalizerPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,8 +24,7 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.calc.*; @@ -64,9 +63,7 @@ Tool tool = new Tool(nodeWorkList, runtime, target, assumptions); for (Node node : nodeWorkList) { if (node instanceof Canonicalizable) { - if (GraalOptions.TraceCanonicalizer) { - TTY.println("Canonicalizer: work on " + node); - } + Debug.log("Canonicalizer: work on %1s"); graph.mark(); ValueNode canonical = ((Canonicalizable) node).canonical(tool); // cases: original node:
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,9 +24,8 @@ import java.util.*; -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.graph.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -50,27 +49,13 @@ @Override protected void run(StructuredGraph graph) { new PropagateProbability(graph.start()).apply(); - if (currentContext.isObserved() && GraalOptions.TraceProbability) { - currentContext.observable.fireCompilationEvent("After PropagateProbability", graph); - } + Debug.dump(graph, "After PropagateProbability"); computeLoopFactors(); - if (currentContext.isObserved() && GraalOptions.TraceProbability) { - currentContext.observable.fireCompilationEvent("After computeLoopFactors", graph); - } + Debug.dump(graph, "After computeLoopFactors"); new PropagateLoopFrequency(graph.start()).apply(); } private void computeLoopFactors() { - if (GraalOptions.TraceProbability) { - for (LoopInfo info : loopInfos) { - TTY.println("\nLoop " + info.loopBegin); - TTY.print(" requires: "); - for (LoopInfo r : info.requires) { - TTY.print(r.loopBegin + " "); - } - TTY.println(); - } - } for (LoopInfo info : loopInfos) { double frequency = info.loopFrequency(); assert frequency != -1;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -22,8 +22,7 @@ */ package com.oracle.max.graal.compiler.phases; -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -81,9 +80,7 @@ if (!flood.isMarked(node)) { LoopBeginNode loop = node.loopBegin(); if (flood.isMarked(loop)) { - if (GraalOptions.TraceDeadCodeElimination) { - TTY.println("Removing loop with unreachable end: " + loop); - } + Debug.log("Removing loop with unreachable end: %s", loop); node.setLoopBegin(null); EndNode endNode = loop.endAt(0); assert endNode.predecessor() != null;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -29,6 +29,7 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.PhiNode.PhiType; @@ -428,21 +429,10 @@ } if (invokes.size() == 0) { - if (currentContext.isObserved()) { - currentContext.observable.fireCompilationEvent("Before escape " + node, graph); - } - if (GraalOptions.TraceEscapeAnalysis || GraalOptions.PrintEscapeAnalysis) { - TTY.println("%n!!!!!!!! non-escaping object: %s (%s)", node, node.exactType()); - } - try { - currentContext.timers.startScope("Escape Analysis Fixup"); - removeAllocation(node, op); - } finally { - currentContext.timers.endScope(); - } - if (currentContext.isObserved()) { - currentContext.observable.fireCompilationEvent("After escape", graph); - } + Debug.dump(graph, "Before escape %s", node); + Debug.log("!!!!!!!! non-escaping object: %s (%s)", node, node.exactType()); + removeAllocation(node, op); + Debug.dump(graph, "After escape", graph); break; } if (weight < minimumWeight) { @@ -457,8 +447,8 @@ if (GraalOptions.TraceEscapeAnalysis || GraalOptions.PrintEscapeAnalysis) { TTY.println("Trying inlining to get a non-escaping object for %s", node); } - new InliningPhase(target, runtime, invokes, assumptions, plan).apply(graph, currentContext); - new DeadCodeEliminationPhase().apply(graph, currentContext); + new InliningPhase(target, runtime, invokes, assumptions, plan).apply(graph); + new DeadCodeEliminationPhase().apply(graph); if (node.isDeleted()) { if (GraalOptions.TraceEscapeAnalysis || GraalOptions.PrintEscapeAnalysis) { TTY.println("%n!!!!!!!! object died while performing escape analysis: %s (%s)", node, node.exactType()); @@ -514,9 +504,7 @@ } } else { exits.add(usage); - if (!GraalOptions.TraceEscapeAnalysis) { - break; - } + break; } } else { if (GraalOptions.ProbabilityAnalysis && usage instanceof FixedNode) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/FloatingReadPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/FloatingReadPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,10 +25,9 @@ import java.util.*; import com.oracle.max.cri.ci.*; -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.loop.*; import com.oracle.max.graal.compiler.schedule.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.PhiNode.PhiType; @@ -74,9 +73,7 @@ } public void mergeWith(MemoryMap otherMemoryMap, Block b) { - if (GraalOptions.TraceMemoryMaps) { - TTY.println("merging block " + otherMemoryMap.block + " into block " + block); - } + Debug.log("Merging block %s into block %s.", otherMemoryMap.block, block); IdentityHashMap<Object, Node> otherMap = otherMemoryMap.map; for (Map.Entry<Object, Node> entry : map.entrySet()) { @@ -109,19 +106,14 @@ private void mergeNodes(Object location, Node original, Node newValue, Block mergeBlock) { if (original == newValue) { - // Nothing to merge. - if (GraalOptions.TraceMemoryMaps) { - TTY.println("Nothing to merge both nodes are " + original); - } + Debug.log("Nothing to merge both nodes are %s.", original); return; } MergeNode m = (MergeNode) mergeBlock.firstNode(); if (m.isPhiAtMerge(original)) { PhiNode phi = (PhiNode) original; phi.addInput((ValueNode) newValue); - if (GraalOptions.TraceMemoryMaps) { - TTY.println("Add new input to " + original + ": " + newValue); - } + Debug.log("Add new input to %s: %s.", original, newValue); assert phi.valueCount() <= phi.merge().endCount() : phi.merge(); } else { PhiNode phi = m.graph().unique(new PhiNode(CiKind.Illegal, m, PhiType.Memory)); @@ -129,9 +121,7 @@ phi.addInput((ValueNode) original); } phi.addInput((ValueNode) newValue); - if (GraalOptions.TraceMemoryMaps) { - TTY.println("Creating new " + phi + " merge=" + phi.merge() + ", mergeOperationCount=" + mergeOperationCount + ", newValue=" + newValue + ", location=" + location); - } + Debug.log("Creating new %s merge=%s newValue=%s location=%s.", phi, phi.merge(), newValue, location); assert phi.valueCount() <= phi.merge().endCount() + ((phi.merge() instanceof LoopBeginNode) ? 1 : 0) : phi.merge() + "/" + phi.valueCount() + "/" + phi.merge().endCount() + "/" + mergeOperationCount; assert m.usages().contains(phi); assert phi.merge().usages().contains(phi); @@ -155,10 +145,7 @@ StructuredGraph graph = (StructuredGraph) readNode.graph(); assert readNode.getNullCheck() == false; - if (GraalOptions.TraceMemoryMaps) { - TTY.println("Register read to node " + readNode); - } - + Debug.log("Register read to node %s.", readNode); FloatingReadNode floatingRead; if (readNode.location().locationIdentity() == LocationNode.FINAL_LOCATION) { floatingRead = graph.unique(new FloatingReadNode(readNode.kind(), readNode.object(), readNode.guard(), readNode.location())); @@ -245,13 +232,11 @@ propagateFromChildren(loop, modifiedValues); } - if (GraalOptions.TraceMemoryMaps) { - print(loopInfo, modifiedValues); - } + Debug.log("Modified values: %s.", modifiedValues); // Identify blocks. final IdentifyBlocksPhase s = new IdentifyBlocksPhase(false); - s.apply(graph, currentContext); + s.apply(graph); List<Block> blocks = s.getBlocks(); // Process blocks (predecessors first). @@ -343,15 +328,6 @@ modifiedValues.get(loop).add(locationIdentity); } - private static void print(LoopInfo loopInfo, HashMap<Loop, Set<Object>> modifiedValues) { - TTY.println(); - TTY.println("Loops:"); - for (Loop loop : loopInfo.loops()) { - TTY.print(loop + " modified values: " + modifiedValues.get(loop)); - TTY.println(); - } - } - private void mark(LoopBeginNode begin, LoopBeginNode outer, NodeMap<LoopBeginNode> nodeToLoop) { if (nodeToLoop.get(begin) != null) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -22,13 +22,14 @@ */ package com.oracle.max.graal.compiler.phases; -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; public class GlobalValueNumberingPhase extends Phase { + public static final DebugMetric metricGlobalValueNumberingHits = Debug.metric("GlobalValueNumberingHits"); + @Override protected void run(StructuredGraph graph) { NodeBitMap visited = graph.createNodeBitMap(); @@ -49,12 +50,8 @@ assert !(n instanceof FixedNode || newNode instanceof FixedNode); n.replaceAtUsages(newNode); n.safeDelete(); - if (GraalOptions.Meter) { - currentContext.metrics.GlobalValueNumberingHits++; - } - if (GraalOptions.TraceGVN) { - TTY.println("GVN applied and new node is " + newNode); - } + metricGlobalValueNumberingHits.increment(); + Debug.log("GVN applied and new node is %1s", newNode); } } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -26,13 +26,13 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; -import com.oracle.max.criutils.*; import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition; import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.compiler.util.InliningUtil.InlineInfo; import com.oracle.max.graal.compiler.util.InliningUtil.InliningCallback; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -54,6 +54,10 @@ private final PhasePlan plan; + // Metrics + private static final DebugMetric metricInliningPerformed = Debug.metric("InliningPerformed"); + private static final DebugMetric metricInliningConsidered = Debug.metric("InliningConsidered"); + public InliningPhase(CiTarget target, GraalRuntime runtime, Collection<Invoke> hints, CiAssumptions assumptions, PhasePlan plan) { this.target = target; this.runtime = runtime; @@ -78,36 +82,24 @@ InlineInfo info = inlineCandidates.remove(); double penalty = Math.pow(GraalOptions.InliningSizePenaltyExp, graph.getNodeCount() / (double) GraalOptions.MaximumDesiredSize) / GraalOptions.InliningSizePenaltyExp; if (info.weight > GraalOptions.MaximumInlineWeight / (1 + penalty * GraalOptions.InliningSizePenalty)) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining (cut off by weight):"); - while (info != null) { - TTY.println(" %f %s", info.weight, info); - info = inlineCandidates.poll(); - } - } + Debug.log("not inlining (cut off by weight): %e", info.weight); return; } Iterable<Node> newNodes = null; if (info.invoke.node().isAlive()) { try { info.inline(graph, runtime, this); - if (GraalOptions.TraceInlining) { - TTY.println("inlining %f: %s", info.weight, info); - } - if (GraalOptions.TraceInlining) { - currentContext.observable.fireCompilationEvent("after inlining " + info, graph); - } + Debug.log("inlining %f: %s", info.weight, info); + Debug.dump(graph, "after inlining %s", info); // get the new nodes here, the canonicalizer phase will reset the mark newNodes = graph.getNewNodes(); if (GraalOptions.OptCanonicalizer) { new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph); } if (GraalOptions.Intrinsify) { - new IntrinsificationPhase(runtime).apply(graph, currentContext); + new IntrinsificationPhase(runtime).apply(graph); } - if (GraalOptions.Meter) { - currentContext.metrics.InlinePerformed++; - } + metricInliningPerformed.increment(); } catch (CiBailout bailout) { // TODO determine if we should really bail out of the whole compilation. throw bailout; @@ -146,10 +138,7 @@ private void scanInvoke(Invoke invoke, int level) { InlineInfo info = InliningUtil.getInlineInfo(invoke, level, runtime, assumptions, this); if (info != null) { - if (GraalOptions.Meter) { - currentContext.metrics.InlineConsidered++; - } - + metricInliningConsidered.increment(); inlineCandidates.add(info); } } @@ -161,14 +150,14 @@ StructuredGraph newGraph = new StructuredGraph(method); if (plan != null) { - plan.runPhases(PhasePosition.AFTER_PARSING, newGraph, currentContext); + plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); } if (GraalOptions.ProbabilityAnalysis) { - new DeadCodeEliminationPhase().apply(newGraph, currentContext, false); - new ComputeProbabilityPhase().apply(newGraph, currentContext, false); + new DeadCodeEliminationPhase().apply(newGraph); + new ComputeProbabilityPhase().apply(newGraph); } - new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph, currentContext, false); + new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph); return newGraph; } @@ -213,9 +202,9 @@ if (!parsedMethods.containsKey(method)) { StructuredGraph newGraph = new StructuredGraph(method); if (plan != null) { - plan.runPhases(PhasePosition.AFTER_PARSING, newGraph, currentContext); + plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); } - new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph, currentContext, false); + new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph); count = graphComplexity(newGraph); parsedMethods.put(method, count); } else {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,7 +40,7 @@ @Override protected void run(final StructuredGraph graph) { final IdentifyBlocksPhase s = new IdentifyBlocksPhase(false); - s.apply(graph, currentContext); + s.apply(graph); s.calculateAlwaysReachedBlock(); NodeBitMap processed = graph.createNodeBitMap();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Sun Jan 29 11:40:04 2012 +0100 @@ -22,100 +22,35 @@ */ package com.oracle.max.graal.compiler.phases; -import com.oracle.max.cri.ci.*; -import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.schedule.*; -import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; public abstract class Phase { - private final String name; - private final boolean shouldVerify; - protected GraalContext currentContext; + private String name; protected Phase() { this.name = this.getClass().getSimpleName(); - this.shouldVerify = GraalOptions.VerifyPhases; + if (name.endsWith("Phase")) { + name = name.substring(0, name.length() - "Phase".length()); + } } protected Phase(String name) { - this(name, GraalOptions.VerifyPhases); - } - - protected Phase(String name, boolean shouldVerify) { this.name = name; - this.shouldVerify = shouldVerify; } protected String getDetailedName() { return getName(); } - public final void apply(StructuredGraph graph) { - apply(graph, GraalContext.EMPTY_CONTEXT); - } - - public final void apply(StructuredGraph graph, GraalContext context) { - apply(graph, context, true); - } - - public final void apply(StructuredGraph graph, boolean plot) { - apply(graph, GraalContext.EMPTY_CONTEXT, plot); - } - - public final void apply(StructuredGraph graph, GraalContext context, boolean plot) { - - this.currentContext = context; - try { - assert graph != null && (!shouldVerify || graph.verify()); - } catch (GraalInternalError e) { - throw e.addContext("start of phase", getDetailedName()); - } - - int startDeletedNodeCount = graph.getDeletedNodeCount(); - int startNodeCount = graph.getNodeCount(); - if (context != null) { - context.timers.startScope(getName()); - } - try { - try { - run(graph); - } catch (CiBailout bailout) { - throw bailout; - } catch (AssertionError e) { - throw new GraalInternalError(e); - } catch (RuntimeException e) { - throw new GraalInternalError(e); - } finally { - if (context != null) { - context.timers.endScope(); - } + public final void apply(final StructuredGraph graph) { + Debug.scope(name, this, new Runnable() { + public void run() { + Phase.this.run(graph); + Debug.dump(graph, "After phase %s", name); } - } catch (GraalInternalError e) { - throw e.addContext(graph).addContext("phase", getDetailedName()); - } - - if (context != null) { - if (GraalOptions.Meter) { - int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount; - int createdNodeCount = graph.getNodeCount() - startNodeCount + deletedNodeCount; - context.metrics.get(getName().concat(".executed")).increment(); - context.metrics.get(getName().concat(".deletedNodes")).increment(deletedNodeCount); - context.metrics.get(getName().concat(".createdNodes")).increment(createdNodeCount); - } - - boolean shouldFireCompilationEvents = context.isObserved() && this.getClass() != IdentifyBlocksPhase.class && (plot || GraalOptions.PlotVerbose); - if (shouldFireCompilationEvents && context.timers.currentLevel() < GraalOptions.PlotLevel) { - context.observable.fireCompilationEvent("After " + getName(), graph); - } - } - - try { - assert !shouldVerify || graph.verify(); - } catch (GraalInternalError e) { - throw e.addContext("end of phase", getDetailedName()); - } + }); } public final String getName() {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/PhasePlan.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/PhasePlan.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,7 +24,6 @@ import java.util.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.nodes.*; /** @@ -68,10 +67,10 @@ phases[pos.ordinal()].add(phase); } - public void runPhases(PhasePosition pos, StructuredGraph graph, GraalContext context) { + public void runPhases(PhasePosition pos, StructuredGraph graph) { if (phases[pos.ordinal()] != null) { for (Phase p : phases[pos.ordinal()]) { - p.apply(graph, context); + p.apply(graph); } } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -22,8 +22,7 @@ */ package com.oracle.max.graal.compiler.phases; -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; @@ -39,9 +38,7 @@ if (memoryInput instanceof WriteNode) { WriteNode other = (WriteNode) memoryInput; if (other.object() == n.object() && other.location() == n.location()) { - if (GraalOptions.TraceReadElimination) { - TTY.println("Eliminated memory read " + n + "and replaced with node " + other.value()); - } + Debug.log("Eliminated memory read %1.1s and replaced with node %s", n, other.value()); graph.replaceFloating(n, other.value()); } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -57,7 +57,7 @@ } public IdentifyBlocksPhase(boolean scheduleAllNodes, BlockFactory blockFactory) { - super(scheduleAllNodes ? "FullSchedule" : "PartSchedule", false); + super(scheduleAllNodes ? "FullSchedule" : "PartSchedule"); this.blockFactory = blockFactory; this.scheduleAllNodes = scheduleAllNodes; }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,7 +28,6 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.max.cri.xir.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.gen.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.graph.*; @@ -57,7 +56,7 @@ } public abstract FrameMap newFrameMap(RiRegisterConfig registerConfig); - public abstract LIRGenerator newLIRGenerator(GraalContext context, Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir); + public abstract LIRGenerator newLIRGenerator(Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir); public abstract AbstractAssembler newAssembler(RiRegisterConfig registerConfig); public abstract CiXirAssembler newXirAssembler();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,7 +27,6 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.max.cri.xir.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.gen.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.target.*; @@ -47,8 +46,8 @@ * @return an appropriate LIR generator instance */ @Override - public LIRGenerator newLIRGenerator(GraalContext context, Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) { - return new AMD64LIRGenerator(context, graph, runtime, target, frameMap, method, lir, xir); + public LIRGenerator newLIRGenerator(Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) { + return new AMD64LIRGenerator(graph, runtime, target, frameMap, method, lir, xir); } @Override
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,7 +37,6 @@ import com.oracle.max.cri.ri.*; import com.oracle.max.cri.xir.CiXirAssembler.XirMark; import com.oracle.max.cri.xir.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.gen.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.target.amd64.AMD64Arithmetic.DivOp; @@ -98,8 +97,8 @@ } } - public AMD64LIRGenerator(GraalContext context, Graph graph, RiRuntime runtime, CiTarget target, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) { - super(context, graph, runtime, target, frameMap, method, lir, xir); + public AMD64LIRGenerator(Graph graph, RiRuntime runtime, CiTarget target, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) { + super(graph, runtime, target, frameMap, method, lir, xir); lir.methodEndMarker = new AMD64MethodEndStub(); lir.spillMoveFactory = new AMD64SpillMoveFactory(); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOp.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOp.java Sun Jan 29 11:40:04 2012 +0100 @@ -38,7 +38,6 @@ import com.oracle.max.cri.xir.CiXirAssembler.XirInstruction; import com.oracle.max.cri.xir.CiXirAssembler.XirLabel; import com.oracle.max.cri.xir.CiXirAssembler.XirMark; -import com.oracle.max.criutils.*; import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.asm.*; import com.oracle.max.graal.compiler.lir.*; @@ -95,16 +94,8 @@ @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - int start = -1; - if (GraalOptions.TraceAssembler) { - TTY.println("Emitting slow path for XIR instruction " + snippet.template.name); - start = masm.codeBuffer.position(); - } emitXirInstructions(tasm, masm, snippet.template.slowPath, labels, getOperands(), snippet.marks); masm.nop(); - if (GraalOptions.TraceAssembler) { - TTY.println("From " + start + " to " + masm.codeBuffer.position()); - } } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,12 +24,13 @@ import java.lang.reflect.*; import java.util.*; +import java.util.concurrent.*; import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; -import com.oracle.max.criutils.*; import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; @@ -51,11 +52,15 @@ } private static String methodName(RiResolvedMethod method, Invoke invoke) { - if (invoke != null && invoke.stateAfter() != null) { - RiMethod parent = invoke.stateAfter().method(); - return parent.name() + "@" + invoke.bci() + ": " + CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; + if (Debug.isLogEnabled()) { + if (invoke != null && invoke.stateAfter() != null) { + RiMethod parent = invoke.stateAfter().method(); + return parent.name() + "@" + invoke.bci() + ": " + CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; + } else { + return CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; + } } else { - return CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; + return null; } } @@ -108,19 +113,13 @@ } @Override - public Node inline(StructuredGraph compilerGraph, GraalRuntime runtime, InliningCallback callback) { - StructuredGraph graph = null; // TODO: Solve graph caching differently! GraphBuilderPhase.cachedGraphs.get(concrete); -// if (graph != null) { -// if (GraalOptions.TraceInlining) { -// TTY.println("Reusing graph for %s", methodName(concrete, invoke)); -// } -// } else { - if (GraalOptions.TraceInlining) { - TTY.println("Building graph for %s, locals: %d, stack: %d", methodName(concrete, invoke), concrete.maxLocals(), concrete.maxStackSize()); + public Node inline(StructuredGraph compilerGraph, GraalRuntime runtime, final InliningCallback callback) { + StructuredGraph graph = Debug.scope("Inlining", concrete, new Callable<StructuredGraph>() { + @Override + public StructuredGraph call() throws Exception { + return callback.buildGraph(concrete); } - graph = callback.buildGraph(concrete); -// } - + }); return InliningUtil.inline(invoke, graph, true); } @@ -157,9 +156,7 @@ assert invoke.predecessor() != null; graph.addBeforeFixed(invoke.node(), guard); - if (GraalOptions.TraceInlining) { - TTY.println("inlining with type check, type probability: %5.3f", probability); - } + Debug.log("inlining with type check, type probability: %5.3f", probability); return super.inline(graph, runtime, callback); } @@ -188,10 +185,10 @@ @Override public Node inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { - if (GraalOptions.TraceInlining) { + if (Debug.isLogEnabled()) { String targetName = CiUtil.format("%H.%n(%p):%r", invoke.callTarget().targetMethod()); String concreteName = CiUtil.format("%H.%n(%p):%r", concrete); - TTY.println("recording concrete method assumption: %s on receiver type %s -> %s", targetName, context, concreteName); + Debug.log("recording concrete method assumption: %s on receiver type %s -> %s", targetName, context, concreteName); } callback.recordConcreteMethodAssumption(invoke.callTarget().targetMethod(), context, concrete); return super.inline(graph, runtime, callback); @@ -273,30 +270,22 @@ } return null; } else { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because GraalOptions.InlineWithTypeCheck == false", methodName(callTarget.targetMethod(), invoke)); - } + Debug.log("not inlining %s because GraalOptions.InlineWithTypeCheck == false", methodName(callTarget.targetMethod(), invoke)); return null; } } else { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because no monomorphic receiver could be found", methodName(callTarget.targetMethod(), invoke)); - } + Debug.log("not inlining %s because no monomorphic receiver could be found", methodName(callTarget.targetMethod(), invoke)); return null; } } private static boolean checkInvokeConditions(Invoke invoke) { if (invoke.stateAfter() == null) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because the invoke has no after state", methodName(invoke.callTarget().targetMethod(), invoke)); - } + Debug.log("not inlining %s because the invoke has no after state", methodName(invoke.callTarget().targetMethod(), invoke)); return false; } if (invoke.predecessor() == null) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because the invoke is dead code", methodName(invoke.callTarget().targetMethod(), invoke)); - } + Debug.log("not inlining %s because the invoke is dead code", methodName(invoke.callTarget().targetMethod(), invoke)); return false; } return true; @@ -304,34 +293,24 @@ private static boolean checkTargetConditions(RiMethod method) { if (!(method instanceof RiResolvedMethod)) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because it is unresolved", method.toString()); - } + Debug.log("not inlining %s because it is unresolved", method.toString()); return false; } RiResolvedMethod resolvedMethod = (RiResolvedMethod) method; if (Modifier.isNative(resolvedMethod.accessFlags())) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because it is a native method", methodName(resolvedMethod)); - } + Debug.log("not inlining %s because it is a native method", methodName(resolvedMethod)); return false; } if (Modifier.isAbstract(resolvedMethod.accessFlags())) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because it is an abstract method", methodName(resolvedMethod)); - } + Debug.log("not inlining %s because it is an abstract method", methodName(resolvedMethod)); return false; } if (!resolvedMethod.holder().isInitialized()) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because of non-initialized class", methodName(resolvedMethod)); - } + Debug.log("not inlining %s because of non-initialized class", methodName(resolvedMethod)); return false; } if (!resolvedMethod.canBeInlined()) { - if (GraalOptions.TraceInlining) { - TTY.println("not inlining %s because it is marked non-inlinable", methodName(resolvedMethod)); - } + Debug.log("not inlining %s because it is marked non-inlinable", methodName(resolvedMethod)); return false; } return true;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug; + +import com.oracle.max.graal.debug.internal.*; +import java.util.*; +import java.util.concurrent.*; + + +public class Debug { + private static boolean ENABLED = false; + + public static void enable() { + ENABLED = true; + DebugScope.initialize(); + } + + public static boolean isEnabled() { + return ENABLED; + } + + public static boolean isDumpEnabled() { + return ENABLED && DebugScope.getInstance().isDumpEnabled(); + } + + public static boolean isMeterEnabled() { + return ENABLED && DebugScope.getInstance().isMeterEnabled(); + } + + public static boolean isTimeEnabled() { + return ENABLED && DebugScope.getInstance().isTimeEnabled(); + } + + public static boolean isLogEnabled() { + return ENABLED && DebugScope.getInstance().isLogEnabled(); + } + + public static void sandbox(String name, Runnable runnable) { + if (ENABLED) { + DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]); + } else { + runnable.run(); + } + } + + public static void scope(String name, Runnable runnable) { + scope(name, null, runnable); + } + + public static <T> T scope(String name, Callable<T> callable) { + return scope(name, null, callable); + } + + public static void scope(String name, Object context, Runnable runnable) { + if (ENABLED) { + DebugScope.getInstance().scope(name, runnable, null, false, new Object[]{context}); + } else { + runnable.run(); + } + } + + public static String currentScope() { + if (ENABLED) { + return DebugScope.getInstance().getQualifiedName(); + } else { + return ""; + } + } + + public static <T> T scope(String name, Object context, Callable<T> callable) { + if (ENABLED) { + return DebugScope.getInstance().scope(name, null, callable, false, new Object[]{context}); + } else { + return DebugScope.call(callable); + } + } + + public static void log(String msg, Object... args) { + if (ENABLED && DebugScope.getInstance().isLogEnabled()) { + DebugScope.getInstance().log(msg, args); + } + } + + public static void dump(Object object, String msg, Object... args) { + if (ENABLED && DebugScope.getInstance().isDumpEnabled()) { + DebugScope.getInstance().dump(object, msg, args); + } + } + + public static Iterable<Object> context() { + if (ENABLED) { + return DebugScope.getInstance().getCurrentContext(); + } else { + return Collections.emptyList(); + } + } + + @SuppressWarnings("unchecked") + public static <T> List<T> contextSnapshot(Class<T> clazz) { + if (ENABLED) { + List<T> result = new ArrayList<>(); + for (Object o : context()) { + if (clazz.isInstance(o)) { + result.add((T) o); + } + } + return result; + } else { + return Collections.emptyList(); + } + } + + public static DebugMetric metric(String name) { + if (ENABLED) { + return new MetricImpl(name); + } else { + return VOID_METRIC; + } + } + + public static void setConfig(DebugConfig config) { + if (ENABLED) { + DebugScope.getInstance().setConfig(config); + } + } + + public static DebugConfig fixedConfig(final boolean isLogEnabled, final boolean isDumpEnabled, final boolean isMeterEnabled, final boolean isTimerEnabled) { + return new DebugConfig() { + + @Override + public boolean isLogEnabled() { + return isLogEnabled; + } + + @Override + public boolean isMeterEnabled() { + return isMeterEnabled; + } + + @Override + public boolean isDumpEnabled() { + return isDumpEnabled; + } + + @Override + public boolean isTimeEnabled() { + return isTimerEnabled; + } + + @Override + public RuntimeException interceptException(RuntimeException e) { + return e; + } + + @Override + public Collection< ? extends DebugDumpHandler> dumpHandlers() { + return Collections.emptyList(); + } + }; + } + + private static final DebugMetric VOID_METRIC = new DebugMetric() { + public void increment() { } + public void add(int value) { } + }; + + public static DebugTimer timer(String name) { + if (ENABLED) { + return new TimerImpl(name); + } else { + return VOID_TIMER; + } + } + + private static final DebugTimer VOID_TIMER = new DebugTimer() { + public TimerCloseable start() { return TimerImpl.VOID_CLOSEABLE; } + }; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugConfig.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug; + +import java.util.*; + + +public interface DebugConfig { + boolean isLogEnabled(); + boolean isMeterEnabled(); + boolean isDumpEnabled(); + boolean isTimeEnabled(); + RuntimeException interceptException(RuntimeException e); + Collection<? extends DebugDumpHandler> dumpHandlers(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugDumpHandler.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug; + +public interface DebugDumpHandler { + void dump(Object object, String message); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugMetric.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug; + +public interface DebugMetric { + void increment(); + void add(int value); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugTimer.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug; + +import com.oracle.max.graal.debug.internal.*; + +public interface DebugTimer { + TimerCloseable start(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug.internal; + +import java.io.*; +import java.util.*; +import java.util.concurrent.*; + +import com.oracle.max.graal.debug.*; + +public final class DebugScope { + + private static ThreadLocal<DebugScope> instanceTL = new ThreadLocal<>(); + private static ThreadLocal<DebugConfig> configTL = new ThreadLocal<>(); + private static ThreadLocal<RuntimeException> lastExceptionThrownTL = new ThreadLocal<>(); + private static DebugTimer scopeTime = Debug.timer("ScopeTime"); + private static DebugMetric scopeCount = Debug.metric("ScopeCount"); + + private final DebugScope parent; + + private Object[] context; + + private List<DebugScope> children; + private DebugValueMap valueMap; + private String qualifiedName; + private String name; + + private static final char SCOPE_SEP = '.'; + + private boolean logEnabled; + private boolean meterEnabled; + private boolean timeEnabled; + private boolean dumpEnabled; + + public static DebugScope getInstance() { + DebugScope result = instanceTL.get(); + if (result == null) { + DebugScope topLevelDebugScope = new DebugScope(Thread.currentThread().getName(), "", null); + instanceTL.set(topLevelDebugScope); + DebugValueMap.registerTopLevel(topLevelDebugScope.getValueMap()); + return topLevelDebugScope; + } else { + return result; + } + } + + public static DebugConfig getConfig() { + return configTL.get(); + } + + private DebugScope(String name, String qualifiedName, DebugScope parent, Object... context) { + this.name = name; + this.parent = parent; + this.context = context; + this.qualifiedName = qualifiedName; + } + + public boolean isDumpEnabled() { + return dumpEnabled; + } + + public boolean isLogEnabled() { + return logEnabled; + } + + public boolean isMeterEnabled() { + return meterEnabled; + } + + public boolean isTimeEnabled() { + return timeEnabled; + } + + public void log(String msg, Object... args) { + if (isLogEnabled()) { + cachedOut.println(String.format(msg, args)); + } + } + + public void dump(Object object, String formatString, Object[] args) { + if (isDumpEnabled()) { + DebugConfig config = getConfig(); + if (config != null) { + String message = String.format(formatString, args); + for (DebugDumpHandler dumpHandler : config.dumpHandlers()) { + dumpHandler.dump(object, message); + } + } + } + } + + public <T> T scope(String newName, Runnable runnable, Callable<T> callable, boolean sandbox, Object[] newContext) { + DebugScope oldContext = getInstance(); + DebugConfig oldConfig = getConfig(); + DebugScope newChild = null; + if (sandbox) { + newChild = new DebugScope(newName, newName, null, newContext); + setConfig(null); + } else { + newChild = oldContext.createChild(newName, newContext); + } + instanceTL.set(newChild); + newChild.updateFlags(); + scopeCount.increment(); + try (TimerCloseable a = scopeTime.start()) { + return executeScope(runnable, callable); + } finally { + if (!sandbox && newChild.hasValueMap()) { + getValueMap().addChild(newChild.getValueMap()); + } + newChild.deactivate(); + instanceTL.set(oldContext); + setConfig(oldConfig); + } + } + + private <T> T executeScope(Runnable runnable, Callable<T> callable) { + try { + instanceTL.get().log("Starting scope %s", instanceTL.get().getQualifiedName()); + if (runnable != null) { + runnable.run(); + } + if (callable != null) { + return call(callable); + } + } catch (RuntimeException e) { + if (e == lastExceptionThrownTL.get()) { + throw e; + } else { + RuntimeException newException = interceptException(e); + lastExceptionThrownTL.set(newException); + throw newException; + } + } + return null; + } + + private void updateFlags() { + DebugConfig config = getConfig(); + if (config == null) { + logEnabled = false; + meterEnabled = false; + timeEnabled = false; + dumpEnabled = false; + } else { + logEnabled = config.isLogEnabled(); + meterEnabled = config.isMeterEnabled(); + timeEnabled = config.isTimeEnabled(); + dumpEnabled = config.isDumpEnabled(); + } + } + + private void deactivate() { + context = null; + } + + private RuntimeException interceptException(final RuntimeException e) { + final DebugConfig config = getConfig(); + if (config != null) { + return scope("InterceptException", null, new Callable<RuntimeException>() { + + @Override + public RuntimeException call() throws Exception { + try { + return config.interceptException(e); + } catch (Throwable t) { + return e; + } + } + }, false, new Object[] {e}); + } + return e; + } + + private DebugValueMap getValueMap() { + if (valueMap == null) { + valueMap = new DebugValueMap(name); + } + return valueMap; + } + + private boolean hasValueMap() { + return valueMap != null; + } + + long getCurrentValue(int index) { + return getValueMap().getCurrentValue(index); + } + + void setCurrentValue(int index, long l) { + getValueMap().setCurrentValue(index, l); + } + + private DebugScope createChild(String newName, Object[] newContext) { + String newQualifiedName = newName; + if (this.qualifiedName.length() > 0) { + newQualifiedName = this.qualifiedName + SCOPE_SEP + newName; + } + DebugScope result = new DebugScope(newName, newQualifiedName, this, newContext); + if (children == null) { + children = new ArrayList<>(4); + } + children.add(result); + return result; + } + + public Iterable<Object> getCurrentContext() { + return new Iterable<Object>() { + + @Override + public Iterator<Object> iterator() { + return new Iterator<Object>() { + + DebugScope currentScope = DebugScope.this; + int objectIndex; + + @Override + public boolean hasNext() { + selectScope(); + return currentScope != null; + } + + private void selectScope() { + while (currentScope != null && currentScope.context.length <= objectIndex) { + currentScope = currentScope.parent; + objectIndex = 0; + } + } + + @Override + public Object next() { + selectScope(); + if (currentScope != null) { + return currentScope.context[objectIndex++]; + } + throw new IllegalStateException("May only be called if there is a next element."); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("This iterator is read only."); + } + }; + } + }; + } + + public static <T> T call(Callable<T> callable) { + try { + return callable.call(); + } catch (Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } else { + throw new RuntimeException(e); + } + } + } + + public void setConfig(DebugConfig newConfig) { + configTL.set(newConfig); + updateFlags(); + } + + public String getQualifiedName() { + return qualifiedName; + } + + public static PrintStream cachedOut; + + public static void initialize() { + cachedOut = System.out; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugValue.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug.internal; + +public class DebugValue { + + private String name; + private int index; + + protected DebugValue(String name) { + this.name = name; + this.index = -1; + } + + protected long getCurrentValue() { + ensureInitialized(); + return DebugScope.getInstance().getCurrentValue(index); + } + + protected void setCurrentValue(long l) { + ensureInitialized(); + DebugScope.getInstance().setCurrentValue(index, l); + } + + private void ensureInitialized() { + if (index == -1) { + index = KeyRegistry.register(name, this); + } + } + + protected void addToCurrentValue(long timeSpan) { + setCurrentValue(getCurrentValue() + timeSpan); + } + + public int getIndex() { + return index; + } + + public String getName() { + return name; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugValueMap.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug.internal; + +import java.util.*; + +public class DebugValueMap { + + private static List<DebugValueMap> topLevelMaps = new ArrayList<>(); + + private long[] values; + private List<DebugValueMap> children; + private String name; + + public DebugValueMap(String name) { + this.name = name; + } + + public void setCurrentValue(int index, long l) { + ensureSize(index); + values[index] = l; + } + + public long getCurrentValue(int index) { + ensureSize(index); + return values[index]; + } + + private void ensureSize(int index) { + if (values == null) { + values = new long[index + 1]; + } + if (values.length <= index) { + values = Arrays.copyOf(values, index + 1); + } + } + + private int capacity() { + return (values == null) ? 0 : values.length; + } + + public void addChild(DebugValueMap map) { + if (children == null) { + children = new ArrayList<>(4); + } + children.add(map); + } + + public List<DebugValueMap> getChildren() { + if (children == null) { + return Collections.emptyList(); + } else { + return Collections.unmodifiableList(children); + } + } + + public boolean hasChildren() { + return children != null && !children.isEmpty(); + } + + public String getName() { + return this.name; + } + + @Override + public String toString() { + return "DebugValueMap<" + getName() + ">"; + } + + public static synchronized void registerTopLevel(DebugValueMap map) { + topLevelMaps.add(map); + } + + public static synchronized List<DebugValueMap> getTopLevelMaps() { + return topLevelMaps; + } + + public void normalize() { + if (this.hasChildren()) { + Map<String, DebugValueMap> occurred = new HashMap<>(); + for (DebugValueMap map : this.children) { + String mapName = map.getName(); + if (!occurred.containsKey(mapName)) { + occurred.put(mapName, map); + map.normalize(); + } else { + occurred.get(mapName).mergeWith(map); + occurred.get(mapName).normalize(); + } + } + + if (occurred.values().size() < children.size()) { + // At least one duplicate was found. + children.clear(); + for (DebugValueMap map : occurred.values()) { + children.add(map); + map.normalize(); + } + } + } + } + + private void mergeWith(DebugValueMap map) { + if (map.hasChildren()) { + if (hasChildren()) { + children.addAll(map.children); + } else { + children = map.children; + } + map.children = null; + } + + int size = Math.max(this.capacity(), map.capacity()); + ensureSize(size); + for (int i = 0; i < size; ++i) { + long curValue = getCurrentValue(i); + long otherValue = map.getCurrentValue(i); + setCurrentValue(i, curValue + otherValue); + } + } + + public void group() { + List<DebugValueMap> oldChildren = new ArrayList<>(this.children); + this.children.clear(); + for (DebugValueMap map : oldChildren) { + mergeWith(map); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/KeyRegistry.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug.internal; + +import java.util.*; + +public class KeyRegistry { + private static int keyCount; + private static Map<String, Integer> keyMap = new HashMap<>(); + private static List<DebugValue> debugValues = new ArrayList<>(); + + public static synchronized int register(String name, DebugValue value) { + if (!keyMap.containsKey(name)) { + keyMap.put(name, keyCount++); + debugValues.add(value); + } + return keyMap.get(name); + } + + public static synchronized List<DebugValue> getDebugValues() { + return Collections.unmodifiableList(debugValues); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/MetricImpl.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug.internal; + +import com.oracle.max.graal.debug.*; + +public final class MetricImpl extends DebugValue implements DebugMetric { + + public MetricImpl(String name) { + super(name); + } + + public void increment() { + add(1); + } + + public void add(int value) { + if (Debug.isMeterEnabled()) { + super.addToCurrentValue(value); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/TimerCloseable.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug.internal; + +public interface TimerCloseable extends AutoCloseable { + void close(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/TimerImpl.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.debug.internal; + +import com.oracle.max.graal.debug.*; + +public final class TimerImpl extends DebugValue implements DebugTimer { + + public static final TimerCloseable VOID_CLOSEABLE = new TimerCloseable() { + @Override + public void close() { + } + }; + + public TimerImpl(String name) { + super(name); + } + + @Override + public TimerCloseable start() { + if (Debug.isTimeEnabled()) { + final long startTime = System.currentTimeMillis(); + return new TimerCloseable() { + @Override + public void close() { + long timeSpan = System.currentTimeMillis() - startTime; + TimerImpl.this.addToCurrentValue(timeSpan); + } + }; + } else { + return VOID_CLOSEABLE; + } + } +}
--- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Node.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Node.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,6 +25,8 @@ import java.lang.annotation.*; import java.util.*; +import com.oracle.max.graal.graph.NodeClass.*; + /** * This class is the base class for all nodes, it represent a node which can be inserted in a {@link Graph}.<br> @@ -45,7 +47,7 @@ * * */ -public abstract class Node implements Cloneable { +public abstract class Node implements Cloneable, Formattable { static final int DELETED_ID_START = -1000000000; static final int INITIAL_ID = -1; @@ -490,4 +492,66 @@ throw new RuntimeException("unknown verbosity: " + verbosity); } } + + @Override + public void formatTo(Formatter formatter, int flags, int width, int precision) { + if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) { + formatter.format(toString(Verbosity.Id)); + } else if ((flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE) { + formatter.format(toString(Verbosity.Long)); + } else { + formatter.format(toString(Verbosity.Short)); + } + + boolean neighborsAlternate = ((flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY); + int neighborsFlags = (neighborsAlternate ? FormattableFlags.ALTERNATE | FormattableFlags.LEFT_JUSTIFY : 0); + if (width > 0) { + if (this.predecessor != null) { + formatter.format(" pred={"); + this.predecessor.formatTo(formatter, neighborsFlags, width - 1, 0); + formatter.format("}"); + } + + NodeClassIterator inputIter = inputs().iterator(); + while (inputIter.hasNext()) { + Position position = inputIter.nextPosition(); + Node input = getNodeClass().get(this, position); + if (input != null) { + formatter.format(" "); + formatter.format(getNodeClass().getName(position)); + formatter.format("={"); + input.formatTo(formatter, neighborsFlags, width - 1, 0); + formatter.format("}"); + } + } + } + + if (precision > 0) { + if (this.usages.size() > 0) { + formatter.format(" usages={"); + int z = 0; + for (Node usage : this.usages) { + if (z != 0) { + formatter.format(", "); + } + usage.formatTo(formatter, neighborsFlags, 0, precision - 1); + ++z; + } + formatter.format("}"); + } + + NodeClassIterator succIter = successors().iterator(); + while (succIter.hasNext()) { + Position position = succIter.nextPosition(); + Node successor = getNodeClass().get(this, position); + if (successor != null) { + formatter.format(" "); + formatter.format(getNodeClass().getName(position)); + formatter.format("={"); + successor.formatTo(formatter, neighborsFlags, 0, precision - 1); + formatter.format("}"); + } + } + } + } }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java Sun Jan 29 11:40:04 2012 +0100 @@ -30,14 +30,12 @@ import com.oracle.max.cri.ri.*; import com.oracle.max.cri.xir.*; import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.compiler.target.*; import com.oracle.max.graal.cri.*; import com.oracle.max.graal.hotspot.bridge.*; import com.oracle.max.graal.hotspot.logging.*; import com.oracle.max.graal.hotspot.ri.*; import com.oracle.max.graal.hotspot.server.*; -import com.oracle.max.graal.printer.*; /** * Singleton class holding the instance of the GraalCompiler. @@ -90,7 +88,6 @@ private final CompilerToVM vmEntries; private final VMToCompiler vmExits; - private GraalContext context; private HotSpotRuntime runtime; private GraalCompiler compiler; private CiTarget target; @@ -163,7 +160,7 @@ Backend backend = Backend.create(target.arch, runtime, target); generator.initialize(backend.newXirAssembler()); - compiler = new GraalCompiler(context, getRuntime(), getTarget(), backend, generator); + compiler = new GraalCompiler(getRuntime(), getTarget(), backend, generator); } return compiler; } @@ -216,20 +213,20 @@ @Override public HotSpotRuntime getRuntime() { if (runtime == null) { - context = new GraalContext("Virtual Machine Compiler"); if (GraalOptions.PrintCFGToFile) { - context.addCompilationObserver(new CFGPrinterObserver()); +// context.addCompilationObserver(new CFGPrinterObserver()); } - if (GraalOptions.PrintIdealGraphLevel != 0 || GraalOptions.Plot || GraalOptions.PlotOnError) { - CompilationObserver observer; - if (GraalOptions.PrintIdealGraphFile) { - observer = new IdealGraphPrinterObserver(); - } else { - observer = new IdealGraphPrinterObserver(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort); - } - context.addCompilationObserver(observer); - } - runtime = new HotSpotRuntime(context, config, this); + // if (GraalOptions.PrintIdealGraphLevel != 0 || GraalOptions.Plot || GraalOptions.PlotOnError) { + // CompilationObserver observer; + // if (GraalOptions.PrintIdealGraphFile) { + // observer = new IdealGraphPrinterObserver(); + // } else { + // observer = new IdealGraphPrinterObserver(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort); + // } +// context.addCompilationObserver(observer); + // TODO(tw): Install observer. + // } + runtime = new HotSpotRuntime(config, this); } return runtime; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.hotspot; + +import java.util.*; +import java.util.regex.*; + +import com.oracle.max.cri.ri.*; +import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.debug.*; +import com.oracle.max.graal.graph.*; +import com.oracle.max.graal.printer.*; + + +public class HotSpotDebugConfig implements DebugConfig { + + private final String logFilter; + private final String meterFilter; + private final String timerFilter; + private final String dumpFilter; + private final String methodFilter; + private final List<DebugDumpHandler> dumpHandlers = new ArrayList<>(); + + public HotSpotDebugConfig(String logFilter, String meterFilter, String timerFilter, String dumpFilter, String methodFilter) { + this.logFilter = logFilter; + this.meterFilter = meterFilter; + this.timerFilter = timerFilter; + this.dumpFilter = dumpFilter; + this.methodFilter = methodFilter; + dumpHandlers.add(new IdealGraphPrinterDumpHandler(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort)); + } + + public boolean isLogEnabled() { + return isEnabled(logFilter); + } + + public boolean isMeterEnabled() { + return isEnabled(meterFilter); + } + + public boolean isDumpEnabled() { + return isEnabled(dumpFilter); + } + + public boolean isTimeEnabled() { + return isEnabled(timerFilter); + } + + private boolean isEnabled(String filter) { + return filter != null && checkContains(Debug.currentScope(), filter) && checkMethodFilter(); + } + + private static boolean checkContains(String currentScope, String filter) { + if (filter.contains("*")) { + /*filter = filter.replace("*", ".*"); + filter = filter.replace("[", "\\["); + filter = filter.replace("]", "\\]"); + filter = filter.replace(":", "\\:");*/ + System.out.println("regexp: " + filter + " string=" + currentScope + ", " + Pattern.matches(filter, currentScope)); + return Pattern.matches(filter, currentScope); + } + return currentScope.contains(filter); + } + + private boolean checkMethodFilter() { + if (methodFilter == null) { + return true; + } else { + for (Object o : Debug.context()) { + if (o instanceof RiMethod) { + RiMethod riMethod = (RiMethod) o; + if (riMethod.toString().contains(methodFilter)) { + return true; + } + } + } + return false; + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Debug config:"); + add(sb, "Log", logFilter); + add(sb, "Meter", meterFilter); + add(sb, "Time", timerFilter); + add(sb, "Dump", dumpFilter); + add(sb, "MethodFilter", methodFilter); + return sb.toString(); + } + + private static void add(StringBuilder sb, String name, String filter) { + if (filter != null) { + sb.append(' '); + sb.append(name); + sb.append('='); + sb.append(filter); + } + } + + @Override + public RuntimeException interceptException(RuntimeException e) { + Debug.setConfig(Debug.fixedConfig(true, true, false, false)); + Debug.log(String.format("Exception occured in scope: %s", Debug.currentScope())); + for (Object o : Debug.context()) { + Debug.log("Context obj %s", o); + if (o instanceof Graph) { + Graph graph = (Graph) o; + Debug.log("Found graph in context: ", graph); + Debug.dump(o, "Exception graph"); + } + } + return e; + } + + @Override + public Collection<? extends DebugDumpHandler> dumpHandlers() { + return dumpHandlers; + } +}
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotOptions.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotOptions.java Sun Jan 29 11:40:04 2012 +0100 @@ -77,7 +77,11 @@ value = Boolean.parseBoolean(valueString); } } else if (f.getType() == String.class) { - value = valueString; + if (valueString == null) { + value = ""; + } else { + value = valueString; + } } } if (value != null) {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,6 +24,7 @@ package com.oracle.max.graal.hotspot.bridge; import java.lang.reflect.*; +import java.util.*; import java.util.concurrent.*; import com.oracle.max.cri.ci.*; @@ -32,6 +33,9 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition; +import com.oracle.max.graal.debug.*; +import com.oracle.max.graal.debug.internal.*; +import com.oracle.max.graal.hotspot.*; import com.oracle.max.graal.hotspot.Compiler; import com.oracle.max.graal.hotspot.ri.*; import com.oracle.max.graal.hotspot.server.*; @@ -44,6 +48,7 @@ public class VMToCompilerImpl implements VMToCompiler, Remote { private final Compiler compiler; + private int compiledMethodCount; public final HotSpotTypePrimitive typeBoolean; public final HotSpotTypePrimitive typeChar; @@ -55,20 +60,33 @@ public final HotSpotTypePrimitive typeLong; public final HotSpotTypePrimitive typeVoid; - ThreadFactory daemonThreadFactory = new ThreadFactory() { + ThreadFactory compilerThreadFactory = new ThreadFactory() { + @Override public Thread newThread(Runnable r) { - Thread t = new CompilerThread(r); - t.setDaemon(true); - return t; + return new CompilerThread(r); } }; - private static final class CompilerThread extends Thread { + + private final class CompilerThread extends Thread { + public CompilerThread(Runnable r) { super(r); - this.setName("CompilerThread-" + this.getId()); + this.setName("GraalCompilerThread-" + this.getId()); + this.setDaemon(true); + } + + @Override + public void run() { + if (GraalOptions.Debug) { + Debug.enable(); + HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter); + Debug.setConfig(hotspotDebugConfig); + } + super.run(); } } + private ThreadPoolExecutor compileQueue; public VMToCompilerImpl(Compiler compiler) { @@ -93,16 +111,17 @@ HotSpotRuntime runtime = (HotSpotRuntime) compiler.getCompiler().runtime; if (GraalOptions.Intrinsify) { GraalIntrinsics.installIntrinsics(runtime, runtime.getCompiler().getTarget(), PhasePlan.DEFAULT); - Snippets.install(runtime, runtime.getCompiler().getTarget(), new SystemSnippets(), GraalOptions.PlotSnippets, PhasePlan.DEFAULT); - Snippets.install(runtime, runtime.getCompiler().getTarget(), new UnsafeSnippets(), GraalOptions.PlotSnippets, PhasePlan.DEFAULT); + Snippets.install(runtime, runtime.getCompiler().getTarget(), new SystemSnippets(), PhasePlan.DEFAULT); + Snippets.install(runtime, runtime.getCompiler().getTarget(), new UnsafeSnippets(), PhasePlan.DEFAULT); } // Create compilation queue. - compileQueue = new ThreadPoolExecutor(GraalOptions.Threads, GraalOptions.Threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), daemonThreadFactory); + compileQueue = new ThreadPoolExecutor(GraalOptions.Threads, GraalOptions.Threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), compilerThreadFactory); // Create queue status printing thread. if (GraalOptions.PrintQueue) { Thread t = new Thread() { + @Override public void run() { while (true) { @@ -120,9 +139,9 @@ } /** - * This method is the first method compiled during bootstrapping. Put any code in there that - * warms up compiler paths that are otherwise no exercised during bootstrapping and lead to later - * deoptimization when application code is compiled. + * This method is the first method compiled during bootstrapping. Put any code in there that warms up compiler paths + * that are otherwise no exercised during bootstrapping and lead to later deoptimization when application code is + * compiled. */ @SuppressWarnings("unused") @Deprecated @@ -163,8 +182,46 @@ } public void shutdownCompiler() throws Throwable { - compiler.getCompiler().context.print(); +// compiler.getCompiler().context.print(); + // TODO(tw): Print context results. compileQueue.shutdown(); + + if (Debug.isEnabled()) { + List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps(); + List<DebugValue> debugValues = KeyRegistry.getDebugValues(); + if (debugValues.size() > 0) { + for (DebugValueMap map : topLevelMaps) { + TTY.println("Showing the results for thread: " + map.getName()); + map.group(); + map.normalize(); + printMap(map, debugValues, 0); + } + } + } + } + + private void printMap(DebugValueMap map, List<DebugValue> debugValues, int level) { + + printIndent(level); + TTY.println(map.getName()); + for (DebugValue value : debugValues) { + long l = map.getCurrentValue(value.getIndex()); + if (l != 0) { + printIndent(level + 1); + TTY.println(value.getName() + "=" + l); + } + } + + for (DebugValueMap child : map.getChildren()) { + printMap(child, debugValues, level + 1); + } + } + + private static void printIndent(int level) { + for (int i = 0; i < level; ++i) { + TTY.print(" "); + } + TTY.print("|-> "); } @Override @@ -175,12 +232,32 @@ } Runnable runnable = new Runnable() { + public void run() { try { PhasePlan plan = new PhasePlan(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime()); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); - CiTargetMethod result = compiler.getCompiler().compileMethod(method, -1, plan); + long startTime = 0; + int index = compiledMethodCount++; + final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); + if (printCompilation) { + TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", index, method.holder().name(), method.name(), method.signature().asString())); + startTime = System.nanoTime(); + } + + CiTargetMethod result = null; + TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); + try { + result = compiler.getCompiler().compileMethod(method, -1, plan); + } finally { + filter.remove(); + if (printCompilation) { + long time = (System.nanoTime() - startTime) / 100000; + TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", index, "", "", "", time / 10, time % 10, 0, (result != null ? result.targetCodeSize() + : -1))); + } + } compiler.getRuntime().installMethod(method, result); } catch (CiBailout bailout) { if (GraalOptions.ExitVMOnBailout) {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java Sun Jan 29 11:40:04 2012 +0100 @@ -52,14 +52,12 @@ * CRI runtime implementation for the HotSpot VM. */ public class HotSpotRuntime implements GraalRuntime { - final GraalContext context; final HotSpotVMConfig config; final HotSpotRegisterConfig regConfig; private final HotSpotRegisterConfig globalStubRegConfig; private final Compiler compiler; - public HotSpotRuntime(GraalContext context, HotSpotVMConfig config, Compiler compiler) { - this.context = context; + public HotSpotRuntime(HotSpotVMConfig config, Compiler compiler) { this.config = config; this.compiler = compiler; regConfig = new HotSpotRegisterConfig(config, false);
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Sun Jan 29 11:40:04 2012 +0100 @@ -36,6 +36,7 @@ import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.java.BlockMap.Block; import com.oracle.max.graal.java.BlockMap.DeoptBlock; @@ -138,12 +139,12 @@ private BlockMap createBlockMap() { BlockMap map = new BlockMap(method, config.useBranchPrediction()); map.build(); - currentContext.metrics.bytecodeCount += method.code().length; - if (currentContext.isObserved()) { - String label = CiUtil.format("BlockListBuilder %f %R %H.%n(%P)", method); - currentContext.observable.fireCompilationEvent(label, map); - } +// if (currentContext.isObserved()) { +// String label = CiUtil.format("BlockListBuilder %f %R %H.%n(%P)", method); +// currentContext.observable.fireCompilationEvent(label, map); +// } + // TODO(tw): Reinstall this logging code when debug framework is finished. return map; } @@ -158,7 +159,6 @@ this.canTrapBitSet = blockMap.canTrap; exceptionHandlers = blockMap.exceptionHandlers(); - currentContext.metrics.blockCount += blockMap.blocks.size(); nextBlockNumber = blockMap.blocks.size(); @@ -200,7 +200,6 @@ } private int nextBlockNumber() { - currentContext.metrics.blockCount++; return nextBlockNumber++; } @@ -606,9 +605,7 @@ assert !x.isDeleted() && !y.isDeleted(); double probability = method.branchProbability(bci()); if (probability < 0) { - if (GraalOptions.TraceProbability) { - TTY.println("missing probability in " + method + " at bci " + bci()); - } + Debug.log("missing probability in %s at bci %d", method, bci()); probability = 0.5; } @@ -892,9 +889,7 @@ } else { exception.exceptionEdge.setNext(createTarget(unwindBlock(bci()), frameState.duplicateWithException(bci(), exception.exception))); } - if (GraalOptions.Meter) { - currentContext.metrics.ExplicitExceptions++; - } + Debug.metric("ExplicitExceptions").increment(); } } @@ -1159,9 +1154,7 @@ if (prob != null) { assert prob.length == numberOfCases; } else { - if (GraalOptions.TraceProbability) { - TTY.println("Missing probability (switch) in " + method + " at bci " + bci); - } + Debug.log("Missing probability (switch) in %s at bci %d", method, bci); prob = new double[numberOfCases]; for (int i = 0; i < numberOfCases; i++) { prob[i] = 1.0d / numberOfCases;
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/IfNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/IfNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,7 +25,6 @@ import java.util.*; import com.oracle.max.cri.ci.*; -import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.spi.*; import com.oracle.max.graal.nodes.type.*;
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/BasicIdealGraphPrinter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/BasicIdealGraphPrinter.java Sun Jan 29 11:40:04 2012 +0100 @@ -29,12 +29,12 @@ /** * Elementary, generic generator of Ideal Graph Visualizer input for use in printers for specific data structures. */ -public class BasicIdealGraphPrinter { +class BasicIdealGraphPrinter { /** * Edge between two nodes. */ - public static class Edge { + protected static class Edge { final String from; final int fromIndex; final String to; @@ -83,37 +83,41 @@ /** * Creates a new {@link IdealGraphPrinter} that writes to the specified output stream. */ - public BasicIdealGraphPrinter(OutputStream stream) { - this.stream = new PrintStream(stream); + protected BasicIdealGraphPrinter(OutputStream stream) { + try { + this.stream = new PrintStream(stream, false, "US-ASCII"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } } /** * Flushes any buffered output. */ - public void flush() { + protected void flush() { stream.flush(); } /** * Starts a new graph document. */ - public void begin() { + protected void begin() { stream.println("<graphDocument>"); } - public void beginGroup() { + protected void beginGroup() { stream.println("<group>"); } - public void beginMethod(String name, String shortName, int bci) { + protected void beginMethod(String name, String shortName, int bci) { stream.printf(" <method name='%s' shortName='%s' bci='%d'>%n", escape(name), escape(shortName), bci); } - public void beginBytecodes() { + protected void beginBytecodes() { stream.println(" <bytecodes>\n<![CDATA["); } - public void printBytecode(int bci, String mnemonic, int[] extra) { + protected void printBytecode(int bci, String mnemonic, int[] extra) { stream.print(bci); stream.print(' '); stream.print(mnemonic); @@ -126,31 +130,31 @@ stream.println(); } - public void endBytecodes() { + protected void endBytecodes() { stream.println(" ]]></bytecodes>"); } - public void endMethod() { + protected void endMethod() { stream.println(" </method>"); } - public void beginGraph(String title) { + protected void beginGraph(String title) { stream.printf(" <graph name='%s'>%n", escape(title)); } - public void beginProperties() { + protected void beginProperties() { stream.print("<properties>"); } - public void printProperty(String name, String value) { + protected void printProperty(String name, String value) { stream.printf("<p name='%s'>%s</p>", escape(name), escape(value)); } - public void endProperties() { + protected void endProperties() { stream.print("</properties>"); } - public void printProperties(Map<String, String> properties) { + protected void printProperties(Map<String, String> properties) { beginProperties(); for (Entry<String, String> entry : properties.entrySet()) { printProperty(entry.getKey(), entry.getValue()); @@ -158,19 +162,19 @@ endProperties(); } - public void beginNodes() { + protected void beginNodes() { stream.println(" <nodes>"); } - public void beginNode(String id) { + protected void beginNode(String id) { stream.printf(" <node id='%s'>", escape(id)); } - public void endNode() { + protected void endNode() { stream.println(" </node>"); } - public void printNode(String id, Map<String, String> properties) { + protected void printNode(String id, Map<String, String> properties) { beginNode(id); if (properties != null) { printProperties(properties); @@ -178,81 +182,87 @@ endNode(); } - public void endNodes() { + protected void endNodes() { stream.println(" </nodes>"); } - public void beginEdges() { + protected void beginEdges() { stream.println(" <edges>"); } - public void printEdge(Edge edge) { + protected void printEdge(Edge edge) { stream.printf(" <edge from='%s' fromIndex='%d' to='%s' toIndex='%d' label='%s' />%n", escape(edge.from), edge.fromIndex, escape(edge.to), edge.toIndex, escape(edge.label)); } - public void endEdges() { + protected void endEdges() { stream.println(" </edges>"); } - public void beginControlFlow() { + protected void beginControlFlow() { stream.println(" <controlFlow>"); } - public void beginBlock(String name) { + protected void beginBlock(String name) { stream.printf(" <block name='%s'>%n", escape(name)); } - public void beginSuccessors() { + protected void beginSuccessors() { stream.println(" <successors>"); } - public void printSuccessor(String name) { + protected void printSuccessor(String name) { stream.printf(" <successor name='%s'/>%n", escape(name)); } - public void endSuccessors() { + protected void endSuccessors() { stream.println(" </successors>"); } - public void beginBlockNodes() { + protected void beginBlockNodes() { stream.println(" <nodes>"); } - public void printBlockNode(String nodeId) { + protected void printBlockNode(String nodeId) { stream.printf(" <node id='%s'/>%n", escape(nodeId)); } - public void endBlockNodes() { + protected void endBlockNodes() { stream.println(" </nodes>"); } - public void endBlock() { + protected void endBlock() { stream.println(" </block>"); } - public void endControlFlow() { + protected void endControlFlow() { stream.println(" </controlFlow>"); } - public void endGraph() { + protected void endGraph() { stream.println(" </graph>"); } /** * Ends the current group. */ - public void endGroup() { + protected void endGroup() { stream.println("</group>"); } /** * Finishes the graph document and flushes the output stream. */ - public void end() { + protected void end() { stream.println("</graphDocument>"); flush(); } + + public boolean isValid() { + return !stream.checkError(); + } + + private static String escape(String s) { StringBuilder str = null; for (int i = 0; i < s.length(); i++) {
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java Sun Jan 29 11:40:04 2012 +0100 @@ -107,7 +107,7 @@ if (schedule == null) { try { schedule = new IdentifyBlocksPhase(true, LIRBlock.FACTORY); - schedule.apply((StructuredGraph) graph, false); + schedule.apply((StructuredGraph) graph); blocks = schedule.getBlocks(); ComputeLinearScanOrder clso = new ComputeLinearScanOrder(schedule.getBlocks().size(), schedule.loopCount(), (LIRBlock) schedule.getStartBlock());
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinter.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,7 +27,6 @@ import java.util.Map.Entry; import com.oracle.max.cri.ri.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.graph.Node.Verbosity; @@ -35,58 +34,30 @@ import com.oracle.max.graal.graph.NodeClass.Position; import com.oracle.max.graal.java.*; import com.oracle.max.graal.nodes.*; -import com.oracle.max.graal.printer.BasicIdealGraphPrinter.Edge; /** * Generates a representation of {@link Graph Graphs} that can be visualized and inspected with the <a * href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. */ -class IdealGraphPrinter { - - private final BasicIdealGraphPrinter printer; - private final HashSet<Class<?>> omittedClasses = new HashSet<>(); - private final Set<Node> noBlockNodes = new HashSet<>(); - +class IdealGraphPrinter extends BasicIdealGraphPrinter { /** * Creates a new {@link IdealGraphPrinter} that writes to the specified output stream. */ public IdealGraphPrinter(OutputStream stream) { - this.printer = new BasicIdealGraphPrinter(stream); - } - - /** - * Adds a node class that is omitted in the output. - */ - public void addOmittedClass(Class<?> clazz) { - omittedClasses.add(clazz); - } - - /** - * Flushes any buffered output. - */ - public void flush() { - printer.flush(); - } - - /** - * Starts a new graph document. - */ - public void begin() { - printer.begin(); + super(stream); } /** * Starts a new group of graphs with the given name, short name and method byte code index (BCI) as properties. */ - public void beginGroup(String name, String shortName, RiResolvedMethod method, int bci, String origin) { - printer.beginGroup(); - printer.beginProperties(); - printer.printProperty("name", name); - printer.printProperty("origin", origin); - printer.endProperties(); - printer.beginMethod(name, shortName, bci); - if (GraalOptions.PrintIdealGraphBytecodes && method != null) { - printer.beginBytecodes(); + public void beginGroup(String name, String shortName, RiResolvedMethod method, int bci) { + beginGroup(); + beginProperties(); + printProperty("name", name); + endProperties(); + beginMethod(name, shortName, bci); + if (method != null) { + beginBytecodes(); BytecodeStream bytecodes = new BytecodeStream(method.code()); while (bytecodes.currentBC() != Bytecodes.END) { int startBCI = bytecodes.currentBCI(); @@ -98,151 +69,84 @@ extra[i] = bytecodes.readUByte(startBCI + 1 + i); } } - printer.printBytecode(startBCI, mnemonic, extra); + printBytecode(startBCI, mnemonic, extra); bytecodes.next(); } - printer.endBytecodes(); + endBytecodes(); } - printer.endMethod(); + endMethod(); } - /** - * Ends the current group. - */ - public void endGroup() { - printer.endGroup(); - } - - /** - * Finishes the graph document and flushes the output stream. - */ - public void end() { - printer.end(); - } - - public void print(Graph graph, String title, boolean shortNames) { - print(graph, title, shortNames, null); + public void print(Graph graph, String title) { + print(graph, title, null); } /** * Prints an entire {@link Graph} with the specified title, optionally using short names for nodes. */ - public void print(Graph graph, String title, boolean shortNames, IdentifyBlocksPhase predefinedSchedule) { - printer.beginGraph(title); - noBlockNodes.clear(); + public void print(Graph graph, String title, IdentifyBlocksPhase predefinedSchedule) { + beginGraph(title); + Set<Node> noBlockNodes = new HashSet<>(); IdentifyBlocksPhase schedule = predefinedSchedule; if (schedule == null) { try { schedule = new IdentifyBlocksPhase(true); - schedule.apply((StructuredGraph) graph, false); + schedule.apply((StructuredGraph) graph); } catch (Throwable t) { // nothing to do here... } } - printer.beginNodes(); - List<Edge> edges = printNodes(graph, shortNames, schedule == null ? null : schedule.getNodeToBlock()); - printer.endNodes(); + beginNodes(); + List<Edge> edges = printNodes(graph, schedule == null ? null : schedule.getNodeToBlock(), noBlockNodes); + endNodes(); - printer.beginEdges(); + beginEdges(); for (Edge edge : edges) { - printer.printEdge(edge); + printEdge(edge); } - printer.endEdges(); + endEdges(); if (schedule != null) { - printer.beginControlFlow(); + beginControlFlow(); for (Block block : schedule.getBlocks()) { printBlock(graph, block, schedule.getNodeToBlock()); } - printNoBlock(); - printer.endControlFlow(); + printNoBlock(noBlockNodes); + endControlFlow(); } - printer.endGraph(); + endGraph(); flush(); } - private List<Edge> printNodes(Graph graph, boolean shortNames, NodeMap<Block> nodeToBlock) { + private List<Edge> printNodes(Graph graph, NodeMap<Block> nodeToBlock, Set<Node> noBlockNodes) { ArrayList<Edge> edges = new ArrayList<>(); NodeMap<Set<Entry<String, Integer>>> colors = graph.createNodeMap(); NodeMap<Set<Entry<String, String>>> colorsToString = graph.createNodeMap(); NodeMap<Set<String>> bits = graph.createNodeMap(); -// TODO This code was never reachable, since there was no code putting a NodeMap or NodeBitMap into the debugObjects. -// If you need to reactivate this code, put the mapping from names to values into a helper object and register it in the new debugObjects array. -// -// if (debugObjects != null) { -// for (Entry<String, Object> entry : debugObjects.entrySet()) { -// String name = entry.getKey(); -// Object obj = entry.getValue(); -// if (obj instanceof NodeMap) { -// Map<Object, Integer> colorNumbers = new HashMap<Object, Integer>(); -// int nextColor = 0; -// NodeMap<?> map = (NodeMap<?>) obj; -// for (Entry<Node, ?> mapEntry : map.entries()) { -// Node node = mapEntry.getKey(); -// Object color = mapEntry.getValue(); -// Integer colorNumber = colorNumbers.get(color); -// if (colorNumber == null) { -// colorNumber = nextColor++; -// colorNumbers.put(color, colorNumber); -// } -// Set<Entry<String, Integer>> nodeColors = colors.get(node); -// if (nodeColors == null) { -// nodeColors = new HashSet<Entry<String, Integer>>(); -// colors.put(node, nodeColors); -// } -// nodeColors.add(new SimpleImmutableEntry<String, Integer>(name + "Color", colorNumber)); -// Set<Entry<String, String>> nodeColorStrings = colorsToString.get(node); -// if (nodeColorStrings == null) { -// nodeColorStrings = new HashSet<Entry<String, String>>(); -// colorsToString.put(node, nodeColorStrings); -// } -// nodeColorStrings.add(new SimpleImmutableEntry<String, String>(name, color.toString())); -// } -// } else if (obj instanceof NodeBitMap) { -// NodeBitMap bitmap = (NodeBitMap) obj; -// for (Node node : bitmap) { -// Set<String> nodeBits = bits.get(node); -// if (nodeBits == null) { -// nodeBits = new HashSet<String>(); -// bits.put(node, nodeBits); -// } -// nodeBits.add(name); -// } -// } -// } -// } for (Node node : graph.getNodes()) { - if (omittedClasses.contains(node.getClass())) { - continue; - } - printer.beginNode(node.toString(Verbosity.Id)); - printer.beginProperties(); - printer.printProperty("idx", node.toString(Verbosity.Id)); + beginNode(node.toString(Verbosity.Id)); + beginProperties(); + printProperty("idx", node.toString(Verbosity.Id)); Map<Object, Object> props = node.getDebugProperties(); if (!props.containsKey("name") || props.get("name").toString().trim().length() == 0) { - String name; - if (shortNames) { - name = node.toString(Verbosity.Name); - } else { - name = node.toString(); - } - printer.printProperty("name", name); + String name = node.toString(Verbosity.Name); + printProperty("name", name); } - printer.printProperty("class", node.getClass().getSimpleName()); + printProperty("class", node.getClass().getSimpleName()); Block block = nodeToBlock == null ? null : nodeToBlock.get(node); if (block != null) { - printer.printProperty("block", Integer.toString(block.blockID())); + printProperty("block", Integer.toString(block.blockID())); if (!(node instanceof PhiNode || node instanceof FrameState || node instanceof LocalNode) && !block.getInstructions().contains(node)) { - printer.printProperty("notInOwnBlock", "true"); + printProperty("notInOwnBlock", "true"); } } else { - printer.printProperty("block", "noBlock"); + printProperty("block", "noBlock"); noBlockNodes.add(node); } @@ -251,7 +155,7 @@ for (Entry<String, Integer> color : nodeColors) { String name = color.getKey(); Integer value = color.getValue(); - printer.printProperty(name, Integer.toString(value)); + printProperty(name, Integer.toString(value)); } } Set<Entry<String, String>> nodeColorStrings = colorsToString.get(node); @@ -259,24 +163,24 @@ for (Entry<String, String> color : nodeColorStrings) { String name = color.getKey(); String value = color.getValue(); - printer.printProperty(name, value); + printProperty(name, value); } } Set<String> nodeBits = bits.get(node); if (nodeBits != null) { for (String bit : nodeBits) { - printer.printProperty(bit, "true"); + printProperty(bit, "true"); } } for (Entry<Object, Object> entry : props.entrySet()) { String key = entry.getKey().toString(); String value = entry.getValue() == null ? "null" : entry.getValue().toString(); - printer.printProperty(key, value); + printProperty(key, value); } - printer.endProperties(); - printer.endNode(); + endProperties(); + endNode(); // successors int fromIndex = 0; @@ -284,7 +188,7 @@ while (succIter.hasNext()) { Position position = succIter.nextPosition(); Node successor = node.getNodeClass().get(node, position); - if (successor != null && !omittedClasses.contains(successor.getClass())) { + if (successor != null) { edges.add(new Edge(node.toString(Verbosity.Id), fromIndex, successor.toString(Verbosity.Id), 0, node.getNodeClass().getName(position))); } fromIndex++; @@ -296,7 +200,7 @@ while (inputIter.hasNext()) { Position position = inputIter.nextPosition(); Node input = node.getNodeClass().get(node, position); - if (input != null && !omittedClasses.contains(input.getClass())) { + if (input != null) { edges.add(new Edge(input.toString(Verbosity.Id), input.successors().explicitCount(), node.toString(Verbosity.Id), toIndex, node.getNodeClass().getName(position))); } toIndex++; @@ -307,15 +211,15 @@ } private void printBlock(Graph graph, Block block, NodeMap<Block> nodeToBlock) { - printer.beginBlock(Integer.toString(block.blockID())); - printer.beginSuccessors(); + beginBlock(Integer.toString(block.blockID())); + beginSuccessors(); for (Block sux : block.getSuccessors()) { if (sux != null) { - printer.printSuccessor(Integer.toString(sux.blockID())); + printSuccessor(Integer.toString(sux.blockID())); } } - printer.endSuccessors(); - printer.beginBlockNodes(); + endSuccessors(); + beginBlockNodes(); Set<Node> nodes = new HashSet<>(block.getInstructions()); @@ -351,25 +255,22 @@ } for (Node node : nodes) { - if (!omittedClasses.contains(node.getClass())) { - printer.printBlockNode(node.toString(Verbosity.Id)); - } + printBlockNode(node.toString(Verbosity.Id)); } } - printer.endBlockNodes(); - printer.endBlock(); + endBlockNodes(); + endBlock(); } - private void printNoBlock() { + private void printNoBlock(Set<Node> noBlockNodes) { if (!noBlockNodes.isEmpty()) { - printer.beginBlock("noBlock"); - printer.beginBlockNodes(); + beginBlock("noBlock"); + beginBlockNodes(); for (Node node : noBlockNodes) { - printer.printBlockNode(node.toString(Verbosity.Id)); + printBlockNode(node.toString(Verbosity.Id)); } - printer.endBlockNodes(); - printer.endBlock(); + endBlockNodes(); + endBlock(); } } - }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterDumpHandler.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.printer; + +import java.io.*; +import java.net.*; +import java.util.*; +import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; +import com.oracle.max.criutils.*; +import com.oracle.max.graal.debug.*; +import com.oracle.max.graal.graph.*; + +/** + * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be + * inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. + */ +public class IdealGraphPrinterDumpHandler implements DebugDumpHandler { + + private static final String DEFAULT_FILE_NAME = "output.igv.xml"; + + private IdealGraphPrinter printer; + private List<RiResolvedMethod> previousInlineContext = new ArrayList<>(); + private String fileName; + private String host; + private int port; + private boolean initialized; + + /** + * Creates a new {@link IdealGraphPrinterDumpHandler} that writes output to a file named after the compiled method. + */ + public IdealGraphPrinterDumpHandler() { + this.fileName = DEFAULT_FILE_NAME; + } + + /** + * Creates a new {@link IdealGraphPrinterDumpHandler} that sends output to a remote IdealGraphVisualizer instance. + */ + public IdealGraphPrinterDumpHandler(String host, int port) { + this.host = host; + this.port = port; + } + + + + private void ensureInitialized() { + if (!initialized) { + initialized = true; + if (fileName != null) { + initializeFilePrinter(); + } else { + initializeNetworkPrinter(); + } + printer.begin(); + } + } + + private void initializeFilePrinter() { + try { + FileOutputStream stream = new FileOutputStream(fileName); + printer = new IdealGraphPrinter(stream); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private void initializeNetworkPrinter() { + try { + Socket socket = new Socket(host, port); + BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream(), 0x4000); + printer = new IdealGraphPrinter(stream); + TTY.println("Connected to the IGV on port %d", port); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public void dump(Object object, final String message) { + if (object instanceof Graph) { + ensureInitialized(); + final Graph graph = (Graph) object; + + if (printer.isValid()) { + // Get all current RiResolvedMethod instances in the context. + List<RiResolvedMethod> inlineContext = Debug.contextSnapshot(RiResolvedMethod.class); + + // Reverse list such that inner method comes after outer method. + Collections.reverse(inlineContext); + + // Check for method scopes that must be closed since the previous dump. + for (int i = 0; i < previousInlineContext.size(); ++i) { + if (i >= inlineContext.size() || inlineContext.get(i) != previousInlineContext.get(i)) { + for (int j = previousInlineContext.size() - 1; j >= i; --j) { + closeMethodScope(); + } + } + } + + // Check for method scopes that must be opened since the previous dump. + for (int i = 0; i < inlineContext.size(); ++i) { + if (i >= previousInlineContext.size() || inlineContext.get(i) != previousInlineContext.get(i)) { + for (int j = i; j < inlineContext.size(); ++j) { + openMethodScope(inlineContext.get(j)); + } + } + } + + // Save inline context for next dump. + previousInlineContext = inlineContext; + + Debug.sandbox("PrintingGraph", new Runnable() { + + @Override + public void run() { + // Finally, output the graph. + printer.print(graph, message); + + } + }); + } else { + TTY.println("Fatal error: Printer invalid!"); + System.exit(-1); + } + } + } + + private void openMethodScope(RiResolvedMethod method) { + printer.beginGroup(CiUtil.format("%H::%n", method), CiUtil.format("%h::%n", method), method, -1); + + } + + private void closeMethodScope() { + printer.endGroup(); + + } +}
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterObserver.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,265 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.max.graal.printer; - -import java.io.*; -import java.net.*; -import java.util.regex.*; - -import com.oracle.max.cri.ri.*; -import com.oracle.max.criutils.*; -import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.observer.*; -import com.oracle.max.graal.compiler.schedule.*; -import com.oracle.max.graal.graph.*; - -/** - * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be - * inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. - */ -public class IdealGraphPrinterObserver implements CompilationObserver { - - private static final Pattern INVALID_CHAR = Pattern.compile("[^A-Za-z0-9_.-]"); - - private final String host; - private final int port; - - private static class PrintingContext { - public IdealGraphPrinter printer; - private OutputStream stream; - private Socket socket; - - } - private final ThreadLocal<PrintingContext> context = new ThreadLocal<PrintingContext>() { - @Override - protected PrintingContext initialValue() { - return new PrintingContext(); - } - }; - - /** - * Creates a new {@link IdealGraphPrinterObserver} that writes output to a file named after the compiled method. - */ - public IdealGraphPrinterObserver() { - this(null, -1); - } - - /** - * Creates a new {@link IdealGraphPrinterObserver} that sends output to a remote IdealGraphVisualizer instance. - */ - public IdealGraphPrinterObserver(String host, int port) { - this.host = host; - this.port = port; - } - - private PrintingContext context() { - return context.get(); - } - - private IdealGraphPrinter printer() { - return context().printer; - } - - private Socket socket() { - return context().socket; - } - - @Override - public void compilationStarted(CompilationEvent event) { - openPrinter(event.debugObject(RiResolvedMethod.class), false); - } - - private void openPrinter(RiResolvedMethod method, boolean error) { - assert (context().stream == null && printer() == null); - if ((!TTY.isSuppressed() && GraalOptions.Plot) || (GraalOptions.PlotOnError && error)) { - String name; - if (method != null) { - name = method.holder().name(); - name = name.substring(1, name.length() - 1).replace('/', '.'); - name = name + "." + method.name(); - } else { - name = "null"; - } - - openPrinter(name, method); - } - } - - private void openPrinter(String title, RiResolvedMethod method) { - assert (context().stream == null && printer() == null); - if (!TTY.isSuppressed()) { - // Use a filter to suppress a recursive attempt to open a printer - TTY.Filter filter = new TTY.Filter(); - try { - if (host != null) { - openNetworkPrinter(title, method); - } else { - openFilePrinter(title, method); - } - } finally { - filter.remove(); - } - } - } - - private void openFilePrinter(String title, RiResolvedMethod method) { - String filename = title + ".igv.xml"; - filename = INVALID_CHAR.matcher(filename).replaceAll("_"); - - try { - context().stream = new FileOutputStream(filename); - context().printer = new IdealGraphPrinter(context().stream); - printer().begin(); - printer().beginGroup(title, title, method, -1, "Graal"); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public boolean networkAvailable() { - try { - Socket s = new Socket(host, port); - s.setSoTimeout(10); - s.close(); - return true; - } catch (IOException e) { - return false; - } - } - - private void openNetworkPrinter(String title, RiResolvedMethod method) { - try { - context().socket = new Socket(host, port); - if (socket().getInputStream().read() == 'y') { - context().stream = new BufferedOutputStream(socket().getOutputStream(), 0x4000); - } else { - // server currently does not accept any input - socket().close(); - context().socket = null; - return; - } - - context().printer = new IdealGraphPrinter(context().stream); - printer().begin(); - printer().beginGroup(title, title, method, -1, "Graal"); - printer().flush(); - if (socket().getInputStream().read() != 'y') { - // server declines input for this method - socket().close(); - context().socket = null; - context().stream = null; - context().printer = null; - } - } catch (IOException e) { - System.err.println("Error opening connection to " + host + ":" + port + ": " + e); - - if (socket() != null) { - try { - socket().close(); - } catch (IOException ioe) { - } - context().socket = null; - } - context().stream = null; - context().printer = null; - } - } - - @Override - public void compilationEvent(CompilationEvent event) { - boolean lazyStart = false; - if (printer() == null && event.hasDebugObject(CompilationEvent.ERROR)) { - openPrinter(event.debugObject(RiResolvedMethod.class), true); - lazyStart = true; - } - Graph graph = event.debugObject(Graph.class); - if (printer() != null && graph != null) { - printer().print(graph, event.label, true, event.debugObject(IdentifyBlocksPhase.class)); - } - if (lazyStart && printer() != null) { - closePrinter(); - } - } - - @Override - public void compilationFinished(CompilationEvent event) { - if (printer() != null) { - closePrinter(); - } - } - - private void closePrinter() { - assert (printer() != null); - - try { - printer().endGroup(); - printer().end(); - - if (socket() != null) { - socket().close(); // also closes stream - } else { - context().stream.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - context().printer = null; - context().stream = null; - context().socket = null; - } - } - - public void printGraphs(String groupTitle, Graph... graphs) { - openPrinter(groupTitle, null); - if (printer() != null) { - int i = 0; - for (Graph graph : graphs) { - printer().print(graph, "Graph " + i, true); - i++; - } - closePrinter(); - } - } - - public void compilationStarted(String groupTitle) { - openPrinter(groupTitle, null); - } - - public void printGraph(String graphTitle, Graph graph) { - if (printer() != null) { - printer().print(graph, graphTitle, true); - } - } - - public void printSingleGraph(String title, Graph graph) { - printSingleGraph(title, title, graph); - } - - public void printSingleGraph(String groupTitle, String graphTitle, Graph graph) { - openPrinter(groupTitle, null); - if (printer() != null) { - printer().print(graph, graphTitle, true); - closePrinter(); - } - } -}
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/GraalIntrinsics.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/GraalIntrinsics.java Sun Jan 29 11:40:04 2012 +0100 @@ -34,11 +34,11 @@ public class GraalIntrinsics { public static void installIntrinsics(GraalRuntime runtime, CiTarget target, PhasePlan plan) { if (GraalOptions.Intrinsify) { - Snippets.install(runtime, target, new MathSnippetsX86(), GraalOptions.PlotSnippets, plan); - Snippets.install(runtime, target, new DoubleSnippets(), GraalOptions.PlotSnippets, plan); - Snippets.install(runtime, target, new FloatSnippets(), GraalOptions.PlotSnippets, plan); - Snippets.install(runtime, target, new NodeClassSnippets(), GraalOptions.PlotSnippets, plan); - Snippets.install(runtime, target, new ArrayCopySnippets(), GraalOptions.PlotSnippets, plan); + Snippets.install(runtime, target, new MathSnippetsX86(), plan); + Snippets.install(runtime, target, new DoubleSnippets(), plan); + Snippets.install(runtime, target, new FloatSnippets(), plan); + Snippets.install(runtime, target, new NodeClassSnippets(), plan); + Snippets.install(runtime, target, new ArrayCopySnippets(), plan); plan.addPhase(PhasePosition.HIGH_LEVEL, new IntrinsifyArrayCopyPhase(runtime)); } }
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java Sun Jan 29 11:40:04 2012 +0100 @@ -26,62 +26,46 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; -import com.oracle.max.graal.compiler.*; -import com.oracle.max.graal.compiler.observer.*; import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.java.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; import com.oracle.max.graal.nodes.java.*; -import com.oracle.max.graal.printer.*; /** * Utilities for snippet installation and management. */ public class Snippets { - public static void install(GraalRuntime runtime, CiTarget target, SnippetsInterface obj, boolean plotGraphs, PhasePlan plan) { + public static void install(GraalRuntime runtime, CiTarget target, SnippetsInterface obj, PhasePlan plan) { Class<? extends SnippetsInterface> clazz = obj.getClass(); - GraalContext context = new GraalContext("Installing Snippet"); BoxingMethodPool pool = new BoxingMethodPool(runtime); if (clazz.isAnnotationPresent(ClassSubstitution.class)) { - installSubstitution(runtime, target, plotGraphs, plan, clazz, context, pool, clazz.getAnnotation(ClassSubstitution.class).value()); + installSubstitution(runtime, target, plan, clazz, pool, clazz.getAnnotation(ClassSubstitution.class).value()); } else { - installSnippets(runtime, target, plotGraphs, plan, clazz, context, pool); + installSnippets(runtime, target, plan, clazz, pool); } } - private static void installSnippets(GraalRuntime runtime, CiTarget target, boolean plotGraphs, PhasePlan plan, Class< ? extends SnippetsInterface> clazz, GraalContext context, + private static void installSnippets(GraalRuntime runtime, CiTarget target, PhasePlan plan, Class< ? extends SnippetsInterface> clazz, BoxingMethodPool pool) { for (Method snippet : clazz.getDeclaredMethods()) { - try { - int modifiers = snippet.getModifiers(); - if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { - throw new RuntimeException("Snippet must not be abstract or native"); - } - RiResolvedMethod snippetRiMethod = runtime.getRiMethod(snippet); - if (snippetRiMethod.compilerStorage().get(Graph.class) == null) { - buildSnippetGraph(snippetRiMethod, runtime, target, context, pool, plotGraphs, plan); - } - } catch (GraalInternalError error) { - if (context.isObserved()) { - if (error.node() != null) { - context.observable.fireCompilationEvent("VerificationError on Node " + error.node(), CompilationEvent.ERROR, error.node().graph()); - } else if (error.graph() != null) { - context.observable.fireCompilationEvent("VerificationError on Graph " + error.graph(), CompilationEvent.ERROR, error.graph()); - } - } - throw error; - } catch (Throwable t) { - throw new RuntimeException("Error when installing snippet for " + clazz, t); + int modifiers = snippet.getModifiers(); + if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { + throw new RuntimeException("Snippet must not be abstract or native"); + } + RiResolvedMethod snippetRiMethod = runtime.getRiMethod(snippet); + if (snippetRiMethod.compilerStorage().get(Graph.class) == null) { + buildSnippetGraph(snippetRiMethod, runtime, target, pool, plan); } } } - private static void installSubstitution(GraalRuntime runtime, CiTarget target, boolean plotGraphs, PhasePlan plan, Class< ? extends SnippetsInterface> clazz, GraalContext context, + private static void installSubstitution(GraalRuntime runtime, CiTarget target, PhasePlan plan, Class< ? extends SnippetsInterface> clazz, BoxingMethodPool pool, Class<?> original) throws GraalInternalError { for (Method snippet : clazz.getDeclaredMethods()) { try { @@ -94,50 +78,24 @@ throw new RuntimeException("Snippet must not be abstract or native"); } RiResolvedMethod snippetRiMethod = runtime.getRiMethod(snippet); - StructuredGraph graph = buildSnippetGraph(snippetRiMethod, runtime, target, context, pool, plotGraphs, plan); + StructuredGraph graph = buildSnippetGraph(snippetRiMethod, runtime, target, pool, plan); runtime.getRiMethod(method).compilerStorage().put(Graph.class, graph); } catch (NoSuchMethodException e) { throw new RuntimeException("Could not resolve method to substitute with: " + snippet.getName(), e); - } catch (GraalInternalError error) { - if (context.isObserved()) { - if (error.node() != null) { - context.observable.fireCompilationEvent("VerificationError on Node " + error.node(), CompilationEvent.ERROR, error.node().graph()); - } else if (error.graph() != null) { - context.observable.fireCompilationEvent("VerificationError on Graph " + error.graph(), CompilationEvent.ERROR, error.graph()); - } - } - throw error; - } catch (Throwable t) { - throw new RuntimeException("Error when installing snippet for " + clazz, t); } } } - private static StructuredGraph buildSnippetGraph(RiResolvedMethod snippetRiMethod, GraalRuntime runtime, CiTarget target, GraalContext context, BoxingMethodPool pool, boolean plotGraphs, PhasePlan plan) { - IdealGraphPrinterObserver observer = null; - if (plotGraphs) { - observer = new IdealGraphPrinterObserver(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort); - observer.compilationStarted(CiUtil.format("snippet:%h.%n(%p)", snippetRiMethod)); - } - StructuredGraph graph = buildSnippetGraph(snippetRiMethod, runtime, target, context, pool, plan, observer); - if (observer != null) { - observer.compilationFinished(null); - } - return graph; - } - - private static StructuredGraph buildSnippetGraph(RiResolvedMethod snippetRiMethod, GraalRuntime runtime, CiTarget target, GraalContext context, BoxingMethodPool pool, PhasePlan plan, IdealGraphPrinterObserver observer) { + private static StructuredGraph buildSnippetGraph(RiResolvedMethod snippetRiMethod, GraalRuntime runtime, CiTarget target, BoxingMethodPool pool, PhasePlan plan) { GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(); GraphBuilderPhase graphBuilder = new GraphBuilderPhase(runtime, config); StructuredGraph graph = new StructuredGraph(snippetRiMethod); - graphBuilder.apply(graph, context); + graphBuilder.apply(graph); - if (observer != null) { - observer.printGraph(snippetRiMethod.name() + ":" + GraphBuilderPhase.class.getSimpleName(), graph); - } + Debug.dump(graph, "%s: %s", snippetRiMethod.name(), GraphBuilderPhase.class.getSimpleName()); - new SnippetIntrinsificationPhase(runtime, pool).apply(graph, context); + new SnippetIntrinsificationPhase(runtime, pool).apply(graph); for (Invoke invoke : graph.getInvokes()) { MethodCallTargetNode callTarget = invoke.callTarget(); @@ -146,29 +104,25 @@ if (holder.isSubtypeOf(runtime.getType(SnippetsInterface.class))) { StructuredGraph targetGraph = (StructuredGraph) targetMethod.compilerStorage().get(Graph.class); if (targetGraph == null) { - targetGraph = buildSnippetGraph(targetMethod, runtime, target, context, pool, plan, observer); + targetGraph = buildSnippetGraph(targetMethod, runtime, target, pool, plan); } InliningUtil.inline(invoke, targetGraph, true); new CanonicalizerPhase(target, runtime, null).apply(graph); } } - new SnippetIntrinsificationPhase(runtime, pool).apply(graph, context); + new SnippetIntrinsificationPhase(runtime, pool).apply(graph); - if (observer != null) { - observer.printGraph(snippetRiMethod.name() + ":" + SnippetIntrinsificationPhase.class.getSimpleName(), graph); - } - new DeadCodeEliminationPhase().apply(graph, context); - new CanonicalizerPhase(target, runtime, null).apply(graph, context); + Debug.dump(graph, "%s: %s", snippetRiMethod.name(), GraphBuilderPhase.class.getSimpleName()); + new DeadCodeEliminationPhase().apply(graph); + new CanonicalizerPhase(target, runtime, null).apply(graph); // TODO (gd) remove when we have safepoint polling elimination for (LoopEndNode end : graph.getNodes(LoopEndNode.class)) { end.setSafepointPolling(false); } - if (observer != null) { - observer.printGraph(snippetRiMethod.name() + ":" + "Final", graph); - } + Debug.dump(graph, "%s: Final", snippetRiMethod.name()); snippetRiMethod.compilerStorage().put(Graph.class, graph);
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/BoxingEliminationTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/BoxingEliminationTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,6 +28,7 @@ import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; @@ -109,9 +110,9 @@ } new InliningPhase(null, runtime(), hints, null, phasePlan).apply(graph); new CanonicalizerPhase(null, runtime(), null).apply(graph); - print(graph); + Debug.dump(graph, "Graph"); new BoxingEliminationPhase().apply(graph); - print(graph); + Debug.dump(graph, "Graph"); new ExpandBoxingNodesPhase(pool).apply(graph); new CanonicalizerPhase(null, runtime(), null).apply(graph); new DeadCodeEliminationPhase().apply(graph);
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,6 +27,7 @@ import org.junit.*; import com.oracle.max.graal.compiler.phases.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -80,7 +81,7 @@ private void test(String snippet) { StructuredGraph graph = parse(snippet); - print(graph); + Debug.dump(graph, "Graph"); LocalNode local = graph.getNodes(LocalNode.class).iterator().next(); ConstantNode constant = ConstantNode.forInt(0, graph); for (Node n : local.usages().snapshot()) { @@ -94,7 +95,7 @@ invoke.intrinsify(null); } new CanonicalizerPhase(null, runtime(), null).apply(graph); - StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); print(referenceGraph); + StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); Debug.dump(referenceGraph, "Graph"); assertEquals(referenceGraph, graph); } }
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/EscapeAnalysisTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/EscapeAnalysisTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,6 +28,7 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.graal.compiler.phases.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.java.*; @@ -122,9 +123,9 @@ new InliningPhase(null, runtime(), null, null, getDefaultPhasePlan()).apply(graph); new DeadCodeEliminationPhase().apply(graph); - print(graph); + Debug.dump(graph, "Graph"); new EscapeAnalysisPhase(null, runtime(), null, getDefaultPhasePlan()).apply(graph); - print(graph); + Debug.dump(graph, "Graph"); int retCount = 0; for (ReturnNode ret : graph.getNodes(ReturnNode.class)) { Assert.assertTrue(ret.result().isConstant());
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/GraphTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/GraphTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,18 +24,15 @@ import java.lang.reflect.*; -import org.junit.*; - import junit.framework.Assert; import com.oracle.max.cri.ri.*; -import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.phases.PhasePlan.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.java.*; import com.oracle.max.graal.nodes.*; -import com.oracle.max.graal.printer.*; /** * Base class for Graal compiler unit tests. These are white box tests @@ -56,23 +53,15 @@ public abstract class GraphTest { protected final GraalRuntime runtime; - private static IdealGraphPrinterObserver observer; public GraphTest() { this.runtime = GraalRuntimeAccess.getGraalRuntime(); } - @BeforeClass - public static void init() { - IdealGraphPrinterObserver o = new IdealGraphPrinterObserver(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort); - if (o.networkAvailable()) { - observer = o; - } - } - protected void assertEquals(StructuredGraph expected, StructuredGraph graph) { if (expected.getNodeCount() != graph.getNodeCount()) { - print("Node count not matching", expected, graph); + Debug.dump(expected, "Node count not matching - expected"); + Debug.dump(graph, "Node count not matching - actual"); Assert.fail("Graphs do not have the same number of nodes"); } } @@ -146,16 +135,4 @@ plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault())); return plan; } - - protected void print(String title, StructuredGraph... graphs) { - if (observer != null) { - observer.printGraphs(getClass().getSimpleName() + ": " + title, graphs); - } - } - - protected void print(StructuredGraph graph) { - if (observer != null) { - observer.printSingleGraph(getClass().getSimpleName(), graph); - } - } }
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/IfBoxingEliminationTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/IfBoxingEliminationTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,6 +28,7 @@ import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.extended.*; @@ -84,9 +85,9 @@ new CanonicalizerPhase(null, runtime(), null).apply(graph); new PhiStampPhase().apply(graph); new CanonicalizerPhase(null, runtime(), null).apply(graph); - print(graph); + Debug.dump(graph, "Graph"); new BoxingEliminationPhase().apply(graph); - print(graph); + Debug.dump(graph, "Graph"); new ExpandBoxingNodesPhase(pool).apply(graph); new CanonicalizerPhase(null, runtime(), null).apply(graph); new DeadCodeEliminationPhase().apply(graph);
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/IfCanonicalizerTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/IfCanonicalizerTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,6 +25,7 @@ import org.junit.*; import com.oracle.max.graal.compiler.phases.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -143,7 +144,7 @@ n.replaceFirstInput(local, constant); } } - print(graph); + Debug.dump(graph, "Graph"); new CanonicalizerPhase(null, runtime(), null).apply(graph); StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); assertEquals(referenceGraph, graph);
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/NestedLoopTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/NestedLoopTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,6 +25,7 @@ import org.junit.*; import com.oracle.max.graal.compiler.loop.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; public class NestedLoopTest extends GraphTest { @@ -142,7 +143,7 @@ private void test(String snippet, int rootExits, int nestedExits, int innerExits) { StructuredGraph graph = parse(snippet); - print(graph); + Debug.dump(graph, "Graph"); LoopInfo loopInfo = LoopUtil.computeLoopInfo(graph); loopInfo.print(); Loop rootLoop = loopInfo.rootLoops().get(0); @@ -161,6 +162,6 @@ Assert.assertEquals(rootExits, rootLoop.exits().cardinality()); Assert.assertEquals(nestedExits, nestedLoop.exits().cardinality()); Assert.assertEquals(innerExits, innerMostLoop.exits().cardinality()); - print(graph); + Debug.dump(graph, "Graph"); } }
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/PhiCreationTests.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/PhiCreationTests.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,6 +24,7 @@ import org.junit.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; /** @@ -66,7 +67,7 @@ @Test public void test3() { StructuredGraph graph = parse("test3Snippet"); - print(graph); + Debug.dump(graph, "Graph"); Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext()); } @@ -82,7 +83,7 @@ @Test public void test4() { StructuredGraph graph = parse("test4Snippet"); - print(graph); + Debug.dump(graph, "Graph"); Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext()); }
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/ScalarTypeSystemTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/ScalarTypeSystemTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,6 +27,7 @@ import org.junit.*; import com.oracle.max.graal.compiler.phases.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; /** @@ -162,7 +163,7 @@ private void test(String snippet, String referenceSnippet) { StructuredGraph graph = parse(snippet); - print(graph); + Debug.dump(graph, "Graph"); new CanonicalizerPhase(null, runtime(), null).apply(graph); StructuredGraph referenceGraph = parse(referenceSnippet); assertEquals(referenceGraph, graph);
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/StraighteningTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/StraighteningTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,6 +27,7 @@ import org.junit.*; import com.oracle.max.graal.compiler.phases.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.nodes.*; public class StraighteningTest extends GraphTest { @@ -87,7 +88,7 @@ private void test(String snippet) { StructuredGraph graph = parse(snippet); - print(graph); + Debug.dump(graph, "Graph"); new CanonicalizerPhase(null, runtime(), null).apply(graph); StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET); assertEquals(referenceGraph, graph);
--- a/mx.bat Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -python mxtool/mx.py %*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mx.cmd Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,1 @@ +python mxtool/mx.py %*
--- a/mx/commands.py Sun Jan 29 11:27:18 2012 +0100 +++ b/mx/commands.py Sun Jan 29 11:40:04 2012 +0100 @@ -330,16 +330,6 @@ if not 'Xusage.txt' in line: sys.stderr.write(line + os.linesep) - # Update graal_paths.hpp - out = StringIO.StringIO() - out.write(_copyrightTemplate.format(time.strftime('%Y'))) - for p in mx.project('com.oracle.max.graal.hotspot').all_deps([], False): - out.write(' prepend_to_graal_classpath(scp_compiler, graal_dir, "' + p.name + '");\n') - graalPaths = join(_graal_home, 'src', 'share', 'vm', 'graal', 'graal_paths.hpp') - assert exists(graalPaths), 'File does not exist: ' + graalPaths - mx.update_file(graalPaths, out.getvalue()) - out.close() - if platform.system() == 'Windows': compilelogfile = _graal_home + '/graalCompile.log' mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
--- a/mx/projects Sun Jan 29 11:27:18 2012 +0100 +++ b/mx/projects Sun Jan 29 11:40:04 2012 +0100 @@ -50,7 +50,12 @@ # graal.graph project@com.oracle.max.graal.graph@subDir=graal project@com.oracle.max.graal.graph@sourceDirs=src -project@com.oracle.max.graal.graph@dependencies=JUNIT +project@com.oracle.max.graal.graph@dependencies=com.oracle.max.graal.debug,JUNIT + +# graal.debug +project@com.oracle.max.graal.debug@subDir=graal +project@com.oracle.max.graal.debug@sourceDirs=src +project@com.oracle.max.graal.debug@checkstyle=com.oracle.max.graal.graph # graal.snippets project@com.oracle.max.graal.snippets@subDir=graal
--- a/mxtool/mx.py Sun Jan 29 11:27:18 2012 +0100 +++ b/mxtool/mx.py Sun Jan 29 11:40:04 2012 +0100 @@ -592,7 +592,14 @@ # The preexec_fn=os.setsid p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags) _currentSubprocess = (p, args) - retcode = p.wait() + if get_os() == 'windows': + # on windows use a poll loop, otherwise signal does not get handled + retcode = None + while retcode == None: + retcode = p.poll() + time.sleep(0.05) + else: + retcode = p.wait() else: def redirect(stream, f): for line in iter(stream.readline, ''):
--- a/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -54,11 +54,11 @@ bciValue = bytecode.getBci() + " " + bciValue; bciValue = bciValue.trim(); - Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<InputNode>(graph.getNodes()); + Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(graph.getNodes()); StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue); List<InputNode> nodeList = selector.selectMultiple(matcher); if (nodeList.size() > 0) { - nodes = new LinkedHashSet<InputNode>(); + nodes = new LinkedHashSet<>(); for (InputNode n : nodeList) { nodes.add(n); }
--- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,6 +37,7 @@ super(NbBundle.getMessage(BytecodeViewAction.class, "CTL_BytecodeViewAction")); } + @Override public void actionPerformed(ActionEvent evt) { TopComponent win = BytecodeViewTopComponent.findInstance(); win.open();
--- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java Sun Jan 29 11:40:04 2012 +0100 @@ -34,11 +34,7 @@ import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerUtils; import org.openide.explorer.view.BeanTreeView; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; +import org.openide.util.*; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; @@ -128,7 +124,7 @@ @Override public void componentOpened() { - Lookup.Template<InputGraphProvider> tpl = new Lookup.Template<InputGraphProvider>(InputGraphProvider.class); + Lookup.Template<InputGraphProvider> tpl = new Lookup.Template<>(InputGraphProvider.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); } @@ -149,6 +145,7 @@ return PREFERRED_ID; } + @Override public ExplorerManager getExplorerManager() { return manager; } @@ -171,10 +168,12 @@ return super.requestFocusInWindow(temporary); } + @Override public void resultChanged(LookupEvent lookupEvent) { final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { InputGraph graph = p.getGraph(); if (graph != null) {
--- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -50,6 +50,7 @@ this.graph = graph; } + @Override protected Node[] createNodes(InputBytecode bc) { if (bc.getInlined() == null) { return new Node[]{new BytecodeNode(bc, graph, bciString)};
--- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,7 +28,6 @@ import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; -import org.openide.util.Utilities; import org.openide.util.actions.CookieAction; /** @@ -37,6 +36,7 @@ */ public final class SelectBytecodesAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { SelectBytecodesCookie c = activatedNodes[0].getCookie(SelectBytecodesCookie.class); InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); @@ -45,14 +45,17 @@ } } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } + @Override public String getName() { return NbBundle.getMessage(SelectBytecodesAction.class, "CTL_SelectBytecodesAction"); } + @Override protected Class[] cookieClasses() { return new Class[]{ SelectBytecodesCookie.class @@ -65,6 +68,7 @@ putValue("noIconInMenu", Boolean.TRUE); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.controlflow" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.controlflow.</description> - <import file="nbproject/build-impl.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.controlflow -OpenIDE-Module-Layer: com/sun/hotspot/igv/controlflow/layer.xml -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/controlflow/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 -
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.controlflow-impl" basedir=".."> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'"> - <condition> - <not> - <available file="${harness.dir}" type="dir"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -build.xml.data.CRC32=b524efb3 -build.xml.script.CRC32=79a27be9 -build.xml.stylesheet.CRC32=79c3b980 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=b524efb3 -nbproject/build-impl.xml.script.CRC32=582bdab7 -nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/platform.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -# Deprecated since 5.0u1; for compatibility with 5.0: -disabled.clusters=\ - apisupport1,\ - harness,\ - ide8,\ - java1,\ - nb6.0,\ - profiler2 -disabled.modules=\ - org.netbeans.core.execution,\ - org.netbeans.core.multiview,\ - org.netbeans.core.output2,\ - org.netbeans.modules.applemenu,\ - org.netbeans.modules.autoupdate.services,\ - org.netbeans.modules.autoupdate.ui,\ - org.netbeans.modules.core.kit,\ - org.netbeans.modules.favorites,\ - org.netbeans.modules.javahelp,\ - org.netbeans.modules.masterfs,\ - org.netbeans.modules.options.keymap,\ - org.netbeans.modules.sendopts,\ - org.netbeans.modules.templates,\ - org.openide.compat,\ - org.openide.execution,\ - org.openide.util.enumerations -enabled.clusters=\ - platform7 -nbjdk.active=JDK_1.6 -nbplatform.active=default
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.controlflow</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.data</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.hierarchicallayout</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.layout</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.util</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.jdesktop.layout</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>1</release-version> - <specification-version>1.16.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.api.visual</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>2.9</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>8.14.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util.lookup</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>8.6.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.windows</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>6.16</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages/> - </data> - </configuration> -</project>
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/suite.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.controlflow; - -import com.sun.hotspot.igv.data.InputBlockEdge; -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import java.awt.BasicStroke; -import java.awt.Point; -import java.awt.Stroke; -import java.util.ArrayList; -import java.util.List; -import org.netbeans.api.visual.widget.ConnectionWidget; - -/** - * - * @author Thomas Wuerthinger - */ -public class BlockConnectionWidget extends ConnectionWidget implements Link { - - private static final Stroke NORMAL_STROKE = new BasicStroke(1.0f); - private static final Stroke BOLD_STROKE = new BasicStroke(2.5f); - private static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0); - private static final Stroke BOLD_DASHED_STROKE = new BasicStroke(2.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0); - - private BlockWidget from; - private BlockWidget to; - private Port inputSlot; - private Port outputSlot; - private List<Point> points; - private InputBlockEdge edge; - private boolean isDashed = false; - private boolean isBold = false; - - public BlockConnectionWidget(ControlFlowScene scene, InputBlockEdge edge) { - super(scene); - - this.edge = edge; - this.from = (BlockWidget) scene.findWidget(edge.getFrom()); - this.to = (BlockWidget) scene.findWidget(edge.getTo()); - inputSlot = to.getInputSlot(); - outputSlot = from.getOutputSlot(); - points = new ArrayList<Point>(); - } - - public InputBlockEdge getEdge() { - return edge; - } - - public Port getTo() { - return inputSlot; - } - - public Port getFrom() { - return outputSlot; - } - - public void setBold(boolean bold) { - this.isBold = bold; - updateStroke(); - } - - public void setDashed(boolean dashed) { - this.isDashed = dashed; - updateStroke(); - } - - private void updateStroke() { - Stroke stroke = NORMAL_STROKE; - if (isBold) { - if (isDashed) { - stroke = BOLD_DASHED_STROKE; - } else { - stroke = BOLD_STROKE; - } - } else if (isDashed) { - stroke = DASHED_STROKE; - } - setStroke(stroke); - } - - public void setControlPoints(List<Point> p) { - this.points = p; - } - - @Override - public List<Point> getControlPoints() { - return points; - } - - @Override - public String toString() { - return "Connection[ " + from.toString() + " - " + to.toString() + "]"; - } -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.controlflow; - -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Point; -import java.awt.Rectangle; -import org.netbeans.api.visual.border.BorderFactory; -import org.netbeans.api.visual.model.ObjectState; -import org.netbeans.api.visual.widget.LabelWidget; - -/** - * - * @author Thomas Wuerthinger - */ -public class BlockWidget extends LabelWidget implements Vertex { - - public static final Dimension MIN_SIZE = new Dimension(20, 20); - private InputBlock block; - private Port inputSlot; - private Port outputSlot; - private Cluster cluster; - private boolean root; - private static final Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 12); - private static final Font boldFont = font.deriveFont(Font.BOLD); - public static final Color NORMAL_FOREGROUND_COLOR = Color.BLACK; - public static final Color HOVER_FOREGROUND_COLOR = Color.BLUE; - - /** Creates a new instance of BlockWidget */ - public BlockWidget(ControlFlowScene scene, InputBlock block) { - super(scene); - this.block = block; - this.setLabel(block.getName()); - this.setForeground(NORMAL_FOREGROUND_COLOR); - this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR)); - this.setMinimumSize(MIN_SIZE); - - this.setFont(font); - this.setAlignment(Alignment.CENTER); - - final BlockWidget widget = this; - inputSlot = new Port() { - public Point getRelativePosition() { - return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); - } - public Vertex getVertex() { - return widget; - } - }; - outputSlot = new Port() { - public Point getRelativePosition() { - return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); - } - public Vertex getVertex() { - return widget; - } - }; - } - - public Port getInputSlot() { - return inputSlot; - } - - public Port getOutputSlot() { - return outputSlot; - } - - public InputBlock getBlock() { - return block; - } - - public Dimension getSize() { - Rectangle bounds = getBounds(); - if (bounds != null) { - return bounds.getSize(); - } else { - return MIN_SIZE; - } - } - - public void setPosition(Point p) { - this.setPreferredLocation(p); - } - - @Override - public String toString() { - return block.getName(); - } - - public Point getPosition() { - return this.getPreferredLocation(); - } - - public Cluster getCluster() { - return cluster; - } - - public boolean isRoot() { - return root; - } - - public void setCluster(Cluster c) { - cluster = c; - } - - public void setRoot(boolean b) { - root = b; - } - - public int compareTo(Vertex o) { - return toString().compareTo(o.toString()); - } - - @Override - protected void notifyStateChanged(ObjectState previousState, ObjectState state) { - super.notifyStateChanged(previousState, state); - - if (previousState.isHovered() != state.isHovered()) { - if (state.isHovered()) { - this.setBorder(BorderFactory.createLineBorder(1, HOVER_FOREGROUND_COLOR)); - } else { - this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR)); - } - } - - if (previousState.isSelected() != state.isSelected()) { - if (state.isSelected()) { - this.setFont(boldFont); - } else { - this.setFont(font); - } - } - } -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -CTL_ControlFlowAction=Control Flow -CTL_ControlFlowTopComponent=Control Flow -HINT_ControlFlowTopComponent=Shows the blocks of the current graph. -OpenIDE-Module-Name=ControlFlow
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.controlflow; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import org.openide.util.NbBundle; -import org.openide.windows.TopComponent; - -/** - * - * @author Thomas Wuerthinger - */ -public class ControlFlowAction extends AbstractAction { - - public ControlFlowAction() { - super(NbBundle.getMessage(ControlFlowAction.class, "CTL_ControlFlowAction")); - } - - public void actionPerformed(ActionEvent evt) { - TopComponent win = ControlFlowTopComponent.findInstance(); - win.open(); - win.requestActive(); - } -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,299 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.controlflow; - -import com.sun.hotspot.igv.data.InputBlockEdge; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.services.InputGraphProvider; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.util.LookupHistory; -import java.awt.Color; -import java.awt.Point; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import javax.swing.BorderFactory; -import org.netbeans.api.visual.action.ActionFactory; -import org.netbeans.api.visual.action.MoveProvider; -import org.netbeans.api.visual.action.RectangularSelectDecorator; -import org.netbeans.api.visual.action.RectangularSelectProvider; -import org.netbeans.api.visual.action.SelectProvider; -import org.netbeans.api.visual.action.WidgetAction; -import org.netbeans.api.visual.anchor.AnchorFactory; -import org.netbeans.api.visual.anchor.AnchorShape; -import org.netbeans.api.visual.router.RouterFactory; -import org.netbeans.api.visual.widget.LayerWidget; -import org.netbeans.api.visual.widget.Widget; -import org.netbeans.api.visual.graph.GraphScene; -import org.netbeans.api.visual.graph.layout.GraphLayout; -import org.netbeans.api.visual.layout.LayoutFactory; -import org.netbeans.api.visual.layout.SceneLayout; -import org.netbeans.api.visual.widget.ConnectionWidget; - -/** - * - * @author Thomas Wuerthinger - */ -public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider { - - private HashSet<BlockWidget> selection; - private InputGraph oldGraph; - private LayerWidget edgeLayer; - private LayerWidget mainLayer; - private LayerWidget selectLayer; - private WidgetAction hoverAction = this.createWidgetHoverAction(); - private WidgetAction selectAction = new DoubleClickSelectAction(this); - private WidgetAction moveAction = ActionFactory.createMoveAction(null, this); - - public ControlFlowScene() { - selection = new HashSet<BlockWidget>(); - - this.getInputBindings().setZoomActionModifiers(0); - this.setLayout(LayoutFactory.createAbsoluteLayout()); - - mainLayer = new LayerWidget(this); - this.addChild(mainLayer); - - edgeLayer = new LayerWidget(this); - this.addChild(edgeLayer); - - selectLayer = new LayerWidget(this); - this.addChild(selectLayer); - - this.getActions().addAction(hoverAction); - this.getActions().addAction(selectAction); - this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this)); - this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); - } - - public void setGraph(InputGraph g) { - if (g == oldGraph) { - return; - } - oldGraph = g; - - ArrayList<InputBlock> blocks = new ArrayList<InputBlock>(this.getNodes()); - for (InputBlock b : blocks) { - removeNode(b); - } - - ArrayList<InputBlockEdge> edges = new ArrayList<InputBlockEdge>(this.getEdges()); - for (InputBlockEdge e : edges) { - removeEdge(e); - } - - for (InputBlock b : g.getBlocks()) { - addNode(b); - } - - for (InputBlockEdge e : g.getBlockEdges()) { - addEdge(e); - assert g.getBlocks().contains(e.getFrom()); - assert g.getBlocks().contains(e.getTo()); - this.setEdgeSource(e, e.getFrom()); - this.setEdgeTarget(e, e.getTo()); - } - - GraphLayout<InputBlock, InputBlockEdge> layout = new HierarchicalGraphLayout<InputBlock, InputBlockEdge>();//GridGraphLayout(); - SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(this, layout); - sceneLayout.invokeLayout(); - - this.validate(); - } - - public void clearSelection() { - for (BlockWidget w : selection) { - w.setState(w.getState().deriveSelected(false)); - } - selection.clear(); - selectionChanged(); - } - - public void selectionChanged() { - InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); - if (p != null) { - Set<InputNode> inputNodes = new HashSet<InputNode>(); - for (BlockWidget w : selection) { - inputNodes.addAll(w.getBlock().getNodes()); - } - p.setSelectedNodes(inputNodes); - } - } - - public void addToSelection(BlockWidget widget) { - widget.setState(widget.getState().deriveSelected(true)); - selection.add(widget); - selectionChanged(); - } - - public void removeFromSelection(BlockWidget widget) { - widget.setState(widget.getState().deriveSelected(false)); - selection.remove(widget); - selectionChanged(); - } - - public boolean isAimingAllowed(Widget widget, Point point, boolean b) { - return false; - } - - public boolean isSelectionAllowed(Widget widget, Point point, boolean b) { - return true; - } - - public void select(Widget widget, Point point, boolean change) { - if (widget == this) { - clearSelection(); - } else { - - assert widget instanceof BlockWidget; - BlockWidget bw = (BlockWidget) widget; - if (change) { - if (selection.contains(bw)) { - removeFromSelection(bw); - } else { - addToSelection(bw); - } - } else { - if (!selection.contains(bw)) { - clearSelection(); - addToSelection(bw); - } - } - } - } - - public void movementStarted(Widget widget) { - } - - public void movementFinished(Widget widget) { - } - - public Point getOriginalLocation(Widget widget) { - return widget.getPreferredLocation(); - } - - public void setNewLocation(Widget widget, Point location) { - if (selection.contains(widget)) { - // move entire selection - Point originalLocation = getOriginalLocation(widget); - int xOffset = location.x - originalLocation.x; - int yOffset = location.y - originalLocation.y; - for (Widget w : selection) { - Point p = new Point(w.getPreferredLocation()); - p.translate(xOffset, yOffset); - w.setPreferredLocation(p); - } - } else { - widget.setPreferredLocation(location); - } - } - - public Widget createSelectionWidget() { - Widget widget = new Widget(this); - widget.setOpaque(false); - widget.setBorder(BorderFactory.createLineBorder(Color.black, 2)); - widget.setForeground(Color.red); - return widget; - } - - public void performSelection(Rectangle rectangle) { - - if (rectangle.width < 0) { - rectangle.x += rectangle.width; - rectangle.width *= -1; - } - - if (rectangle.height < 0) { - rectangle.y += rectangle.height; - rectangle.height *= -1; - } - - boolean changed = false; - for (InputBlock b : this.getNodes()) { - BlockWidget w = (BlockWidget) findWidget(b); - Rectangle r = new Rectangle(w.getBounds()); - r.setLocation(w.getLocation()); - if (r.intersects(rectangle)) { - if (!selection.contains(w)) { - changed = true; - selection.add(w); - w.setState(w.getState().deriveSelected(true)); - } - } else { - if (selection.contains(w)) { - changed = true; - selection.remove(w); - w.setState(w.getState().deriveSelected(false)); - } - } - } - - if (changed) { - selectionChanged(); - } - - } - - protected Widget attachNodeWidget(InputBlock node) { - BlockWidget w = new BlockWidget(this, node); - mainLayer.addChild(w); - w.getActions().addAction(hoverAction); - w.getActions().addAction(selectAction); - w.getActions().addAction(moveAction); - return w; - } - - protected Widget attachEdgeWidget(InputBlockEdge edge) { - BlockConnectionWidget w = new BlockConnectionWidget(this, edge); - switch (edge.getState()) { - case NEW: - w.setBold(true); - break; - case DELETED: - w.setDashed(true); - break; - } - w.setRouter(RouterFactory.createDirectRouter()); - w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); - edgeLayer.addChild(w); - return w; - } - - protected void attachEdgeSourceAnchor(InputBlockEdge edge, InputBlock oldSourceNode, InputBlock sourceNode) { - Widget w = this.findWidget(edge); - assert w instanceof ConnectionWidget; - ConnectionWidget cw = (ConnectionWidget) w; - cw.setSourceAnchor(AnchorFactory.createRectangularAnchor(findWidget(sourceNode))); - - } - - protected void attachEdgeTargetAnchor(InputBlockEdge edge, InputBlock oldTargetNode, InputBlock targetNode) { - Widget w = this.findWidget(edge); - assert w instanceof ConnectionWidget; - ConnectionWidget cw = (ConnectionWidget) w; - cw.setTargetAnchor(AnchorFactory.createRectangularAnchor(findWidget(targetNode))); - } -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> - <AuxValues> - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - </AuxValues> - - <Layout> - <DimensionLayout dim="0"> - <Group type="103" groupAlignment="0" attributes="0"> - <EmptySpace min="0" pref="400" max="32767" attributes="0"/> - </Group> - </DimensionLayout> - <DimensionLayout dim="1"> - <Group type="103" groupAlignment="0" attributes="0"> - <EmptySpace min="0" pref="300" max="32767" attributes="0"/> - </Group> - </DimensionLayout> - </Layout> -</Form>
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.controlflow; - -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.services.InputGraphProvider; -import com.sun.hotspot.igv.util.LookupHistory; -import java.awt.BorderLayout; -import java.io.Serializable; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; -import org.openide.ErrorManager; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; -import org.openide.windows.TopComponent; -import org.openide.windows.WindowManager; - -/** - * - * @author Thomas Wuerthinger - */ -final class ControlFlowTopComponent extends TopComponent implements LookupListener { - - private static ControlFlowTopComponent instance; - private Lookup.Result result = null; - private static final String PREFERRED_ID = "ControlFlowTopComponent"; - private ControlFlowScene scene; - - private ControlFlowTopComponent() { - initComponents(); - setName(NbBundle.getMessage(ControlFlowTopComponent.class, "CTL_ControlFlowTopComponent")); - setToolTipText(NbBundle.getMessage(ControlFlowTopComponent.class, "HINT_ControlFlowTopComponent")); - - scene = new ControlFlowScene(); - this.setLayout(new BorderLayout()); - this.associateLookup(scene.getLookup()); - - - JScrollPane panel = new JScrollPane(scene.createView()); - this.add(panel, BorderLayout.CENTER); - } - - - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents - private void initComponents() { - - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 400, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 300, Short.MAX_VALUE) - ); - }// </editor-fold>//GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables - - /** - * Gets default instance. Do not use directly: reserved for *.settings files only, - * i.e. deserialization routines; otherwise you could get a non-deserialized instance. - * To obtain the singleton instance, use {@link findInstance}. - */ - public static synchronized ControlFlowTopComponent getDefault() { - if (instance == null) { - instance = new ControlFlowTopComponent(); - } - return instance; - } - - /** - * Obtain the ControlFlowTopComponent instance. Never call {@link #getDefault} directly! - */ - public static synchronized ControlFlowTopComponent findInstance() { - TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); - if (win == null) { - ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find ControlFlow component. It will not be located properly in the window system."); - return getDefault(); - } - if (win instanceof ControlFlowTopComponent) { - return (ControlFlowTopComponent) win; - } - ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior."); - return getDefault(); - } - - @Override - public int getPersistenceType() { - return TopComponent.PERSISTENCE_ALWAYS; - } - - @Override - public void componentOpened() { - Lookup.Template<InputGraphProvider> tpl = new Lookup.Template<InputGraphProvider>(InputGraphProvider.class); - result = Utilities.actionsGlobalContext().lookup(tpl); - result.addLookupListener(this); - } - - @Override - public void componentClosed() { - result.removeLookupListener(this); - result = null; - } - - public void resultChanged(LookupEvent lookupEvent) { - final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); - if (p != null) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - InputGraph g = p.getGraph(); - if (g != null) { - scene.setGraph(g); - } - } - }); - } - } - - @Override - public Object writeReplace() { - return new ResolvableHelper(); - } - - @Override - protected String preferredID() { - return PREFERRED_ID; - } - - @Override - public void requestActive() { - super.requestActive(); - scene.getView().requestFocus(); - } - - final static class ResolvableHelper implements Serializable { - - private static final long serialVersionUID = 1L; - - public Object readResolve() { - return ControlFlowTopComponent.getDefault(); - } - } -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentSettings.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd"> -<settings version="1.0"> - <module name="com.sun.hotspot.igv.controlflow" spec="1.0"/> - <instanceof class="org.openide.windows.TopComponent"/> - <instanceof class="com.sun.hotspot.igv.controlflow.ControlFlowTopComponent"/> - <instance class="com.sun.hotspot.igv.controlflow.ControlFlowTopComponent" method="getDefault"/> -</settings>
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentWstcref.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd"> -<tc-ref version="2.0" > - <module name="com.sun.hotspot.igv.controlflow" spec="1.0"/> - <tc-id id="ControlFlowTopComponent"/> - <state opened="true"/> -</tc-ref>
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.controlflow; - -import java.awt.Point; -import java.awt.event.MouseEvent; -import org.netbeans.api.visual.action.SelectProvider; -import org.netbeans.api.visual.action.WidgetAction; -import org.netbeans.api.visual.widget.Widget; - -/** - * Selection action that acts on double-click only. Does not support aiming. - * - * @author Peter Hofer - */ -public class DoubleClickSelectAction extends WidgetAction.LockedAdapter { - - private final SelectProvider provider; - - public DoubleClickSelectAction(SelectProvider provider) { - this.provider = provider; - } - - protected boolean isLocked() { - return false; - } - - @Override - public State mousePressed(Widget widget, WidgetMouseEvent event) { - if (event.getClickCount() >= 2 && (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2)) { - boolean invert = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0; - Point point = event.getPoint(); - if (provider.isSelectionAllowed(widget, point, invert)) { - provider.select(widget, point, invert); - return State.CHAIN_ONLY; - } - } - return State.REJECTED; - } -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.controlflow; - -import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager; -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.LayoutGraph; -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; -import java.awt.Dimension; -import java.awt.Point; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.netbeans.api.visual.graph.layout.GraphLayout; -import org.netbeans.api.visual.graph.layout.UniversalGraph; -import org.netbeans.api.visual.widget.Widget; - -/** - * - * @author Thomas Wuerthinger - */ -public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> { - - public HierarchicalGraphLayout() { - } - - private class LinkWrapper implements Link { - - private VertexWrapper from; - private VertexWrapper to; - - public LinkWrapper(VertexWrapper from, VertexWrapper to) { - this.from = from; - this.to = to; - } - - public Port getFrom() { - return from.getSlot(); - } - - public Port getTo() { - return to.getSlot(); - } - - public List<Point> getControlPoints() { - return new ArrayList<Point>(); - } - - public void setControlPoints(List<Point> list) { - // Do nothing for now - } - } - - private class VertexWrapper implements Vertex { - - private N node; - private UniversalGraph<N, E> graph; - private Port slot; - private Point position; - - public VertexWrapper(N node, UniversalGraph<N, E> graph) { - this.node = node; - this.graph = graph; - final VertexWrapper vertex = this; - this.slot = new Port() { - - public Vertex getVertex() { - return vertex; - } - - public Point getRelativePosition() { - return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); - } - }; - - Widget w = graph.getScene().findWidget(node); - this.position = w.getPreferredLocation(); - } - - public Cluster getCluster() { - return null; - } - - public Dimension getSize() { - Widget w = graph.getScene().findWidget(node); - return w.getBounds().getSize(); - } - - public Point getPosition() { - return position; - } - - public void setPosition(Point p) { - HierarchicalGraphLayout.this.setResolvedNodeLocation(graph, node, p); - position = p; - } - - public boolean isRoot() { - return false; - } - - public int compareTo(Vertex o) { - @SuppressWarnings("unchecked") - VertexWrapper vw = (VertexWrapper) o; - return node.toString().compareTo(vw.node.toString()); - } - - public Port getSlot() { - return slot; - } - } - - protected void performGraphLayout(UniversalGraph<N, E> graph) { - - Set<LinkWrapper> links = new LinkedHashSet<LinkWrapper>(); - Set<VertexWrapper> vertices = new LinkedHashSet<VertexWrapper>(); - Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>(); - - for (N node : graph.getNodes()) { - VertexWrapper v = new VertexWrapper(node, graph); - vertexMap.put(node, v); - vertices.add(v); - } - - for (E edge : graph.getEdges()) { - N source = graph.getEdgeSource(edge); - N target = graph.getEdgeTarget(edge); - LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target)); - links.add(l); - } - - HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE); - - LayoutGraph layoutGraph = new LayoutGraph(links, vertices); - m.doLayout(layoutGraph); - } - - protected void performNodesLayout(UniversalGraph<N, E> graph, Collection<N> nodes) { - throw new UnsupportedOperationException(); - } -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/layer.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> - <folder name="Actions"> - <folder name="Window"> - <file name="com-sun-hotspot-igv-controlflow-ControlFlowAction.instance"/> - </folder> - </folder> - <folder name="Menu"> - <folder name="Window"> - <file name="ControlFlowAction.shadow"> - <attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-controlflow-ControlFlowAction.instance"/> - </file> - </folder> - </folder> - <folder name="Windows2"> - <folder name="Components"> - <file name="ControlFlowTopComponent.settings" url="ControlFlowTopComponentSettings.xml"/> - </folder> - <folder name="Modes"> - <folder name="customRightTopMode"> - <file name="ControlFlowTopComponent.wstcref" url="ControlFlowTopComponentWstcref.xml"/> - </folder> - </folder> - </folder> -</filesystem>
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml Sun Jan 29 11:40:04 2012 +0100 @@ -1,134 +1,142 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.coordinator</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.data</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.difference</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.settings</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.util</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.api.progress</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>1</release-version> - <specification-version>1.23.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.actions</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>6.21.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.awt</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>7.30.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.dialogs</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>7.18.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.explorer</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>6.34.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.filesystems</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>7.46.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.loaders</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>7.20.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.nodes</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>7.20.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>8.14.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util.lookup</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>8.6.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.windows</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>6.39.1</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages/> - </data> - </configuration> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.apisupport.project</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> + <code-name-base>com.sun.hotspot.igv.coordinator</code-name-base> + <suite-component/> + <module-dependencies> + <dependency> + <code-name-base>com.sun.hotspot.igv.connection</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>com.sun.hotspot.igv.data</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>com.sun.hotspot.igv.difference</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>com.sun.hotspot.igv.settings</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>com.sun.hotspot.igv.util</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.netbeans.api.progress</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <release-version>1</release-version> + <specification-version>1.23.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.actions</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>6.21.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.awt</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>7.30.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.dialogs</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>7.18.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.explorer</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>6.34.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.filesystems</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>7.46.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.loaders</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>7.20.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.nodes</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>7.20.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.util</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>8.14.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.util.lookup</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>8.6.1</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>org.openide.windows</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>6.39.1</specification-version> + </run-dependency> + </dependency> + </module-dependencies> + <public-packages/> + </data> + </configuration> +</project>
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -com.sun.hotspot.igv.coordinator.StandardGroupOrganizer -com.sun.hotspot.igv.coordinator.GraphCountGroupOrganizer \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,6 +1,6 @@ -AdvancedOption_DisplayName_Coordinator=Settings -AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings -CTL_OutlineTopComponent=Outline -CTL_SomeAction=test -HINT_OutlineTopComponent=Displays loaded groups of graphs. -OpenIDE-Module-Name=Coordinator \ No newline at end of file +AdvancedOption_DisplayName_Coordinator=Settings +AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings +CTL_OutlineTopComponent=Outline +CTL_SomeAction=test +HINT_OutlineTopComponent=Displays loaded groups of graphs. +OpenIDE-Module-Name=Coordinator
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,14 +24,8 @@ package com.sun.hotspot.igv.coordinator; import com.sun.hotspot.igv.coordinator.actions.RemoveCookie; -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.data.*; import java.awt.Image; -import java.util.ArrayList; import java.util.List; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; @@ -46,108 +40,67 @@ */ public class FolderNode extends AbstractNode { - private GroupOrganizer organizer; private InstanceContent content; - private List<Pair<String, List<Group>>> structure; - private List<String> subFolders; private FolderChildren children; - private static class FolderChildren extends Children.Keys<Pair<String, List<Group>>> implements ChangedListener<Group> { + private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener { - private FolderNode parent; - private List<Group> registeredGroups; - private final GraphDocument document; + private final Folder folder; - public FolderChildren(GraphDocument document) { - this.document = document; - } - - public void setParent(FolderNode parent) { - this.parent = parent; - this.registeredGroups = new ArrayList<Group>(); + public FolderChildren(Folder folder) { + this.folder = folder; + folder.getChangedEvent().addListener(this); } @Override - protected Node[] createNodes(Pair<String, List<Group>> p) { - - for(Group g : registeredGroups) { - g.getChangedEvent().removeListener(this); - } - registeredGroups.clear(); - - if (p.getLeft().length() == 0) { - - List<Node> curNodes = new ArrayList<Node>(); - for (Group g : p.getRight()) { - for (InputGraph graph : g.getGraphListCopy()) { - curNodes.add(new GraphNode(document, graph)); - } - g.getChangedEvent().addListener(this); - registeredGroups.add(g); - } - - Node[] result = new Node[curNodes.size()]; - for (int i = 0; i < curNodes.size(); i++) { - result[i] = curNodes.get(i); - } - return result; - - } else { - return new Node[]{new FolderNode(document, p.getLeft(), parent.organizer, parent.subFolders, p.getRight())}; + protected Node[] createNodes(FolderElement e) { + if (e instanceof InputGraph) { + return new Node[]{new GraphNode((InputGraph) e)}; + } else if (e instanceof Folder) { + return new Node[]{new FolderNode((Folder) e)}; + } else { + return null; } } @Override public void addNotify() { - this.setKeys(parent.structure); + this.setKeys(folder.getElements()); } - public void changed(Group source) { - for(Pair<String, List<Group>> p : parent.structure) { - refreshKey(p); - } + @Override + public void changed(Object source) { + addNotify(); } } - protected InstanceContent getContent() { - return content; - } - @Override public Image getIcon(int i) { return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png"); } - protected FolderNode(GraphDocument document, String name, GroupOrganizer organizer, List<String> subFolders, List<Group> groups) { - this(document, name, organizer, subFolders, groups, new FolderChildren(document), new InstanceContent()); + protected FolderNode(Folder folder) { + this(folder, new FolderChildren(folder), new InstanceContent()); } - private FolderNode(final GraphDocument document, String name, GroupOrganizer organizer, List<String> oldSubFolders, final List<Group> groups, FolderChildren children, InstanceContent content) { + private FolderNode(final Folder folder, FolderChildren children, InstanceContent content) { super(children, new AbstractLookup(content)); - children.setParent(this); this.content = content; this.children = children; - content.add(new RemoveCookie() { - - public void remove() { - for (Group g : groups) { - document.removeGroup(g); - + if (folder instanceof FolderElement) { + final FolderElement folderElement = (FolderElement) folder; + this.setDisplayName(folderElement.getName()); + content.add(new RemoveCookie() { + @Override + public void remove() { + folderElement.getParent().removeElement(folderElement); } - } - }); - init(name, organizer, oldSubFolders, groups); + }); + } } - public void init(String name, GroupOrganizer organizer, List<String> oldSubFolders, List<Group> groups) { + public void init(String name, List<Group> groups) { this.setDisplayName(name); - this.organizer = organizer; - this.subFolders = new ArrayList<String>(oldSubFolders); - if (name.length() > 0) { - this.subFolders.add(name); - } - structure = organizer.organize(subFolders, groups); - assert structure != null; children.addNotify(); for (Group g : groups) {
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.coordinator; - -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * - * @author Thomas Wuerthinger - */ -public class GraphCountGroupOrganizer implements GroupOrganizer { - - public String getName() { - return "Graph count structure"; - } - - public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups) { - - List<Pair<String, List<Group>>> result = new ArrayList<Pair<String, List<Group>>>(); - - if (subFolders.size() == 0) { - Map<Integer, List<Group>> map = new HashMap<Integer, List<Group>>(groups.size()); - for (Group g : groups) { - Integer cur = g.getGraphsCount(); - if (!map.containsKey(cur)) { - map.put(cur, new ArrayList<Group>()); - } - map.get(cur).add(g); - } - - SortedSet<Integer> keys = new TreeSet<Integer>(map.keySet()); - for (Integer i : keys) { - result.add(new Pair<String, List<Group>>("Graph count " + i, map.get(i))); - } - - } else if (subFolders.size() == 1) { - for (Group g : groups) { - List<Group> children = new ArrayList<Group>(); - children.add(g); - Pair<String, List<Group>> p = new Pair<String, List<Group>>(); - p.setLeft(g.getName()); - p.setRight(children); - result.add(p); - } - } else if (subFolders.size() == 2) { - result.add(new Pair<String, List<Group>>("", groups)); - } - - return result; - } -}
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,7 +27,6 @@ import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie; import com.sun.hotspot.igv.coordinator.actions.GraphOpenCookie; import com.sun.hotspot.igv.coordinator.actions.GraphRemoveCookie; -import com.sun.hotspot.igv.data.GraphDocument; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.services.GraphViewer; @@ -48,18 +47,15 @@ * @author Thomas Wuerthinger */ public class GraphNode extends AbstractNode { - private final GraphDocument document; private final InputGraph graph; /** Creates a new instance of GraphNode */ - public GraphNode(GraphDocument document, InputGraph graph) { - this(document, graph, new InstanceContent()); + public GraphNode(InputGraph graph) { + this(graph, new InstanceContent()); } - private GraphNode(GraphDocument document, InputGraph graph, InstanceContent content) { + private GraphNode(InputGraph graph, InstanceContent content) { super(Children.LEAF, new AbstractLookup(content)); - - this.document = document; this.graph = graph; this.setDisplayName(graph.getName()); content.add(graph); @@ -72,7 +68,7 @@ } // Action for removing a graph - content.add(new GraphRemoveCookie(document, graph)); + content.add(new GraphRemoveCookie(graph)); // Action for diffing to the current graph content.add(new DiffGraphCookie(graph));
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form Sun Jan 29 11:40:04 2012 +0100 @@ -16,28 +16,17 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> <SubComponents> - <Container class="javax.swing.JPanel" name="jPanel2"> + <Container class="javax.swing.JScrollPane" name="treeView"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new BeanTreeView();"/> + </AuxValues> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> <BorderConstraints direction="Center"/> </Constraint> </Constraints> - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> - <SubComponents> - <Container class="javax.swing.JScrollPane" name="treeView"> - <AuxValues> - <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new BeanTreeView();"/> - </AuxValues> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="Center"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> - </Container> - </SubComponents> + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> </Container> </SubComponents> </Form>
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,37 +23,25 @@ */ package com.sun.hotspot.igv.coordinator; -import com.sun.hotspot.igv.coordinator.actions.ImportAction; -import com.sun.hotspot.igv.coordinator.actions.RemoveAction; -import com.sun.hotspot.igv.coordinator.actions.RemoveAllAction; -import com.sun.hotspot.igv.coordinator.actions.SaveAllAction; -import com.sun.hotspot.igv.coordinator.actions.SaveAsAction; -import com.sun.hotspot.igv.coordinator.actions.StructuredViewAction; +import com.sun.hotspot.igv.connection.Server; +import com.sun.hotspot.igv.coordinator.actions.*; import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.services.GroupCallback; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.services.GroupReceiver; import java.awt.BorderLayout; -import java.awt.Component; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import javax.swing.BoxLayout; -import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.border.Border; import org.openide.ErrorManager; +import org.openide.actions.GarbageCollectAction; import org.openide.awt.Toolbar; import org.openide.awt.ToolbarPool; import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerUtils; import org.openide.explorer.view.BeanTreeView; -import org.openide.util.Lookup; import org.openide.util.LookupEvent; import org.openide.util.LookupListener; import org.openide.util.NbBundle; @@ -72,7 +60,7 @@ private ExplorerManager manager; private GraphDocument document; private FolderNode root; - private GroupOrganizer organizer; + private Server server; private OutlineTopComponent() { initComponents(); @@ -88,18 +76,10 @@ private void initListView() { manager = new ExplorerManager(); - organizer = new StandardGroupOrganizer(); - root = new FolderNode(document, "", organizer, new ArrayList<String>(), document.getGroups()); + root = new FolderNode(document); manager.setRootContext(root); ((BeanTreeView) this.treeView).setRootVisible(false); - document.getChangedEvent().addListener(new ChangedListener<GraphDocument>() { - - public void changed(GraphDocument document) { - updateStructure(); - } - }); - associateLookup(ExplorerUtils.createLookup(manager, getActionMap())); } @@ -117,50 +97,32 @@ toolbar.add(((NodeAction) RemoveAction.get(RemoveAction.class)).createContextAwareInstance(this.getLookup())); toolbar.add(RemoveAllAction.get(RemoveAllAction.class)); - - toolbar.add(StructuredViewAction.get(StructuredViewAction.class).getToolbarPresenter()); + + toolbar.add(GarbageCollectAction.get(GarbageCollectAction.class).getToolbarPresenter()); for (Toolbar tb : ToolbarPool.getDefault().getToolbars()) { tb.setVisible(false); } } - public void setOrganizer(GroupOrganizer organizer) { - this.organizer = organizer; - updateStructure(); - } - private void initReceivers() { final GroupCallback callback = new GroupCallback() { + @Override public void started(Group g) { - getDocument().addGroup(g); + getDocument().addElement(g); } }; - - Collection<? extends GroupReceiver> receivers = Lookup.getDefault().lookupAll(GroupReceiver.class); - if (receivers.size() > 0) { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - - for (GroupReceiver r : receivers) { - Component c = r.init(callback); - panel.add(c); - } - - jPanel2.add(panel, BorderLayout.PAGE_START); - } - } - - private void updateStructure() { - root.init("", organizer, new ArrayList<String>(), document.getGroups()); + + server = new Server(callback); } public void clear() { document.clear(); } + @Override public ExplorerManager getExplorerManager() { return manager; } @@ -234,6 +196,7 @@ return super.requestFocusInWindow(temporary); } + @Override public void resultChanged(LookupEvent lookupEvent) { } @@ -266,19 +229,13 @@ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { - jPanel2 = new javax.swing.JPanel(); treeView = new BeanTreeView(); setLayout(new java.awt.BorderLayout()); - - jPanel2.setLayout(new java.awt.BorderLayout()); - jPanel2.add(treeView, java.awt.BorderLayout.CENTER); - - add(jPanel2, java.awt.BorderLayout.CENTER); + add(treeView, java.awt.BorderLayout.CENTER); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane treeView; // End of variables declaration//GEN-END:variables }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml Sun Jan 29 11:40:04 2012 +0100 @@ -4,7 +4,7 @@ <Row> <Toolbar name="Edit" position="1" visible="false"/> <Toolbar name="File" position="1" visible="false" /> - <Toolbar name="Memory" position="1" visible="false" /> + <Toolbar name="Memory" position="1" visible="true" /> </Row> <Row> <Toolbar name="WorkspaceSwitcher" />
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.coordinator; - -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.Pair; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class StandardGroupOrganizer implements GroupOrganizer { - - public String getName() { - return "-- None --"; - } - - public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups) { - List<Pair<String, List<Group>>> result = new ArrayList<Pair<String, List<Group>>>(); - if (groups.size() == 1 && subFolders.size() > 0) { - result.add(new Pair<String, List<Group>>("", groups)); - } else { - for (Group g : groups) { - Pair<String, List<Group>> p = new Pair<String, List<Group>>(); - p.setLeft(g.getName()); - p.setRight(Arrays.asList(g)); - result.add(p); - } - } - return result; - } -}
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -35,12 +35,14 @@ */ public final class DiffGraphAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class); assert c != null; c.openDiff(); } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } @@ -58,12 +60,14 @@ return false; } + @Override public String getName() { return NbBundle.getMessage(DiffGraphAction.class, "CTL_DiffGraphAction"); } - protected Class[] cookieClasses() { - return new Class[]{ + @Override + protected Class<?>[] cookieClasses() { + return new Class<?>[]{ DiffGraphCookie.class }; } @@ -73,6 +77,7 @@ return "com/sun/hotspot/igv/coordinator/images/diff.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,9 +28,6 @@ import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.difference.Difference; import com.sun.hotspot.igv.util.LookupHistory; -import org.openide.DialogDescriptor; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; import org.openide.nodes.Node; import org.openide.util.Lookup; @@ -60,16 +57,6 @@ public void openDiff() { InputGraph other = getCurrentGraph(); - - if (!graph.getGroup().isComplete() || !other.getGroup().isComplete()) { - String msg = "One of the graphs or the groups they belong to are still being loaded. Creating a diff now can cause problems. Do you want to continue?"; - NotifyDescriptor desc = new NotifyDescriptor(msg, "Incomplete data", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION); - - if (DialogDisplayer.getDefault().notify(desc) == DialogDescriptor.NO_OPTION) { - return; - } - } - final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class); if (viewer != null) { InputGraph diffGraph = Difference.createDiffGraph(other, graph);
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,9 +25,6 @@ import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.GraphViewer; -import org.openide.DialogDescriptor; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; import org.openide.cookies.OpenCookie; public class GraphOpenCookie implements OpenCookie { @@ -40,16 +37,8 @@ this.graph = graph; } + @Override public void open() { - if (!graph.getGroup().isComplete()) { - String msg = "This graph or the group it belongs to is still being loaded. Opening this graph now can cause problems. Do you want to continue and open the graph?"; - NotifyDescriptor desc = new NotifyDescriptor(msg, "Incomplete data", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION); - - if (DialogDisplayer.getDefault().notify(desc) == DialogDescriptor.NO_OPTION) { - return; - } - } - viewer.view(graph); } }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,36 +23,17 @@ */ package com.sun.hotspot.igv.coordinator.actions; -import com.sun.hotspot.igv.data.GraphDocument; import com.sun.hotspot.igv.data.InputGraph; -import org.openide.DialogDescriptor; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; public class GraphRemoveCookie implements RemoveCookie { - private final GraphDocument document; private final InputGraph graph; - public GraphRemoveCookie(GraphDocument document, InputGraph graph) { - this.document = document; + public GraphRemoveCookie(InputGraph graph) { this.graph = graph; } + @Override public void remove() { - if (!graph.getGroup().isComplete()) { - String msg = "This graph or the group it belongs to is still being loaded. Removing this graph now can cause problems. Do you want to continue and remove the graph?"; - NotifyDescriptor desc = new NotifyDescriptor(msg, "Incomplete data", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION); - - if (DialogDisplayer.getDefault().notify(desc) == DialogDescriptor.NO_OPTION) { - return; - } - } - - if (graph.getGroup().getGraphsCount() > 1) { - graph.getGroup().removeGraph(graph); - } else { - // Last graph, remove the entire group - document.removeGroup(graph.getGroup()); - } + graph.getGroup().removeElement(graph); } }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,8 +27,8 @@ import com.sun.hotspot.igv.coordinator.OutlineTopComponent; import com.sun.hotspot.igv.data.GraphDocument; import com.sun.hotspot.igv.data.serialization.Parser; +import com.sun.hotspot.igv.data.serialization.XMLParser; import com.sun.hotspot.igv.settings.Settings; -import com.sun.hotspot.igv.data.serialization.XMLParser; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.io.File; @@ -38,6 +38,7 @@ import javax.swing.Action; import javax.swing.JFileChooser; import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; @@ -59,16 +60,19 @@ public static FileFilter getFileFilter() { return new FileFilter() { + @Override public boolean accept(File f) { return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory(); } + @Override public String getDescription() { return "XML files (*.xml)"; } }; } + @Override public void performAction() { JFileChooser fc = new JFileChooser(); @@ -96,6 +100,7 @@ final XMLParser.ParseMonitor parseMonitor = new XMLParser.ParseMonitor() { + @Override public void setProgress(double d) { try { int curAvailable = inputStream.available(); @@ -105,6 +110,7 @@ } } + @Override public void setState(String state) { setProgress(0.0); handle.progress(state); @@ -117,12 +123,18 @@ RequestProcessor.getDefault().post(new Runnable() { + @Override public void run() { - GraphDocument document = null; try { - document = parser.parse(is, parseMonitor); + final GraphDocument document = parser.parse(is, parseMonitor); parseMonitor.setState("Finishing"); - component.getDocument().addGraphDocument(document); + SwingUtilities.invokeLater(new Runnable(){ + + @Override + public void run() { + component.getDocument().addGraphDocument(document); + } + }); } catch (SAXException ex) { String s = "Exception during parsing the XML file, could not load document!"; if (ex instanceof XMLParser.MissingAttributeException) { @@ -145,6 +157,7 @@ } } + @Override public String getName() { return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction"); } @@ -159,6 +172,7 @@ return "com/sun/hotspot/igv/coordinator/images/import.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,7 +24,7 @@ package com.sun.hotspot.igv.coordinator.actions; -import com.sun.hotspot.igv.coordinator.*; +import com.sun.hotspot.igv.coordinator.OutlineTopComponent; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import org.openide.util.NbBundle; @@ -40,6 +40,7 @@ super(NbBundle.getMessage(OutlineAction.class, "CTL_OutlineAction")); } + @Override public void actionPerformed(ActionEvent evt) { TopComponent win = OutlineTopComponent.findInstance(); win.open();
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -36,6 +36,7 @@ */ public final class RemoveAction extends NodeAction { + @Override protected void performAction(Node[] activatedNodes) { for (Node n : activatedNodes) { RemoveCookie removeCookie = n.getCookie(RemoveCookie.class); @@ -49,6 +50,7 @@ putValue(Action.SHORT_DESCRIPTION, "Remove selected graphs and groups"); } + @Override public String getName() { return NbBundle.getMessage(RemoveAction.class, "CTL_RemoveAction"); } @@ -58,6 +60,7 @@ return "com/sun/hotspot/igv/coordinator/images/remove.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -67,6 +70,7 @@ return false; } + @Override protected boolean enable(Node[] nodes) { return nodes.length > 0; }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,6 +40,7 @@ public final class RemoveAllAction extends CallableSystemAction { + @Override public String getName() { return NbBundle.getMessage(RemoveAllAction.class, "CTL_RemoveAllAction"); } @@ -54,6 +55,7 @@ return "com/sun/hotspot/igv/coordinator/images/removeall.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -39,11 +39,13 @@ */ public final class SaveAllAction extends CallableSystemAction { + @Override public void performAction() { final OutlineTopComponent component = OutlineTopComponent.findInstance(); SaveAsAction.save(component.getDocument()); } + @Override public String getName() { return NbBundle.getMessage(SaveAllAction.class, "CTL_SaveAllAction"); } @@ -58,6 +60,7 @@ return "com/sun/hotspot/igv/coordinator/images/saveall.gif"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,12 +28,7 @@ import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.serialization.Printer; import com.sun.hotspot.igv.settings.Settings; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; +import java.io.*; import javax.swing.Action; import javax.swing.JFileChooser; import org.openide.nodes.Node; @@ -52,12 +47,13 @@ putValue(Action.SHORT_DESCRIPTION, "Save selected groups to XML file..."); } + @Override protected void performAction(Node[] activatedNodes) { GraphDocument doc = new GraphDocument(); for (Node n : activatedNodes) { Group group = n.getLookup().lookup(Group.class); - doc.addGroup(group); + doc.addElement(group); } save(doc); @@ -80,10 +76,10 @@ } Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); try { - Writer writer = new OutputStreamWriter(new FileOutputStream(file)); - Printer p = new Printer(); - p.export(writer, doc); - writer.close(); + try (Writer writer = new OutputStreamWriter(new FileOutputStream(file))) { + Printer p = new Printer(); + p.export(writer, doc); + } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { @@ -97,6 +93,7 @@ return CookieAction.MODE_SOME; } + @Override public String getName() { return NbBundle.getMessage(SaveAsAction.class, "CTL_SaveAsAction"); } @@ -106,6 +103,7 @@ return "com/sun/hotspot/igv/coordinator/images/save.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -115,6 +113,7 @@ return false; } + @Override protected boolean enable(Node[] nodes) { int cnt = 0;
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.coordinator.actions; - -import com.sun.hotspot.igv.coordinator.OutlineTopComponent; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import java.awt.Component; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.swing.Action; -import javax.swing.ButtonGroup; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import org.openide.awt.DropDownButtonFactory; -import org.openide.util.HelpCtx; -import org.openide.util.ImageUtilities; -import org.openide.util.Lookup; -import org.openide.util.actions.CallableSystemAction; - -public class StructuredViewAction extends CallableSystemAction { - - private static JButton dropDownButton; - private static ButtonGroup buttonGroup; - private static JPopupMenu popup; - private MyMenuItemListener menuItemListener; - private Map<JMenuItem, GroupOrganizer> map; - - public StructuredViewAction() { - - putValue(Action.SHORT_DESCRIPTION, "Cluster nodes into blocks"); - } - - @Override - public Component getToolbarPresenter() { - - Image iconImage = ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/structure.png"); - ImageIcon icon = new ImageIcon(iconImage); - - popup = new JPopupMenu(); - - menuItemListener = new MyMenuItemListener(); - - buttonGroup = new ButtonGroup(); - - Collection<? extends GroupOrganizer> organizersCollection = Lookup.getDefault().lookupAll(GroupOrganizer.class); - - List<GroupOrganizer> organizers = new ArrayList<GroupOrganizer>(organizersCollection); - Collections.sort(organizers, new Comparator<GroupOrganizer>() { - public int compare(GroupOrganizer a, GroupOrganizer b) { - return a.getName().compareTo(b.getName()); - } - }); - - map = new HashMap<JMenuItem, GroupOrganizer>(); - - boolean first = true; - for(GroupOrganizer organizer : organizers) { - JCheckBoxMenuItem item = new JCheckBoxMenuItem(organizer.getName()); - map.put(item, organizer); - item.addActionListener(menuItemListener); - buttonGroup.add(item); - popup.add(item); - if(first) { - item.setSelected(true); - first = false; - } - } - - dropDownButton = DropDownButtonFactory.createDropDownButton( - new ImageIcon( - new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), - popup); - - dropDownButton.setIcon(icon); - - dropDownButton.setToolTipText("Choose group organization"); - - dropDownButton.addItemListener(new ItemListener() { - - public void itemStateChanged(ItemEvent e) { - int state = e.getStateChange(); - if (state == ItemEvent.SELECTED) { - performAction(); - } - } - }); - - dropDownButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - performAction(); - } - }); - - popup.addPopupMenuListener(new PopupMenuListener() { - - public void popupMenuCanceled(PopupMenuEvent e) { - dropDownButton.setSelected(false); - } - - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - dropDownButton.setSelected(false); - } - - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - dropDownButton.setSelected(true); - } - }); - - return dropDownButton; - - } - - private class MyMenuItemListener implements ActionListener { - - public void actionPerformed(ActionEvent ev) { - JMenuItem item = (JMenuItem) ev.getSource(); - GroupOrganizer organizer = map.get(item); - assert organizer != null : "Organizer must exist!"; - OutlineTopComponent.findInstance().setOrganizer(organizer); - } - } - - - @Override - public void performAction() { - popup.show(dropDownButton, 0, dropDownButton.getHeight()); - } - - public String getName() { - return "Structured View"; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - @Override - protected boolean asynchronous() { - return false; - } - -}
--- a/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,8 +1,8 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial -src.dir=src -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -test.src.dir=test -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial +src.dir=src +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +test.src.dir=test +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java Sun Jan 29 11:40:04 2012 +0100 @@ -39,6 +39,7 @@ this.object = object; } + @Override protected void fire(ChangedListener<T> l) { l.changed(object); }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java Sun Jan 29 11:40:04 2012 +0100 @@ -45,6 +45,7 @@ enabled = b; } + @Override public void changed(T source) { if(enabled) { filteredChanged(source);
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,7 +37,7 @@ private boolean eventWasFired; public Event() { - listener = new ArrayList<L>(); + listener = new ArrayList<>(); fireEvents = true; } @@ -55,7 +55,7 @@ public void fire() { if(fireEvents) { - List<L> tmpList = new ArrayList<L>(listener); + List<L> tmpList = new ArrayList<>(listener); for (L l : tmpList) { fire(l); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Folder.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.data; + +import java.util.List; + +public interface Folder { + List<? extends FolderElement> getElements(); + void removeElement(FolderElement element); + void addElement(FolderElement group); + ChangedEvent<? extends Folder> getChangedEvent(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/FolderElement.java Sun Jan 29 11:40:04 2012 +0100 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.data; + +public interface FolderElement { + + Folder getParent(); + String getName(); + void setParent(Folder parent); +}
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,51 +24,36 @@ package com.sun.hotspot.igv.data; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** * * @author Thomas Wuerthinger */ -public class GraphDocument extends Properties.Entity implements ChangedEventProvider<GraphDocument> { +public class GraphDocument extends Properties.Entity implements ChangedEventProvider<GraphDocument>, Folder { - private List<Group> groups; + private List<FolderElement> elements; private ChangedEvent<GraphDocument> changedEvent; public GraphDocument() { - groups = new ArrayList<Group>(); - changedEvent = new ChangedEvent<GraphDocument>(this); + elements = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); } public void clear() { - groups.clear(); + elements.clear(); getChangedEvent().fire(); } + @Override public ChangedEvent<GraphDocument> getChangedEvent() { return changedEvent; } - public List<Group> getGroups() { - return Collections.unmodifiableList(groups); - } - - public void addGroup(Group group) { - groups.add(group); - getChangedEvent().fire(); - } - - public void removeGroup(Group group) { - if (groups.contains(group)) { - groups.remove(group); - getChangedEvent().fire(); - } - } - public void addGraphDocument(GraphDocument document) { - for (Group g : document.groups) { - this.addGroup(g); + for (FolderElement e : document.elements) { + e.setParent(this); + this.addElement(e); } document.clear(); getChangedEvent().fire(); @@ -78,12 +63,30 @@ public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("GraphDocument: " + getProperties().toString() + " \n\n"); - for (Group g : getGroups()) { + sb.append("GraphDocument: ").append(getProperties().toString()).append(" \n\n"); + for (FolderElement g : getElements()) { sb.append(g.toString()); sb.append("\n\n"); } return sb.toString(); } + + @Override + public List<? extends FolderElement> getElements() { + return elements; + } + + @Override + public void removeElement(FolderElement element) { + if (elements.remove(element)) { + getChangedEvent().fire(); + } + } + + @Override + public void addElement(FolderElement element) { + elements.add(element); + getChangedEvent().fire(); + } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,54 +23,36 @@ */ package com.sun.hotspot.igv.data; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * * @author Thomas Wuerthinger */ -public class Group extends Properties.Entity implements ChangedEventProvider<Group> { +public class Group extends Properties.Entity implements ChangedEventProvider<Group>, Folder, FolderElement { + private final List<FolderElement> elements; private final List<InputGraph> graphs; private InputMethod method; - private String assembly; private transient ChangedEvent<Group> changedEvent; - private transient boolean complete = true; + private Folder parent; - public Group() { - graphs = Collections.synchronizedList(new ArrayList<InputGraph>()); - changedEvent = new ChangedEvent<Group>(this); + public Group(Folder parent) { + elements = new ArrayList<>(); + graphs = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); + this.parent = parent; // Ensure that name and type are never null getProperties().setProperty("name", ""); getProperties().setProperty("type", ""); } - public void setComplete(boolean complete) { - this.complete = complete; - } - - public boolean isComplete() { - return complete; - } - public void fireChangedEvent() { changedEvent.fire(); } - public void setAssembly(String s) { - this.assembly = s; - } - - public String getAssembly() { - return assembly; - } - public void setMethod(InputMethod method) { this.method = method; } @@ -79,56 +61,37 @@ return method; } + @Override public ChangedEvent<Group> getChangedEvent() { return changedEvent; } - public List<InputGraph> getGraphs() { - return Collections.unmodifiableList(graphs); + @Override + public List<FolderElement> getElements() { + return Collections.unmodifiableList(elements); } public int getGraphsCount() { - return graphs.size(); + return elements.size(); } - - public List<InputGraph> getGraphListCopy() { - synchronized (graphs) { - return new ArrayList<InputGraph>(graphs); + + @Override + public void addElement(FolderElement element) { + elements.add(element); + if (element instanceof InputGraph) { + graphs.add((InputGraph) element); + } else { + } - } - - public void addGraph(InputGraph graph) { - synchronized (graphs) { - graph.setParent(this, graphs.size()); - graphs.add(graph); - } + element.setParent(this); changedEvent.fire(); } - public InputGraph addGraph(String name) { - return addGraph(name, null); - } - - public InputGraph addGraph(String name, Pair<InputGraph, InputGraph> pair) { - InputGraph g; - synchronized (graphs) { - g = new InputGraph(graphs.size(), this, name, pair); - graphs.add(g); - } - changedEvent.fire(); - return g; - } - - public void removeGraph(InputGraph g) { - if (graphs.remove(g)) { - changedEvent.fire(); - } - } - public Set<Integer> getAllNodes() { - Set<Integer> result = new HashSet<Integer>(); - synchronized (graphs) { - for (InputGraph g : graphs) { + Set<Integer> result = new HashSet<>(); + for (FolderElement e : elements) { + if (e instanceof InputGraph) { + InputGraph g = (InputGraph) e; result.addAll(g.getNodesAsSet()); } } @@ -138,21 +101,80 @@ @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("Group " + getProperties().toString() + "\n"); - synchronized (graphs) { - for (InputGraph g : graphs) { - sb.append(g.toString()); - sb.append('\n'); - } + sb.append("Group ").append(getProperties()).append("\n"); + for (FolderElement g : elements) { + sb.append(g.toString()); + sb.append('\n'); } return sb.toString(); } + @Override public String getName() { return getProperties().get("name"); } public String getType() { return getProperties().get("type"); + + } + + InputGraph getPrev(InputGraph graph) { + InputGraph lastGraph = null; + for (FolderElement e : elements) { + if (e == graph) { + return lastGraph; + } + if (e instanceof InputGraph) { + lastGraph = (InputGraph) e; + } + } + return null; + } + + InputGraph getNext(InputGraph graph) { + boolean found = false; + for (FolderElement e : elements) { + if (e == graph) { + found = true; + } else if (found && e instanceof InputGraph) { + return (InputGraph) e; + } + } + return null; + } + + public InputGraph getLastGraph() { + InputGraph lastGraph = null; + for (FolderElement e : elements) { + if (e instanceof InputGraph) { + lastGraph = (InputGraph) e; + } + } + return lastGraph; + } + + @Override + public Folder getParent() { + return parent; + } + + @Override + public void removeElement(FolderElement element) { + if (elements.remove(element)) { + if (element instanceof InputGraph) { + graphs.remove((InputGraph) element); + } + changedEvent.fire(); + } + } + + public List<InputGraph> getGraphs() { + return graphs; + } + + @Override + public void setParent(Folder parent) { + this.parent = parent; } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,12 +23,7 @@ */ package com.sun.hotspot.igv.data; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * @@ -63,7 +58,7 @@ return false; } - final HashSet<String> s = new HashSet<String>(); + final HashSet<String> s = new HashSet<>(); for (InputBlock succ : successors) { s.add(succ.name); } @@ -80,8 +75,8 @@ InputBlock(InputGraph graph, String name) { this.graph = graph; this.name = name; - nodes = new ArrayList<InputNode>(); - successors = new LinkedHashSet<InputBlock>(2); + nodes = new ArrayList<>(); + successors = new LinkedHashSet<>(2); } public String getName() {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,6 +40,7 @@ public static final Comparator<InputEdge> OUTGOING_COMPARATOR = new Comparator<InputEdge>(){ + @Override public int compare(InputEdge o1, InputEdge o2) { if(o1.getFromIndex() == o2.getFromIndex()) { return o1.getTo() - o2.getTo(); @@ -51,6 +52,7 @@ public static final Comparator<InputEdge> INGOING_COMPARATOR = new Comparator<InputEdge>(){ + @Override public int compare(InputEdge o1, InputEdge o2) { if(o1.getToIndex() == o2.getToIndex()) { return o1.getFrom() - o2.getFrom();
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,54 +23,38 @@ */ package com.sun.hotspot.igv.data; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * * @author Thomas Wuerthinger */ -public class InputGraph extends Properties.Entity { +public class InputGraph extends Properties.Entity implements FolderElement { private Map<Integer, InputNode> nodes; private Set<InputEdge> edges; - private Group parent; + private Folder parent; + private Group parentGroup; private Map<String, InputBlock> blocks; private Set<InputBlockEdge> blockEdges; private Map<Integer, InputBlock> nodeToBlock; - private Pair<InputGraph, InputGraph> sourceGraphs; - private int parentIndex; - public static InputGraph createWithoutGroup(String name, Pair<InputGraph, InputGraph> sourceGraphs) { - return new InputGraph(-1, null, name, sourceGraphs); - } - - InputGraph(int parentIndex, Group parent, String name, Pair<InputGraph, InputGraph> sourceGraphs) { - this.parentIndex = parentIndex; - this.parent = parent; - this.sourceGraphs = sourceGraphs; + public InputGraph(String name) { setName(name); - nodes = new LinkedHashMap<Integer, InputNode>(); - edges = new LinkedHashSet<InputEdge>(); - blocks = new LinkedHashMap<String, InputBlock>(); - blockEdges = new LinkedHashSet<InputBlockEdge>(); - nodeToBlock = new LinkedHashMap<Integer, InputBlock>(); + nodes = new LinkedHashMap<>(); + edges = new LinkedHashSet<>(); + blocks = new LinkedHashMap<>(); + blockEdges = new LinkedHashSet<>(); + nodeToBlock = new LinkedHashMap<>(); } - public void setParent(Group parent, int parentIndex) { - assert (this.parent == null); - assert (this.parentIndex == -1); - + @Override + public void setParent(Folder parent) { this.parent = parent; - this.parentIndex = parentIndex; + if (parent instanceof Group) { + assert this.parentGroup == null; + this.parentGroup = (Group) parent; + } } public InputBlockEdge addBlockEdge(InputBlock left, InputBlock right) { @@ -79,14 +63,10 @@ left.addSuccessor(right); return edge; } - - public Pair<InputGraph, InputGraph> getSourceGraphs() { - return sourceGraphs; - } public List<InputNode> findRootNodes() { - List<InputNode> result = new ArrayList<InputNode>(); - Set<Integer> nonRoot = new HashSet<Integer>(); + List<InputNode> result = new ArrayList<>(); + Set<Integer> nonRoot = new HashSet<>(); for(InputEdge curEdges : getEdges()) { nonRoot.add(curEdges.getTo()); } @@ -102,7 +82,7 @@ public Map<InputNode, List<InputEdge>> findAllOutgoingEdges() { - Map<InputNode, List<InputEdge>> result = new HashMap<InputNode, List<InputEdge>>(getNodes().size()); + Map<InputNode, List<InputEdge>> result = new HashMap<>(getNodes().size()); for(InputNode n : this.getNodes()) { result.put(n, new ArrayList<InputEdge>()); } @@ -125,7 +105,7 @@ public Map<InputNode, List<InputEdge>> findAllIngoingEdges() { - Map<InputNode, List<InputEdge>> result = new HashMap<InputNode, List<InputEdge>>(getNodes().size()); + Map<InputNode, List<InputEdge>> result = new HashMap<>(getNodes().size()); for(InputNode n : this.getNodes()) { result.put(n, new ArrayList<InputEdge>()); } @@ -147,7 +127,7 @@ } public List<InputEdge> findOutgoingEdges(InputNode n) { - List<InputEdge> result = new ArrayList<InputEdge>(); + List<InputEdge> result = new ArrayList<>(); for(InputEdge e : this.edges) { if(e.getFrom() == n.getId()) { @@ -177,7 +157,7 @@ public void ensureNodesInBlocks() { InputBlock noBlock = null; - Set<InputNode> scheduledNodes = new HashSet<InputNode>(); + Set<InputNode> scheduledNodes = new HashSet<>(); for (InputBlock b : getBlocks()) { for (InputNode n : b.getNodes()) { @@ -213,27 +193,18 @@ } public InputGraph getNext() { - List<InputGraph> list = parent.getGraphs(); - if (parentIndex == list.size() - 1) { - return null; - } else { - return list.get(parentIndex + 1); - } + return parentGroup.getNext(this); } public InputGraph getPrev() { - List<InputGraph> list = parent.getGraphs(); - if (parentIndex == 0) { - return null; - } else { - return list.get(parentIndex - 1); - } + return parentGroup.getPrev(this); } private void setName(String name) { this.getProperties().setProperty("name", name); } + @Override public String getName() { return getProperties().get("name"); } @@ -279,13 +250,13 @@ } public Group getGroup() { - return parent; + return parentGroup; } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("Graph " + getName() + " " + getProperties().toString() + "\n"); + sb.append("Graph ").append(getName()).append(" ").append(getProperties().toString()).append("\n"); for (InputNode n : nodes.values()) { sb.append(n.toString()); sb.append("\n"); @@ -317,4 +288,9 @@ public Collection<InputBlockEdge> getBlockEdges() { return Collections.unmodifiableSet(blockEdges); } + + @Override + public Folder getParent() { + return parent; + } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java Sun Jan 29 11:40:04 2012 +0100 @@ -70,8 +70,8 @@ this.name = name; this.bci = bci; this.shortName = shortName; - inlined = new ArrayList<InputMethod>(); - bytecodes = new ArrayList<InputBytecode>(); + inlined = new ArrayList<>(); + bytecodes = new ArrayList<>(); } public List<InputBytecode> getBytecodes() {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -34,6 +34,7 @@ private int id; public static final Comparator<InputNode> COMPARATOR = new Comparator<InputNode>() { + @Override public int compare(InputNode o1, InputNode o2) { return o1.getId() - o2.getId(); } @@ -42,6 +43,7 @@ public static Comparator<InputNode> getPropertyComparator(final String propertyName) { return new Comparator<InputNode>() { + @Override public int compare(InputNode o1, InputNode o2) { int i1 = 0;
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java Sun Jan 29 11:40:04 2012 +0100 @@ -61,7 +61,7 @@ if (o == null || !(o instanceof Pair)) { return false; } - Pair obj = (Pair) o; + Pair<?,?> obj = (Pair<?,?>) o; boolean b1 = (l == obj.l); if (l != null) { b1 = l.equals(obj.l);
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,12 +24,7 @@ package com.sun.hotspot.igv.data; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -119,6 +114,7 @@ properties = new Properties(object.getProperties()); } + @Override public Properties getProperties() { return properties; } @@ -139,10 +135,12 @@ this.matcher = matcher; } + @Override public String getName() { return matcher.getName(); } + @Override public boolean match(String p) { if (p == null) { return false; @@ -167,10 +165,12 @@ this.value = value; } + @Override public String getName() { return name; } + @Override public boolean match(String p) { if (p == null) { throw new IllegalArgumentException("Property value must not be null!"); @@ -207,10 +207,12 @@ } } + @Override public String getName() { return name; } + @Override public boolean match(String p) { if (p == null) { throw new IllegalArgumentException("Property value must not be null!"); @@ -244,7 +246,7 @@ @Override public String toString() { - List<String[]> pairs = new ArrayList<String[]>(); + List<String[]> pairs = new ArrayList<>(); for (int i = 0; i < map.length; i += 2) { if (map[i + 1] != null) { pairs.add(new String[]{map[i], map[i + 1]}); @@ -252,6 +254,7 @@ } Collections.sort(pairs, new Comparator<String[]>() { + @Override public int compare(String[] o1, String[] o2) { assert o1.length == 2; assert o2.length == 2; @@ -294,7 +297,7 @@ } public List<T> selectMultiple(PropertyMatcher matcher) { - List<T> result = new ArrayList<T>(); + List<T> result = new ArrayList<>(); for (T t : objects) { Property p = t.getProperties().selectSingle(matcher); @@ -358,6 +361,7 @@ int index; + @Override public boolean hasNext() { while (index < map.length && map[index + 1] == null) { index += 2; @@ -365,6 +369,7 @@ return index < map.length; } + @Override public Property next() { if (index < map.length) { index += 2; @@ -373,11 +378,13 @@ return null; } + @Override public void remove() { throw new UnsupportedOperationException("Not supported yet."); } } + @Override public Iterator<Property> iterator() { return new PropertiesIterator(); }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.data; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * @@ -39,8 +35,8 @@ private Set<Integer> set; public Source() { - sourceNodes = new ArrayList<InputNode>(1); - set = new LinkedHashSet<Integer>(1); + sourceNodes = new ArrayList<>(1); + set = new LinkedHashSet<>(1); } public List<InputNode> getSourceNodes() {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,25 +23,18 @@ */ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputMethod; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.services.GroupCallback; +import com.sun.hotspot.igv.data.*; import com.sun.hotspot.igv.data.serialization.XMLParser.ElementHandler; import com.sun.hotspot.igv.data.serialization.XMLParser.HandoverElementHandler; import com.sun.hotspot.igv.data.serialization.XMLParser.ParseMonitor; import com.sun.hotspot.igv.data.serialization.XMLParser.TopElementHandler; +import com.sun.hotspot.igv.data.services.GroupCallback; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.Map; +import javax.swing.SwingUtilities; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Source; @@ -98,12 +91,14 @@ public static final String SUCCESSOR_ELEMENT = "successor"; public static final String ASSEMBLY_ELEMENT = "assembly"; public static final String DIFFERENCE_PROPERTY = "difference"; - private TopElementHandler<GraphDocument> xmlDocument = new TopElementHandler<GraphDocument>(); - private boolean difference; + private TopElementHandler<GraphDocument> xmlDocument = new TopElementHandler<>(); + private Map<Group, Boolean> differenceEncoding = new HashMap<>(); + private Map<Group, InputGraph> lastParsedGraph = new HashMap<>(); private GroupCallback groupCallback; - private HashMap<String, Integer> idCache = new HashMap<String, Integer>(); - private ArrayList<Pair<String, String>> blockConnections = new ArrayList<Pair<String, String>>(); + private HashMap<String, Integer> idCache = new HashMap<>(); + private ArrayList<Pair<String, String>> blockConnections = new ArrayList<>(); private int maxId = 0; + private GraphDocument graphDocument; private int lookupID(String i) { try { @@ -124,19 +119,19 @@ @Override protected GraphDocument start() throws SAXException { - return new GraphDocument(); + graphDocument = new GraphDocument(); + return graphDocument; } }; // <group> - private ElementHandler<Group, GraphDocument> groupHandler = new XMLParser.ElementHandler<Group, GraphDocument>(GROUP_ELEMENT) { + private ElementHandler<Group, Folder> groupHandler = new XMLParser.ElementHandler<Group, Folder>(GROUP_ELEMENT) { @Override protected Group start() throws SAXException { - Group group = new Group(); - group.setComplete(false); + Group group = new Group(this.getParentObject()); String differenceProperty = this.readAttribute(DIFFERENCE_PROPERTY); - Parser.this.difference = (differenceProperty != null && (differenceProperty.equals("1") || differenceProperty.equals("true"))); + Parser.this.differenceEncoding.put(group, (differenceProperty != null && (differenceProperty.equals("1") || differenceProperty.equals("true")))); ParseMonitor monitor = getMonitor(); if (monitor != null) { @@ -148,20 +143,18 @@ @Override protected void end(String text) throws SAXException { - Group group = getObject(); - group.setComplete(true); - if (groupCallback == null) { - getParentObject().addGroup(group); + final Group group = getObject(); + final Folder parent = getParentObject(); + if (groupCallback == null || parent instanceof Group) { + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run() { + parent.addElement(group); + } + }); } } }; - private HandoverElementHandler<Group> assemblyHandler = new XMLParser.HandoverElementHandler<Group>(ASSEMBLY_ELEMENT, true) { - - @Override - protected void end(String text) throws SAXException { - getParentObject().setAssembly(text); - } - }; // <method> private ElementHandler<InputMethod, Group> methodHandler = new XMLParser.ElementHandler<InputMethod, Group>(METHOD_ELEMENT) { @@ -174,7 +167,7 @@ } }; - private InputMethod parseMethod(XMLParser.ElementHandler handler, Group group) throws SAXException { + private InputMethod parseMethod(XMLParser.ElementHandler<?,?> handler, Group group) throws SAXException { String s = handler.readRequiredAttribute(METHOD_BCI_PROPERTY); int bci = 0; try { @@ -194,7 +187,7 @@ } }; // <inlined> - private HandoverElementHandler<InputMethod> inlinedHandler = new XMLParser.HandoverElementHandler<InputMethod>(INLINE_ELEMENT); + private HandoverElementHandler<InputMethod> inlinedHandler = new XMLParser.HandoverElementHandler<>(INLINE_ELEMENT); // <inlined><method> private ElementHandler<InputMethod, InputMethod> inlinedMethodHandler = new XMLParser.ElementHandler<InputMethod, InputMethod>(METHOD_ELEMENT) { @@ -208,16 +201,14 @@ // <graph> private ElementHandler<InputGraph, Group> graphHandler = new XMLParser.ElementHandler<InputGraph, Group>(GRAPH_ELEMENT) { - private InputGraph graph; - @Override protected InputGraph start() throws SAXException { String name = readAttribute(GRAPH_NAME_PROPERTY); - InputGraph curGraph = InputGraph.createWithoutGroup(name, null); - if (difference) { - List<InputGraph> list = getParentObject().getGraphs(); - if (list.size() > 0) { - InputGraph previous = list.get(list.size() - 1); + InputGraph curGraph = new InputGraph(name); + if (differenceEncoding.get(getParentObject())) { + InputGraph previous = lastParsedGraph.get(getParentObject()); + lastParsedGraph.put(getParentObject(), curGraph); + if (previous != null) { for (InputNode n : previous.getNodes()) { curGraph.addNode(n); } @@ -226,7 +217,6 @@ } } } - this.graph = curGraph; return curGraph; } @@ -239,6 +229,8 @@ // block to some artificial block below unless blocks are // defined and nodes are assigned to them. + final InputGraph graph = getObject(); + final Group parent = getParentObject(); if (graph.getBlocks().size() > 0) { boolean blocksContainNodes = false; for (InputBlock b : graph.getBlocks()) { @@ -279,14 +271,20 @@ } blockConnections.clear(); - // Add to group - getParentObject().addGraph(graph); + SwingUtilities.invokeLater(new Runnable(){ + + @Override + public void run() { + // Add to group + parent.addElement(graph); + } + }); } }; // <nodes> - private HandoverElementHandler<InputGraph> nodesHandler = new HandoverElementHandler<InputGraph>(NODES_ELEMENT); + private HandoverElementHandler<InputGraph> nodesHandler = new HandoverElementHandler<>(NODES_ELEMENT); // <controlFlow> - private HandoverElementHandler<InputGraph> controlFlowHandler = new HandoverElementHandler<InputGraph>(CONTROL_FLOW_ELEMENT); + private HandoverElementHandler<InputGraph> controlFlowHandler = new HandoverElementHandler<>(CONTROL_FLOW_ELEMENT); // <block> private ElementHandler<InputBlock, InputGraph> blockHandler = new ElementHandler<InputBlock, InputGraph>(BLOCK_ELEMENT) { @@ -302,7 +300,7 @@ } }; // <nodes> - private HandoverElementHandler<InputBlock> blockNodesHandler = new HandoverElementHandler<InputBlock>(NODES_ELEMENT); + private HandoverElementHandler<InputBlock> blockNodesHandler = new HandoverElementHandler<>(NODES_ELEMENT); // <node> private ElementHandler<InputBlock, InputBlock> blockNodeHandler = new ElementHandler<InputBlock, InputBlock>(NODE_ELEMENT) { @@ -321,14 +319,14 @@ } }; // <successors> - private HandoverElementHandler<InputBlock> successorsHandler = new HandoverElementHandler<InputBlock>(SUCCESSORS_ELEMENT); + private HandoverElementHandler<InputBlock> successorsHandler = new HandoverElementHandler<>(SUCCESSORS_ELEMENT); // <successor> private ElementHandler<InputBlock, InputBlock> successorHandler = new ElementHandler<InputBlock, InputBlock>(SUCCESSOR_ELEMENT) { @Override protected InputBlock start() throws SAXException { String name = readRequiredAttribute(BLOCK_NAME_PROPERTY); - blockConnections.add(new Pair<String, String>(getParentObject().getName(), name)); + blockConnections.add(new Pair<>(getParentObject().getName(), name)); return getParentObject(); } }; @@ -365,7 +363,7 @@ } }; // <graph> - private HandoverElementHandler<InputGraph> edgesHandler = new HandoverElementHandler<InputGraph>(EDGES_ELEMENT); + private HandoverElementHandler<InputGraph> edgesHandler = new HandoverElementHandler<>(EDGES_ELEMENT); // Local class for edge elements private class EdgeElementHandler extends ElementHandler<InputEdge, InputGraph> { @@ -431,14 +429,20 @@ } }; // <properties> - private HandoverElementHandler<Properties.Provider> propertiesHandler = new HandoverElementHandler<Properties.Provider>(PROPERTIES_ELEMENT); + private HandoverElementHandler<Properties.Provider> propertiesHandler = new HandoverElementHandler<>(PROPERTIES_ELEMENT); // <properties> private HandoverElementHandler<Group> groupPropertiesHandler = new HandoverElementHandler<Group>(PROPERTIES_ELEMENT) { @Override public void end(String text) throws SAXException { - if (groupCallback != null) { - groupCallback.started(getParentObject()); + if (groupCallback != null && getParentObject().getParent() instanceof GraphDocument) { + final Group group = getParentObject(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + groupCallback.started(group); + } + }); } } }; @@ -469,8 +473,8 @@ topHandler.addChild(groupHandler); groupHandler.addChild(methodHandler); - groupHandler.addChild(assemblyHandler); groupHandler.addChild(graphHandler); + groupHandler.addChild(groupHandler); methodHandler.addChild(inlinedHandler); methodHandler.addChild(bytecodesHandler); @@ -506,7 +510,7 @@ } // Returns a new GraphDocument object deserialized from an XML input source. - public synchronized GraphDocument parse(InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { + public GraphDocument parse(InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { XMLReader reader = createReader(); reader.setContentHandler(new XMLParser(xmlDocument, monitor)); @@ -516,7 +520,7 @@ throw new SAXException(ex); } - return topHandler.getObject(); + return graphDocument; } private XMLReader createReader() throws SAXException {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,16 +23,7 @@ */ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputBytecode; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputMethod; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.Property; +import com.sun.hotspot.igv.data.*; import java.io.IOException; import java.io.InputStream; import java.io.Writer; @@ -68,8 +59,12 @@ private void export(XMLWriter xmlWriter, GraphDocument document) throws IOException { xmlWriter.startTag(Parser.ROOT_ELEMENT); xmlWriter.writeProperties(document.getProperties()); - for (Group g : document.getGroups()) { - export(xmlWriter, g); + for (FolderElement e : document.getElements()) { + if (e instanceof Group) { + export(xmlWriter, (Group) e); + } else if (e instanceof InputGraph) { + export(xmlWriter, (InputGraph)e, null, false); + } } xmlWriter.endTag(); @@ -96,9 +91,14 @@ } InputGraph previous = null; - for (InputGraph graph : g.getGraphs()) { - export(writer, graph, previous, true); - previous = graph; + for (FolderElement e : g.getElements()) { + if (e instanceof InputGraph) { + InputGraph graph = (InputGraph) e; + export(writer, graph, previous, true); + previous = graph; + } else if (e instanceof Group) { + export(writer, (Group) e); + } } } @@ -111,8 +111,8 @@ writer.writeProperties(graph.getProperties()); writer.startTag(Parser.NODES_ELEMENT); - Set<InputNode> removed = new HashSet<InputNode>(); - Set<InputNode> equal = new HashSet<InputNode>(); + Set<InputNode> removed = new HashSet<>(); + Set<InputNode> equal = new HashSet<>(); if (previous != null) { for (InputNode n : previous.getNodes()) { @@ -143,8 +143,8 @@ writer.endTag(); writer.startTag(Parser.EDGES_ELEMENT); - Set<InputEdge> removedEdges = new HashSet<InputEdge>(); - Set<InputEdge> equalEdges = new HashSet<InputEdge>(); + Set<InputEdge> removedEdges = new HashSet<>(); + Set<InputEdge> equalEdges = new HashSet<>(); if (previous != null) { for (InputEdge e : previous.getEdges()) {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java Sun Jan 29 11:40:04 2012 +0100 @@ -84,24 +84,25 @@ public static class ElementHandler<T, P> { private String name; - private T object; + private Stack<T> object = new Stack<>(); private Attributes attr; private StringBuilder currentText; private ParseMonitor monitor; private HashMap<String, ElementHandler<?, ? super T>> hashtable; private boolean needsText; - private ElementHandler<P, ?> parentElement; + private Stack<ElementHandler<P, ?>> parentElement = new Stack<>(); + private Stack<P> parentObject = new Stack<>(); public ElementHandler(String name) { this(name, false); } public ElementHandler<P, ?> getParentElement() { - return parentElement; + return parentElement.peek(); } public P getParentObject() { - return getParentElement().getObject(); + return parentObject.peek(); } protected boolean needsText() { @@ -109,7 +110,7 @@ } public ElementHandler(String name, boolean needsText) { - this.hashtable = new HashMap<String, ElementHandler<?, ? super T>>(); + this.hashtable = new HashMap<>(); this.name = name; this.needsText = needsText; } @@ -132,7 +133,7 @@ } public T getObject() { - return object; + return object.size() == 0 ? null : object.peek(); } public String readAttribute(String name) { @@ -160,8 +161,9 @@ this.currentText = new StringBuilder(); this.attr = attr; this.monitor = monitor; - this.parentElement = parentElement; - object = start(); + this.parentElement.push(parentElement); + parentObject.push(parentElement.getObject()); + object.push(start()); } protected T start() throws SAXException { @@ -174,6 +176,9 @@ public void endElement() throws SAXException { end(currentText.toString()); + object.pop(); + parentElement.pop(); + parentObject.pop(); } protected void text(char[] c, int start, int length) { @@ -185,30 +190,36 @@ private ParseMonitor monitor; public XMLParser(TopElementHandler rootHandler, ParseMonitor monitor) { - this.stack = new Stack<ElementHandler>(); + this.stack = new Stack<>(); this.monitor = monitor; this.stack.push(rootHandler); } + @Override public void setDocumentLocator(Locator locator) { if (monitor != null) { monitor.setState("Starting parsing"); } } + @Override public void startDocument() throws SAXException { } + @Override public void endDocument() throws SAXException { } + @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { } + @Override public void endPrefixMapping(String prefix) throws SAXException { } @SuppressWarnings("unchecked") + @Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { assert !stack.isEmpty(); @@ -225,6 +236,7 @@ stack.push(null); } + @Override public void endElement(String uri, String localName, String qName) throws SAXException { ElementHandler handler = stack.pop(); if (handler != null) { @@ -232,6 +244,7 @@ } } + @Override public void characters(char[] ch, int start, int length) throws SAXException { assert !stack.isEmpty(); @@ -243,12 +256,15 @@ } } + @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { } + @Override public void processingInstruction(String target, String data) throws SAXException { } + @Override public void skippedEntity(String name) throws SAXException { } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java Sun Jan 29 11:40:04 2012 +0100 @@ -41,7 +41,7 @@ public XMLWriter(Writer inner) { this.inner = inner; - elementStack = new Stack<String>(); + elementStack = new Stack<>(); } @Override @@ -49,6 +49,7 @@ write(arr, 0, arr.length); } + @Override public void write(char[] cbuf, int off, int len) throws IOException { for (int i = off; i < off + len; i++) { char c = cbuf[i]; @@ -64,10 +65,12 @@ } } + @Override public void flush() throws IOException { inner.flush(); } + @Override public void close() throws IOException { inner.close(); }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.data.services; - -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.Pair; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public interface GroupOrganizer { - - public String getName(); - - public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups); -}
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.data.services; - -import java.awt.Component; - -/** - * - * @author Thomas Wuerthinger - */ -public interface GroupReceiver { - - public Component init(GroupCallback callback); -}
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,12 +24,8 @@ package com.sun.hotspot.igv.data; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import org.junit.*; /** * @@ -62,10 +58,11 @@ @Test public void testBase() { - ChangedEvent<Integer> e = new ChangedEvent<Integer>(5); + ChangedEvent<Integer> e = new ChangedEvent<>(5); final int[] fireCount = new int[1]; e.addListener(new ChangedListener<Integer>() { + @Override public void changed(Integer s) { assertEquals(s.intValue(), 5); fireCount[0]++;
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,12 +24,8 @@ package com.sun.hotspot.igv.data; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import static org.junit.Assert.*; +import org.junit.*; /** *
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -26,12 +26,8 @@ import java.util.Arrays; import java.util.HashSet; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import org.junit.*; /** * @@ -64,9 +60,11 @@ */ @Test public void testGetAllNodes() { - final Group g = new Group(); - final InputGraph graph1 = g.addGraph("1"); - final InputGraph graph2 = g.addGraph("2"); + final Group g = new Group(null); + final InputGraph graph1 = new InputGraph("1"); + final InputGraph graph2 = new InputGraph("2"); + g.addElement(graph1); + g.addElement(graph2); graph1.addNode(new InputNode(1)); graph1.addNode(new InputNode(2)); graph2.addNode(new InputNode(2));
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -27,12 +27,9 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.junit.*; /** * @@ -68,11 +65,13 @@ @BeforeClass public static void setUpClass() throws Exception { - Group group = new Group(); + Group group = new Group(null); - emptyGraph = group.addGraph("emptyGraph"); - - referenceGraph = group.addGraph("referenceGraph"); + emptyGraph = new InputGraph("emptyGraph"); + group.addElement(emptyGraph); + + referenceGraph = new InputGraph("referenceGraph"); + group.addElement(referenceGraph); referenceGraph.addNode(N1); referenceGraph.addNode(N2); referenceGraph.addNode(N3); @@ -104,13 +103,16 @@ @Test public void testEquals() { - Group parentA = new Group(); - InputGraph a = parentA.addGraph("graph"); + Group parentA = new Group(null); + InputGraph a = new InputGraph("graph"); + parentA.addElement(a); - Group parentB = new Group(); - InputGraph b = parentB.addGraph("graph"); + Group parentB = new Group(null); + InputGraph b = new InputGraph("graph"); + parentB.addElement(b); - InputGraph c = parentB.addGraph("graph"); + InputGraph c = new InputGraph("graph"); + parentB.addElement(b); Util.assertGraphEquals(a, b); Util.assertGraphEquals(b, c); @@ -127,7 +129,7 @@ */ @Test public void testFindRootNodes() { - assertTrue(emptyGraph.findRootNodes().size() == 0); + assertTrue(emptyGraph.findRootNodes().isEmpty()); List<InputNode> result = referenceGraph.findRootNodes(); assertTrue(result.size() == 2); @@ -140,7 +142,7 @@ */ @Test public void testFindAllOutgoingEdges() { - assertTrue(emptyGraph.findAllOutgoingEdges().size() == 0); + assertTrue(emptyGraph.findAllOutgoingEdges().isEmpty()); Map<InputNode, List<InputEdge>> result = referenceGraph.findAllOutgoingEdges(); assertTrue(result.size() == 5); @@ -156,7 +158,7 @@ */ @Test public void testFindAllIngoingEdges() { - assertTrue(emptyGraph.findAllIngoingEdges().size() == 0); + assertTrue(emptyGraph.findAllIngoingEdges().isEmpty()); Map<InputNode, List<InputEdge>> result = referenceGraph.findAllIngoingEdges(); assertTrue(result.size() == 5); @@ -172,7 +174,7 @@ */ @Test public void testFindOutgoingEdges() { - assertTrue(emptyGraph.findOutgoingEdges(new InputNode(1)).size() == 0); + assertTrue(emptyGraph.findOutgoingEdges(new InputNode(1)).isEmpty()); assertEquals(referenceGraph.findOutgoingEdges(N1), Arrays.asList(E12, E13)); assertEquals(referenceGraph.findOutgoingEdges(N2), Arrays.asList(E24)); @@ -186,13 +188,16 @@ */ @Test public void testGetNextPrev() { - final Group group = new Group(); + final Group group = new Group(null); - final InputGraph a = group.addGraph("a"); + final InputGraph a = new InputGraph("a"); - final InputGraph b = group.addGraph("b"); + final InputGraph b = new InputGraph("b"); - final InputGraph c = group.addGraph("c"); + final InputGraph c = new InputGraph("c"); + group.addElement(a); + group.addElement(b); + group.addElement(c); assertEquals(null, a.getPrev()); assertEquals(b, a.getNext());
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,13 +24,10 @@ package com.sun.hotspot.igv.data; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; +import org.junit.*; /** * @@ -72,7 +69,7 @@ "7 iconst_0\n" + "8 ireturn"; - final Group g = new Group(); + final Group g = new Group(null); InputMethod m = new InputMethod(g, "name", "shortName", -1); m.setBytecodes(input);
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,12 +25,8 @@ package com.sun.hotspot.igv.data; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import static org.junit.Assert.*; +import org.junit.*; /** *
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -106,12 +106,14 @@ PropertyMatcher matcher = new PropertyMatcher() { + @Override public String getName() { assertFalse(called[0]); called[0] = true; return n; } + @Override public boolean match(String value) { assertTrue(v.equals(value)); return true; @@ -129,12 +131,14 @@ called[0] = false; PropertyMatcher matcher2 = new PropertyMatcher() { + @Override public String getName() { assertFalse(called[0]); called[0] = true; return n; } + @Override public boolean match(String value) { return false; } @@ -246,7 +250,7 @@ * Test property selector */ public void testPropertySelector() { - final Collection<Properties.Entity> c = new ArrayList<Properties.Entity>(); + final Collection<Properties.Entity> c = new ArrayList<>(); final Properties.Entity e1 = new Properties.Entity(); e1.getProperties().setProperty("p1", "1"); @@ -264,7 +268,7 @@ e3.getProperties().setProperty("p4", "4"); c.add(e3); - final PropertySelector<Properties.Entity> sel = new PropertySelector<Properties.Entity>(c); + final PropertySelector<Properties.Entity> sel = new PropertySelector<>(c); final StringPropertyMatcher matcher1 = new StringPropertyMatcher("p2", "2"); assertTrue(sel.selectMultiple(matcher1).size() == 2);
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,12 +25,8 @@ package com.sun.hotspot.igv.data; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import static org.junit.Assert.*; +import org.junit.*; /** *
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,19 +24,10 @@ package com.sun.hotspot.igv.data; -import java.lang.Integer; import java.util.Arrays; -import java.util.HashSet; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertEquals; +import org.junit.*; /** * @@ -75,14 +66,14 @@ s.addSourceNode(N1); assertEquals(s.getSourceNodes(), Arrays.asList(N1)); - assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<Integer>(Arrays.asList(1))); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1))); s.addSourceNode(N2); assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); - assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<Integer>(Arrays.asList(1, 2))); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1, 2))); s.addSourceNode(N1); assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); - assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<Integer>(Arrays.asList(1, 2))); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1, 2))); } } \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java Sun Jan 29 11:40:04 2012 +0100 @@ -45,16 +45,19 @@ public static void assertGraphDocumentEquals(GraphDocument a, GraphDocument b) { - if (a.getGroups().size() != b.getGroups().size()) { + if (a.getElements().size() != b.getElements().size()) { fail(); } int z = 0; - for (Group g : b.getGroups()) { + for (FolderElement e : b.getElements()) { - Group thisG = a.getGroups().get(z); - assertGroupEquals(thisG, g); + if (e instanceof Group) { + Group g = (Group) e; + Group thisG = (Group) a.getElements().get(z); + assertGroupEquals(thisG, g); z++; + } } } @@ -90,16 +93,6 @@ fail(); } } - - if (a.getAssembly() == null || b.getAssembly() == null) { - if (a.getAssembly() != b.getAssembly()) { - fail(); - } - } else { - if (!a.getAssembly().equals(b.getAssembly())) { - fail(); - } - } } public static void assertGraphNotEquals(InputGraph a, InputGraph b) { @@ -129,7 +122,5 @@ for (InputNode n : a.getNodes()) { assertEquals(a.getBlock(n), b.getBlock(n)); } - - assertEquals(a.getSourceGraphs(), b.getSourceGraphs()); } }
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,22 +25,12 @@ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputMethod; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Util; +import com.sun.hotspot.igv.data.*; import java.io.CharArrayWriter; import java.io.StringReader; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import org.junit.*; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -104,15 +94,16 @@ test(doc); - final Group group1 = new Group(); - doc.addGroup(group1); + final Group group1 = new Group(doc); + doc.addElement(group1); test(doc); - final Group group2 = new Group(); - doc.addGroup(group2); + final Group group2 = new Group(doc); + doc.addElement(group2); test(doc); - final InputGraph graph = group1.addGraph(""); + final InputGraph graph = new InputGraph(""); + group1.addElement(graph); test(doc); graph.addNode(new InputNode(0)); @@ -154,13 +145,13 @@ final GraphDocument document2 = new GraphDocument(); doc.addGraphDocument(document2); test(doc); - assertTrue(doc.getGroups().size() == 2); + assertTrue(doc.getElements().size() == 2); - final Group group3 = new Group(); - document2.addGroup(group3); + final Group group3 = new Group(document2); + document2.addElement(group3); doc.addGraphDocument(document2); - assertTrue(doc.getGroups().size() == 3); - assertTrue(document2.getGroups().size() == 0); + assertTrue(doc.getElements().size() == 3); + assertTrue(document2.getElements().size() == 0); doc.clear(); test(doc); @@ -170,10 +161,11 @@ @Test public void testSimpleExport() { GraphDocument document = new GraphDocument(); - Group g = new Group(); - document.addGroup(g); + Group g = new Group(document); + document.addElement(g); - InputGraph graph = g.addGraph("TestGraph"); + InputGraph graph = new InputGraph("TestGraph"); + g.addElement(graph); graph.getProperties().setProperty("testName", "testValue"); InputNode n1 = new InputNode(0); @@ -192,10 +184,11 @@ public void testComplexExport() { GraphDocument document = new GraphDocument(); - Group g = new Group(); - document.addGroup(g); + Group g = new Group(document); + document.addElement(g); - InputGraph graph = g.addGraph("TestGraph"); + InputGraph graph = new InputGraph("TestGraph"); + g.addElement(graph); graph.getProperties().setProperty("testName", "testValue"); InputNode n1 = new InputNode(0); @@ -207,7 +200,8 @@ graph.addEdge(e1); graph.addEdge(e2); - InputGraph graph2 = g.addGraph("TestGraph2"); + InputGraph graph2 = new InputGraph("TestGraph2"); + g.addElement(graph2); graph2.addNode(n1); InputNode n3 = new InputNode(2); graph2.addNode(n3);
--- a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,21 +24,10 @@ */ package com.sun.hotspot.igv.difference; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputBlockEdge; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.Property; +import com.sun.hotspot.igv.data.*; import com.sun.hotspot.igv.data.services.Scheduler; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import org.openide.util.Lookup; /** @@ -66,14 +55,14 @@ } private static InputGraph createDiffSameGroup(InputGraph a, InputGraph b) { - Map<Integer, InputNode> keyMapB = new HashMap<Integer, InputNode>(b.getNodes().size()); + Map<Integer, InputNode> keyMapB = new HashMap<>(b.getNodes().size()); for (InputNode n : b.getNodes()) { Integer key = n.getId(); assert !keyMapB.containsKey(key); keyMapB.put(key, n); } - Set<NodePair> pairs = new HashSet<NodePair>(); + Set<NodePair> pairs = new HashSet<>(); for (InputNode n : a.getNodes()) { Integer key = n.getId(); @@ -101,9 +90,8 @@ ensureScheduled(a); ensureScheduled(b); - Group g = new Group(); + Group g = new Group(null); g.setMethod(a.getGroup().getMethod()); - g.setAssembly(a.getGroup().getAssembly()); if (a.getGroup() == b.getGroup()) { g.getProperties().add(a.getGroup().getProperties()); } else { @@ -117,9 +105,10 @@ } } g.getProperties().setProperty("name", "Difference"); - InputGraph graph = g.addGraph(a.getName() + ", " + b.getName(), new Pair<InputGraph, InputGraph>(a, b)); + InputGraph graph = new InputGraph(a.getName() + ", " + b.getName()); + g.addElement(graph); - Map<InputBlock, InputBlock> blocksMap = new HashMap<InputBlock, InputBlock>(); + Map<InputBlock, InputBlock> blocksMap = new HashMap<>(); for (InputBlock blk : a.getBlocks()) { InputBlock diffblk = graph.addBlock(blk.getName()); blocksMap.put(blk, diffblk); @@ -133,14 +122,14 @@ } // Difference between block edges - Set<Pair<String, String>> aEdges = new HashSet<Pair<String, String>>(); + Set<Pair<String, String>> aEdges = new HashSet<>(); for (InputBlockEdge edge : a.getBlockEdges()) { - aEdges.add(new Pair<String, String>(edge.getFrom().getName(), edge.getTo().getName())); + aEdges.add(new Pair<>(edge.getFrom().getName(), edge.getTo().getName())); } for (InputBlockEdge bEdge : b.getBlockEdges()) { InputBlock from = bEdge.getFrom(); InputBlock to = bEdge.getTo(); - Pair<String, String> pair = new Pair<String, String>(from.getName(), to.getName()); + Pair<String, String> pair = new Pair<>(from.getName(), to.getName()); if (aEdges.contains(pair)) { // same graph.addBlockEdge(blocksMap.get(from), blocksMap.get(to)); @@ -159,10 +148,10 @@ edge.setState(InputBlockEdge.State.DELETED); } - Set<InputNode> nodesA = new HashSet<InputNode>(a.getNodes()); - Set<InputNode> nodesB = new HashSet<InputNode>(b.getNodes()); + Set<InputNode> nodesA = new HashSet<>(a.getNodes()); + Set<InputNode> nodesB = new HashSet<>(b.getNodes()); - Map<InputNode, InputNode> inputNodeMap = new HashMap<InputNode, InputNode>(pairs.size()); + Map<InputNode, InputNode> inputNodeMap = new HashMap<>(pairs.size()); for (NodePair p : pairs) { InputNode n = p.getLeft(); assert nodesA.contains(n); @@ -209,7 +198,7 @@ Collection<InputEdge> edgesA = a.getEdges(); Collection<InputEdge> edgesB = b.getEdges(); - Set<InputEdge> newEdges = new HashSet<InputEdge>(); + Set<InputEdge> newEdges = new HashSet<>(); for (InputEdge e : edgesA) { int from = e.getFrom(); @@ -291,9 +280,9 @@ private static InputGraph createDiff(InputGraph a, InputGraph b) { - Set<InputNode> matched = new HashSet<InputNode>(); + Set<InputNode> matched = new HashSet<>(); - Set<NodePair> pairs = new HashSet<NodePair>(); + Set<NodePair> pairs = new HashSet<>(); for (InputNode n : a.getNodes()) { String s = n.getProperties().get(MAIN_PROPERTY); if (s == null) { @@ -312,7 +301,7 @@ } } - Set<NodePair> selectedPairs = new HashSet<NodePair>(); + Set<NodePair> selectedPairs = new HashSet<>(); while (pairs.size() > 0) { double min = Double.MAX_VALUE; @@ -330,7 +319,7 @@ } else { selectedPairs.add(minPair); - Set<NodePair> toRemove = new HashSet<NodePair>(); + Set<NodePair> toRemove = new HashSet<>(); for (NodePair p : pairs) { if (p.getLeft() == minPair.getLeft() || p.getRight() == minPair.getRight()) { toRemove.add(p);
--- a/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -42,14 +42,17 @@ properties = new Properties(); } + @Override public Properties getProperties() { return properties; } + @Override public OpenCookie getEditor() { return null; } + @Override public ChangedEvent<Filter> getChangedEvent() { return changedEvent; }
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,13 +23,9 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; +import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.graph.Connection.ConnectionStyle; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; -import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.graph.*; import java.awt.Color; import java.util.ArrayList; import java.util.List; @@ -45,16 +41,18 @@ public ColorFilter(String name) { this.name = name; - colorRules = new ArrayList<ColorRule>(); + colorRules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures()); + Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<>(diagram.getFigures()); for (ColorRule rule : colorRules) { if (rule.getSelector() != null) { List<Figure> figures = rule.getSelector().selected(diagram);
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,13 +23,9 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Properties.PropertyMatcher; +import com.sun.hotspot.igv.graph.*; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -46,23 +42,25 @@ public CombineFilter(String name) { this.name = name; - rules = new ArrayList<CombineRule>(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures()); + Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<>(diagram.getFigures()); for (CombineRule r : rules) { List<Figure> list = selector.selectMultiple(r.getFirstMatcher()); - Set<Figure> figuresToRemove = new HashSet<Figure>(); + Set<Figure> figuresToRemove = new HashSet<>(); for (Figure f : list) { - List<Figure> successors = new ArrayList<Figure>(f.getSuccessors()); + List<Figure> successors = new ArrayList<>(f.getSuccessors()); if (r.isReversed()) { if (successors.size() == 1) { Figure succ = successors.get(0);
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ConnectionFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ConnectionFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,12 +23,8 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.graph.*; import java.awt.Color; import java.util.ArrayList; import java.util.List; @@ -44,16 +40,18 @@ public ConnectionFilter(String name) { this.name = name; - connectionStyleRules = new ArrayList<ConnectionStyleRule>(); + connectionStyleRules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures()); + Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<>(diagram.getFigures()); for (ConnectionStyleRule rule : connectionStyleRules) { List<Figure> figures = null; if (rule.getSelector() != null) {
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -29,18 +29,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; +import javax.script.*; import org.openide.cookies.OpenCookie; -import org.openide.filesystems.Repository; -import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; -import org.openide.util.Lookup; /** * @@ -49,7 +44,6 @@ public class CustomFilter extends AbstractFilter { public static final String JAVASCRIPT_HELPER_ID = "JavaScriptHelper"; - private static ScriptEngineAbstraction engine; private String code; private String name; @@ -59,6 +53,7 @@ getProperties().setProperty("name", name); } + @Override public String getName() { return name; } @@ -81,6 +76,7 @@ public OpenCookie getEditor() { return new OpenCookie() { + @Override public void open() { openInEditor(); } @@ -100,29 +96,6 @@ return getName(); } - public static ScriptEngineAbstraction getEngine() { - if (engine == null) { - - Collection<? extends ScriptEngineAbstraction> list = Lookup.getDefault().lookupAll(ScriptEngineAbstraction.class); - ScriptEngineAbstraction chosen = null; - for (ScriptEngineAbstraction s : list) { - if (s.initialize(getJsHelperText())) { - chosen = s; - } - } - - if (chosen == null) { - NotifyDescriptor message = new NotifyDescriptor.Message("Could not find a scripting engine. Please make sure that the Rhino scripting engine is available. Otherwise filter cannot be used.", NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notifyLater(message); - chosen = new NullScriptEngine(); - } - - engine = chosen; - } - - return engine; - } - private static String getJsHelperText() { InputStream is = null; StringBuilder sb = new StringBuilder("importPackage(Packages.com.sun.hotspot.igv.filter);importPackage(Packages.com.sun.hotspot.igv.graph);importPackage(Packages.com.sun.hotspot.igv.data);importPackage(Packages.com.sun.hotspot.igv.util);importPackage(java.awt);"); @@ -148,7 +121,18 @@ return sb.toString(); } + @Override public void apply(Diagram d) { - getEngine().execute(d, code); + try { + ScriptEngineManager sem = new ScriptEngineManager(); + ScriptEngine e = sem.getEngineByName("ECMAScript"); + e.eval(getJsHelperText()); + Bindings b = e.getContext().getBindings(ScriptContext.ENGINE_SCOPE); + b.put("graph", d); + b.put("IO", System.out); + e.eval(code, b); + } catch (ScriptException ex) { + Exceptions.printStackTrace(ex); + } } }
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EdgeColorIndexFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EdgeColorIndexFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,12 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Slot; +import com.sun.hotspot.igv.graph.*; import java.awt.Color; import java.util.List; @@ -48,10 +43,12 @@ this.colors = color; } + @Override public String getName() { return "Edge Color Index Filter"; } + @Override public void apply(Diagram d) { List<Figure> figures = d.getFigures(); for (Figure f : figures) {
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Filter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Filter.java Sun Jan 29 11:40:04 2012 +0100 @@ -41,5 +41,6 @@ OpenCookie getEditor(); + @Override ChangedEvent<Filter> getChangedEvent(); }
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,10 +23,10 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Diagram; import com.sun.hotspot.igv.data.ChangedEvent; import com.sun.hotspot.igv.data.ChangedEventProvider; import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.graph.Diagram; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -41,21 +41,23 @@ private transient ChangedEvent<FilterChain> changedEvent; private ChangedListener<Filter> changedListener = new ChangedListener<Filter>() { + @Override public void changed(Filter source) { changedEvent.fire(); } }; public FilterChain() { - filters = new ArrayList<Filter>(); - changedEvent = new ChangedEvent<FilterChain>(this); + filters = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); } public FilterChain(FilterChain f) { - this.filters = new ArrayList<Filter>(f.filters); - changedEvent = new ChangedEvent<FilterChain>(this); + this.filters = new ArrayList<>(f.filters); + changedEvent = new ChangedEvent<>(this); } + @Override public ChangedEvent<FilterChain> getChangedEvent() { return changedEvent; } @@ -72,7 +74,7 @@ } public void apply(Diagram d, FilterChain sequence) { - List<Filter> applied = new ArrayList<Filter>(); + List<Filter> applied = new ArrayList<>(); for (Filter f : sequence.getFilters()) { if (filters.contains(f)) { f.apply(d);
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterSetting.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterSetting.java Sun Jan 29 11:40:04 2012 +0100 @@ -42,7 +42,7 @@ public FilterSetting(String name) { this.name = name; - filters = new HashSet<Filter>(); + filters = new HashSet<>(); } public Set<Filter> getFilters() {
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/GradientColorFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/GradientColorFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,11 +25,7 @@ import com.sun.hotspot.igv.graph.Diagram; import com.sun.hotspot.igv.graph.Figure; -import java.awt.Color; -import java.awt.LinearGradientPaint; -import java.awt.PaintContext; -import java.awt.Rectangle; -import java.awt.RenderingHints; +import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.image.Raster; import java.util.List; @@ -53,10 +49,12 @@ private int shadeCount = 8; private String mode = LINEAR; + @Override public String getName() { return "Gradient Color Filter"; } + @Override public void apply(Diagram d) { boolean logarithmic = mode.equalsIgnoreCase(LOGARITHMIC); if (!logarithmic && !mode.equalsIgnoreCase(LINEAR)) {
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/NullScriptEngine.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.filter; - -import com.sun.hotspot.igv.graph.Diagram; - -/** - * - * @author Thomas Wuerthinger - */ -public class NullScriptEngine implements ScriptEngineAbstraction { - - public boolean initialize(String jsHelperText) { - return true; - } - - public void execute(Diagram d, String code) { - } -}
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -42,17 +42,19 @@ public RemoveFilter(String name) { this.name = name; - rules = new ArrayList<RemoveRule>(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { for (RemoveRule r : rules) { List<Figure> selected = r.getSelector().selected(diagram); - Set<Figure> toRemove = new HashSet<Figure>(selected); + Set<Figure> toRemove = new HashSet<>(selected); if (r.getRemoveOrphans()) { boolean changed;
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,12 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; +import com.sun.hotspot.igv.graph.*; import java.util.ArrayList; import java.util.List; @@ -43,13 +38,15 @@ public RemoveInputsFilter(String name) { this.name = name; - rules = new ArrayList<RemoveInputsRule>(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { for (RemoveInputsRule r : rules) { @@ -57,7 +54,7 @@ List<Figure> list = r.getSelector().selected(diagram); for (Figure f : list) { int z = 0; - List<InputSlot> last = new ArrayList<InputSlot>(); + List<InputSlot> last = new ArrayList<>(); for (InputSlot is : f.getInputSlots()) { if (z >= r.getStartingIndex() && z <= r.getEndIndex() && is.getConnections().size() > 0) { StringBuilder sb = new StringBuilder();
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; +import com.sun.hotspot.igv.graph.*; import java.util.ArrayList; import java.util.List; @@ -44,17 +40,19 @@ this.name = name; } + @Override public String getName() { return name; } + @Override public void apply(Diagram d) { for (Figure f : d.getFigures()) { for (InputSlot is : f.getInputSlots()) { - List<Connection> toRemove = new ArrayList<Connection>(); + List<Connection> toRemove = new ArrayList<>(); for (Connection c : is.getConnections()) { if (c.getOutputSlot().getFigure() == f) {
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ScriptEngineAbstraction.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.filter; - -import com.sun.hotspot.igv.graph.Diagram; - -/** - * - * @author Thomas Wuerthinger - */ -public interface ScriptEngineAbstraction { - - public boolean initialize(String jsHelperText); - - public void execute(Diagram d, String code); -}
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,12 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; +import com.sun.hotspot.igv.graph.*; import java.util.List; /** @@ -47,10 +42,12 @@ this.propertyName = propertyName; } + @Override public String getName() { return name; } + @Override public void apply(Diagram d) { List<Figure> list = selector.selected(d);
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/UnconnectedSlotFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/UnconnectedSlotFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Slot; +import com.sun.hotspot.igv.graph.*; import java.util.ArrayList; import java.util.List; @@ -44,10 +40,12 @@ this.removeOutputs = outputs; } + @Override public String getName() { return "Unconnected Slot Filter"; } + @Override public void apply(Diagram d) { if (!removeInputs && !removeOutputs) { return; @@ -55,7 +53,7 @@ List<Figure> figures = d.getFigures(); for (Figure f : figures) { - List<Slot> remove = new ArrayList<Slot>(); + List<Slot> remove = new ArrayList<>(); if (removeInputs) { for (InputSlot is : f.getInputSlots()) { if (is.getConnections().isEmpty()) {
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java Sun Jan 29 11:40:04 2012 +0100 @@ -44,8 +44,8 @@ } @Override - protected JList createList() { - JList tmpList = super.createList(); + protected JList<Object> createList() { + JList<Object> tmpList = super.createList(); tmpList.setCellRenderer(new CheckRenderer(tmpList)); return tmpList; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,7 +40,7 @@ public CheckNode(Children c, Lookup lookup) { super(c, lookup); - selectionChangedEvent = new ChangedEvent<CheckNode>(this); + selectionChangedEvent = new ChangedEvent<>(this); selected = false; enabled = true; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.filterwindow; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; +import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JCheckBox; @@ -37,12 +33,12 @@ /** * @author Thomas Wuerthinger */ -public class CheckRenderer extends JCheckBox implements ListCellRenderer { +public class CheckRenderer extends JCheckBox implements ListCellRenderer<Object> { - private JList list; + private JList<Object> list; private Color startBackground; - public CheckRenderer(final JList list) { + public CheckRenderer(final JList<Object> list) { this.list = list; list.addMouseListener( new MouseAdapter() { @@ -65,7 +61,8 @@ startBackground = this.getBackground(); } - public Component getListCellRendererComponent(final JList list, Object value, final int index, boolean isSelected, boolean cellHasFocus) { + @Override + public Component getListCellRendererComponent(final JList<? extends Object> list, Object value, final int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index); this.setSelected(node.isSelected());
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterChainProviderImplementation.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterChainProviderImplementation.java Sun Jan 29 11:40:04 2012 +0100 @@ -32,10 +32,12 @@ */ public class FilterChainProviderImplementation implements FilterChainProvider { + @Override public FilterChain getFilterChain() { return FilterTopComponent.findInstance().getFilterChain(); } + @Override public FilterChain getSequence() { return FilterTopComponent.findInstance().getSequence(); }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,12 +23,12 @@ */ package com.sun.hotspot.igv.filterwindow; +import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.filter.Filter; +import com.sun.hotspot.igv.filter.FilterChain; import com.sun.hotspot.igv.filterwindow.actions.MoveFilterDownAction; import com.sun.hotspot.igv.filterwindow.actions.MoveFilterUpAction; import com.sun.hotspot.igv.filterwindow.actions.RemoveFilterAction; -import com.sun.hotspot.igv.filter.Filter; -import com.sun.hotspot.igv.filter.FilterChain; -import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.util.PropertiesSheet; import javax.swing.Action; import org.openide.actions.OpenAction; @@ -48,7 +48,7 @@ public class FilterNode extends CheckNode implements LookupListener, ChangedListener<FilterTopComponent> { private Filter filter; - private Lookup.Result result; + private Lookup.Result<FilterChain> result; public FilterNode(Filter filter) { this(filter, new InstanceContent()); @@ -62,6 +62,7 @@ this.filter = filter; filter.getChangedEvent().addListener(new ChangedListener<Filter>() { + @Override public void changed(Filter source) { update(); } @@ -69,7 +70,7 @@ update(); - Lookup.Template<FilterChain> tpl = new Lookup.Template<FilterChain>(FilterChain.class); + Lookup.Template<FilterChain> tpl = new Lookup.Template<>(FilterChain.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); @@ -104,10 +105,12 @@ return OpenAction.get(OpenAction.class).createContextAwareInstance(Utilities.actionsGlobalContext()); } + @Override public void resultChanged(LookupEvent lookupEvent) { changed(FilterTopComponent.findInstance()); } + @Override public void changed(FilterTopComponent source) { setSelected(source.getFilterChain().containsFilter(filter)); }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form Sun Jan 29 11:40:04 2012 +0100 @@ -4,6 +4,7 @@ <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,66 +23,38 @@ */ package com.sun.hotspot.igv.filterwindow; -import com.sun.hotspot.igv.filterwindow.actions.MoveFilterDownAction; -import com.sun.hotspot.igv.filterwindow.actions.MoveFilterUpAction; -import com.sun.hotspot.igv.filterwindow.actions.NewFilterAction; -import com.sun.hotspot.igv.filterwindow.actions.RemoveFilterAction; -import com.sun.hotspot.igv.filterwindow.actions.RemoveFilterSettingsAction; -import com.sun.hotspot.igv.filterwindow.actions.SaveFilterSettingsAction; +import com.sun.hotspot.igv.data.ChangedEvent; +import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.filter.CustomFilter; import com.sun.hotspot.igv.filter.Filter; import com.sun.hotspot.igv.filter.FilterChain; import com.sun.hotspot.igv.filter.FilterSetting; -import com.sun.hotspot.igv.data.ChangedEvent; -import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.filterwindow.actions.*; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Serializable; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.io.*; +import java.util.*; import javax.swing.JComboBox; import javax.swing.UIManager; import javax.swing.border.Border; import org.openide.DialogDisplayer; import org.openide.ErrorManager; import org.openide.NotifyDescriptor; +import org.openide.awt.Toolbar; import org.openide.awt.ToolbarPool; import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerUtils; +import org.openide.filesystems.FileLock; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; -import org.openide.util.Exceptions; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; -import org.openide.awt.Toolbar; -import org.openide.filesystems.FileLock; +import org.openide.util.*; import org.openide.util.actions.SystemAction; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; -import org.openide.filesystems.Repository; -import org.openide.filesystems.FileSystem; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; /** * @@ -99,13 +71,14 @@ private ExplorerManager manager; private FilterChain filterChain; private FilterChain sequence; - private Lookup.Result result; + private Lookup.Result<FilterChain> result; private JComboBox comboBox; private List<FilterSetting> filterSettings; private FilterSetting customFilterSetting = new FilterSetting("-- Custom --"); private ChangedEvent<FilterTopComponent> filterSettingsChangedEvent; private ActionListener comboBoxActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { comboBoxSelectionChanged(); } @@ -141,7 +114,7 @@ if (s != customFilterSetting) { FilterChain chain = getFilterChain(); chain.getChangedEvent().beginAtomic(); - List<Filter> toRemove = new ArrayList<Filter>(); + List<Filter> toRemove = new ArrayList<>(); for (Filter f : chain.getFilters()) { if (!s.containsFilter(f)) { toRemove.add(f); @@ -204,6 +177,7 @@ // Sort alphabetically Collections.sort(filterSettings, new Comparator<FilterSetting>() { + @Override public int compare(FilterSetting o1, FilterSetting o2) { return o1.getName().compareTo(o2.getName()); } @@ -270,8 +244,9 @@ private class FilterChildren extends Children.Keys<Filter> implements ChangedListener<CheckNode> { - private HashMap<Filter, Node> nodeHash = new HashMap<Filter, Node>(); + private HashMap<Filter, Node> nodeHash = new HashMap<>(); + @Override protected Node[] createNodes(Filter filter) { if (nodeHash.containsKey(filter)) { return new Node[]{nodeHash.get(filter)}; @@ -286,6 +261,7 @@ public FilterChildren() { sequence.getChangedEvent().addListener(new ChangedListener<FilterChain>() { + @Override public void changed(FilterChain source) { addNotify(); } @@ -300,6 +276,7 @@ updateSelection(); } + @Override public void changed(CheckNode source) { FilterNode node = (FilterNode) source; Filter f = node.getFilter(); @@ -324,7 +301,7 @@ } private FilterTopComponent() { - filterSettingsChangedEvent = new ChangedEvent<FilterTopComponent>(this); + filterSettingsChangedEvent = new ChangedEvent<>(this); initComponents(); setName(NbBundle.getMessage(FilterTopComponent.class, "CTL_FilterTopComponent")); setToolTipText(NbBundle.getMessage(FilterTopComponent.class, "HINT_FilterTopComponent")); @@ -354,7 +331,7 @@ toolBar.add(MoveFilterDownAction.get(MoveFilterDownAction.class).createContextAwareInstance(this.getLookup())); this.add(view, BorderLayout.CENTER); - filterSettings = new ArrayList<FilterSetting>(); + filterSettings = new ArrayList<>(); updateComboBox(); comboBox.addActionListener(comboBoxActionListener); @@ -394,6 +371,7 @@ filter = cf; } + @Override public void changed(Filter source) { try { if (!fileObject.getName().equals(filter.getName())) { @@ -402,15 +380,14 @@ lock.releaseLock(); FileObject newFileObject = fileObject.getParent().getFileObject(filter.getName()); fileObject = newFileObject; - } FileLock lock = fileObject.lock(); OutputStream os = fileObject.getOutputStream(lock); - Writer w = new OutputStreamWriter(os); - String s = filter.getCode(); - w.write(s); - w.close(); + try (Writer w = new OutputStreamWriter(os)) { + String s = filter.getCode(); + w.write(s); + } lock.releaseLock(); } catch (IOException ex) { @@ -423,10 +400,10 @@ FileObject folder = FileUtil.getConfigRoot().getFileObject(FOLDER_ID); FileObject[] children = folder.getChildren(); - List<CustomFilter> customFilters = new ArrayList<CustomFilter>(); - HashMap<CustomFilter, String> afterMap = new HashMap<CustomFilter, String>(); - Set<CustomFilter> enabledSet = new HashSet<CustomFilter>(); - HashMap<String, CustomFilter> map = new HashMap<String, CustomFilter>(); + List<CustomFilter> customFilters = new ArrayList<>(); + HashMap<CustomFilter, String> afterMap = new HashMap<>(); + Set<CustomFilter> enabledSet = new HashSet<>(); + HashMap<String, CustomFilter> map = new HashMap<>(); for (final FileObject fo : children) { InputStream is = null; @@ -478,7 +455,7 @@ for (int j = 0; j < customFilters.size(); j++) { for (int i = 0; i < customFilters.size(); i++) { - List<CustomFilter> copiedList = new ArrayList<CustomFilter>(customFilters); + List<CustomFilter> copiedList = new ArrayList<>(customFilters); for (CustomFilter cf : copiedList) { String after = afterMap.get(cf); @@ -556,13 +533,14 @@ return PREFERRED_ID; } + @Override public ExplorerManager getExplorerManager() { return manager; } @Override public void componentOpened() { - Lookup.Template<FilterChain> tpl = new Lookup.Template<FilterChain>(FilterChain.class); + Lookup.Template<FilterChain> tpl = new Lookup.Template<>(FilterChain.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); } @@ -573,6 +551,7 @@ result = null; } + @Override public void resultChanged(LookupEvent lookupEvent) { setChain(Utilities.actionsGlobalContext().lookup(FilterChain.class)); }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/FilterAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/FilterAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,7 +23,7 @@ */ package com.sun.hotspot.igv.filterwindow.actions; -import com.sun.hotspot.igv.filterwindow.*; +import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import org.openide.util.NbBundle; @@ -39,6 +39,7 @@ super(NbBundle.getMessage(FilterAction.class, "CTL_FilterAction")); } + @Override public void actionPerformed(ActionEvent evt) { TopComponent win = FilterTopComponent.findInstance(); win.open();
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterDownAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterDownAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,8 +23,8 @@ */ package com.sun.hotspot.igv.filterwindow.actions; +import com.sun.hotspot.igv.filter.Filter; import com.sun.hotspot.igv.filterwindow.FilterTopComponent; -import com.sun.hotspot.igv.filter.Filter; import javax.swing.Action; import org.openide.nodes.Node; import org.openide.util.HelpCtx; @@ -37,6 +37,7 @@ */ public final class MoveFilterDownAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { for (Node n : activatedNodes) { Filter c = n.getLookup().lookup(Filter.class); @@ -44,6 +45,7 @@ } } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } @@ -53,10 +55,12 @@ putValue(Action.SHORT_DESCRIPTION, "Move selected filter downwards"); } + @Override public String getName() { return NbBundle.getMessage(MoveFilterUpAction.class, "CTL_MoveFilterDownAction"); } + @Override protected Class[] cookieClasses() { return new Class[]{ Filter.class @@ -74,6 +78,7 @@ putValue("noIconInMenu", Boolean.TRUE); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterUpAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterUpAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,8 +23,8 @@ */ package com.sun.hotspot.igv.filterwindow.actions; +import com.sun.hotspot.igv.filter.Filter; import com.sun.hotspot.igv.filterwindow.FilterTopComponent; -import com.sun.hotspot.igv.filter.Filter; import javax.swing.Action; import org.openide.nodes.Node; import org.openide.util.HelpCtx; @@ -37,6 +37,7 @@ */ public final class MoveFilterUpAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { for (Node n : activatedNodes) { Filter c = n.getLookup().lookup(Filter.class); @@ -44,6 +45,7 @@ } } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } @@ -52,10 +54,12 @@ putValue(Action.SHORT_DESCRIPTION, "Move selected filter upwards"); } + @Override public String getName() { return NbBundle.getMessage(MoveFilterUpAction.class, "CTL_MoveFilterUpAction"); } + @Override protected Class[] cookieClasses() { return new Class[]{ Filter.class @@ -73,6 +77,7 @@ putValue("noIconInMenu", Boolean.TRUE); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/NewFilterAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/NewFilterAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -39,10 +39,12 @@ putValue(Action.SHORT_DESCRIPTION, "Create new filter"); } + @Override public void performAction() { FilterTopComponent.findInstance().newFilter(); } + @Override public String getName() { return NbBundle.getMessage(SaveFilterSettingsAction.class, "CTL_NewFilterAction"); } @@ -52,6 +54,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,8 +23,8 @@ */ package com.sun.hotspot.igv.filterwindow.actions; +import com.sun.hotspot.igv.filter.Filter; import com.sun.hotspot.igv.filterwindow.FilterTopComponent; -import com.sun.hotspot.igv.filter.Filter; import javax.swing.Action; import javax.swing.JOptionPane; import org.openide.nodes.Node; @@ -39,6 +39,7 @@ */ public final class RemoveFilterAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { Object[] options = {"Yes", "No", @@ -59,10 +60,12 @@ } } + @Override protected int mode() { return CookieAction.MODE_ALL; } + @Override public String getName() { return NbBundle.getMessage(RemoveFilterAction.class, "CTL_RemoveFilterAction"); } @@ -71,6 +74,7 @@ putValue(Action.SHORT_DESCRIPTION, "Remove selected filter"); } + @Override protected Class[] cookieClasses() { return new Class[]{ Filter.class @@ -88,6 +92,7 @@ return "com/sun/hotspot/igv/filterwindow/images/minus.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterSettingsAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterSettingsAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -35,10 +35,12 @@ */ public final class RemoveFilterSettingsAction extends CallableSystemAction { + @Override public void performAction() { FilterTopComponent.findInstance().removeFilterSetting(); } + @Override public String getName() { return NbBundle.getMessage(RemoveFilterSettingsAction.class, "CTL_RemoveFilterSettingsAction"); } @@ -52,6 +54,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/SaveFilterSettingsAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/SaveFilterSettingsAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -35,10 +35,12 @@ */ public final class SaveFilterSettingsAction extends CallableSystemAction { + @Override public void performAction() { FilterTopComponent.findInstance().addFilterSetting(); } + @Override public String getName() { return NbBundle.getMessage(SaveFilterSettingsAction.class, "CTL_SaveFilterSettingsAction"); } @@ -52,6 +54,7 @@ putValue(Action.SHORT_DESCRIPTION, "Save filter configuration as profile..."); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/Graal/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/build.xml Sun Jan 29 11:40:04 2012 +0100 @@ -1,8 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.graal" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.graal.</description> - <import file="nbproject/build-impl.xml"/> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- You may freely edit this file. See harness/README in the NetBeans platform --> +<!-- for some information on what you could do (e.g. targets to override). --> +<!-- If you delete this file and reopen the project it will be recreated. --> +<project name="com.sun.hotspot.igv.graal" default="netbeans" basedir="."> + <description>Builds, tests, and runs the project com.sun.hotspot.igv.graal.</description> + <import file="nbproject/build-impl.xml"/> +</project>
--- a/src/share/tools/IdealGraphVisualizer/Graal/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/build-impl.xml Sun Jan 29 11:40:04 2012 +0100 @@ -1,45 +1,45 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.graal-impl" basedir=".."> - <fail message="Please build using Ant 1.7.1 or higher."> - <condition> - <not> - <antversion atleast="1.7.1"/> - </not> - </condition> - </fail> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="property"/> - <attribute name="value"/> - <sequential> - <property name="@{property}" value="@{value}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> - <condition> - <not> - <contains string="${cluster.path.evaluated}" substring="platform"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- +*** GENERATED FROM project.xml - DO NOT EDIT *** +*** EDIT ../build.xml INSTEAD *** +--> +<project name="com.sun.hotspot.igv.graal-impl" basedir=".."> + <fail message="Please build using Ant 1.7.1 or higher."> + <condition> + <not> + <antversion atleast="1.7.1"/> + </not> + </condition> + </fail> + <property file="nbproject/private/suite-private.properties"/> + <property file="nbproject/suite.properties"/> + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> + <property file="${suite.dir}/nbproject/private/platform-private.properties"/> + <property file="${suite.dir}/nbproject/platform.properties"/> + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property name="@{name}" value="${@{value}}"/> + </sequential> + </macrodef> + <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> + <attribute name="property"/> + <attribute name="value"/> + <sequential> + <property name="@{property}" value="@{value}"/> + </sequential> + </macrodef> + <property file="${user.properties.file}"/> + <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> + <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> + <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> + <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> + <condition> + <not> + <contains string="${cluster.path.evaluated}" substring="platform"/> + </not> + </condition> + </fail> + <import file="${harness.dir}/build.xml"/> +</project>
--- a/src/share/tools/IdealGraphVisualizer/Graal/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/genfiles.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,8 +1,8 @@ -build.xml.data.CRC32=2bb741e3 -build.xml.script.CRC32=3534d355 -build.xml.stylesheet.CRC32=a56c6a5b@1.45.1 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=2bb741e3 -nbproject/build-impl.xml.script.CRC32=2867f2d5 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 +build.xml.data.CRC32=79002a09 +build.xml.script.CRC32=3534d355 +build.xml.stylesheet.CRC32=a56c6a5b@2.47.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=79002a09 +nbproject/build-impl.xml.script.CRC32=2867f2d5 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47.1
--- a/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.xml Sun Jan 29 11:40:04 2012 +0100 @@ -1,53 +1,37 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.graal</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.data</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.filter</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graph</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graphtotext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages/> - </data> - </configuration> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.apisupport.project</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> + <code-name-base>com.sun.hotspot.igv.graal</code-name-base> + <suite-component/> + <module-dependencies> + <dependency> + <code-name-base>com.sun.hotspot.igv.data</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>com.sun.hotspot.igv.filter</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>com.sun.hotspot.igv.graph</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + </module-dependencies> + <public-packages/> + </data> + </configuration> +</project>
--- a/src/share/tools/IdealGraphVisualizer/Graal/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.graal.GraalGraphToTextConverter \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/GraalGraphToTextConverter.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,209 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.graal; - -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.Properties.PropertyMatcher; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import java.awt.Color; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; - -/** - * @author Peter Hofer - * @author Thomas Wuerthinger - */ -public class GraalGraphToTextConverter implements GraphToTextConverter { - - private Map<InputNode, Set<Figure>> map; - private Map<InputNode, List<InputEdge>> incomingEdges; - private Map<InputNode, List<InputEdge>> outgoingEdges; - private InputGraph graph; - - private Collection<InputNode> sortNodes(Collection<InputNode> nodes) { - List<InputNode> result = new ArrayList<InputNode>(nodes); - Collections.sort(result, InputNode.getPropertyComparator("idx")); - return result; - } - - public StructuredText convert(InputGraph graph, Diagram diagram) { - - this.graph = graph; - map = diagram.calcSourceToFigureRelation(); - - incomingEdges = graph.findAllIngoingEdges(); - outgoingEdges = graph.findAllOutgoingEdges(); - - final StructuredText result = new StructuredText(graph.getName()); - - for (InputBlock b : graph.getBlocks()) { - result.addChild(new SimpleElement("Block " + b.getName() + "\n")); - for (InputNode n : sortNodes(b.getNodes())) { - result.addChild(getNodeElement(n)); - } - } - - boolean first = true; - for (InputNode n : sortNodes(graph.getNodes())) { - if (graph.getBlock(n) == null) { - if (first) { - first = false; - result.addChild(new SimpleElement("No block: \n")); - } - result.addChild(getNodeElement(n)); - } - } - - return result; - } - - private Element getNodeNameElement(InputNode n) { - - final SimpleElement name = new SimpleElement(n.getProperties().get("idx") + " " + n.getProperties().get("name"), calcStyle(n)); - name.addSource(n.getId()); - return name; - } - - private Element getNodeShortElement(InputNode n) { - final SimpleElement id = new SimpleElement(n.getProperties().get("idx"), calcStyle(n)); - id.addSource(n.getId()); - return id; - } - - private Element getNodeElement(InputNode n) { - - final MultiElement result = new MultiElement(); - - result.print("\t"); - result.addChild(getNodeNameElement(n)); - - result.print(" :::"); - - // NOTE: lists in ingoingEdges/outgoingEdges are sorted by from/to slot - // and for slots that are connected with multiple edges, by - // from/to node - - InputEdge[] outgoing = outgoingEdges.get(n).toArray(new InputEdge[0]); - int succCount = outgoing.length - Integer.parseInt(n.getProperties().get("usageCount")); - - int i = 0; - if (outgoing.length > 0 && outgoing[0].getFromIndex() < succCount) { - // Node has successors (each connected to a different slot) - result.print(" Succ = ["); - while (i < outgoing.length && outgoing[i].getFromIndex() < succCount) { - result.print(" "); - result.addChild(getNodeShortElement(graph.getNode(outgoing[i].getTo()))); - result.print(" "); - i++; - } - result.print("]"); - } - if (i < outgoing.length) { - // Node has usages (all connected to a single slot) - result.print(" Usages = ["); - while (i < outgoing.length) { - result.print(" "); - result.addChild(getNodeShortElement(graph.getNode(outgoing[i].getTo()))); - result.print(" "); - i++; - } - result.print("]"); - } - - int predCount = Integer.parseInt(n.getProperties().get("predecessorCount")); - InputEdge[] incoming = incomingEdges.get(n).toArray(new InputEdge[0]); - - int j = 0; - if (incoming.length > 0 && incoming[0].getToIndex() < predCount) { - // Node has predecessors (each connected to a different slot) - result.print(" Pred = ["); - while (j < incoming.length && incoming[j].getToIndex() < predCount) { - result.print(" "); - result.addChild(getNodeShortElement(graph.getNode(incoming[j].getFrom()))); - result.print(" "); - j++; - } - result.print("]"); - } - if (j < incoming.length) { - // Node has inputs (each connected to a different slot) - result.print(" Inputs = ["); - while (j < incoming.length) { - result.print(" "); - result.addChild(getNodeShortElement(graph.getNode(incoming[j].getFrom()))); - result.print(" "); - j++; - } - result.print("]"); - } - - result.print("\n"); - return result; - } - private static final PropertyMatcher MATCHER = new Properties.StringPropertyMatcher("origin", "Graal"); - - public boolean canConvert(InputGraph graph) { - return graph.getGroup().getProperties().selectSingle(MATCHER) != null; - } - - private Color calcColor(InputNode node) { - Set<Figure> figureSet = this.map.get(node); - if (figureSet != null && figureSet.size() == 1) { - return figureSet.iterator().next().getColor(); - } else { - return Color.WHITE; - } - } - - private Color lessColor(Color c) { - return new Color(255 - (255 - c.getRed()) / 4, 255 - (255 - c.getGreen()) / 4, 255 - (255 - c.getBlue()) / 4); - } - - private Style calcStyle(InputNode node) { - Color c = calcColor(node); - Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); - Style newStyle = StyleContext.getDefaultStyleContext().addStyle(null, defaultStyle); - - StyleConstants.setBackground(newStyle, lessColor(c)); - return newStyle; - } -}
--- a/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalCFGFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalCFGFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -34,13 +34,15 @@ public class GraalCFGFilter extends AbstractFilter { + @Override public String getName() { return "Graal CFG Filter"; } + @Override public void apply(Diagram d) { - Set<Figure> figuresToRemove = new HashSet<Figure>(); - Set<Connection> connectionsToRemove = new HashSet<Connection>(); + Set<Figure> figuresToRemove = new HashSet<>(); + Set<Connection> connectionsToRemove = new HashSet<>(); for (Figure f : d.getFigures()) { final String prop = f.getProperties().get("probability");
--- a/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalColoringFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalColoringFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -38,10 +38,12 @@ this.colorName = colorName; } + @Override public String getName() { return "Graal Coloring Filter (" + colorName + ")"; } + @Override public void apply(Diagram d) { List<Figure> figures = d.getFigures(); int colors = 0;
--- a/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java Sun Jan 29 11:40:04 2012 +0100 @@ -26,6 +26,7 @@ import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.filter.AbstractFilter; import com.sun.hotspot.igv.graph.Connection; +import com.sun.hotspot.igv.graph.Connection.ConnectionStyle; import com.sun.hotspot.igv.graph.Diagram; import com.sun.hotspot.igv.graph.Figure; import com.sun.hotspot.igv.graph.InputSlot; @@ -46,10 +47,12 @@ public GraalEdgeColorFilter() { } + @Override public String getName() { return "Graal Edge Color Filter"; } + @Override public void apply(Diagram d) { List<Figure> figures = d.getFigures(); for (Figure f : figures) { @@ -62,8 +65,10 @@ } for (InputSlot is : f.getInputSlots()) { Color color; + ConnectionStyle style = ConnectionStyle.NORMAL; if (is.getPosition() < predCount) { color = successorColor; + style = ConnectionStyle.BOLD; } else { color = usageColor; } @@ -72,9 +77,11 @@ for (Connection c : is.getConnections()) { if (c.getLabel() == null || !c.getLabel().endsWith("#NDF")) { c.setColor(color); + c.setStyle(style); } else if ("EndNode".equals(c.getOutputSlot().getFigure().getProperties().get("class")) || "EndNode".equals(c.getOutputSlot().getProperties().get("class"))) { c.setColor(successorColor); + c.setStyle(ConnectionStyle.BOLD); } } }
--- a/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/AndSelector.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/AndSelector.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,10 +40,11 @@ this.selector2 = s2; } + @Override public List<Figure> selected(Diagram d) { List<Figure> l1 = selector1.selected(d); List<Figure> l2 = selector2.selected(d); - List<Figure> result = new ArrayList<Figure>(); + List<Figure> result = new ArrayList<>(); for (Figure f : l2) { if (l1.contains(f)) { result.add(f);
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.graph; - -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.layout.Cluster; -import java.awt.Rectangle; -import java.util.HashSet; -import java.util.Set; - -/** - * - * @author Thomas Wuerthinger - */ -public class Block implements Cluster { - - private InputBlock inputBlock; - private Rectangle bounds; - private Diagram diagram; - - public Block(InputBlock inputBlock, Diagram diagram) { - this.inputBlock = inputBlock; - this.diagram = diagram; - } - - public Cluster getOuter() { - return null; - } - - public InputBlock getInputBlock() { - return inputBlock; - } - - public Set<? extends Cluster> getSuccessors() { - Set<Block> succs = new HashSet<Block>(); - for (InputBlock b : inputBlock.getSuccessors()) { - succs.add(diagram.getBlock(b)); - } - return succs; - } - - public void setBounds(Rectangle r) { - this.bounds = r; - } - - public Rectangle getBounds() { - return bounds; - } - - public int compareTo(Cluster o) { - return toString().compareTo(o.toString()); - } - - @Override - public String toString() { - return inputBlock.getName(); - } -} -
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,6 +37,11 @@ */ public class Connection implements Source.Provider, Link { + @Override + public boolean isVIP() { + return style == ConnectionStyle.BOLD; + } + public enum ConnectionStyle { NORMAL, @@ -57,7 +62,7 @@ this.label = label; this.inputSlot.connections.add(this); this.outputSlot.connections.add(this); - controlPoints = new ArrayList<Point>(); + controlPoints = new ArrayList<>(); Figure sourceFigure = this.outputSlot.getFigure(); Figure destFigure = this.inputSlot.getFigure(); sourceFigure.addSuccessor(destFigure); @@ -92,6 +97,7 @@ style = s; } + @Override public Source getSource() { return source; } @@ -125,18 +131,22 @@ return "Connection('" + label + "', " + getFrom().getVertex() + " to " + getTo().getVertex() + ")"; } + @Override public Port getFrom() { return outputSlot; } + @Override public Port getTo() { return inputSlot; } + @Override public List<Point> getControlPoints() { return controlPoints; } + @Override public void setControlPoints(List<Point> list) { controlPoints = list; }
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,24 +23,13 @@ */ package com.sun.hotspot.igv.graph; -import com.sun.hotspot.igv.data.InputBlock; import com.sun.hotspot.igv.data.InputEdge; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; import java.awt.Font; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @@ -49,7 +38,6 @@ public class Diagram { private List<Figure> figures; - private Map<InputBlock, Block> blocks; private InputGraph graph; private int curId; private String nodeText; @@ -65,38 +53,20 @@ } private Diagram() { - figures = new ArrayList<Figure>(); - blocks = new LinkedHashMap<InputBlock, Block>(8); + figures = new ArrayList<>(); this.nodeText = ""; this.font = new Font("Arial", Font.PLAIN, 13); this.slotFont = new Font("Arial", Font.PLAIN, 10); } - public Block getBlock(InputBlock b) { - assert blocks.containsKey(b); - return blocks.get(b); - } - public String getNodeText() { return nodeText; } - public void updateBlocks() { - blocks.clear(); - for (InputBlock b : graph.getBlocks()) { - Block curBlock = new Block(b, this); - blocks.put(b, curBlock); - } - } - public Diagram getNext() { return Diagram.createDiagram(graph.getNext(), nodeText); } - public Collection<Block> getBlocks() { - return Collections.unmodifiableCollection(blocks.values()); - } - public Diagram getPrev() { return Diagram.createDiagram(graph.getPrev(), nodeText); } @@ -119,7 +89,7 @@ } public Map<InputNode, Set<Figure>> calcSourceToFigureRelation() { - Map<InputNode, Set<Figure>> map = new HashMap<InputNode, Set<Figure>>(); + Map<InputNode, Set<Figure>> map = new HashMap<>(); for(InputNode node : this.getGraph().getNodes()) { map.put(node, new HashSet<Figure>()); @@ -143,10 +113,8 @@ d.graph = graph; d.nodeText = nodeText; - d.updateBlocks(); - Collection<InputNode> nodes = graph.getNodes(); - Hashtable<Integer, Figure> figureHash = new Hashtable<Integer, Figure>(); + Hashtable<Integer, Figure> figureHash = new Hashtable<>(); for (InputNode n : nodes) { Figure f = d.createFigure(); f.getSource().addSourceNode(n); @@ -194,7 +162,7 @@ freeFigure(f); } - ArrayList<Figure> newFigures = new ArrayList<Figure>(); + ArrayList<Figure> newFigures = new ArrayList<>(); for (Figure f : this.figures) { if (!figuresToRemove.contains(f)) { newFigures.add(f); @@ -205,12 +173,12 @@ private void freeFigure(Figure succ) { - List<InputSlot> inputSlots = new ArrayList<InputSlot>(succ.getInputSlots()); + List<InputSlot> inputSlots = new ArrayList<>(succ.getInputSlots()); for (InputSlot s : inputSlots) { succ.removeInputSlot(s); } - List<OutputSlot> outputSlots = new ArrayList<OutputSlot>(succ.getOutputSlots()); + List<OutputSlot> outputSlots = new ArrayList<>(succ.getOutputSlots()); for (OutputSlot s : outputSlots) { succ.removeOutputSlot(s); } @@ -239,7 +207,7 @@ public Set<Connection> getConnections() { - Set<Connection> connections = new HashSet<Connection>(); + Set<Connection> connections = new HashSet<>(); for (Figure f : figures) { for (InputSlot s : f.getInputSlots()) { @@ -251,7 +219,7 @@ } public Figure getRootFigure() { - Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(figures); + Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<>(figures); Figure root = selector.selectSingle(new StringPropertyMatcher("name", "Root")); if (root == null) { root = selector.selectSingle(new StringPropertyMatcher("name", "Start")); @@ -278,9 +246,10 @@ System.out.println("Number of figures: " + tmpFigures.size()); System.out.println("Number of connections: " + connections.size()); - List<Figure> figuresSorted = new ArrayList<Figure>(tmpFigures); + List<Figure> figuresSorted = new ArrayList<>(tmpFigures); Collections.sort(figuresSorted, new Comparator<Figure>() { + @Override public int compare(Figure a, Figure b) { return b.getPredecessors().size() + b.getSuccessors().size() - a.getPredecessors().size() - a.getSuccessors().size(); } @@ -303,7 +272,7 @@ } public List<Figure> getRootFigures() { - ArrayList<Figure> rootFigures = new ArrayList<Figure>(); + ArrayList<Figure> rootFigures = new ArrayList<>(); for (Figure f : figures) { if (f.getPredecessors().size() == 0) { rootFigures.add(f);
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,25 +23,14 @@ */ package com.sun.hotspot.igv.graph; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.Source; import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.Vertex; import com.sun.hotspot.igv.data.Properties; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Point; +import com.sun.hotspot.igv.data.Source; +import com.sun.hotspot.igv.layout.Vertex; +import java.awt.*; import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.*; /** * @@ -82,7 +71,7 @@ } public static <T> List<T> getAllBefore(List<T> inputList, T tIn) { - List<T> result = new ArrayList<T>(); + List<T> result = new ArrayList<>(); for(T t : inputList) { if(t.equals(tIn)) { break; @@ -123,10 +112,10 @@ protected Figure(Diagram diagram, int id) { this.diagram = diagram; this.source = new Source(); - inputSlots = new ArrayList<InputSlot>(5); - outputSlots = new ArrayList<OutputSlot>(1); - predecessors = new ArrayList<Figure>(6); - successors = new ArrayList<Figure>(6); + inputSlots = new ArrayList<>(5); + outputSlots = new ArrayList<>(1); + predecessors = new ArrayList<>(6); + successors = new ArrayList<>(6); this.id = id; idString = Integer.toString(id); @@ -151,7 +140,7 @@ } public Set<Figure> getPredecessorSet() { - Set<Figure> result = new HashSet<Figure>(); + Set<Figure> result = new HashSet<>(); for (Figure f : getPredecessors()) { result.add(f); } @@ -159,7 +148,7 @@ } public Set<Figure> getSuccessorSet() { - Set<Figure> result = new HashSet<Figure>(); + Set<Figure> result = new HashSet<>(); for (Figure f : getSuccessors()) { result.add(f); } @@ -188,10 +177,12 @@ successors.remove(f); } + @Override public void setPosition(Point p) { this.position = p; } + @Override public Point getPosition() { return position; } @@ -200,6 +191,7 @@ return diagram; } + @Override public Source getSource() { return source; } @@ -221,7 +213,7 @@ assert inputSlots.contains(s) || outputSlots.contains(s); - List<Connection> connections = new ArrayList<Connection>(s.getConnections()); + List<Connection> connections = new ArrayList<>(s.getConnections()); for (Connection c : connections) { c.remove(); } @@ -251,7 +243,7 @@ } public Set<Slot> getSlots() { - Set<Slot> result = new HashSet<Slot>(); + Set<Slot> result = new HashSet<>(); result.addAll(getInputSlots()); result.addAll(getOutputSlots()); return result; @@ -321,6 +313,7 @@ return sb.toString(); } + @Override public Dimension getSize() { if (VERTICAL_LAYOUT) { int width = Math.max(getWidth(), Figure.SLOT_WIDTH * (Math.max(inputSlots.size(), outputSlots.size()) + 1)); @@ -340,19 +333,7 @@ return idString; } - public Cluster getCluster() { - if (getSource().getSourceNodes().size() == 0) { - assert false : "Should never reach here, every figure must have at least one source node!"; - return null; - } else { - final InputBlock inputBlock = diagram.getGraph().getBlock(getSource().getSourceNodes().get(0)); - assert inputBlock != null; - Cluster result = diagram.getBlock(inputBlock); - assert result != null; - return result; - } - } - + @Override public boolean isRoot() { List<InputNode> sourceNodes = source.getSourceNodes(); @@ -363,7 +344,12 @@ } } + @Override public int compareTo(Vertex f) { return toString().compareTo(f.toString()); } + + public Rectangle getBounds() { + return new Rectangle(this.getPosition(), new Dimension(this.getWidth(), this.getHeight())); + } }
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java Sun Jan 29 11:40:04 2012 +0100 @@ -36,15 +36,18 @@ super(figure, wantedIndex); } + @Override public int getPosition() { return getFigure().getInputSlots().indexOf(this); } + @Override public void setPosition(int position) { List<InputSlot> inputSlots = getFigure().inputSlots; InputSlot s = inputSlots.remove(position); inputSlots.add(position, s); } + @Override public Point getRelativePosition() { int gap = getFigure().getWidth() - Figure.getSlotsWidth(getFigure().getInputSlots()); double gapRatio = (double)gap / (double)(getFigure().getInputSlots().size() + 1);
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InvertSelector.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InvertSelector.java Sun Jan 29 11:40:04 2012 +0100 @@ -38,9 +38,10 @@ this.selector = selector; } + @Override public List<Figure> selected(Diagram d) { - List<Figure> result = new ArrayList<Figure>(); + List<Figure> result = new ArrayList<>(); List<Figure> otherResult = selector.selected(d); for (Figure f : d.getFigures()) { if (!otherResult.contains(f)) {
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/MatcherSelector.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/MatcherSelector.java Sun Jan 29 11:40:04 2012 +0100 @@ -39,8 +39,9 @@ this.matcher = matcher; } + @Override public List<Figure> selected(Diagram d) { - Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(d.getFigures()); + Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<>(d.getFigures()); List<Figure> list = selector.selectMultiple(matcher); return list; }
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OrSelector.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OrSelector.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,6 +40,7 @@ this.selector2 = s2; } + @Override public List<Figure> selected(Diagram d) { List<Figure> l1 = selector1.selected(d);
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java Sun Jan 29 11:40:04 2012 +0100 @@ -35,15 +35,18 @@ super(figure, wantedIndex); } + @Override public int getPosition() { return getFigure().getOutputSlots().indexOf(this); } + @Override public void setPosition(int position) { OutputSlot s = getFigure().outputSlots.remove(position); getFigure().outputSlots.add(position, s); } + @Override public Point getRelativePosition() { int gap = getFigure().getWidth() - Figure.getSlotsWidth(getFigure().getOutputSlots()); if(gap < 0) {
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/PredecessorSelector.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/PredecessorSelector.java Sun Jan 29 11:40:04 2012 +0100 @@ -38,9 +38,10 @@ this.innerSelector = innerSelector; } + @Override public List<Figure> selected(Diagram d) { List<Figure> inner = innerSelector.selected(d); - List<Figure> result = new ArrayList<Figure>(); + List<Figure> result = new ArrayList<>(); for (Figure f : d.getFigures()) { boolean saved = false; for (Figure f2 : f.getSuccessors()) {
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java Sun Jan 29 11:40:04 2012 +0100 @@ -35,8 +35,8 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; -import java.util.Comparator; /** * @@ -55,7 +55,7 @@ protected Slot(Figure figure, int wantedIndex) { this.figure = figure; - connections = new ArrayList<Connection>(2); + connections = new ArrayList<>(2); source = new Source(); this.wantedIndex = wantedIndex; text = ""; @@ -63,6 +63,7 @@ assert figure != null; } + @Override public Properties getProperties() { Properties p = new Properties(); if (source.getSourceNodes().size() > 0) { @@ -78,12 +79,14 @@ } public static final Comparator<Slot> slotIndexComparator = new Comparator<Slot>() { + @Override public int compare(Slot o1, Slot o2) { return o1.wantedIndex - o2.wantedIndex; } }; public static final Comparator<Slot> slotFigureComparator = new Comparator<Slot>() { + @Override public int compare(Slot o1, Slot o2) { return o1.figure.getId() - o2.figure.getId(); } @@ -113,6 +116,7 @@ return wantedIndex; } + @Override public Source getSource() { return source; } @@ -173,12 +177,13 @@ } public void removeAllConnections() { - List<Connection> connectionsCopy = new ArrayList<Connection>(this.connections); + List<Connection> connectionsCopy = new ArrayList<>(this.connections); for (Connection c : connectionsCopy) { c.remove(); } } + @Override public Vertex getVertex() { return figure; }
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/SuccessorSelector.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/SuccessorSelector.java Sun Jan 29 11:40:04 2012 +0100 @@ -38,9 +38,10 @@ this.innerSelector = innerSelector; } + @Override public List<Figure> selected(Diagram d) { List<Figure> inner = innerSelector.selected(d); - List<Figure> result = new ArrayList<Figure>(); + List<Figure> result = new ArrayList<>(); for (Figure f : d.getFigures()) { boolean saved = false; for (Figure f2 : f.getPredecessors()) {
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.graphtexteditor" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.graphtexteditor.</description> - <import file="nbproject/build-impl.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/manifest.mf Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.graphtexteditor -OpenIDE-Module-Layer: com/sun/hotspot/igv/graphtexteditor/layer.xml -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/graphtexteditor/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 -
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.graphtexteditor-impl" basedir=".."> - <fail message="Please build using Ant 1.7.1 or higher."> - <condition> - <not> - <antversion atleast="1.7.1"/> - </not> - </condition> - </fail> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="property"/> - <attribute name="value"/> - <sequential> - <property name="@{property}" value="@{value}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> - <condition> - <not> - <contains string="${cluster.path.evaluated}" substring="platform"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=f0880ef0 -nbproject/build-impl.xml.script.CRC32=9388e04e -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.graphtexteditor</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.data</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graph</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graphtotext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.selectioncoordinator</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.texteditor</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.util</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.modules.diff</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>1</release-version> - <specification-version>1.32.1.42.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>7.12.0.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util.lookup</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>8.6.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.windows</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>6.20</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages/> - </data> - </configuration> -</project>
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/suite.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -CTL_TextAction=Text -CTL_TextTopComponent=Text -HINT_TextTopComponent=Shows a textual representation of the graph. -OpenIDE-Module-Name=GraphTextEditor
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtexteditor; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import org.openide.util.NbBundle; -import org.openide.windows.TopComponent; - -/** - * Action which shows Text component. - */ -public class TextAction extends AbstractAction { - - public TextAction() { - super(NbBundle.getMessage(TextAction.class, "CTL_TextAction")); - } - - public void actionPerformed(ActionEvent evt) { - TopComponent win = TextTopComponent.findInstance(); - win.open(); - win.requestActive(); - } -}
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -<?xml version="1.1" encoding="UTF-8" ?> - -<Form version="1.4" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> - <AuxValues> - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> - </AuxValues> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> -</Form>
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,440 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.graphtexteditor; - -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.texteditor.*; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.Property; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.services.DiagramProvider; -import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter; -import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import com.sun.hotspot.igv.util.LookupHistory; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.IOException; -import java.io.Serializable; -import java.io.StringReader; -import java.util.Collection; -import java.util.logging.Logger; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JToolBar; -import org.netbeans.api.diff.Diff; -import org.netbeans.api.diff.DiffView; -import org.netbeans.api.diff.StreamSource; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; -import org.openide.windows.TopComponent; -import org.openide.windows.WindowManager; - -/** - * @author Thomas Wuerthinger - * @author Peter Hofer - */ -final class TextTopComponent extends TopComponent implements LookupListener { - - private static TextTopComponent instance; - private Lookup.Result result = null; - private static final String PREFERRED_ID = "TextTopComponent"; - private Diagram lastDiagram; - private TextEditor leftEditor; - private TextEditor rightEditor; - private TextEditor singleEditor; - private JSplitPane splitPane; - private CardLayout cardLayout; - private JPanel cardLayoutPanel; - private JComboBox sourceCombo; - private boolean firstTimeSplitter = true; - private JPanel textDiffPanel; - - private static final String TWO_GRAPHS_TEXT_DIFF = "twoGraphsTextDiff"; - private static final String TWO_GRAPHS = "twoGraphs"; - private static final String ONE_GRAPH = "oneGraph"; - private static final String NO_GRAPH = "noGraph"; - - private static final String GRAPH_TEXT_REPRESENTATION = "< Graph Text Representation >"; - - private DiagramProvider currentDiagramProvider; - - private TextTopComponent() { - initComponents(); - setName(NbBundle.getMessage(TextTopComponent.class, "CTL_TextTopComponent")); - setToolTipText(NbBundle.getMessage(TextTopComponent.class, "HINT_TextTopComponent")); - - setLayout(new BorderLayout()); - - // Selector for displayed data - JToolBar sourceSelectBar = new JToolBar(); - sourceSelectBar.setLayout(new BorderLayout()); - sourceSelectBar.setFloatable(false); - sourceSelectBar.add(new JLabel("Show: "), BorderLayout.WEST); - sourceCombo = new JComboBox(); - sourceCombo.addItem(GRAPH_TEXT_REPRESENTATION); - sourceCombo.addItemListener(sourceSelectionListener); - sourceSelectBar.add(sourceCombo, BorderLayout.CENTER); - add(sourceSelectBar, BorderLayout.NORTH); - - // Card layout for three different views. - cardLayout = new CardLayout(); - cardLayoutPanel = new JPanel(cardLayout); - add(cardLayoutPanel, BorderLayout.CENTER); - - // No graph selected. - JLabel noGraphLabel = new JLabel("No graph open.", JLabel.CENTER); - noGraphLabel.setOpaque(true); - noGraphLabel.setBackground(Color.WHITE); - cardLayoutPanel.add(noGraphLabel, NO_GRAPH); - - // Single graph selected. - singleEditor = new TextEditor(); - cardLayoutPanel.add(singleEditor.getComponent(), ONE_GRAPH); - - // Graph difference => show split pane with two graphs. - splitPane = new JSplitPane(); - leftEditor = new TextEditor(); - rightEditor = new TextEditor(); - // Work around a problem with JSplitPane and the NetBeans editor: - // setDividerLocation() doesn't work when the split pane has not been - // layouted and painted yet. JSplitPane then initially uses a tiny width - // for the left editor component, which causes the editor to calculate - // invalid offsets and constantly throw exceptions, particularly on - // mouse events. Thus, defer adding the two components and setting the - // divider's location. - splitPane.addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - if (firstTimeSplitter && splitPane.getWidth() > 0) { - splitPane.setLeftComponent(leftEditor.getComponent()); - splitPane.setRightComponent(rightEditor.getComponent()); - splitPane.setDividerLocation(0.5); - firstTimeSplitter = false; - } - } - }); - cardLayoutPanel.add(splitPane, TWO_GRAPHS); - - // Text difference => NetBeans diff view - // Diff component is created and added on demand - textDiffPanel = new JPanel(new BorderLayout()); - cardLayoutPanel.add(textDiffPanel, TWO_GRAPHS_TEXT_DIFF); - } - - - private StructuredText convert(InputGraph graph, Diagram diagram) { - Collection<? extends GraphToTextConverter> converters = Lookup.getDefault().lookupAll(GraphToTextConverter.class); - StructuredText text = null; - if (converters.size() == 0) { - text = new StructuredText(graph.getName()); - text.println("No graph-to-text converter exists!"); - return text; - } - - for (GraphToTextConverter converter : converters) { - if (converter.canConvert(graph)) { - text = converter.convert(graph, diagram); - if (text == null) { - text = new StructuredText(graph.getName()); - text.println("Class " + converter.getClass().getName() + " misbehaved and returned null on graph-to-text conversion!"); - } - return text; - } - } - - text = new StructuredText(graph.getName()); - text.println("No appropriate graph-to-text converter found!"); - return text; - } - - private StructuredText createStructuredPlainText(String name, String text) { - StructuredText structured = new StructuredText(name); - MultiElement multi = new MultiElement(); - multi.print(text); - structured.addChild(multi); - return structured; - } - - private ItemListener sourceSelectionListener = new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - if (e.getItem() == GRAPH_TEXT_REPRESENTATION) { - displayDiagram(lastDiagram); - } else { - displayGroupProperty(lastDiagram, (String) e.getItem()); - } - } - } - }; - - private void setDiagram(Diagram diagram) { - if (diagram == lastDiagram) { - // No change => return. - return; - } - lastDiagram = diagram; - - // Rebuild combobox choices - Object selection = sourceCombo.getSelectedItem(); - sourceCombo.removeAllItems(); - // NOTE: addItem() makes the first inserted item the selected item, - // so use insertItemAt() instead - sourceCombo.insertItemAt(GRAPH_TEXT_REPRESENTATION, 0); - if (diagram != null) { - if (diagram.getGraph().getSourceGraphs() != null) { - // Diff graph with source graphs with possibly different groups: - // show properties from both graphs - Pair<InputGraph, InputGraph> sourceGraphs = diagram.getGraph().getSourceGraphs(); - Properties props = new Properties(sourceGraphs.getLeft().getGroup().getProperties()); - if (sourceGraphs.getLeft().getGroup() != sourceGraphs.getRight().getGroup()) { - props.add(sourceGraphs.getRight().getGroup().getProperties()); - } - for (Property p : props) { - sourceCombo.addItem(p.getName()); - } - } else { - // Single graph - for (Property p : diagram.getGraph().getGroup().getProperties()) { - sourceCombo.addItem(p.getName()); - } - } - } - // NOTE: The following triggers a display update. - sourceCombo.setSelectedItem(selection); - if (sourceCombo.getSelectedItem() == null) { - // previously selected property doesn't exist in new graph's group: - // default to show graph representation - sourceCombo.setSelectedItem(GRAPH_TEXT_REPRESENTATION); - } - } - - private void displayGroupProperty(Diagram diagram, String property) { - if (diagram == null) { - showCard(NO_GRAPH); - } else if (diagram.getGraph().getSourceGraphs() != null) { - showCard(TWO_GRAPHS_TEXT_DIFF); - textDiffPanel.removeAll(); - try { - Pair<InputGraph, InputGraph> sourceGraphs = diagram.getGraph().getSourceGraphs(); - - String ltext = sourceGraphs.getLeft().getGroup().getProperties().get(property); - if (ltext == null) { - ltext = ""; - } - StreamSource leftsrc = StreamSource.createSource("left", sourceGraphs.getLeft().getName(), "text/plain", new StringReader(ltext)); - - String rtext = sourceGraphs.getRight().getGroup().getProperties().get(property); - if (rtext == null) { - rtext = ""; - } - StreamSource rightsrc = StreamSource.createSource("right", sourceGraphs.getRight().getName(), "text/plain", new StringReader(rtext)); - - DiffView view = Diff.getDefault().createDiff(leftsrc, rightsrc); - textDiffPanel.add(view.getComponent(), BorderLayout.CENTER); - } catch (IOException e) { - throw new RuntimeException(e); - } - textDiffPanel.revalidate(); // required when card was visible before - } else { - showCard(ONE_GRAPH); - String text = diagram.getGraph().getGroup().getProperties().get(property); - singleEditor.setStructuredText(createStructuredPlainText(diagram.getGraph().getName(), text)); - } - } - - private void displayDiagram(Diagram diagram) { - if (diagram == null) { - showCard(NO_GRAPH); - } /* This side-by-side view of the source graphs for diff graphs doesn't - * work properly because nodes that exist only in graph B (the 'new' - * graph) are in most cases assigned different ids. - - else if (diagram.getGraph().getSourceGraphs() != null) { - showCard(TWO_GRAPHS); - Pair<InputGraph, InputGraph> graphs = diagram.getGraph().getSourceGraphs(); - leftEditor.setStructuredText(convert(graphs.getLeft(), diagram)); - rightEditor.setStructuredText(convert(graphs.getRight(), diagram)); - - // TODO: Hack to update view - remove - SelectionCoordinator.getInstance().getHighlightedChangedEvent().fire(); - } */ - else { - showCard(ONE_GRAPH); - StructuredText text = convert(diagram.getGraph(), diagram); - singleEditor.setStructuredText(text); - - // TODO: Hack to update view - remove - SelectionCoordinator.getInstance().getHighlightedChangedEvent().fire(); - } - } - - private ChangedListener<DiagramProvider> diagramChangedListener = new ChangedListener<DiagramProvider>() { - - public void changed(DiagramProvider source) { - setDiagram(source.getDiagram()); - } - - }; - - private void setDiagramProvider(DiagramProvider provider) { - if (provider == currentDiagramProvider) { - return; - } - - if (currentDiagramProvider != null) { - currentDiagramProvider.getChangedEvent().removeListener(diagramChangedListener); - } - - currentDiagramProvider = provider; - - if (currentDiagramProvider != null) { - currentDiagramProvider.getChangedEvent().addListener(diagramChangedListener); - setDiagram(currentDiagramProvider.getDiagram()); - } else { - setDiagram(null); - } - } - - private void showCard(final String card) { - cardLayout.show(cardLayoutPanel, card); - } - - public void resultChanged(LookupEvent lookupEvent) { - DiagramProvider p = Utilities.actionsGlobalContext().lookup(DiagramProvider.class); - - if (p == null) { - p = LookupHistory.getLast(DiagramProvider.class); - } - - setDiagramProvider(p); - } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents - private void initComponents() { - - setLayout(new java.awt.BorderLayout()); - }// </editor-fold>//GEN-END:initComponents - - - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables - /** - * Gets default instance. Do not use directly: reserved for *.settings files only, - * i.e. deserialization routines; otherwise you could get a non-deserialized instance. - * To obtain the singleton instance, use {@link findInstance}. - */ - public static synchronized TextTopComponent getDefault() { - if (instance == null) { - instance = new TextTopComponent(); - } - return instance; - } - - /** - * Obtain the TextTopComponent instance. Never call {@link #getDefault} directly! - */ - public static synchronized TextTopComponent findInstance() { - TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); - if (win == null) { - Logger.getLogger(TextTopComponent.class.getName()).warning( - "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system."); - return getDefault(); - } - if (win instanceof TextTopComponent) { - return (TextTopComponent) win; - } - Logger.getLogger(TextTopComponent.class.getName()).warning( - "There seem to be multiple components with the '" + PREFERRED_ID + - "' ID. That is a potential source of errors and unexpected behavior."); - return getDefault(); - } - - @Override - public int getPersistenceType() { - return TopComponent.PERSISTENCE_ALWAYS; - } - - @Override - public void componentOpened() { - - DiagramProvider p = LookupHistory.getLast(DiagramProvider.class); - setDiagramProvider(p); - - Lookup.Template<DiagramProvider> tpl = new Lookup.Template<DiagramProvider>(DiagramProvider.class); - result = Utilities.actionsGlobalContext().lookup(tpl); - result.addLookupListener(this); - } - - @Override - public void componentClosed() { - result.removeLookupListener(this); - result = null; - setDiagramProvider(null); - } - - /** replaces this in object stream */ - @Override - public Object writeReplace() { - return new ResolvableHelper(); - } - - @Override - protected String preferredID() { - return PREFERRED_ID; - } - - @Override - public void requestActive() { - super.requestActive(); - cardLayoutPanel.requestFocus(); - } - - final static class ResolvableHelper implements Serializable { - - private static final long serialVersionUID = 1L; - - public Object readResolve() { - return TextTopComponent.getDefault(); - } - } -}
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -To change this template, choose Tools | Templates -and open the template in the editor. ---> -<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd"> -<settings version="1.0"> - <module name="com.sun.hotspot.igv.graphtexteditor" spec="1.0"/> - <instanceof class="org.openide.windows.TopComponent"/> - <instanceof class="com.sun.hotspot.igv.graphtexteditor.TextTopComponent"/> - <instance class="com.sun.hotspot.igv.graphtexteditor.TextTopComponent" method="getDefault"/> -</settings>
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -To change this template, choose Tools | Templates -and open the template in the editor. ---> -<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd"> -<tc-ref version="2.0" > - <module name="com.sun.hotspot.igv.graphtexteditor" spec="1.0"/> - <tc-id id="TextTopComponent"/> - <state opened="true"/> -</tc-ref>
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> - <folder name="Actions"> - <folder name="Window"> - <file name="com-sun-hotspot-igv-graphtexteditor-TextAction.instance"/> - </folder> - </folder> - <folder name="Menu"> - <folder name="Window"> - <file name="TextAction.shadow"> - <attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-graphtexteditor-TextAction.instance"/> - </file> - </folder> - </folder> - <folder name="Windows2"> - <folder name="Components"> - <file name="TextTopComponent.settings" url="TextTopComponentSettings.xml"/> - </folder> - <folder name="Modes"> - <folder name="customRightTopMode"> - <file name="TextTopComponent.wstcref" url="TextTopComponentWstcref.xml"/> - </folder> - </folder> - </folder> - -</filesystem>
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.graphtotext" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.graphtotext.</description> - <import file="nbproject/build-impl.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/manifest.mf Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.graphtotext -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/graphtotext/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 -
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.graphtotext-impl" basedir=".."> - <fail message="Please build using Ant 1.7.1 or higher."> - <condition> - <not> - <antversion atleast="1.7.1"/> - </not> - </condition> - </fail> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="property"/> - <attribute name="value"/> - <sequential> - <property name="@{property}" value="@{value}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> - <condition> - <not> - <contains string="${cluster.path.evaluated}" substring="platform"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=10eff8f6 -nbproject/build-impl.xml.script.CRC32=b176ca1a -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/platform.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -cluster.path=\ - ${nbplatform.active.dir}/ide:\ - ${nbplatform.active.dir}/platform -disabled.modules=\ - org.apache.xml.resolver,\ - org.mozilla.rhino.patched,\ - org.netbeans.api.debugger,\ - org.netbeans.api.java.classpath,\ - org.netbeans.api.xml,\ - org.netbeans.core.browser,\ - org.netbeans.core.execution,\ - org.netbeans.core.ide,\ - org.netbeans.core.multiview,\ - org.netbeans.lib.cvsclient,\ - org.netbeans.lib.terminalemulator,\ - org.netbeans.libs.antlr3.runtime,\ - org.netbeans.libs.bugtracking,\ - org.netbeans.libs.bugzilla,\ - org.netbeans.libs.bytelist,\ - org.netbeans.libs.commons_codec,\ - org.netbeans.libs.commons_logging,\ - org.netbeans.libs.commons_net,\ - org.netbeans.libs.freemarker,\ - org.netbeans.libs.ini4j,\ - org.netbeans.libs.jakarta_oro,\ - org.netbeans.libs.jaxb,\ - org.netbeans.libs.jsch,\ - org.netbeans.libs.jsr223,\ - org.netbeans.libs.jvyamlb,\ - org.netbeans.libs.jzlib,\ - org.netbeans.libs.lucene,\ - org.netbeans.libs.smack,\ - org.netbeans.libs.svnClientAdapter,\ - org.netbeans.libs.svnClientAdapter.javahl,\ - org.netbeans.libs.svnClientAdapter.svnkit,\ - org.netbeans.libs.swingx,\ - org.netbeans.libs.xerces,\ - org.netbeans.modules.autoupdate.services,\ - org.netbeans.modules.autoupdate.ui,\ - org.netbeans.modules.bugtracking,\ - org.netbeans.modules.bugtracking.bridge,\ - org.netbeans.modules.bugzilla,\ - org.netbeans.modules.core.kit,\ - org.netbeans.modules.csl.api,\ - org.netbeans.modules.css.editor,\ - org.netbeans.modules.css.visual,\ - org.netbeans.modules.db,\ - org.netbeans.modules.db.core,\ - org.netbeans.modules.db.dataview,\ - org.netbeans.modules.db.drivers,\ - org.netbeans.modules.db.kit,\ - org.netbeans.modules.db.metadata.model,\ - org.netbeans.modules.db.mysql,\ - org.netbeans.modules.db.sql.editor,\ - org.netbeans.modules.db.sql.visualeditor,\ - org.netbeans.modules.dbapi,\ - org.netbeans.modules.defaults,\ - org.netbeans.modules.derby,\ - org.netbeans.modules.diff,\ - org.netbeans.modules.dlight.nativeexecution,\ - org.netbeans.modules.dlight.terminal,\ - org.netbeans.modules.editor.bookmarks,\ - org.netbeans.modules.editor.bracesmatching,\ - org.netbeans.modules.editor.codetemplates,\ - org.netbeans.modules.editor.completion,\ - org.netbeans.modules.editor.errorstripe,\ - org.netbeans.modules.editor.errorstripe.api,\ - org.netbeans.modules.editor.guards,\ - org.netbeans.modules.editor.indent.project,\ - org.netbeans.modules.editor.kit,\ - org.netbeans.modules.editor.macros,\ - org.netbeans.modules.editor.plain,\ - org.netbeans.modules.editor.plain.lib,\ - org.netbeans.modules.editor.structure,\ - org.netbeans.modules.extbrowser,\ - org.netbeans.modules.extexecution,\ - org.netbeans.modules.extexecution.destroy,\ - org.netbeans.modules.favorites,\ - org.netbeans.modules.glassfish.common,\ - org.netbeans.modules.gototest,\ - org.netbeans.modules.gsf.codecoverage,\ - org.netbeans.modules.gsf.testrunner,\ - org.netbeans.modules.html,\ - org.netbeans.modules.html.editor,\ - org.netbeans.modules.html.editor.lib,\ - org.netbeans.modules.html.lexer,\ - org.netbeans.modules.html.parser,\ - org.netbeans.modules.html.validation,\ - org.netbeans.modules.httpserver,\ - org.netbeans.modules.hudson,\ - org.netbeans.modules.hudson.mercurial,\ - org.netbeans.modules.hudson.subversion,\ - org.netbeans.modules.ide.kit,\ - org.netbeans.modules.image,\ - org.netbeans.modules.javascript.editing,\ - org.netbeans.modules.javascript.hints,\ - org.netbeans.modules.javascript.kit,\ - org.netbeans.modules.javascript.refactoring,\ - org.netbeans.modules.jellytools.ide,\ - org.netbeans.modules.jumpto,\ - org.netbeans.modules.languages,\ - org.netbeans.modules.languages.diff,\ - org.netbeans.modules.languages.manifest,\ - org.netbeans.modules.languages.yaml,\ - org.netbeans.modules.lexer.nbbridge,\ - org.netbeans.modules.localhistory,\ - org.netbeans.modules.mercurial,\ - org.netbeans.modules.options.editor,\ - org.netbeans.modules.parsing.api,\ - org.netbeans.modules.parsing.lucene,\ - org.netbeans.modules.print.editor,\ - org.netbeans.modules.project.ant,\ - org.netbeans.modules.project.libraries,\ - org.netbeans.modules.projectapi,\ - org.netbeans.modules.projectui,\ - org.netbeans.modules.projectui.buildmenu,\ - org.netbeans.modules.projectuiapi,\ - org.netbeans.modules.properties,\ - org.netbeans.modules.properties.syntax,\ - org.netbeans.modules.refactoring.api,\ - org.netbeans.modules.schema2beans,\ - org.netbeans.modules.server,\ - org.netbeans.modules.servletapi,\ - org.netbeans.modules.spellchecker,\ - org.netbeans.modules.spellchecker.apimodule,\ - org.netbeans.modules.spellchecker.bindings.htmlxml,\ - org.netbeans.modules.spellchecker.bindings.properties,\ - org.netbeans.modules.spellchecker.dictionary_en,\ - org.netbeans.modules.spellchecker.kit,\ - org.netbeans.modules.subversion,\ - org.netbeans.modules.swing.validation,\ - org.netbeans.modules.target.iterator,\ - org.netbeans.modules.tasklist.kit,\ - org.netbeans.modules.tasklist.projectint,\ - org.netbeans.modules.tasklist.todo,\ - org.netbeans.modules.tasklist.ui,\ - org.netbeans.modules.terminal,\ - org.netbeans.modules.usersguide,\ - org.netbeans.modules.utilities,\ - org.netbeans.modules.utilities.project,\ - org.netbeans.modules.versioning,\ - org.netbeans.modules.versioning.indexingbridge,\ - org.netbeans.modules.versioning.system.cvss,\ - org.netbeans.modules.versioning.util,\ - org.netbeans.modules.web.client.tools.api,\ - org.netbeans.modules.web.common,\ - org.netbeans.modules.xml,\ - org.netbeans.modules.xml.axi,\ - org.netbeans.modules.xml.catalog,\ - org.netbeans.modules.xml.core,\ - org.netbeans.modules.xml.jaxb.api,\ - org.netbeans.modules.xml.lexer,\ - org.netbeans.modules.xml.multiview,\ - org.netbeans.modules.xml.retriever,\ - org.netbeans.modules.xml.schema.completion,\ - org.netbeans.modules.xml.schema.model,\ - org.netbeans.modules.xml.tax,\ - org.netbeans.modules.xml.text,\ - org.netbeans.modules.xml.tools,\ - org.netbeans.modules.xml.wsdl.model,\ - org.netbeans.modules.xml.xam,\ - org.netbeans.modules.xml.xdm,\ - org.netbeans.modules.xsl,\ - org.netbeans.spi.debugger.ui,\ - org.netbeans.spi.editor.hints,\ - org.netbeans.spi.navigator,\ - org.netbeans.spi.palette,\ - org.netbeans.spi.tasklist,\ - org.netbeans.spi.viewmodel,\ - org.netbeans.swing.dirchooser,\ - org.openide.compat,\ - org.openide.execution,\ - org.openide.options,\ - org.openide.util.enumerations -nbplatform.active=default
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.graphtotext</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.data</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graph</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages> - <package>com.sun.hotspot.igv.graphtotext</package> - <package>com.sun.hotspot.igv.graphtotext.services</package> - </public-packages> - </data> - </configuration> -</project>
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/suite.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtotext; - -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graphtotext.services.GraphToTextVisitor; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; - -/** - * - * @author Thomas - */ -public class BFSGraphToTextConverter { - - private GraphToTextVisitor visitor; - private Map<Properties.PropertyMatcher, GraphToTextVisitor> visitorMap; - private InputGraph graph; - private Diagram diagram; - - public BFSGraphToTextConverter(GraphToTextVisitor visitor) { - this.visitor = visitor; - visitorMap = new HashMap<Properties.PropertyMatcher, GraphToTextVisitor>(); - } - - public void registerVisitor(GraphToTextVisitor visitor, Properties.PropertyMatcher matcher) { - visitorMap.put(matcher, visitor); - } - - private GraphToTextVisitor chooseVisitor(GraphToTextVisitor defaultVisitor, InputNode node) { - for(Properties.PropertyMatcher matcher : visitorMap.keySet()) { - if(node.getProperties().selectSingle(matcher) != null) { - return visitorMap.get(matcher); - } - } - - return defaultVisitor; - } - - private Element cyclicVisit(GraphToTextVisitor visitor, InputNode node, List<InputEdge> path) { - return chooseVisitor(visitor, node).cyclicVisit(node, path); - } - - private Element visit(GraphToTextVisitor visitor, InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children) { - return chooseVisitor(visitor, node).visit(node, path, children); - } - - protected Diagram getDiagram() { - return diagram; - } - - public StructuredText convert(InputGraph graph, Diagram diagram) { - - this.graph = graph; - this.diagram = diagram; - StructuredText text = new StructuredText(graph.getName()); - - Map<InputNode, List<InputEdge>> outgoing = graph.findAllOutgoingEdges(); - Map<InputNode, List<InputEdge>> pathMap = new HashMap<InputNode, List<InputEdge>>(); - Queue<InputNode> queue = new LinkedList<InputNode>(); - List<InputNode> rootNodes = graph.findRootNodes(); - queue.addAll(rootNodes); - for(InputNode node : rootNodes) { - pathMap.put(node, new ArrayList<InputEdge>()); - } - - Set<InputNode> visited = new HashSet<InputNode>(); - visited.addAll(rootNodes); - - Set<InputEdge> fullEdges = new HashSet<InputEdge>(); - List<InputNode> visitOrder = new ArrayList<InputNode>(); - while(!queue.isEmpty()) { - - InputNode current = queue.remove(); - visitOrder.add(current); - List<InputEdge> path = pathMap.get(current); - - List<InputEdge> edges = outgoing.get(current); - for(InputEdge e : edges) { - InputNode dest = graph.getNode(e.getTo()); - if(!visited.contains(dest)) { - queue.add(dest); - visited.add(dest); - List<InputEdge> curPath = new ArrayList<InputEdge>(path); - curPath.add(e); - pathMap.put(dest, curPath); - fullEdges.add(e); - } - } - } - - - - Map<InputNode, Element> fullVisitCache = new HashMap<InputNode, Element>(); - for(int i=visitOrder.size() - 1; i>=0; i--) { - InputNode current = visitOrder.get(i); - List<InputEdge> path = pathMap.get(current); - List<InputEdge> edges = outgoing.get(current); - List<Pair<InputEdge, Element>> list = new ArrayList<Pair<InputEdge, Element>>(); - for(InputEdge e : edges) { - if(fullEdges.contains(e)) { - assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - list.add(new Pair<InputEdge, Element>(e, fullVisitCache.get(graph.getNode(e.getTo())))); - } else { -// assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - List<InputEdge> curPath = new ArrayList<InputEdge>(path); - curPath.add(e); - list.add(new Pair<InputEdge, Element>(e, cyclicVisit(visitor, graph.getNode(e.getTo()), curPath))); - } - } - - Element e = visit(visitor, current, pathMap.get(current), list); - fullVisitCache.put(current, e); - } - - for(InputNode node : rootNodes) { - text.addChild(fullVisitCache.get(node)); - } - - return text; - } -}
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=GraphToText
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtotext.services; - -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import java.util.List; - -/** - * - * @author Thomas - */ -public class AbstractGraphToTextVisitor implements GraphToTextVisitor { - - public Element cyclicVisit(InputNode node, List<InputEdge> path) { - return SimpleElement.EMPTY; - } - - public Element visit(InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children) { - return cyclicVisit(node, path); - } - -}
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtotext.services; - -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.structuredtext.StructuredText; - -/** - * - * @author Thomas Wuerthinger - */ -public interface GraphToTextConverter { - StructuredText convert(InputGraph graph, Diagram diagram); - boolean canConvert(InputGraph graph); -}
--- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtotext.services; - -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.structuredtext.Element; -import java.util.List; - -/** - * - * @author Thomas - */ -public interface GraphToTextVisitor { - - Element cyclicVisit(InputNode node, List<InputEdge> path); - Element visit(InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children); -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterEdge.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import java.awt.Point; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class ClusterEdge implements Link { - - private ClusterNode from; - private ClusterNode to; - private List<Point> points; - - public ClusterEdge(ClusterNode from, ClusterNode to) { - assert from != null; - assert to != null; - this.from = from; - this.to = to; - } - - public Port getTo() { - return to.getInputSlot(); - } - - public Port getFrom() { - return from.getInputSlot(); - } - - public void setControlPoints(List<Point> p) { - this.points = p; - } - - public List<Point> getControlPoints() { - return points; - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterIngoingConnection.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import java.awt.Point; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class ClusterIngoingConnection implements Link { - - private List<Point> controlPoints; - private ClusterInputSlotNode inputSlotNode; - private Link connection; - private Port inputSlot; - private Port outputSlot; - - public ClusterIngoingConnection(ClusterInputSlotNode inputSlotNode, Link c) { - this.inputSlotNode = inputSlotNode; - this.connection = c; - this.controlPoints = new ArrayList<Point>(); - - inputSlot = c.getTo(); - outputSlot = inputSlotNode.getOutputSlot(); - } - - public Link getConnection() { - return connection; - } - - public ClusterInputSlotNode getInputSlotNode() { - return inputSlotNode; - } - - public Port getTo() { - return inputSlot; - } - - public Port getFrom() { - return outputSlot; - } - - public void setControlPoints(List<Point> p) { - this.controlPoints = p; - } - - public List<Point> getControlPoints() { - return controlPoints; - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterInputSlotNode.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; -import java.awt.Dimension; -import java.awt.Point; - -/** - * - * @author Thomas Wuerthinger - */ -public class ClusterInputSlotNode implements Vertex { - - private final int SIZE = 0; - private Point position; - private Port inputSlot; - private Port outputSlot; - private ClusterNode blockNode; - private InterClusterConnection interBlockConnection; - private Cluster cluster; - private ClusterIngoingConnection conn; - - public void setIngoingConnection(ClusterIngoingConnection c) { - conn = c; - } - - public ClusterIngoingConnection getIngoingConnection() { - return conn; - } - private String id; - - @Override - public String toString() { - return id; - } - - public ClusterInputSlotNode(ClusterNode n, String id) { - this.blockNode = n; - this.id = id; - - n.addSubNode(this); - - final Vertex thisNode = this; - final ClusterNode thisBlockNode = blockNode; - - outputSlot = new Port() { - - public Point getRelativePosition() { - return new Point(0, 0); - } - - public Vertex getVertex() { - return thisNode; - } - - @Override - public String toString() { - return "OutPort of " + thisNode.toString(); - } - }; - - inputSlot = new Port() { - - public Point getRelativePosition() { - Point p = new Point(thisNode.getPosition()); - p.x += ClusterNode.BORDER; - p.y = 0; - return p; - } - - public Vertex getVertex() { - return thisBlockNode; - } - - @Override - public String toString() { - return "InPort of " + thisNode.toString(); - } - }; - } - - public Port getInputSlot() { - return inputSlot; - } - - public InterClusterConnection getInterBlockConnection() { - return interBlockConnection; - } - - public Port getOutputSlot() { - return outputSlot; - } - - public Dimension getSize() { - return new Dimension(SIZE, SIZE); - } - - public void setPosition(Point p) { - this.position = p; - } - - public Point getPosition() { - return position; - } - - public void setInterBlockConnection(InterClusterConnection interBlockConnection) { - this.interBlockConnection = interBlockConnection; - } - - public Cluster getCluster() { - return cluster; - } - - public boolean isRoot() { - return true; - } - - public int compareTo(Vertex o) { - return toString().compareTo(o.toString()); - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; -import java.awt.Dimension; -import java.awt.Point; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * - * @author Thomas Wuerthinger - */ -public class ClusterNode implements Vertex { - - private Cluster cluster; - private Port inputSlot; - private Port outputSlot; - private Set<Vertex> subNodes; - private Dimension size; - private Point position; - private Set<Link> subEdges; - private boolean dirty; - private boolean root; - private String name; - public static final int BORDER = 20; - - public ClusterNode(Cluster cluster, String name) { - this.subNodes = new HashSet<Vertex>(); - this.subEdges = new HashSet<Link>(); - this.cluster = cluster; - position = new Point(0, 0); - this.name = name; - } - - public void addSubNode(Vertex v) { - subNodes.add(v); - } - - public void addSubEdge(Link l) { - subEdges.add(l); - } - - public Set<Link> getSubEdges() { - return Collections.unmodifiableSet(subEdges); - } - - public void updateSize() { - - - calculateSize(); - - final ClusterNode widget = this; - inputSlot = new Port() { - - public Point getRelativePosition() { - return new Point(size.width / 2, 0); - } - - public Vertex getVertex() { - return widget; - } - }; - - outputSlot = new Port() { - - public Point getRelativePosition() { - return new Point(size.width / 2, 0);//size.height); - } - - public Vertex getVertex() { - return widget; - } - }; - } - - private void calculateSize() { - - if (subNodes.size() == 0) { - size = new Dimension(0, 0); - } - - int minX = Integer.MAX_VALUE; - int maxX = Integer.MIN_VALUE; - int minY = Integer.MAX_VALUE; - int maxY = Integer.MIN_VALUE; - - - for (Vertex n : subNodes) { - Point p = n.getPosition(); - minX = Math.min(minX, p.x); - minY = Math.min(minY, p.y); - maxX = Math.max(maxX, p.x + n.getSize().width); - maxY = Math.max(maxY, p.y + n.getSize().height); - } - - for (Link l : subEdges) { - List<Point> points = l.getControlPoints(); - for (Point p : points) { - if (p != null) { - minX = Math.min(minX, p.x); - maxX = Math.max(maxX, p.x); - minY = Math.min(minY, p.y); - maxY = Math.max(maxY, p.y); - } - } - } - - size = new Dimension(maxX - minX, maxY - minY); - - // Normalize coordinates - for (Vertex n : subNodes) { - n.setPosition(new Point(n.getPosition().x - minX, n.getPosition().y - minY)); - } - - for (Link l : subEdges) { - List<Point> points = new ArrayList<Point>(l.getControlPoints()); - for (Point p : points) { - p.x -= minX; - p.y -= minY; - } - l.setControlPoints(points); - - } - - size.width += 2 * BORDER; - size.height += 2 * BORDER; - } - - public Port getInputSlot() { - return inputSlot; - - } - - public Port getOutputSlot() { - return outputSlot; - } - - public Dimension getSize() { - return size; - } - - public Point getPosition() { - return position; - } - - public void setPosition(Point pos) { - - this.position = pos; - for (Vertex n : subNodes) { - Point cur = new Point(n.getPosition()); - cur.translate(pos.x + BORDER, pos.y + BORDER); - n.setPosition(cur); - } - - for (Link e : subEdges) { - List<Point> arr = e.getControlPoints(); - ArrayList<Point> newArr = new ArrayList<Point>(arr.size()); - for (Point p : arr) { - if (p != null) { - Point p2 = new Point(p); - p2.translate(pos.x + BORDER, pos.y + BORDER); - newArr.add(p2); - } else { - newArr.add(null); - } - } - - e.setControlPoints(newArr); - } - } - - public Cluster getCluster() { - return cluster; - } - - public void setCluster(Cluster c) { - cluster = c; - } - - public void setDirty(boolean b) { - dirty = b; - } - - public void setRoot(boolean b) { - root = b; - } - - public boolean isRoot() { - return root; - } - - public int compareTo(Vertex o) { - return toString().compareTo(o.toString()); - } - - @Override - public String toString() { - return name; - } - - public Set<? extends Vertex> getSubNodes() { - return subNodes; - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutgoingConnection.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import java.awt.Point; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class ClusterOutgoingConnection implements Link { - - private List<Point> intermediatePoints; - private ClusterOutputSlotNode outputSlotNode; - private Link connection; - private Port inputSlot; - private Port outputSlot; - - public ClusterOutgoingConnection(ClusterOutputSlotNode outputSlotNode, Link c) { - this.outputSlotNode = outputSlotNode; - this.connection = c; - this.intermediatePoints = new ArrayList<Point>(); - - outputSlot = c.getFrom(); - inputSlot = outputSlotNode.getInputSlot(); - } - - public Port getTo() { - return inputSlot; - } - - public Port getFrom() { - return outputSlot; - } - - public void setControlPoints(List<Point> p) { - this.intermediatePoints = p; - } - - public List<Point> getControlPoints() { - return intermediatePoints; - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; -import java.awt.Dimension; -import java.awt.Point; - -/** - * - * @author Thomas Wuerthinger - */ -public class ClusterOutputSlotNode implements Vertex { - - private final int SIZE = 0; - private Point position; - private Port inputSlot; - private Port outputSlot; - private ClusterNode blockNode; - private boolean root; - private Cluster cluster; - private ClusterOutgoingConnection conn; - private String id; - - public void setOutgoingConnection(ClusterOutgoingConnection c) { - this.conn = c; - } - - public ClusterOutgoingConnection getOutgoingConnection() { - return conn; - } - - @Override - public String toString() { - return id; - } - - public ClusterOutputSlotNode(ClusterNode n, String id) { - this.blockNode = n; - this.id = id; - - n.addSubNode(this); - - final Vertex thisNode = this; - final ClusterNode thisBlockNode = blockNode; - - inputSlot = new Port() { - - public Point getRelativePosition() { - return new Point(0, 0); - } - - public Vertex getVertex() { - return thisNode; - } - - @Override - public String toString() { - return "InPort of " + thisNode.toString(); - } - }; - - outputSlot = new Port() { - - public Point getRelativePosition() { - Point p = new Point(thisNode.getPosition()); - p.x += ClusterNode.BORDER; - p.y = 0;//thisBlockNode.getSize().height; - return p; - } - - public Vertex getVertex() { - return thisBlockNode; - } - - @Override - public String toString() { - return "OutPort of " + thisNode.toString(); - } - }; - } - - public Dimension getSize() { - return new Dimension(SIZE, SIZE); - } - - public void setPosition(Point p) { - this.position = p; - } - - public Point getPosition() { - return position; - } - - public Port getInputSlot() { - return inputSlot; - } - - public Port getOutputSlot() { - return outputSlot; - } - - public void setCluster(Cluster c) { - cluster = c; - } - - public void setRoot(boolean b) { - root = b; - } - - public Cluster getCluster() { - return cluster; - } - - public boolean isRoot() { - return root; - } - - public int compareTo(Vertex o) { - return toString().compareTo(o.toString()); - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.java Sun Jan 29 11:40:04 2012 +0100 @@ -83,6 +83,7 @@ dest.addInEdge(this); } + @Override public String toString() { return "Edge (" + source + " -- " + dest + "): " + data; }
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Graph.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Graph.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,13 +23,7 @@ */ package com.sun.hotspot.igv.hierarchicallayout; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; +import java.util.*; /** * @@ -42,13 +36,13 @@ private List<Node<N, E>> nodeList; public Graph() { - nodes = new HashMap<Object, Node<N, E>>(); - edges = new HashMap<Object, Edge<N, E>>(); - nodeList = new ArrayList<Node<N, E>>(); + nodes = new HashMap<>(); + edges = new HashMap<>(); + nodeList = new ArrayList<>(); } public Node<N, E> createNode(N data, Object key) { - Node<N, E> n = new Node<N, E>(this, data); + Node<N, E> n = new Node<>(this, data); assert key == null || !nodes.containsKey(key); if (key != null) { nodes.put(key, n); @@ -58,7 +52,7 @@ } public Edge<N, E> createEdge(Node<N, E> source, Node<N, E> dest, E data, Object key) { - Edge<N, E> e = new Edge<N, E>(this, source, dest, data); + Edge<N, E> e = new Edge<>(this, source, dest, data); source.addOutEdge(e); dest.addInEdge(e); if (key != null) { @@ -114,7 +108,7 @@ public List<Node<N, E>> getNodesWithInDegree(int x, boolean countSelfLoops) { - List<Node<N, E>> result = new ArrayList<Node<N, E>>(); + List<Node<N, E>> result = new ArrayList<>(); for (Node<N, E> n : getNodes()) { if (n.getInDegree(countSelfLoops) == x) { result.add(n); @@ -126,7 +120,7 @@ } private void markReachable(Node<N, E> startingNode) { - ArrayList<Node<N, E>> arr = new ArrayList<Node<N, E>>(); + ArrayList<Node<N, E>> arr = new ArrayList<>(); arr.add(startingNode); for (Node<N, E> n : getNodes()) { n.setReachable(false); @@ -151,7 +145,7 @@ n.setActive(false); } - Queue<Node<N, E>> queue = new LinkedList<Node<N, E>>(); + Queue<Node<N, E>> queue = new LinkedList<>(); queue.add(startingNode); startingNode.setVisited(true); int layer = 0;
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import java.awt.Point; -import java.awt.Rectangle; -import java.util.HashMap; -import java.util.List; -import java.util.Set; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.TreeSet; -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.LayoutGraph; -import com.sun.hotspot.igv.layout.LayoutManager; -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; - -/** - * - * @author Thomas Wuerthinger - */ -public class HierarchicalClusterLayoutManager implements LayoutManager { - - private OldHierarchicalLayoutManager.Combine combine; - private LayoutManager subManager = new OldHierarchicalLayoutManager(combine); - private LayoutManager manager = new OldHierarchicalLayoutManager(combine, 150); - private static final boolean TRACE = false; - - public HierarchicalClusterLayoutManager(OldHierarchicalLayoutManager.Combine combine) { - this.combine = combine; - } - - public void doLayout(LayoutGraph graph) { - doLayout(graph, new HashSet<Vertex>(), new HashSet<Vertex>(), new HashSet<Link>()); - } - - public void setSubManager(LayoutManager manager) { - this.subManager = manager; - } - - public void setManager(LayoutManager manager) { - this.manager = manager; - } - - public void doLayout(LayoutGraph graph, Set<? extends Vertex> firstLayerHint, Set<? extends Vertex> lastLayerHint, Set<? extends Link> importantLinks) { - - assert graph.verify(); - - HashMap<Cluster, List<Vertex>> lists = new HashMap<Cluster, List<Vertex>>(); - HashMap<Cluster, List<Link>> listsConnection = new HashMap<Cluster, List<Link>>(); - HashMap<Cluster, HashMap<Port, ClusterInputSlotNode>> clusterInputSlotHash = new HashMap<Cluster, HashMap<Port, ClusterInputSlotNode>>(); - HashMap<Cluster, HashMap<Port, ClusterOutputSlotNode>> clusterOutputSlotHash = new HashMap<Cluster, HashMap<Port, ClusterOutputSlotNode>>(); - - HashMap<Cluster, ClusterNode> clusterNodes = new HashMap<Cluster, ClusterNode>(); - HashMap<Cluster, Set<ClusterInputSlotNode>> clusterInputSlotSet = new HashMap<Cluster, Set<ClusterInputSlotNode>>(); - HashMap<Cluster, Set<ClusterOutputSlotNode>> clusterOutputSlotSet = new HashMap<Cluster, Set<ClusterOutputSlotNode>>(); - Set<Link> clusterEdges = new HashSet<Link>(); - Set<Link> interClusterEdges = new HashSet<Link>(); - HashMap<Link, ClusterOutgoingConnection> linkClusterOutgoingConnection = new HashMap<Link, ClusterOutgoingConnection>(); - HashMap<Link, InterClusterConnection> linkInterClusterConnection = new HashMap<Link, InterClusterConnection>(); - HashMap<Link, ClusterIngoingConnection> linkClusterIngoingConnection = new HashMap<Link, ClusterIngoingConnection>(); - Set<ClusterNode> clusterNodeSet = new HashSet<ClusterNode>(); - - Set<Cluster> cluster = graph.getClusters(); - int z = 0; - for (Cluster c : cluster) { - lists.put(c, new ArrayList<Vertex>()); - listsConnection.put(c, new ArrayList<Link>()); - clusterInputSlotHash.put(c, new HashMap<Port, ClusterInputSlotNode>()); - clusterOutputSlotHash.put(c, new HashMap<Port, ClusterOutputSlotNode>()); - clusterOutputSlotSet.put(c, new TreeSet<ClusterOutputSlotNode>()); - clusterInputSlotSet.put(c, new TreeSet<ClusterInputSlotNode>()); - ClusterNode cn = new ClusterNode(c, "" + z); - clusterNodes.put(c, cn); - clusterNodeSet.add(cn); - z++; - } - - // Add cluster edges - for (Cluster c : cluster) { - - ClusterNode start = clusterNodes.get(c); - - for (Cluster succ : c.getSuccessors()) { - ClusterNode end = clusterNodes.get(succ); - if (end != null && start != end) { - ClusterEdge e = new ClusterEdge(start, end); - clusterEdges.add(e); - interClusterEdges.add(e); - } - } - } - - for (Vertex v : graph.getVertices()) { - Cluster c = v.getCluster(); - assert c != null : "Cluster of vertex " + v + " is null!"; - clusterNodes.get(c).addSubNode(v); - } - - for (Link l : graph.getLinks()) { - - Port fromPort = l.getFrom(); - Port toPort = l.getTo(); - Vertex fromVertex = fromPort.getVertex(); - Vertex toVertex = toPort.getVertex(); - Cluster fromCluster = fromVertex.getCluster(); - Cluster toCluster = toVertex.getCluster(); - - Port samePort = null; - if (combine == OldHierarchicalLayoutManager.Combine.SAME_INPUTS) { - samePort = toPort; - } else if (combine == OldHierarchicalLayoutManager.Combine.SAME_OUTPUTS) { - samePort = fromPort; - } - - assert listsConnection.containsKey(fromCluster); - assert listsConnection.containsKey(toCluster); - - if (fromCluster == toCluster) { - listsConnection.get(fromCluster).add(l); - clusterNodes.get(fromCluster).addSubEdge(l); - } else { - ClusterInputSlotNode inputSlotNode = null; - ClusterOutputSlotNode outputSlotNode = null; - - if (samePort != null) { - outputSlotNode = clusterOutputSlotHash.get(fromCluster).get(samePort); - inputSlotNode = clusterInputSlotHash.get(toCluster).get(samePort); - } - - if (outputSlotNode == null) { - outputSlotNode = new ClusterOutputSlotNode(clusterNodes.get(fromCluster), "Out " + fromCluster.toString() + " " + samePort.toString()); - clusterOutputSlotSet.get(fromCluster).add(outputSlotNode); - ClusterOutgoingConnection conn = new ClusterOutgoingConnection(outputSlotNode, l); - outputSlotNode.setOutgoingConnection(conn); - clusterNodes.get(fromCluster).addSubEdge(conn); - if (samePort != null) { - clusterOutputSlotHash.get(fromCluster).put(samePort, outputSlotNode); - } - - linkClusterOutgoingConnection.put(l, conn); - } else { - linkClusterOutgoingConnection.put(l, outputSlotNode.getOutgoingConnection()); - } - - if (inputSlotNode == null) { - inputSlotNode = new ClusterInputSlotNode(clusterNodes.get(toCluster), "In " + toCluster.toString() + " " + samePort.toString()); - clusterInputSlotSet.get(toCluster).add(inputSlotNode); - } - - ClusterIngoingConnection conn = new ClusterIngoingConnection(inputSlotNode, l); - inputSlotNode.setIngoingConnection(conn); - clusterNodes.get(toCluster).addSubEdge(conn); - if (samePort != null) { - clusterInputSlotHash.get(toCluster).put(samePort, inputSlotNode); - } - - linkClusterIngoingConnection.put(l, conn); - - - InterClusterConnection interConn = new InterClusterConnection(outputSlotNode, inputSlotNode); - linkInterClusterConnection.put(l, interConn); - clusterEdges.add(interConn); - } - } - - Timing t = null; - - if (TRACE) { - new Timing("Child timing"); - t.start(); - } - - for (Cluster c : cluster) { - ClusterNode n = clusterNodes.get(c); - subManager.doLayout(new LayoutGraph(n.getSubEdges(), n.getSubNodes()), clusterInputSlotSet.get(c), clusterOutputSlotSet.get(c), new HashSet<Link>()); - n.updateSize(); - } - - Set<Vertex> roots = new LayoutGraph(interClusterEdges).findRootVertices(); - for (Vertex v : roots) { - assert v instanceof ClusterNode; - ((ClusterNode) v).setRoot(true); - } - - manager.doLayout(new LayoutGraph(clusterEdges, clusterNodeSet), new HashSet<Vertex>(), new HashSet<Vertex>(), interClusterEdges); - - for (Cluster c : cluster) { - ClusterNode n = clusterNodes.get(c); - c.setBounds(new Rectangle(n.getPosition(), n.getSize())); - } - - // TODO: handle case where blocks are not fully connected - - if (TRACE) { - t.stop(); - t.print(); - } - - for (Link l : graph.getLinks()) { - - if (linkInterClusterConnection.containsKey(l)) { - ClusterOutgoingConnection conn1 = linkClusterOutgoingConnection.get(l); - InterClusterConnection conn2 = linkInterClusterConnection.get(l); - ClusterIngoingConnection conn3 = linkClusterIngoingConnection.get(l); - - assert conn1 != null; - assert conn2 != null; - assert conn3 != null; - - List<Point> points = new ArrayList<Point>(); - - points.addAll(conn1.getControlPoints()); - points.addAll(conn2.getControlPoints()); - points.addAll(conn3.getControlPoints()); - - l.setControlPoints(points); - } - } - } - - public void doRouting(LayoutGraph graph) { - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java Sun Jan 29 11:40:04 2012 +0100 @@ -29,19 +29,7 @@ import com.sun.hotspot.igv.layout.Vertex; import java.awt.Dimension; import java.awt.Point; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.Set; -import java.util.SortedSet; -import java.util.Stack; -import java.util.TreeSet; +import java.util.*; /** * @@ -59,6 +47,7 @@ public static final int LAYER_OFFSET = 30; public static final int MAX_LAYER_LENGTH = -1; public static final int MIN_LAYER_DIFFERENCE = 1; + public static final int VIP_BONUS = 10; public enum Combine { @@ -103,10 +92,10 @@ public int bottomYOffset; public Vertex vertex; // Only used for non-dummy nodes, otherwise null - public List<LayoutEdge> preds = new ArrayList<LayoutEdge>(); - public List<LayoutEdge> succs = new ArrayList<LayoutEdge>(); - public HashMap<Integer, Integer> outOffsets = new HashMap<Integer, Integer>(); - public HashMap<Integer, Integer> inOffsets = new HashMap<Integer, Integer>(); + public List<LayoutEdge> preds = new ArrayList<>(); + public List<LayoutEdge> succs = new ArrayList<>(); + public HashMap<Integer, Integer> outOffsets = new HashMap<>(); + public HashMap<Integer, Integer> inOffsets = new HashMap<>(); public int pos = -1; // Position within layer public int crossingNumber; @@ -124,6 +113,7 @@ public int relativeFrom; public int relativeTo; public Link link; + public boolean vip; } private abstract class AlgorithmPart { @@ -174,7 +164,7 @@ this.layerOffset = LAYER_OFFSET; this.maxLayerLength = MAX_LAYER_LENGTH; this.minLayerDifference = MIN_LAYER_DIFFERENCE; - this.linksToFollow = new HashSet<Link>(); + this.linksToFollow = new HashSet<>(); } public int getMaxLayerLength() { @@ -189,11 +179,13 @@ minLayerDifference = v; } + @Override public void doLayout(LayoutGraph graph) { doLayout(graph, new HashSet<Vertex>(), new HashSet<Vertex>(), new HashSet<Link>()); } + @Override public void doLayout(LayoutGraph graph, Set<? extends Vertex> firstLayerHint, Set<? extends Vertex> lastLayerHint, Set<? extends Link> importantLinks) { this.importantLinks = importantLinks; @@ -201,14 +193,14 @@ this.firstLayerHint = firstLayerHint; this.lastLayerHint = lastLayerHint; - vertexToLayoutNode = new HashMap<Vertex, LayoutNode>(); - reversedLinks = new HashSet<Link>(); - reversedLinkStartPoints = new HashMap<Link, List<Point>>(); - reversedLinkEndPoints = new HashMap<Link, List<Point>>(); - bottomEdgeHash = new HashMap<LayoutEdge, LayoutEdge>(); - nodes = new ArrayList<LayoutNode>(); - splitStartPoints = new HashMap<Link, List<Point>>(); - splitEndPoints = new HashMap<Link, List<Point>>(); + vertexToLayoutNode = new HashMap<>(); + reversedLinks = new HashSet<>(); + reversedLinkStartPoints = new HashMap<>(); + reversedLinkEndPoints = new HashMap<>(); + bottomEdgeHash = new HashMap<>(); + nodes = new ArrayList<>(); + splitStartPoints = new HashMap<>(); + splitEndPoints = new HashMap<>(); // ############################################################# // Step 1: Build up data structure @@ -219,7 +211,7 @@ new ReverseEdges().start(); for (LayoutNode n : nodes) { - ArrayList<LayoutEdge> tmpArr = new ArrayList<LayoutEdge>(); + ArrayList<LayoutEdge> tmpArr = new ArrayList<>(); for (LayoutEdge e : n.succs) { if (importantLinks.contains(e.link)) { tmpArr.add(e); @@ -247,8 +239,7 @@ // ############################################################# // STEP 7: Assign X coordinates - //new AssignXCoordinates().start(); - new AssignXCoordinates2().start(); + new AssignXCoordinates().start(); // ############################################################# // STEP 6: Assign Y coordinates @@ -263,10 +254,11 @@ private int pointCount; + @Override protected void run() { - HashMap<Vertex, Point> vertexPositions = new HashMap<Vertex, Point>(); - HashMap<Link, List<Point>> linkPositions = new HashMap<Link, List<Point>>(); + HashMap<Vertex, Point> vertexPositions = new HashMap<>(); + HashMap<Link, List<Point>> linkPositions = new HashMap<>(); for (Vertex v : graph.getVertices()) { LayoutNode n = vertexToLayoutNode.get(v); assert !vertexPositions.containsKey(v); @@ -277,7 +269,7 @@ for (LayoutEdge e : n.preds) { if (e.link != null) { - ArrayList<Point> points = new ArrayList<Point>(); + ArrayList<Point> points = new ArrayList<>(); Point p = new Point(e.to.x + e.relativeTo, e.to.y + e.to.yOffset + e.link.getTo().getRelativePosition().y); points.add(p); @@ -362,7 +354,7 @@ for (LayoutEdge e : n.succs) { if (e.link != null) { - ArrayList<Point> points = new ArrayList<Point>(); + ArrayList<Point> points = new ArrayList<>(); Point p = new Point(e.from.x + e.relativeFrom, e.from.y + e.from.height - e.from.bottomYOffset + e.link.getFrom().getRelativePosition().y); points.add(p); if (e.from.outOffsets.containsKey(e.relativeFrom)) { @@ -498,13 +490,14 @@ public float d; public int orderNumber = -1; - public ArrayList<LayoutNode> nodes = new ArrayList<LayoutNode>(); - public HashSet<Segment> succs = new HashSet<Segment>(); - public HashSet<Segment> preds = new HashSet<Segment>(); + public ArrayList<LayoutNode> nodes = new ArrayList<>(); + public HashSet<Segment> succs = new HashSet<>(); + public HashSet<Segment> preds = new HashSet<>(); public Region region; } private static final Comparator<Segment> segmentComparator = new Comparator<Segment>() { + @Override public int compare(Segment s1, Segment s2) { return s1.orderNumber - s2.orderNumber; } @@ -514,23 +507,26 @@ public float d; public int minOrderNumber; - public SortedSet<Segment> segments = new TreeSet<Segment>(segmentComparator); - public HashSet<Region> succs = new HashSet<Region>(4); - public HashSet<Region> preds = new HashSet<Region>(4); + public SortedSet<Segment> segments = new TreeSet<>(segmentComparator); + public HashSet<Region> succs = new HashSet<>(4); + public HashSet<Region> preds = new HashSet<>(4); } private static final Comparator<Region> regionComparator = new Comparator<Region>() { + @Override public int compare(Region r1, Region r2) { return r1.minOrderNumber - r2.minOrderNumber; } }; private static final Comparator<LayoutNode> nodePositionComparator = new Comparator<LayoutNode>() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { return n1.pos - n2.pos; } }; private static final Comparator<LayoutNode> nodeProcessingDownComparator = new Comparator<LayoutNode>() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { if (n1.vertex == null) { if (n2.vertex == null) { @@ -546,6 +542,7 @@ }; private static final Comparator<LayoutNode> nodeProcessingUpComparator = new Comparator<LayoutNode>() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { if (n1.vertex == null) { if (n2.vertex == null) { @@ -560,7 +557,7 @@ } }; - private class AssignXCoordinates2 extends AlgorithmPart { + private class AssignXCoordinates extends AlgorithmPart { private ArrayList<Integer>[] space; private ArrayList<LayoutNode>[] downProcessingOrder; @@ -579,13 +576,14 @@ upProcessingOrder = new ArrayList[layers.length]; } + @Override protected void run() { createArrays(); for (int i = 0; i < layers.length; i++) { - space[i] = new ArrayList<Integer>(); - downProcessingOrder[i] = new ArrayList<LayoutNode>(); - upProcessingOrder[i] = new ArrayList<LayoutNode>(); + space[i] = new ArrayList<>(); + downProcessingOrder[i] = new ArrayList<>(); + upProcessingOrder[i] = new ArrayList<>(); int curX = 0; for (LayoutNode n : layers[i]) { @@ -604,10 +602,11 @@ sweepDown(); sweepUp(); } - - for (int i = 0; i < SWEEP_ITERATIONS; i++) { - doubleSweep(); - } + + sweepDown(); + //for (int i = 0; i < SWEEP_ITERATIONS; i++) { + // doubleSweep(); + //} } private int calculateOptimalDown(LayoutNode n) { @@ -619,6 +618,9 @@ for (int i = 0; i < size; i++) { LayoutEdge e = n.preds.get(i); values[i] = e.from.x + e.relativeFrom - e.relativeTo; + if (e.vip) { + return values[i]; + } } return median(values); } @@ -649,11 +651,15 @@ if (size == 0) { return n.x; } - long sum = 0; - for (LayoutEdge e : n.succs) { - sum += e.to.x + e.relativeTo - e.relativeFrom; + int[] values = new int[size]; + for (int i = 0; i < size; i++) { + LayoutEdge e = n.succs.get(i); + values[i] = e.to.x + e.relativeTo - e.relativeFrom; + if (e.vip) { + return values[i]; + } } - return (int) (sum / size); // why not the median? + return median(values); } private int median(int[] values) { @@ -673,14 +679,6 @@ r.insert(n, optimal); } } - /* - for(int i=0; i<layers.length; i++) { - NodeRow r = new NodeRow(space[i]); - for(LayoutNode n : upProcessingOrder[i]) { - int optimal = calculateOptimalUp(n); - r.insert(n, optimal); - } - }*/ } private void doubleSweep() { @@ -710,7 +708,7 @@ private ArrayList<Integer> space; public NodeRow(ArrayList<Integer> space) { - treeSet = new TreeSet<LayoutNode>(nodePositionComparator); + treeSet = new TreeSet<>(nodePositionComparator); this.space = space; } @@ -755,351 +753,9 @@ treeSet.add(n); } } - - private class AssignXCoordinates extends AlgorithmPart { - - HashMap<LayoutNode, Segment> hashMap = new HashMap<LayoutNode, Segment>(); - ArrayList<Segment> segments = new ArrayList<Segment>(); - - private void generateSegments() { - - for (int i = 0; i < layerCount; i++) { - for (LayoutNode n : layers[i]) { - if (!hashMap.containsKey(n)) { - Segment s = new Segment(); - segments.add(s); - LayoutNode curNode = n; - - int maxLength = 0; - while (curNode.succs.size() == 1 && curNode.preds.size() == 1) { - s.nodes.add(curNode); - assert !hashMap.containsKey(curNode); - hashMap.put(curNode, s); - curNode = curNode.succs.get(0).to; - maxLength++; - //if(maxLength > 10) break; - } - - if (s.nodes.size() > 0 && curNode.preds.size() == 1 && curNode.vertex == null) { - s.nodes.add(curNode); - assert !hashMap.containsKey(curNode); - hashMap.put(curNode, s); - } - - if (s.nodes.size() == 0) { - // Simple segment with a single node - s.nodes.add(n); - hashMap.put(n, s); - } - } - } - } - } - - private void addEdges() { - - for (int i = 0; i < layerCount; i++) { - LayoutNode prev = null; - for (LayoutNode n : layers[i]) { - - if (prev != null) { - Segment s1 = hashMap.get(prev); - Segment s2 = hashMap.get(n); - - if (s1 != s2) { - s1.succs.add(s2); - s2.preds.add(s1); - } - } - prev = n; - - } - } - } - - private void topologicalSorting() { - - Queue<Segment> queue = new LinkedList<Segment>(); - - int index = 0; - ArrayList<Segment> newList = new ArrayList<Segment>(); - for (Segment s : segments) { - if (s.preds.size() == 0) { - s.orderNumber = index; - newList.add(s); - index++; - queue.add(s); - } - } - - while (!queue.isEmpty()) { - Segment s = queue.remove(); - - for (Segment succ : s.succs) { - succ.preds.remove(s); - if (succ.preds.size() == 0) { - queue.add(succ); - succ.orderNumber = index; - newList.add(succ); - index++; - } - } - } - - segments = newList; - } - - private void initialPositions() { - - int[] minPos = new int[layers.length]; - - for (Segment s : segments) { - int max = 0; - for (LayoutNode n : s.nodes) { - int x = minPos[n.layer]; - if (x > max) { - max = x; - } - } - - for (LayoutNode n : s.nodes) { - minPos[n.layer] = max + n.width + xOffset; - n.x = max; - } - } - } - - private int predSum(LayoutNode n) { - int sum = 0; - for (LayoutEdge e : n.preds) { - assert e.to == n; - //sum += (e.from.x + e.relativeFrom + (int)hashMap.get(e.from).d) - (e.to.x + e.relativeTo + (int)hashMap.get(e.to).d); - sum += (e.from.x + e.relativeFrom) - (e.to.x + e.relativeTo); - } - - return sum; - } - - private int succSum(LayoutNode n) { - int sum = 0; - for (LayoutEdge e : n.succs) { - - assert e.from == n; - sum += (e.to.x + e.relativeTo) - (e.from.x + e.relativeFrom); - //sum += (e.to.x + e.relativeTo + (int)hashMap.get(e.to).d) - (e.from.x + e.relativeFrom + (int)hashMap.get(e.from).d); - } - - return sum; - - } - - private void downValues() { - - for (Segment s : segments) { - downValues(s); - - } - - } - - private void downValues(Segment s) { - LayoutNode n = s.nodes.get(0); // Only first node needed, all other have same coordinate - - if (n.preds.size() == 0) { - // Value is 0.0; - if (n.succs.size() == 0) { - s.d = 0.0f; - } else { - s.d = (((float) succSum(n) / (float) n.succs.size())) / 2; - } - } else { - s.d = (float) predSum(n) / (float) n.preds.size(); - } - } - - private void upValues() { - for (Segment s : segments) { - upValues(s); - } - } - - private void upValues(Segment s) { - LayoutNode n = s.nodes.get(0); // Only first node needed, all other have same coordinate - - if (n.succs.size() == 0) { - // Value is 0.0; - if (n.preds.size() == 0) { - s.d = 0.0f; - } else { - s.d = (float) predSum(n) / (float) n.preds.size(); - } - } else { - s.d = ((float) succSum(n) / (float) n.succs.size()) / 2; - } - } - - private void sweep(boolean down) { - - if (down) { - downValues(); - } else { - upValues(); - } - - SortedSet<Region> regions = new TreeSet<Region>(regionComparator); - for (Segment s : segments) { - s.region = new Region(); - s.region.minOrderNumber = s.orderNumber; - s.region.segments.add(s); - s.region.d = s.d; - regions.add(s.region); - } - - for (Segment s : segments) { - for (LayoutNode n : s.nodes) { - if (n.pos != 0) { - LayoutNode prevNode = layers[n.layer].get(n.pos - 1); - if (prevNode.x + prevNode.width + xOffset == n.x) { - Segment other = hashMap.get(prevNode); - Region r1 = s.region; - Region r2 = other.region; - // They are close together - if (r1 != r2 && r2.d >= r1.d) { - - if (r2.segments.size() < r1.segments.size()) { - - r1.d = (r1.d * r1.segments.size() + r2.d * r2.segments.size()) / (r1.segments.size() + r2.segments.size()); - - for (Segment tempS : r2.segments) { - r1.segments.add(tempS); - tempS.region = r1; - r1.minOrderNumber = Math.min(r1.minOrderNumber, tempS.orderNumber); - } - - regions.remove(r2); - } else { - - r2.d = (r1.d * r1.segments.size() + r2.d * r2.segments.size()) / (r1.segments.size() + r2.segments.size()); - - for (Segment tempS : r1.segments) { - r2.segments.add(tempS); - tempS.region = r2; - r2.minOrderNumber = Math.min(r2.minOrderNumber, tempS.orderNumber); - } - - regions.remove(r1); - } - } - } - } - } - } - - - - ArrayList<Region> reversedRegions = new ArrayList<Region>(); - for (Region r : regions) { - if (r.d < 0) { - processRegion(r, down); - } else { - reversedRegions.add(0, r); - } - } - - for (Region r : reversedRegions) { - processRegion(r, down); - } - - } - - private void processRegion(Region r, boolean down) { - - // Do not move - if ((int) r.d == 0) { - return; - } - - ArrayList<Segment> arr = new ArrayList<Segment>(); - for (Segment s : r.segments) { - arr.add(s); - } - - if (r.d > 0) { - Collections.reverse(arr); - } - - for (Segment s : arr) { - - - int min = (int) r.d; - if (min < 0) { - min = -min; - } - - for (LayoutNode n : s.nodes) { - - int layer = n.layer; - int pos = n.pos; - - - if (r.d > 0) { - - if (pos != layers[layer].size() - 1) { - - int off = layers[layer].get(pos + 1).x - n.x - xOffset - n.width; - assert off >= 0; - if (off < min) { - min = off; - } - } - - } else { - - if (pos != 0) { - - int off = n.x - xOffset - layers[layer].get(pos - 1).x - layers[layer].get(pos - 1).width; - assert off >= 0; - if (off < min) { - min = off; - } - } - } - } - - assert min >= 0; - if (min != 0) { - for (LayoutNode n : s.nodes) { - if (r.d > 0) { - n.x += min; - } else { - n.x -= min; - } - - } - } - } - } - - protected void run() { - - generateSegments(); - addEdges(); - topologicalSorting(); - initialPositions(); - for (int i = 0; i < SWEEP_ITERATIONS; i++) { - - sweep(true); - sweep(true); - sweep(false); - sweep(false); - } - - sweep(true); - sweep(true); - } - } private static Comparator<LayoutNode> crossingNodeComparator = new Comparator<LayoutNode>() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { return n1.crossingNumber - n2.crossingNumber; } @@ -1119,15 +775,16 @@ layers = new List[layerCount]; for (int i = 0; i < layerCount; i++) { - layers[i] = new ArrayList<LayoutNode>(); + layers[i] = new ArrayList<>(); } } + @Override protected void run() { createLayers(); // Generate initial ordering - HashSet<LayoutNode> visited = new HashSet<LayoutNode>(); + HashSet<LayoutNode> visited = new HashSet<>(); for (LayoutNode n : nodes) { if (n.layer == 0) { layers[0].add(n); @@ -1205,21 +862,20 @@ for (LayoutNode n : layers[i]) { int sum = 0; + int count = 0; for (LayoutEdge e : n.preds) { int cur = e.from.x + e.relativeFrom; - - /*pos; - if(e.from.width != 0 && e.relativeFrom != 0) { - cur += (float)e.relativeFrom / (float)(e.from.width); - }*/ - - sum += cur; + int factor = 1; + if (e.vip) { + factor = VIP_BONUS; + } + sum += cur*factor; + count+=factor; } - if (n.preds.size() > 0) { - sum /= n.preds.size(); + if (count > 0) { + sum /= count; n.crossingNumber = sum; - //if(n.vertex == null) n.crossingNumber += layers[i].size(); } } @@ -1248,9 +904,9 @@ next = layers[index].get(i + 1); } - boolean cond = (n.succs.size() == 0); + boolean cond = n.succs.isEmpty(); if (down) { - cond = (n.preds.size() == 0); + cond = n.preds.isEmpty(); } if (cond) { @@ -1276,21 +932,21 @@ for (LayoutNode n : layers[i]) { + int count = 0; int sum = 0; for (LayoutEdge e : n.succs) { - int cur = e.to.x + e.relativeTo;//pos; - /* - if(e.to.width != 0 && e.relativeTo != 0) { - cur += (float)e.relativeTo / (float)(e.to.width); - }*/ - - sum += cur; + int cur = e.to.x + e.relativeTo; + int factor = 1; + if (e.vip) { + factor = VIP_BONUS; + } + sum += cur*factor; + count+=factor; } - if (n.succs.size() > 0) { - sum /= n.succs.size(); + if (count > 0) { + sum /= count; n.crossingNumber = sum; - //if(n.vertex == null) n.crossingNumber += layers[i].size(); } } @@ -1310,7 +966,7 @@ @Override public void postCheck() { - HashSet<LayoutNode> visited = new HashSet<LayoutNode>(); + HashSet<LayoutNode> visited = new HashSet<>(); for (int i = 0; i < layers.length; i++) { for (LayoutNode n : layers[i]) { assert !visited.contains(n); @@ -1324,6 +980,7 @@ private class AssignYCoordinates extends AlgorithmPart { + @Override protected void run() { int curY = 0; @@ -1380,6 +1037,7 @@ } } + @Override protected void run() { oldNodeCount = nodes.size(); @@ -1388,18 +1046,19 @@ Comparator<LayoutEdge> comparator = new Comparator<LayoutEdge>() { + @Override public int compare(LayoutEdge e1, LayoutEdge e2) { return e1.to.layer - e2.to.layer; } }; - HashMap<Integer, List<LayoutEdge>> portHash = new HashMap<Integer, List<LayoutEdge>>(); - ArrayList<LayoutNode> currentNodes = new ArrayList<LayoutNode>(nodes); + HashMap<Integer, List<LayoutEdge>> portHash = new HashMap<>(); + ArrayList<LayoutNode> currentNodes = new ArrayList<>(nodes); for (LayoutNode n : currentNodes) { portHash.clear(); - ArrayList<LayoutEdge> succs = new ArrayList<LayoutEdge>(n.succs); - HashMap<Integer, LayoutNode> topNodeHash = new HashMap<Integer, LayoutNode>(); - HashMap<Integer, HashMap<Integer, LayoutNode>> bottomNodeHash = new HashMap<Integer, HashMap<Integer, LayoutNode>>(); + ArrayList<LayoutEdge> succs = new ArrayList<>(n.succs); + HashMap<Integer, LayoutNode> topNodeHash = new HashMap<>(); + HashMap<Integer, HashMap<Integer, LayoutNode>> bottomNodeHash = new HashMap<>(); for (LayoutEdge e : succs) { assert e.from.layer < e.to.layer; if (e.from.layer != e.to.layer - 1) { @@ -1418,6 +1077,7 @@ topEdge.relativeTo = topNode.width / 2; topEdge.to = topNode; topEdge.link = e.link; + topEdge.vip = e.vip; e.from.succs.add(topEdge); topNode.preds.add(topEdge); } else { @@ -1433,6 +1093,7 @@ topEdge.relativeTo = topNode.width / 2; topEdge.to = topNode; topEdge.link = e.link; + topEdge.vip = e.vip; e.from.succs.add(topEdge); topNode.preds.add(topEdge); topNodeHash.put(e.relativeFrom, topNode); @@ -1460,6 +1121,7 @@ bottomEdge.relativeFrom = bottomNode.width / 2; bottomEdge.from = bottomNode; bottomEdge.link = e.link; + bottomEdge.vip = e.vip; e.to.preds.add(bottomEdge); bottomEdgeHash.put(topEdge, bottomEdge); bottomNode.succs.add(bottomEdge); @@ -1474,7 +1136,7 @@ } } - succs = new ArrayList<LayoutEdge>(n.succs); + succs = new ArrayList<>(n.succs); for (LayoutEdge e : succs) { Integer i = e.relativeFrom; @@ -1499,6 +1161,7 @@ edges[0] = new LayoutEdge(); edges[0].from = n; edges[0].relativeFrom = i; + edges[0].vip = e.vip; n.succs.add(edges[0]); nodes[0] = new LayoutNode(); @@ -1510,6 +1173,7 @@ edges[0].relativeTo = nodes[0].width / 2; for (int j = 1; j < cnt; j++) { edges[j] = new LayoutEdge(); + edges[j].vip = e.vip; edges[j].from = nodes[j - 1]; edges[j].relativeFrom = nodes[j - 1].width / 2; nodes[j - 1].succs.add(edges[j]); @@ -1541,7 +1205,7 @@ } else if (combine == Combine.SAME_INPUTS) { throw new UnsupportedOperationException("Currently not supported"); } else { - ArrayList<LayoutNode> currentNodes = new ArrayList<LayoutNode>(nodes); + ArrayList<LayoutNode> currentNodes = new ArrayList<>(nodes); for (LayoutNode n : currentNodes) { for (LayoutEdge e : n.succs) { processSingleEdge(e); @@ -1568,6 +1232,7 @@ n.preds.add(e); nodes.add(n); LayoutEdge result = new LayoutEdge(); + result.vip = e.vip; n.succs.add(result); result.from = n; result.relativeFrom = n.width / 2; @@ -1587,7 +1252,7 @@ @Override public void postCheck() { - ArrayList<LayoutNode> currentNodes = new ArrayList<LayoutNode>(nodes); + ArrayList<LayoutNode> currentNodes = new ArrayList<>(nodes); for (LayoutNode n : currentNodes) { for (LayoutEdge e : n.succs) { assert e.from.layer == e.to.layer - 1; @@ -1612,11 +1277,12 @@ } } + @Override protected void run() { - List<LayoutNode> insertOrder = new ArrayList<LayoutNode>(); + List<LayoutNode> insertOrder = new ArrayList<>(); - HashSet<LayoutNode> set = new HashSet<LayoutNode>(); + HashSet<LayoutNode> set = new HashSet<>(); for (LayoutNode n : nodes) { if (n.preds.size() == 0) { set.add(n); @@ -1626,8 +1292,8 @@ } int z = minLayerDifference; - HashSet<LayoutNode> newSet = new HashSet<LayoutNode>(); - HashSet<LayoutNode> failed = new HashSet<LayoutNode>(); + HashSet<LayoutNode> newSet = new HashSet<>(); + HashSet<LayoutNode> failed = new HashSet<>(); while (!set.isEmpty()) { newSet.clear(); @@ -1718,11 +1384,12 @@ private HashSet<LayoutNode> visited; private HashSet<LayoutNode> active; + @Override protected void run() { // Remove self-edges for (LayoutNode node : nodes) { - ArrayList<LayoutEdge> succs = new ArrayList<LayoutEdge>(node.succs); + ArrayList<LayoutEdge> succs = new ArrayList<>(node.succs); for (LayoutEdge e : succs) { assert e.from == node; if (e.to == node) { @@ -1750,8 +1417,8 @@ // Start DFS and reverse back edges - visited = new HashSet<LayoutNode>(); - active = new HashSet<LayoutNode>(); + visited = new HashSet<>(); + active = new HashSet<>(); for (LayoutNode node : nodes) { DFS(node); } @@ -1759,7 +1426,7 @@ for (LayoutNode node : nodes) { - SortedSet<Integer> reversedDown = new TreeSet<Integer>(); + SortedSet<Integer> reversedDown = new TreeSet<>(); for (LayoutEdge e : node.succs) { if (reversedLinks.contains(e.link)) { @@ -1770,9 +1437,9 @@ SortedSet<Integer> reversedUp = null; if (reversedDown.size() == 0) { - reversedUp = new TreeSet<Integer>(Collections.reverseOrder()); + reversedUp = new TreeSet<>(Collections.reverseOrder()); } else { - reversedUp = new TreeSet<Integer>(); + reversedUp = new TreeSet<>(); } for (LayoutEdge e : node.preds) { @@ -1786,7 +1453,7 @@ int curX = 0; int curWidth = node.width + reversedDown.size() * offset; for (int pos : reversedDown) { - ArrayList<LayoutEdge> reversedSuccs = new ArrayList<LayoutEdge>(); + ArrayList<LayoutEdge> reversedSuccs = new ArrayList<>(); for (LayoutEdge e : node.succs) { if (e.relativeFrom == pos && reversedLinks.contains(e.link)) { reversedSuccs.add(e); @@ -1794,7 +1461,7 @@ } } - ArrayList<Point> startPoints = new ArrayList<Point>(); + ArrayList<Point> startPoints = new ArrayList<>(); startPoints.add(new Point(curWidth, curX)); startPoints.add(new Point(pos, curX)); startPoints.add(new Point(pos, reversedDown.size() * offset)); @@ -1824,7 +1491,7 @@ int oldNodeHeight = node.height; for (int pos : reversedUp) { - ArrayList<LayoutEdge> reversedPreds = new ArrayList<LayoutEdge>(); + ArrayList<LayoutEdge> reversedPreds = new ArrayList<>(); for (LayoutEdge e : node.preds) { if (e.relativeTo == pos && reversedLinks.contains(e.link)) { if (reversedDown.size() == 0) { @@ -1837,7 +1504,7 @@ } } node.height += offset; - ArrayList<Point> endPoints = new ArrayList<Point>(); + ArrayList<Point> endPoints = new ArrayList<>(); if (reversedDown.size() == 0) { @@ -1885,7 +1552,7 @@ return; } - Stack<LayoutNode> stack = new Stack<LayoutNode>(); + Stack<LayoutNode> stack = new Stack<>(); stack.push(startNode); while (!stack.empty()) { @@ -1902,7 +1569,7 @@ visited.add(node); active.add(node); - ArrayList<LayoutEdge> succs = new ArrayList<LayoutEdge>(node.succs); + ArrayList<LayoutEdge> succs = new ArrayList<>(node.succs); for (LayoutEdge e : succs) { if (active.contains(e.to)) { assert visited.contains(e.to); @@ -1957,8 +1624,8 @@ for (LayoutNode n : nodes) { - HashSet<LayoutNode> curVisited = new HashSet<LayoutNode>(); - Queue<LayoutNode> queue = new LinkedList<LayoutNode>(); + HashSet<LayoutNode> curVisited = new HashSet<>(); + Queue<LayoutNode> queue = new LinkedList<>(); for (LayoutEdge e : n.succs) { LayoutNode s = e.to; queue.add(s); @@ -1981,6 +1648,7 @@ } private Comparator<Link> linkComparator = new Comparator<Link>() { + @Override public int compare(Link l1, Link l2) { int result = l1.getFrom().getVertex().compareTo(l2.getFrom().getVertex()); @@ -2002,9 +1670,10 @@ private class BuildDatastructure extends AlgorithmPart { + @Override protected void run() { // Set up nodes - List<Vertex> vertices = new ArrayList<Vertex>(graph.getVertices()); + List<Vertex> vertices = new ArrayList<>(graph.getVertices()); Collections.sort(vertices); for (Vertex v : vertices) { @@ -2018,7 +1687,7 @@ } // Set up edges - List<Link> links = new ArrayList<Link>(graph.getLinks()); + List<Link> links = new ArrayList<>(graph.getLinks()); Collections.sort(links, linkComparator); for (Link l : links) { LayoutEdge edge = new LayoutEdge(); @@ -2031,6 +1700,7 @@ edge.link = l; edge.from.succs.add(edge); edge.to.preds.add(edge); + edge.vip = l.isVIP(); //assert edge.from != edge.to; // No self-loops allowed } @@ -2072,6 +1742,7 @@ } } + @Override public void doRouting(LayoutGraph graph) { // Do nothing for now }
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/InterClusterConnection.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import java.awt.Point; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class InterClusterConnection implements Link { - - private Port inputSlot; - private Port outputSlot; - private List<Point> intermediatePoints; - private ClusterInputSlotNode inputSlotNode; - private ClusterOutputSlotNode outputSlotNode; - - public InterClusterConnection(ClusterOutputSlotNode outputSlotNode, ClusterInputSlotNode inputSlotNode) { - this.outputSlotNode = outputSlotNode; - this.inputSlotNode = inputSlotNode; - this.inputSlot = inputSlotNode.getInputSlot(); - this.outputSlot = outputSlotNode.getOutputSlot(); - intermediatePoints = new ArrayList<Point>(); - } - - public ClusterOutputSlotNode getOutputSlotNode() { - return outputSlotNode; - } - - public Port getTo() { - return inputSlot; - } - - public Port getFrom() { - return outputSlot; - } - - public void setControlPoints(List<Point> p) { - this.intermediatePoints = p; - } - - public List<Point> getControlPoints() { - return intermediatePoints; - } - - @Override - public String toString() { - return "InterClusterConnection[from=" + getFrom() + ", to=" + getTo() + "]"; - } -}
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Node.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Node.java Sun Jan 29 11:40:04 2012 +0100 @@ -90,8 +90,8 @@ protected Node(Graph<N, E> graph, N data) { setData(data); this.graph = graph; - inEdges = new ArrayList<Edge<N, E>>(); - outEdges = new ArrayList<Edge<N, E>>(); + inEdges = new ArrayList<>(); + outEdges = new ArrayList<>(); } protected void addInEdge(Edge<N, E> e) { @@ -125,7 +125,7 @@ } public List<Node<N, E>> getSuccessors() { - ArrayList<Node<N, E>> succ = new ArrayList<Node<N, E>>(); + ArrayList<Node<N, E>> succ = new ArrayList<>(); for (Edge<N, E> e : getOutEdges()) { Node<N, E> n = e.getDest(); if (!succ.contains(n)) { @@ -136,7 +136,7 @@ } public List<Node<N, E>> getPredecessors() { - ArrayList<Node<N, E>> pred = new ArrayList<Node<N, E>>(); + ArrayList<Node<N, E>> pred = new ArrayList<>(); for (Edge<N, E> e : getInEdges()) { Node<N, E> n = e.getSource(); if (!pred.contains(n)) {
--- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1222 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import java.awt.Point; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import com.sun.hotspot.igv.layout.LayoutGraph; -import com.sun.hotspot.igv.layout.LayoutManager; -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; - -/** - * - * @author Thomas Wuerthinger - */ -public class OldHierarchicalLayoutManager implements LayoutManager { - - public static final int DUMMY_WIDTH = 0; - public static final int DUMMY_HEIGHT = 0; - public static final int LAYER_OFFSET = 50; - public static final int OFFSET = 8; - public static final boolean VERTICAL_LAYOUT = true; - public static final boolean ASSERT = false; - public static final boolean TRACE = false; - public static final Timing initTiming = new Timing("init"); - public static final Timing removeCyclesTiming = new Timing("removeCycles"); - public static final Timing reversedEdgesTiming = new Timing("reversedEdges"); - public static final Timing assignLayersTiming = new Timing("assignLayers"); - public static final Timing dummyNodesTiming = new Timing("dummyNodes"); - public static final Timing crossingReductionTiming = new Timing("crossingReduction"); - public static final Timing assignCoordinatesTiming = new Timing("assignCoordinates"); - public static final Timing assignRealTiming = new Timing("assignReal"); - public static final Timing rootVertexTiming = new Timing("rootVertex"); - public static final Timing createEdgesTiming = new Timing("createEdges"); - public static final Timing optimizeMedianTiming = new Timing("optimizeMedian"); - private Combine combine; - - public enum Combine { - - NONE, - SAME_INPUTS, - SAME_OUTPUTS - } - - private class NodeData { - - private Map<Port, Integer> reversePositions; - private Vertex node; - private Link edge; - private int layer; - private int x; - private int y; - private int width; - - public NodeData(Vertex node) { - reversePositions = new HashMap<Port, Integer>(); - layer = -1; - this.node = node; - assert node != null; - - if (VERTICAL_LAYOUT) { - width = node.getSize().width; - } else { - width = node.getSize().height; - } - } - - public NodeData(Link edge) { - layer = -1; - this.edge = edge; - assert edge != null; - - if (VERTICAL_LAYOUT) { - width = DUMMY_WIDTH; - } else { - width = DUMMY_HEIGHT; - } - } - - public Vertex getNode() { - return node; - } - - public Link getEdge() { - return edge; - } - - public int getCoordinate() { - return x; - } - - public void setCoordinate(int x) { - this.x = x; - } - - public int getX() { - if (VERTICAL_LAYOUT) { - return x; - } else { - return y; - } - } - - public int getY() { - if (VERTICAL_LAYOUT) { - return y; - } else { - return x; - } - } - - public void setLayerCoordinate(int y) { - this.y = y; - } - - public void setLayer(int x) { - layer = x; - } - - public int getLayer() { - return layer; - } - - public boolean isDummy() { - return edge != null; - } - - public int getWidth() { - return width; - } - - public void addReversedStartEdge(Edge<NodeData, EdgeData> e) { - assert e.getData().isReversed(); - Port port = e.getData().getEdge().getTo(); - int pos = addReversedPort(port); - Point start = e.getData().getRelativeStart(); - e.getData().addStartPoint(start); - int yCoord = node.getSize().height + width - node.getSize().width; - e.getData().addStartPoint(new Point(start.x, yCoord)); - e.getData().addStartPoint(new Point(pos, yCoord)); - e.getData().setRelativeStart(new Point(pos, 0)); - } - - private int addReversedPort(Port p) { - if (reversePositions.containsKey(p)) { - return reversePositions.get(p); - } else { - width += OFFSET; - reversePositions.put(p, width); - return width; - } - } - - public void addReversedEndEdge(Edge<NodeData, EdgeData> e) { - assert e.getData().isReversed(); - int pos = addReversedPort(e.getData().getEdge().getFrom()); - Point end = e.getData().getRelativeEnd(); - e.getData().setRelativeEnd(new Point(pos, node.getSize().height)); - int yCoord = 0 - width + node.getSize().width; - e.getData().addEndPoint(new Point(pos, yCoord)); - e.getData().addEndPoint(new Point(end.x, yCoord)); - e.getData().addEndPoint(end); - } - - public int getHeight() { - if (isDummy()) { - if (VERTICAL_LAYOUT) { - return DUMMY_HEIGHT; - } else { - return DUMMY_WIDTH; - } - - } else { - if (VERTICAL_LAYOUT) { - return node.getSize().height; - } else { - return node.getSize().width; - } - } - } - - @Override - public String toString() { - if (isDummy()) { - return edge.toString() + "(layer=" + layer + ")"; - } else { - return node.toString() + "(layer=" + layer + ")"; - } - } - } - - private class EdgeData { - - private Point relativeEnd; - private Point relativeStart; - private List<Point> startPoints; - private List<Point> endPoints; - private boolean important; - private boolean reversed; - private Link edge; - - public EdgeData(Link edge) { - this(edge, false); - } - - public EdgeData(Link edge, boolean rev) { - this.edge = edge; - reversed = rev; - relativeStart = edge.getFrom().getRelativePosition(); - relativeEnd = edge.getTo().getRelativePosition(); - assert relativeStart.x >= 0 && relativeStart.x <= edge.getFrom().getVertex().getSize().width; - assert relativeStart.y >= 0 && relativeStart.y <= edge.getFrom().getVertex().getSize().height; - assert relativeEnd.x >= 0 && relativeEnd.x <= edge.getTo().getVertex().getSize().width; - assert relativeEnd.y >= 0 && relativeEnd.y <= edge.getTo().getVertex().getSize().height; - startPoints = new ArrayList<Point>(); - endPoints = new ArrayList<Point>(); - this.important = true; - } - - public boolean isImportant() { - return important; - } - - public void setImportant(boolean b) { - this.important = b; - } - - public List<Point> getStartPoints() { - return startPoints; - } - - public List<Point> getEndPoints() { - return endPoints; - } - - public List<Point> getAbsoluteEndPoints() { - if (endPoints.size() == 0) { - return endPoints; - } - - List<Point> result = new ArrayList<Point>(); - Point point = edge.getTo().getVertex().getPosition(); - for (Point p : endPoints) { - Point p2 = new Point(p.x + point.x, p.y + point.y); - result.add(p2); - } - - return result; - } - - public List<Point> getAbsoluteStartPoints() { - if (startPoints.size() == 0) { - return startPoints; - } - - List<Point> result = new ArrayList<Point>(); - Point point = edge.getFrom().getVertex().getPosition(); - for (Point p : startPoints) { - Point p2 = new Point(p.x + point.x, p.y + point.y); - result.add(p2); - } - - return result; - } - - public void addEndPoint(Point p) { - endPoints.add(p); - } - - public void addStartPoint(Point p) { - startPoints.add(p); - } - - public Link getEdge() { - return edge; - } - - public void setRelativeEnd(Point p) { - relativeEnd = p; - } - - public void setRelativeStart(Point p) { - relativeStart = p; - } - - public Point getRelativeEnd() { - return relativeEnd; - } - - public Point getRelativeStart() { - return relativeStart; - } - - public boolean isReversed() { - return reversed; - } - - public void setReversed(boolean b) { - reversed = b; - } - - @Override - public String toString() { - return "EdgeData[reversed=" + reversed + "]"; - } - } - private Graph<NodeData, EdgeData> graph; - private Map<Vertex, Node<NodeData, EdgeData>> nodeMap; - private int layerOffset; - - /** Creates a new instance of HierarchicalPositionManager */ - public OldHierarchicalLayoutManager(Combine combine) { - this(combine, LAYER_OFFSET); - } - - public OldHierarchicalLayoutManager(Combine combine, int layerOffset) { - this.combine = combine; - this.layerOffset = layerOffset; - } - - public void doRouting(LayoutGraph graph) { - } - - //public void setPositions(PositionedNode rootNode, List<? extends PositionedNode> nodes, List<? extends PositionedEdge> edges) { - public void doLayout(LayoutGraph layoutGraph) { - doLayout(layoutGraph, new HashSet<Vertex>(), new HashSet<Vertex>()); - } - - public void doLayout(LayoutGraph layoutGraph, Set<? extends Vertex> firstLayerHint, Set<? extends Vertex> lastLayerHint) { - doLayout(layoutGraph, firstLayerHint, lastLayerHint, new HashSet<Link>()); - } - - public void doLayout(LayoutGraph layoutGraph, Set<? extends Vertex> firstLayerHint, Set<? extends Vertex> lastLayerHint, Set<? extends Link> importantLinksHint) { - - if (TRACE) { - System.out.println("HierarchicalPositionManager.doLayout called"); - System.out.println("Vertex count = " + layoutGraph.getVertices().size() + " Link count = " + layoutGraph.getLinks().size()); - } - - // Nothing to do => quit immediately - if (layoutGraph.getVertices().size() == 0) { - return; - } - - initTiming.start(); - - // Mapping vertex to Node in graph - nodeMap = new HashMap<Vertex, Node<NodeData, EdgeData>>(); - - graph = new Graph<NodeData, EdgeData>(); - - Set<Node<NodeData, EdgeData>> rootNodes = new HashSet<Node<NodeData, EdgeData>>(); - Set<Vertex> startRootVertices = new HashSet<Vertex>(); - - for (Vertex v : layoutGraph.getVertices()) { - if (v.isRoot()) { - startRootVertices.add(v); - } - } - - rootVertexTiming.start(); - Set<Vertex> rootVertices = layoutGraph.findRootVertices(startRootVertices); - rootVertexTiming.stop(); - - - for (Vertex node : layoutGraph.getVertices()) { - - NodeData data = new NodeData(node); - Node<NodeData, EdgeData> n = graph.createNode(data, node); - nodeMap.put(node, n); - - if (rootVertices.contains(node)) { - rootNodes.add(n); - } - } - - Set<? extends Link> links = layoutGraph.getLinks(); - Link[] linkArr = new Link[links.size()]; - links.toArray(linkArr); - - List<Link> linkList = new ArrayList<Link>(); - for (Link l : linkArr) { - linkList.add(l); - } - - createEdgesTiming.start(); - Collections.sort(linkList, new Comparator<Link>() { - - public int compare(Link o1, Link o2) { - int result = o1.getFrom().getVertex().compareTo(o2.getFrom().getVertex()); - if (result == 0) { - return o1.getTo().getVertex().compareTo(o2.getTo().getVertex()); - } else { - return result; - } - } - }); - - for (Link edge : linkList) { - EdgeData data = new EdgeData(edge); - graph.createEdge(graph.getNode(edge.getFrom().getVertex()), graph.getNode(edge.getTo().getVertex()), data, data); - if (importantLinksHint.size() > 0 && !importantLinksHint.contains(edge)) { - data.setImportant(false); - } - } - createEdgesTiming.stop(); - - initTiming.stop(); - - removeCyclesTiming.start(); - - // STEP 1: Remove cycles! - removeCycles(rootNodes); - if (ASSERT) { - assert checkRemoveCycles(); - } - - removeCyclesTiming.stop(); - - reversedEdgesTiming.start(); - - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - List<Edge<NodeData, EdgeData>> edges = new ArrayList<Edge<NodeData, EdgeData>>(n.getOutEdges()); - Collections.sort(edges, new Comparator<Edge<NodeData, EdgeData>>() { - - public int compare(Edge<NodeData, EdgeData> o1, Edge<NodeData, EdgeData> o2) { - return o2.getData().getRelativeEnd().x - o1.getData().getRelativeEnd().x; - } - }); - - - for (Edge<NodeData, EdgeData> e : edges) { - - if (e.getData().isReversed()) { - e.getSource().getData().addReversedEndEdge(e); - } - } - } - - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - List<Edge<NodeData, EdgeData>> edges = new ArrayList<Edge<NodeData, EdgeData>>(n.getInEdges()); - Collections.sort(edges, new Comparator<Edge<NodeData, EdgeData>>() { - - public int compare(Edge<NodeData, EdgeData> o1, Edge<NodeData, EdgeData> o2) { - return o2.getData().getRelativeStart().x - o1.getData().getRelativeStart().x; - } - }); - - - for (Edge<NodeData, EdgeData> e : edges) { - if (e.getData().isReversed()) { - e.getDest().getData().addReversedStartEdge(e); - } - } - } - - reversedEdgesTiming.stop(); - - assignLayersTiming.start(); - // STEP 2: Assign layers! - int maxLayer = assignLayers(rootNodes, firstLayerHint, lastLayerHint); - if (ASSERT) { - assert checkAssignLayers(); - } - - // Put into layer array - //int maxLayer = 0; - //for(Node<NodeData, EdgeData> n : graph.getNodes()) { - // maxLayer = Math.max(maxLayer, n.getData().getLayer()); - //} - - - @SuppressWarnings("unchecked") - ArrayList<Node<NodeData, EdgeData>> layers[] = (ArrayList<Node<NodeData, EdgeData>>[]) new ArrayList[maxLayer + 1]; - int layerSizes[] = new int[maxLayer + 1]; - for (int i = 0; i < maxLayer + 1; i++) { - layers[i] = new ArrayList<Node<NodeData, EdgeData>>(); - } - - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - int curLayer = n.getData().getLayer(); - layers[curLayer].add(n); - } - - assignLayersTiming.stop(); - - // STEP 3: Insert dummy nodes! - dummyNodesTiming.start(); - insertDummyNodes(layers); - if (ASSERT) { - assert checkDummyNodes(); - } - dummyNodesTiming.stop(); - - crossingReductionTiming.start(); - // STEP 4: Assign Y coordinates - assignLayerCoordinates(layers, layerSizes); - - // STEP 5: Crossing reduction - crossingReduction(layers); - crossingReductionTiming.stop(); - - // STEP 6: Assign Y coordinates - assignCoordinatesTiming.start(); - assignCoordinates(layers); - assignCoordinatesTiming.stop(); - - assignRealTiming.start(); - - // Assign coordinates of nodes to real objects - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - if (!n.getData().isDummy()) { - - Vertex node = n.getData().getNode(); - node.setPosition(new Point(n.getData().getX(), n.getData().getY())); - } - } - - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - if (!n.getData().isDummy()) { - - Vertex node = n.getData().getNode(); - - List<Edge<NodeData, EdgeData>> outEdges = n.getOutEdges(); - for (Edge<NodeData, EdgeData> e : outEdges) { - Node<NodeData, EdgeData> succ = e.getDest(); - if (succ.getData().isDummy()) { - //PositionedEdge edge = succ.getData().getEdge(); - List<Point> points = new ArrayList<Point>(); - assignToRealObjects(layerSizes, succ, points); - } else { - List<Point> points = new ArrayList<Point>(); - - EdgeData otherEdgeData = e.getData(); - points.addAll(otherEdgeData.getAbsoluteStartPoints()); - Link otherEdge = otherEdgeData.getEdge(); - Point relFrom = new Point(otherEdgeData.getRelativeStart()); - Point from = otherEdge.getFrom().getVertex().getPosition(); - relFrom.move(relFrom.x + from.x, relFrom.y + from.y); - points.add(relFrom); - - Point relTo = new Point(otherEdgeData.getRelativeEnd()); - Point to = otherEdge.getTo().getVertex().getPosition(); - relTo.move(relTo.x + to.x, relTo.y + to.y); - assert from != null; - assert to != null; - points.add(relTo); - points.addAll(otherEdgeData.getAbsoluteEndPoints()); - e.getData().getEdge().setControlPoints(points); - } - } - } - } - - assignRealTiming.stop(); - - initTiming.print(); - removeCyclesTiming.print(); - reversedEdgesTiming.print(); - assignLayersTiming.print(); - dummyNodesTiming.print(); - crossingReductionTiming.print(); - assignCoordinatesTiming.print(); - assignRealTiming.print(); - rootVertexTiming.print(); - createEdgesTiming.print(); - optimizeMedianTiming.print(); - } - - public boolean onOneLine(Point p1, Point p2, Point p3) { - int xoff1 = p1.x - p2.x; - int yoff1 = p1.y - p2.y; - int xoff2 = p3.x - p2.x; - int yoff2 = p3.y - p2.x; - - return (xoff1 * yoff2 - yoff1 * xoff2 == 0); - } - - private void assignToRealObjects(int layerSizes[], Node<NodeData, EdgeData> cur, List<Point> points) { - assert cur.getData().isDummy(); - - ArrayList<Point> otherPoints = new ArrayList<Point>(points); - - int size = layerSizes[cur.getData().getLayer()]; - otherPoints.add(new Point(cur.getData().getX(), cur.getData().getY() - size / 2)); - if (otherPoints.size() >= 3 && onOneLine(otherPoints.get(otherPoints.size() - 1), otherPoints.get(otherPoints.size() - 2), otherPoints.get(otherPoints.size() - 3))) { - otherPoints.remove(otherPoints.size() - 2); - } - otherPoints.add(new Point(cur.getData().getX(), cur.getData().getY() + size / 2)); - if (otherPoints.size() >= 3 && onOneLine(otherPoints.get(otherPoints.size() - 1), otherPoints.get(otherPoints.size() - 2), otherPoints.get(otherPoints.size() - 3))) { - otherPoints.remove(otherPoints.size() - 2); - } - - for (int i = 0; i < cur.getOutEdges().size(); i++) { - Node<NodeData, EdgeData> otherSucc = cur.getOutEdges().get(i).getDest(); - - if (otherSucc.getData().isDummy()) { - assignToRealObjects(layerSizes, otherSucc, otherPoints); - } else { - EdgeData otherEdgeData = cur.getOutEdges().get(i).getData(); - Link otherEdge = otherEdgeData.getEdge(); - - List<Point> middlePoints = new ArrayList<Point>(otherPoints); - if (cur.getOutEdges().get(i).getData().isReversed()) { - Collections.reverse(middlePoints); - } - - ArrayList<Point> copy = new ArrayList<Point>(); - Point relFrom = new Point(otherEdgeData.getRelativeStart()); - Point from = otherEdge.getFrom().getVertex().getPosition(); - //int moveUp = (size - otherEdge.getFrom().getVertex().getSize().height) / 2; - relFrom.move(relFrom.x + from.x, relFrom.y + from.y); - copy.addAll(otherEdgeData.getAbsoluteStartPoints()); - copy.add(relFrom); - copy.addAll(middlePoints); - - Point relTo = new Point(otherEdgeData.getRelativeEnd()); - Point to = otherEdge.getTo().getVertex().getPosition(); - relTo.move(relTo.x + to.x, relTo.y + to.y); - copy.add(relTo); - - copy.addAll(otherEdgeData.getAbsoluteEndPoints()); - - - otherEdge.setControlPoints(copy); - } - } - } - - private boolean checkDummyNodes() { - for (Edge<NodeData, EdgeData> e : graph.getEdges()) { - if (e.getSource().getData().getLayer() != e.getDest().getData().getLayer() - 1) { - return false; - } - } - - return true; - } - - private void insertDummyNodes(ArrayList<Node<NodeData, EdgeData>> layers[]) { - - int sum = 0; - List<Node<NodeData, EdgeData>> nodes = new ArrayList<Node<NodeData, EdgeData>>(graph.getNodes()); - int edgeCount = 0; - int innerMostLoop = 0; - - for (Node<NodeData, EdgeData> n : nodes) { - List<Edge<NodeData, EdgeData>> edges = new ArrayList<Edge<NodeData, EdgeData>>(n.getOutEdges()); - for (Edge<NodeData, EdgeData> e : edges) { - - edgeCount++; - Link edge = e.getData().getEdge(); - Node<NodeData, EdgeData> destNode = e.getDest(); - Node<NodeData, EdgeData> lastNode = n; - Edge<NodeData, EdgeData> lastEdge = e; - - boolean searchForNode = (combine != Combine.NONE); - for (int i = n.getData().getLayer() + 1; i < destNode.getData().getLayer(); i++) { - - Node<NodeData, EdgeData> foundNode = null; - if (searchForNode) { - for (Node<NodeData, EdgeData> sameLayerNode : layers[i]) { - innerMostLoop++; - - if (combine == Combine.SAME_OUTPUTS) { - if (sameLayerNode.getData().isDummy() && sameLayerNode.getData().getEdge().getFrom() == edge.getFrom()) { - foundNode = sameLayerNode; - break; - } - } else if (combine == Combine.SAME_INPUTS) { - if (sameLayerNode.getData().isDummy() && sameLayerNode.getData().getEdge().getTo() == edge.getTo()) { - foundNode = sameLayerNode; - break; - } - } - } - } - - if (foundNode == null) { - searchForNode = false; - NodeData intermediateData = new NodeData(edge); - Node<NodeData, EdgeData> curNode = graph.createNode(intermediateData, null); - curNode.getData().setLayer(i); - layers[i].add(0, curNode); - sum++; - lastEdge.remove(); - graph.createEdge(lastNode, curNode, e.getData(), null); - assert lastNode.getData().getLayer() == curNode.getData().getLayer() - 1; - lastEdge = graph.createEdge(curNode, destNode, e.getData(), null); - lastNode = curNode; - } else { - lastEdge.remove(); - lastEdge = graph.createEdge(foundNode, destNode, e.getData(), null); - lastNode = foundNode; - } - - } - } - } - - if (TRACE) { - System.out.println("Number of edges: " + edgeCount); - } - if (TRACE) { - System.out.println("Dummy nodes inserted: " + sum); - } - } - - private void assignLayerCoordinates(ArrayList<Node<NodeData, EdgeData>> layers[], int layerSizes[]) { - int cur = 0; - for (int i = 0; i < layers.length; i++) { - int maxHeight = 0; - for (Node<NodeData, EdgeData> n : layers[i]) { - maxHeight = Math.max(maxHeight, n.getData().getHeight()); - } - - layerSizes[i] = maxHeight; - for (Node<NodeData, EdgeData> n : layers[i]) { - int curCoordinate = cur + (maxHeight - n.getData().getHeight()) / 2; - n.getData().setLayerCoordinate(curCoordinate); - } - cur += maxHeight + layerOffset; - - } - } - - private void assignCoordinates(ArrayList<Node<NodeData, EdgeData>> layers[]) { - - for (int i = 0; i < layers.length; i++) { - ArrayList<Node<NodeData, EdgeData>> curArray = layers[i]; - int curY = 0; - for (Node<NodeData, EdgeData> n : curArray) { - - n.getData().setCoordinate(curY); - if (!n.getData().isDummy()) { - curY += n.getData().getWidth(); - } - curY += OFFSET; - - } - } - - int curSol = evaluateSolution(); - if (TRACE) { - System.out.println("First coordinate solution found: " + curSol); - } - - // Sort to correct order - for (int i = 0; i < layers.length; i++) { - Collections.sort(layers[i], new Comparator<Node<NodeData, EdgeData>>() { - - public int compare(Node<NodeData, EdgeData> o1, Node<NodeData, EdgeData> o2) { - if (o2.getData().isDummy()) { - return 1; - } else if (o1.getData().isDummy()) { - return -1; - } - return o2.getInEdges().size() + o2.getOutEdges().size() - o1.getInEdges().size() - o1.getOutEdges().size(); - } - }); - } - - - optimizeMedianTiming.start(); - for (int i = 0; i < 2; i++) { - optimizeMedian(layers); - curSol = evaluateSolution(); - if (TRACE) { - System.out.println("Current coordinate solution found: " + curSol); - } - } - optimizeMedianTiming.stop(); - normalizeCoordinate(); - - } - - private void normalizeCoordinate() { - - int min = Integer.MAX_VALUE; - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - min = Math.min(min, n.getData().getCoordinate()); - } - - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - n.getData().setCoordinate(n.getData().getCoordinate() - min); - } - - } - - private void optimizeMedian(ArrayList<Node<NodeData, EdgeData>> layers[]) { - - // Downsweep - for (int i = 1; i < layers.length; i++) { - - ArrayList<Node<NodeData, EdgeData>> processingList = layers[i]; - ArrayList<Node<NodeData, EdgeData>> alreadyAssigned = new ArrayList<Node<NodeData, EdgeData>>(); - for (Node<NodeData, EdgeData> n : processingList) { - - - ArrayList<Node<NodeData, EdgeData>> preds = new ArrayList<Node<NodeData, EdgeData>>(n.getPredecessors()); - int pos = n.getData().getCoordinate(); - if (preds.size() > 0) { - - Collections.sort(preds, new Comparator<Node<NodeData, EdgeData>>() { - - public int compare(Node<NodeData, EdgeData> o1, Node<NodeData, EdgeData> o2) { - return o1.getData().getCoordinate() - o2.getData().getCoordinate(); - } - }); - - if (preds.size() % 2 == 0) { - assert preds.size() >= 2; - pos = (preds.get(preds.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(preds.get(preds.size() / 2), n) + preds.get(preds.size() / 2 - 1).getData().getCoordinate() - calcRelativeCoordinate(preds.get(preds.size() / 2 - 1), n)) / 2; - } else { - assert preds.size() >= 1; - pos = preds.get(preds.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(preds.get(preds.size() / 2), n); - } - } - - tryAdding(alreadyAssigned, n, pos); - } - } - // Upsweep - for (int i = layers.length - 2; i >= 0; i--) { - ArrayList<Node<NodeData, EdgeData>> processingList = layers[i]; - ArrayList<Node<NodeData, EdgeData>> alreadyAssigned = new ArrayList<Node<NodeData, EdgeData>>(); - for (Node<NodeData, EdgeData> n : processingList) { - - ArrayList<Node<NodeData, EdgeData>> succs = new ArrayList<Node<NodeData, EdgeData>>(n.getSuccessors()); - int pos = n.getData().getCoordinate(); - if (succs.size() > 0) { - - Collections.sort(succs, new Comparator<Node<NodeData, EdgeData>>() { - - public int compare(Node<NodeData, EdgeData> o1, Node<NodeData, EdgeData> o2) { - return o1.getData().getCoordinate() - o2.getData().getCoordinate(); - } - }); - - if (succs.size() % 2 == 0) { - assert succs.size() >= 2; - pos = (succs.get(succs.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(n, succs.get(succs.size() / 2)) + succs.get(succs.size() / 2 - 1).getData().getCoordinate() - calcRelativeCoordinate(n, succs.get(succs.size() / 2 - 1))) / 2; - } else { - assert succs.size() >= 1; - pos = succs.get(succs.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(n, succs.get(succs.size() / 2)); - } - } - - tryAdding(alreadyAssigned, n, pos); - } - } - } - - private int median(ArrayList<Integer> arr) { - assert arr.size() > 0; - Collections.sort(arr); - if (arr.size() % 2 == 0) { - return (arr.get(arr.size() / 2) + arr.get(arr.size() / 2 - 1)) / 2; - } else { - return arr.get(arr.size() / 2); - } - } - - private int calcRelativeCoordinate(Node<NodeData, EdgeData> n, Node<NodeData, EdgeData> succ) { - - if (n.getData().isDummy() && succ.getData().isDummy()) { - return 0; - } - - int pos = 0; - int pos2 = 0; - ArrayList<Integer> coords2 = new ArrayList<Integer>(); - ArrayList<Integer> coords = new ArrayList<Integer>(); - /*if(!n.getData().isDummy())*/ { - for (Edge<NodeData, EdgeData> e : n.getOutEdges()) { - - //System.out.println("reversed: " + e.getData().isReversed()); - if (e.getDest() == succ) { - - if (e.getData().isReversed()) { - if (!n.getData().isDummy()) { - coords.add(e.getData().getRelativeEnd().x); - } - - if (!succ.getData().isDummy()) { - coords2.add(e.getData().getRelativeStart().x); - } - } else { - if (!n.getData().isDummy()) { - coords.add(e.getData().getRelativeStart().x); - } - - if (!succ.getData().isDummy()) { - coords2.add(e.getData().getRelativeEnd().x); - } - } - } - } - - // assert coords.size() > 0; - if (!n.getData().isDummy()) { - pos = median(coords); - } - - if (!succ.getData().isDummy()) { - pos2 = median(coords2); - } - } - //System.out.println("coords=" + coords); - //System.out.println("coords2=" + coords2); - - return pos - pos2; - } - - private boolean intersect(int v1, int w1, int v2, int w2) { - if (v1 >= v2 && v1 < v2 + w2) { - return true; - } - if (v1 + w1 > v2 && v1 + w1 < v2 + w2) { - return true; - } - if (v1 < v2 && v1 + w1 > v2) { - return true; - } - return false; - } - - private boolean intersect(Node<NodeData, EdgeData> n1, Node<NodeData, EdgeData> n2) { - return intersect(n1.getData().getCoordinate(), n1.getData().getWidth() + OFFSET, n2.getData().getCoordinate(), n2.getData().getWidth() + OFFSET); - } - - private void tryAdding(List<Node<NodeData, EdgeData>> alreadyAssigned, Node<NodeData, EdgeData> node, int pos) { - - boolean doesIntersect = false; - node.getData().setCoordinate(pos); - for (Node<NodeData, EdgeData> n : alreadyAssigned) { - if (n.getData().getCoordinate() + n.getData().getWidth() < pos) { - break; - } else if (intersect(node, n)) { - doesIntersect = true; - break; - } - - } - - if (!doesIntersect) { - - // Everything fine, just place the node - int z = 0; - for (Node<NodeData, EdgeData> n : alreadyAssigned) { - if (pos > n.getData().getCoordinate()) { - break; - } - z++; - } - - if (z == -1) { - z = alreadyAssigned.size(); - } - - - if (ASSERT) { - assert !findOverlap(alreadyAssigned, node); - } - alreadyAssigned.add(z, node); - - } else { - - assert alreadyAssigned.size() > 0; - - // Search for alternative location - int minOffset = Integer.MAX_VALUE; - int minIndex = -1; - int minPos = 0; - int w = node.getData().getWidth() + OFFSET; - - // Try top-most - minIndex = 0; - minPos = alreadyAssigned.get(0).getData().getCoordinate() + alreadyAssigned.get(0).getData().getWidth() + OFFSET; - minOffset = Math.abs(minPos - pos); - - // Try bottom-most - Node<NodeData, EdgeData> lastNode = alreadyAssigned.get(alreadyAssigned.size() - 1); - int lastPos = lastNode.getData().getCoordinate() - w; - int lastOffset = Math.abs(lastPos - pos); - if (lastOffset < minOffset) { - minPos = lastPos; - minOffset = lastOffset; - minIndex = alreadyAssigned.size(); - } - - // Try between - for (int i = 0; i < alreadyAssigned.size() - 1; i++) { - Node<NodeData, EdgeData> curNode = alreadyAssigned.get(i); - Node<NodeData, EdgeData> nextNode = alreadyAssigned.get(i + 1); - - int start = nextNode.getData().getCoordinate() + nextNode.getData().getWidth() + OFFSET; - int end = curNode.getData().getCoordinate() - OFFSET; - - int bestPoss = end - node.getData().getWidth(); - if (bestPoss < pos && pos - bestPoss > minOffset) { - // No better solution possible => break - break; - } - - if (end - start >= node.getData().getWidth()) { - // Node could fit here - int cand1 = start; - int cand2 = end - node.getData().getWidth(); - int off1 = Math.abs(cand1 - pos); - int off2 = Math.abs(cand2 - pos); - if (off1 < minOffset) { - minPos = cand1; - minOffset = off1; - minIndex = i + 1; - } - - if (off2 < minOffset) { - minPos = cand2; - minOffset = off2; - minIndex = i + 1; - } - } - } - - assert minIndex != -1; - node.getData().setCoordinate(minPos); - if (ASSERT) { - assert !findOverlap(alreadyAssigned, node); - } - alreadyAssigned.add(minIndex, node); - } - - } - - private boolean findOverlap(List<Node<NodeData, EdgeData>> nodes, Node<NodeData, EdgeData> node) { - - for (Node<NodeData, EdgeData> n1 : nodes) { - if (intersect(n1, node)) { - return true; - } - } - - return false; - } - - private int evaluateSolution() { - - int sum = 0; - for (Edge<NodeData, EdgeData> e : graph.getEdges()) { - Node<NodeData, EdgeData> source = e.getSource(); - Node<NodeData, EdgeData> dest = e.getDest(); - int offset = 0; - offset = Math.abs(source.getData().getCoordinate() - dest.getData().getCoordinate()); - sum += offset; - } - - return sum; - } - - private void crossingReduction(ArrayList<Node<NodeData, EdgeData>> layers[]) { - - for (int i = 0; i < layers.length - 1; i++) { - - ArrayList<Node<NodeData, EdgeData>> curNodes = layers[i]; - ArrayList<Node<NodeData, EdgeData>> nextNodes = layers[i + 1]; - for (Node<NodeData, EdgeData> n : curNodes) { - for (Node<NodeData, EdgeData> succ : n.getSuccessors()) { - if (ASSERT) { - assert nextNodes.contains(succ); - } - nextNodes.remove(succ); - nextNodes.add(succ); - } - } - - } - - } - - private void removeCycles(Set<Node<NodeData, EdgeData>> rootNodes) { - final List<Edge<NodeData, EdgeData>> reversedEdges = new ArrayList<Edge<NodeData, EdgeData>>(); - - - int removedCount = 0; - int reversedCount = 0; - - Graph<NodeData, EdgeData>.DFSTraversalVisitor visitor = graph.new DFSTraversalVisitor() { - - @Override - public boolean visitEdge(Edge<NodeData, EdgeData> e, boolean backEdge) { - if (backEdge) { - if (ASSERT) { - assert !reversedEdges.contains(e); - } - reversedEdges.add(e); - e.getData().setReversed(!e.getData().isReversed()); - } - - return e.getData().isImportant(); - } - }; - Set<Node<NodeData, EdgeData>> nodes = new HashSet<Node<NodeData, EdgeData>>(); - nodes.addAll(rootNodes); - - assert nodes.size() > 0; - - this.graph.traverseDFS(nodes, visitor); - - for (Edge<NodeData, EdgeData> e : reversedEdges) { - if (e.isSelfLoop()) { - e.remove(); - removedCount++; - } else { - e.reverse(); - reversedCount++; - } - } - } - - private boolean checkRemoveCycles() { - return !graph.hasCycles(); - } - // Only used by assignLayers - private int maxLayerTemp; - - private int assignLayers(Set<Node<NodeData, EdgeData>> rootNodes, Set<? extends Vertex> firstLayerHints, - Set<? extends Vertex> lastLayerHints) { - this.maxLayerTemp = -1; - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - n.getData().setLayer(-1); - } - - Graph<NodeData, EdgeData>.BFSTraversalVisitor traverser = graph.new BFSTraversalVisitor() { - - @Override - public void visitNode(Node<NodeData, EdgeData> n, int depth) { - if (depth > n.getData().getLayer()) { - n.getData().setLayer(depth); - maxLayerTemp = Math.max(maxLayerTemp, depth); - } - } - }; - - for (Node<NodeData, EdgeData> n : rootNodes) { - if (n.getData().getLayer() == -1) { - this.graph.traverseBFS(n, traverser, true); - } - } - - for (Vertex v : firstLayerHints) { - assert nodeMap.containsKey(v); - nodeMap.get(v).getData().setLayer(0); - } - - for (Vertex v : lastLayerHints) { - assert nodeMap.containsKey(v); - nodeMap.get(v).getData().setLayer(maxLayerTemp); - } - - return maxLayerTemp; - } - - private boolean checkAssignLayers() { - - for (Edge<NodeData, EdgeData> e : graph.getEdges()) { - Node<NodeData, EdgeData> source = e.getSource(); - Node<NodeData, EdgeData> dest = e.getDest(); - - - if (source.getData().getLayer() >= dest.getData().getLayer()) { - return false; - } - } - int maxLayer = 0; - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - assert n.getData().getLayer() >= 0; - if (n.getData().getLayer() > maxLayer) { - maxLayer = n.getData().getLayer(); - } - } - - int countPerLayer[] = new int[maxLayer + 1]; - for (Node<NodeData, EdgeData> n : graph.getNodes()) { - countPerLayer[n.getData().getLayer()]++; - } - - if (TRACE) { - System.out.println("Number of layers: " + maxLayer); - } - return true; - } -}
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.java6scriptingproxy" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.java6scriptingproxy.</description> - <import file="nbproject/build-impl.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/manifest.mf Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.java6scriptingproxy -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 -
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.java6scriptingproxy-impl" basedir=".."> - <fail message="Please build using Ant 1.7.1 or higher."> - <condition> - <not> - <antversion atleast="1.7.1"/> - </not> - </condition> - </fail> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="property"/> - <attribute name="value"/> - <sequential> - <property name="@{property}" value="@{value}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> - <condition> - <not> - <contains string="${cluster.path.evaluated}" substring="platform"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=485d21b4 -nbproject/build-impl.xml.script.CRC32=341e7d1e -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.java6scriptingproxy</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.filter</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graph</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages> - <package>com.sun.hotspot.igv.java6scriptingproxy</package> - </public-packages> - </data> - </configuration> -</project>
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/suite.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.java6scriptingproxy.JavaSE6ScriptEngine \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=Java6ScriptingProxy
--- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.hotspot.igv.java6scriptingproxy; - -import com.sun.hotspot.igv.filter.*; -import com.sun.hotspot.igv.graph.Diagram; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -/** - * - * @author Thomas Wuerthinger - */ -public class JavaSE6ScriptEngine implements ScriptEngineAbstraction { - - private Object engine; - private Object bindings; - private Method Bindings_put; - private Method ScriptEngine_eval; - - public boolean initialize(String jsHelperText) { - try { - ClassLoader cl = JavaSE6ScriptEngine.class.getClassLoader(); - Class<?> managerClass = cl.loadClass("javax.script.ScriptEngineManager"); - Class<?> engineClass = cl.loadClass("javax.script.ScriptEngine"); - Class<?> bindingsClass = cl.loadClass("javax.script.Bindings"); - Class<?> contextClass = cl.loadClass("javax.script.ScriptContext"); - - Object manager = managerClass.newInstance(); - Method getEngineByName = managerClass.getMethod("getEngineByName", String.class); - engine = getEngineByName.invoke(manager, "ECMAScript"); - Method eval = engineClass.getMethod("eval", String.class); - ScriptEngine_eval = engineClass.getMethod("eval", String.class, bindingsClass); - eval.invoke(engine, jsHelperText); - Method getContext = engineClass.getMethod("getContext"); - Object context = getContext.invoke(engine); - Method getBindings = contextClass.getMethod("getBindings", Integer.TYPE); - Field f = contextClass.getField("ENGINE_SCOPE"); - bindings = getBindings.invoke(context, f.getInt(null)); - Bindings_put = bindingsClass.getMethod("put", String.class, Object.class); - Bindings_put.invoke(bindings, "IO", System.out); - - /* - * Non-reflective code: - ScriptEngineManager sem = new ScriptEngineManager(); - ScriptEngine e = sem.getEngineByName("ECMAScript"); - engine = e; - e.eval(jsHelperText); - Bindings b = e.getContext().getBindings(ScriptContext.ENGINE_SCOPE); - b.put("IO", System.out); - bindings = b; - */ - - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public void execute(Diagram d, String code) { - try { - Bindings_put.invoke(bindings, "graph", d); - ScriptEngine_eval.invoke(engine, code, bindings); - } catch (Exception ex) { - ex.printStackTrace(); - } - } -}
--- a/src/share/tools/IdealGraphVisualizer/Layout/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Layout/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.layout; - -import java.awt.Rectangle; -import java.util.Set; - -/** - * - * @author Thomas Wuerthinger - */ -public interface Cluster extends Comparable<Cluster> { - - public Cluster getOuter(); - - public void setBounds(Rectangle r); - - public Set<? extends Cluster> getSuccessors(); -}
--- a/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.layout; -import java.util.HashSet; -import java.util.HashMap; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.*; /** * @@ -49,10 +45,10 @@ this.links = links; assert verify(); - vertices = new TreeSet<Vertex>(); - portLinks = new HashMap<Port, Set<Link>>(links.size()); - inputPorts = new HashMap<Vertex, Set<Port>>(links.size()); - outputPorts = new HashMap<Vertex, Set<Port>>(links.size()); + vertices = new TreeSet<>(); + portLinks = new HashMap<>(links.size()); + inputPorts = new HashMap<>(links.size()); + outputPorts = new HashMap<>(links.size()); for (Link l : links) { Port p = l.getFrom(); @@ -76,7 +72,7 @@ } if (!portLinks.containsKey(p)) { - HashSet<Link> hashSet = new HashSet<Link>(3); + HashSet<Link> hashSet = new HashSet<>(3); portLinks.put(p, hashSet); } @@ -152,7 +148,7 @@ // whole graph is visited. public Set<Vertex> findRootVertices(Set<Vertex> startingRoots) { - Set<Vertex> notRootSet = new HashSet<Vertex>(); + Set<Vertex> notRootSet = new HashSet<>(); for (Vertex v : startingRoots) { if (!notRootSet.contains(v)) { markNotRoot(notRootSet, v, v); @@ -174,7 +170,7 @@ } } - Set<Vertex> result = new HashSet<Vertex>(); + Set<Vertex> result = new HashSet<>(); for (Vertex v : tmpVertices) { if (!notRootSet.contains(v)) { result.add(v); @@ -187,16 +183,4 @@ public Set<Vertex> findRootVertices() { return findRootVertices(new HashSet<Vertex>()); } - - public SortedSet<Cluster> getClusters() { - - SortedSet<Cluster> clusters = new TreeSet<Cluster>(); - for (Vertex v : getVertices()) { - if (v.getCluster() != null) { - clusters.add(v.getCluster()); - } - } - - return clusters; - } }
--- a/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Link.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Link.java Sun Jan 29 11:40:04 2012 +0100 @@ -35,6 +35,8 @@ public Port getFrom(); public Port getTo(); + + public boolean isVIP(); public List<Point> getControlPoints();
--- a/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Vertex.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Vertex.java Sun Jan 29 11:40:04 2012 +0100 @@ -32,8 +32,6 @@ */ public interface Vertex extends Comparable<Vertex> { - public Cluster getCluster(); - public Dimension getSize(); public Point getPosition();
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupReceiver Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.connection.Server \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,14 +24,12 @@ */ package com.sun.hotspot.igv.connection; -import com.sun.hotspot.igv.data.Group; +import com.sun.hotspot.igv.data.serialization.Parser; import com.sun.hotspot.igv.data.services.GroupCallback; -import com.sun.hotspot.igv.data.serialization.Parser; -import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher; +import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.Socket; -import javax.swing.JTextField; import org.openide.util.Exceptions; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -40,54 +38,37 @@ * * @author Thomas Wuerthinger */ -public class Client implements Runnable, GroupCallback { +public class Client implements Runnable { private Socket socket; - private JTextField networkTextField; private GroupCallback callback; - public Client(Socket socket, JTextField networkTextField, GroupCallback callback) { + public Client(Socket socket, GroupCallback callback) { this.callback = callback; this.socket = socket; - this.networkTextField = networkTextField; } + @Override public void run() { try { - InputStream inputStream = socket.getInputStream(); - - if (networkTextField.isEnabled()) { - - socket.getOutputStream().write('y'); - InputSource is = new InputSource(inputStream); + InputStream inputStream = new BufferedInputStream(socket.getInputStream()); + InputSource is = new InputSource(inputStream); - try { - Parser parser = new Parser(this); - parser.parse(is, null); - } catch (SAXException ex) { - ex.printStackTrace(); - } - } else { - socket.getOutputStream().write('n'); + try { + Parser parser = new Parser(callback); + parser.parse(is, null); + } catch (SAXException ex) { + ex.printStackTrace(); } - - socket.close(); } catch (IOException ex) { Exceptions.printStackTrace(ex); + } finally { + try { + socket.close(); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } } } - - public void started(final Group g) { - try { - RegexpPropertyMatcher matcher = new RegexpPropertyMatcher("name", ".*" + networkTextField.getText() + ".*"); - if (g.getProperties().selectSingle(matcher) != null && networkTextField.isEnabled()) { - socket.getOutputStream().write('y'); - callback.started(g); - } else { - socket.getOutputStream().write('n'); - } - } catch (IOException e) { - } - } -} +} \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,17 +24,13 @@ */ package com.sun.hotspot.igv.connection; -import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.services.GroupCallback; -import com.sun.hotspot.igv.data.services.GroupReceiver; import com.sun.hotspot.igv.settings.Settings; -import java.awt.Component; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.util.prefs.PreferenceChangeEvent; import java.util.prefs.PreferenceChangeListener; -import javax.swing.SwingUtilities; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.RequestProcessor; @@ -43,51 +39,21 @@ * * @author Thomas Wuerthinger */ -public class Server implements GroupCallback, GroupReceiver, PreferenceChangeListener { +public class Server implements PreferenceChangeListener { - private javax.swing.JPanel jPanel1; - private javax.swing.JCheckBox networkCheckBox; - private javax.swing.JTextField networkTextField; private ServerSocket serverSocket; private GroupCallback callback; private int port; private Runnable serverRunnable; - public Component init(GroupCallback callback) { + public Server(GroupCallback callback) { this.callback = callback; - - jPanel1 = new javax.swing.JPanel(); - networkTextField = new javax.swing.JTextField(); - networkCheckBox = new javax.swing.JCheckBox(); - - - jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); - jPanel1.setLayout(new java.awt.BorderLayout(10, 10)); - jPanel1.add(networkTextField, java.awt.BorderLayout.CENTER); - - networkCheckBox.setSelected(true); - org.openide.awt.Mnemonics.setLocalizedText(networkCheckBox, "Receive when name contains"); - networkCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); - networkCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); - networkCheckBox.addChangeListener(new javax.swing.event.ChangeListener() { - - public void stateChanged(javax.swing.event.ChangeEvent evt) { - networkCheckBoxChanged(evt); - } - }); - jPanel1.add(networkCheckBox, java.awt.BorderLayout.WEST); - networkCheckBox.getAccessibleContext().setAccessibleName("Read from network when name contains"); - initializeNetwork(); Settings.get().addPreferenceChangeListener(this); - return jPanel1; } - private void networkCheckBoxChanged(javax.swing.event.ChangeEvent evt) { - networkTextField.setEnabled(networkCheckBox.isSelected()); - } - + @Override public void preferenceChange(PreferenceChangeEvent e) { int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT)); @@ -110,6 +76,7 @@ Runnable runnable = new Runnable() { + @Override public void run() { while (true) { try { @@ -118,7 +85,7 @@ clientSocket.close(); return; } - RequestProcessor.getDefault().post(new Client(clientSocket, networkTextField, Server.this), 0, Thread.MAX_PRIORITY); + RequestProcessor.getDefault().post(new Client(clientSocket, callback), 0, Thread.MAX_PRIORITY); } catch (IOException ex) { serverSocket = null; NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE); @@ -133,13 +100,4 @@ RequestProcessor.getDefault().post(runnable, 0, Thread.MAX_PRIORITY); } - - public void started(final Group g) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - callback.started(g); - } - }); - } }
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.rhino" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.rhino.</description> - <import file="nbproject/build-impl.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/manifest.mf Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.rhino -OpenIDE-Module-Layer: com/sun/hotspot/igv/rhino/layer.xml -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/rhino/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 -
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.rhino-impl" basedir=".."> - <fail message="Please build using Ant 1.7.1 or higher."> - <condition> - <not> - <antversion atleast="1.7.1"/> - </not> - </condition> - </fail> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="property"/> - <attribute name="value"/> - <sequential> - <property name="@{property}" value="@{value}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> - <condition> - <not> - <contains string="${cluster.path.evaluated}" substring="platform"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=0c3e7912 -nbproject/build-impl.xml.script.CRC32=87376d18 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.rhino</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.filter</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graph</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages> - <package>com.sun.hotspot.igv.rhino</package> - </public-packages> - </data> - </configuration> -</project>
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/suite.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.rhino.RhinoScriptEngine \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=RhinoScriptEngineProxy
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.rhino; - -import com.sun.hotspot.igv.filter.ScriptEngineAbstraction; -import com.sun.hotspot.igv.graph.Diagram; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -/** - * - * @author Thomas Wuerthinger - */ -public class RhinoScriptEngine implements ScriptEngineAbstraction { - - private String jsHelperText; - private Constructor importer; - private Method scope_put; - private Method cx_evaluateString; - private Method context_enter; - private Method context_exit; - - public boolean initialize(String s) { - this.jsHelperText = s; - Class<?> importerTopLevel = null; - try { - ClassLoader cl = RhinoScriptEngine.class.getClassLoader(); - Class<?> context = cl.loadClass("org.mozilla.javascript.Context"); - Class<?> scriptable = cl.loadClass("org.mozilla.javascript.Scriptable"); - importerTopLevel = cl.loadClass("org.mozilla.javascript.ImporterTopLevel"); - importer = importerTopLevel.getDeclaredConstructor(context); - scope_put = importerTopLevel.getMethod("put", String.class, scriptable, Object.class); - cx_evaluateString = context.getDeclaredMethod("evaluateString", scriptable, String.class, String.class, Integer.TYPE, Object.class); - context_enter = context.getDeclaredMethod("enter"); - context_exit = context.getDeclaredMethod("exit"); - return true; - } catch (Exception e) { - return false; - } - } - - public void execute(Diagram d, String code) { - try { - Object cx = context_enter.invoke(null, (Object[]) null); - try { - Object scope = importer.newInstance(cx); - scope_put.invoke(scope, "IO", scope, System.out); - scope_put.invoke(scope, "graph", scope, d); - cx_evaluateString.invoke(cx, scope, jsHelperText, "jsHelper.js", 1, null); - cx_evaluateString.invoke(cx, scope, code, "<cmd>", 1, null); - } finally { - // Exit from the context. - context_exit.invoke(null, (Object[]) null); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -}
--- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> -</filesystem>
--- a/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java Sun Jan 29 11:40:04 2012 +0100 @@ -46,10 +46,10 @@ } private SelectionCoordinator() { - selectedChangedEvent = new ChangedEvent<SelectionCoordinator>(this); - highlightedChangedEvent = new ChangedEvent<SelectionCoordinator>(this); - selectedObjects = new HashSet<Object>(); - highlightedObjects = new HashSet<Object>(); + selectedChangedEvent = new ChangedEvent<>(this); + highlightedChangedEvent = new ChangedEvent<>(this); + selectedObjects = new HashSet<>(); + highlightedObjects = new HashSet<>(); } public Set<Object> getSelectedObjects() {
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml Sun Jan 29 11:40:04 2012 +0100 @@ -1,45 +1,29 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.servercompiler</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.data</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graph</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.graphtotext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages/> - </data> - </configuration> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.apisupport.project</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> + <code-name-base>com.sun.hotspot.igv.servercompiler</code-name-base> + <suite-component/> + <module-dependencies> + <dependency> + <code-name-base>com.sun.hotspot.igv.data</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + <dependency> + <code-name-base>com.sun.hotspot.igv.graph</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <specification-version>1.0</specification-version> + </run-dependency> + </dependency> + </module-dependencies> + <public-packages/> + </data> + </configuration> +</project>
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.servercompiler.JavaGroupOrganizer \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.servercompiler.ServerCompilerGraphToTextConverter \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.servercompiler; - -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.Pair; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class JavaGroupOrganizer implements GroupOrganizer { - - public String getName() { - return "Java structure"; - } - - public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups) { - - List<Pair<String, List<Group>>> result = new ArrayList<Pair<String, List<Group>>>(); - - if (subFolders.size() == 0) { - buildResult(result, groups, packageNameProvider); - } else if (subFolders.size() == 1) { - buildResult(result, groups, classNameProvider); - } else if (subFolders.size() == 2) { - for (Group g : groups) { - List<Group> children = new ArrayList<Group>(); - children.add(g); - Pair<String, List<Group>> p = new Pair<String, List<Group>>(); - p.setLeft(reducedNameProvider.getName(g)); - p.setRight(children); - result.add(p); - } - } else { - result.add(new Pair<String, List<Group>>("", groups)); - } - - return result; - } - - private void buildResult(List<Pair<String, List<Group>>> result, List<Group> groups, NameProvider provider) { - HashMap<String, List<Group>> map = new HashMap<String, List<Group>>(groups.size()); - for (Group g : groups) { - String s = provider.getName(g); - - if (!map.containsKey(s)) { - List<Group> list = new ArrayList<Group>(); - Pair<String, List<Group>> pair = new Pair<String, List<Group>>(s, list); - result.add(pair); - map.put(s, list); - } - - List<Group> curList = map.get(s); - curList.add(g); - } - - Collections.sort(result, new Comparator<Pair<String, List<Group>>>() { - - public int compare(Pair<String, List<Group>> a, Pair<String, List<Group>> b) { - return a.getLeft().compareTo(b.getLeft()); - } - }); - } - - private static interface NameProvider { - - public String getName(Group g); - } - private NameProvider reducedNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - final String noReducedName = name; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noReducedName; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noReducedName; - } - - int current = firstPoint; - while (current >= 0 && name.charAt(current) != ' ') { - current--; - } - - String tmp = name.substring(0, firstParenthese); - int lastPoint = tmp.lastIndexOf("."); - if (lastPoint == -1) { - return noReducedName; - } - - name = name.substring(0, current + 1) + name.substring(lastPoint + 1); - return name; - } - }; - private NameProvider packageNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - final String noPackage = "<default>"; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noPackage; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noPackage; - } - - int current = firstPoint; - while (current >= 0 && name.charAt(current) != ' ') { - current--; - } - - String fullClassName = name.substring(current + 1, firstParenthese); - int lastPoint = fullClassName.lastIndexOf("."); - if (lastPoint == -1) { - return noPackage; - } - lastPoint = fullClassName.lastIndexOf(".", lastPoint - 1); - if (lastPoint == -1) { - return noPackage; - } - - String packageName = fullClassName.substring(0, lastPoint); - return packageName; - } - }; - private NameProvider classNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - - final String noClass = "<noclass>"; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noClass; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noClass; - } - - int current = firstPoint; - while (current >= 0 && name.charAt(current) != ' ') { - current--; - } - - String fullClassName = name.substring(current + 1, firstParenthese); - int lastPoint = fullClassName.lastIndexOf("."); - if (lastPoint == -1) { - return noClass; - } - int lastlastPoint = fullClassName.lastIndexOf(".", lastPoint - 1); - - String className = fullClassName.substring(lastlastPoint + 1, lastPoint); - return className; - } - }; -}
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerGraphToTextConverter.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,176 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.hotspot.igv.servercompiler; - -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.Properties.PropertyMatcher; -import com.sun.hotspot.igv.data.Properties.PropertySelector; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import java.awt.Color; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; - -/** - * - * @author Thomas Wuerthinger - */ -public class ServerCompilerGraphToTextConverter implements GraphToTextConverter { - - - private Map<InputNode, Set<Figure>> map; - private Map<InputNode, List<InputEdge>> ingoingEdges; - private Map<InputNode, List<InputEdge>> outgoingEdges; - private InputGraph graph; - - private Collection<InputNode> sortNodes(Collection<InputNode> nodes) { - List<InputNode> result = new ArrayList<InputNode>(nodes); - - Collections.sort(result, InputNode.getPropertyComparator("idx")); - - - return result; - } - - public StructuredText convert(InputGraph graph, Diagram diagram) { - - this.graph = graph; - map = diagram.calcSourceToFigureRelation(); - ingoingEdges = graph.findAllIngoingEdges(); - outgoingEdges = graph.findAllOutgoingEdges(); - - final StructuredText result = new StructuredText(graph.getName()); - - for (InputBlock b : graph.getBlocks()) { - result.addChild(new SimpleElement("Block " + b.getName() + "\n")); - for (InputNode n : sortNodes(b.getNodes())) { - result.addChild(getNodeElement(n)); - } - } - - boolean first = true; - for (InputNode n : sortNodes(graph.getNodes())) { - if (graph.getBlock(n) == null) { - if (first) { - first = false; - result.addChild(new SimpleElement("No block: \n")); - } - result.addChild(getNodeElement(n)); - } - } - - - return result; - } - - private Element getNodeNameElement(InputNode n) { - - final SimpleElement name = new SimpleElement(n.getProperties().get("idx") + " " + n.getProperties().get("name"), calcStyle(n)); - name.addSource(n.getId()); - return name; - } - - private Element getNodeSmallElement(InputNode n) { - final SimpleElement id = new SimpleElement(n.getProperties().get("idx"), calcStyle(n)); - id.addSource(n.getId()); - return id; - } - - private Element getNodeElement(InputNode n) { - - final MultiElement result = new MultiElement(); - - result.print("\t"); - result.addChild(getNodeNameElement(n)); - - result.print(" === "); - - for (InputEdge e : outgoingEdges.get(n)) { - result.print(" "); - result.addChild(getNodeSmallElement(graph.getNode(e.getTo()))); - result.print(" "); - } - - result.print(" [["); - - for (InputEdge e : ingoingEdges.get(n)) { - result.print(" "); - result.addChild(getNodeSmallElement(graph.getNode(e.getFrom()))); - result.print(" "); - } - - result.print("]] "); - - result.print(n.getProperties().get("dump_spec")); - - result.print("\n"); - - return result; - } - - private static final PropertyMatcher MATCHER = new Properties.RegexpPropertyMatcher("name", "Root"); - public boolean canConvert(InputGraph graph) { - return new PropertySelector<InputNode>(graph.getNodes()).selectSingle(MATCHER) != null; - } - - private Color calcColor(InputNode node) { - Set<Figure> figureSet = this.map.get(node); - if(figureSet != null && figureSet.size() == 1) { - return figureSet.iterator().next().getColor(); - } else { - return Color.WHITE; - } - } - - private Color lessColor(Color c) { - return new Color(255 - (255 - c.getRed()) / 4, 255 - (255 - c.getGreen()) / 4, 255 - (255 - c.getBlue()) / 4); - } - - private Style calcStyle(InputNode node) { - Color c = calcColor(node); - Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); - Style newStyle = StyleContext.getDefaultStyleContext().addStyle(null, defaultStyle); - - StyleConstants.setBackground(newStyle, lessColor(c)); - return newStyle; - } -}
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Sun Jan 29 11:40:04 2012 +0100 @@ -29,17 +29,7 @@ import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.services.Scheduler; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.Vector; +import java.util.*; /** * @@ -50,8 +40,8 @@ private static class Node { public InputNode inputNode; - public Set<Node> succs = new HashSet<Node>(); - public List<Node> preds = new ArrayList<Node>(); + public Set<Node> succs = new HashSet<>(); + public List<Node> preds = new ArrayList<>(); public InputBlock block; public boolean isBlockProjection; public boolean isBlockStart; @@ -65,6 +55,7 @@ private InputBlock[][] commonDominator; private static final Comparator<InputEdge> edgeComparator = new Comparator<InputEdge>() { + @Override public int compare(InputEdge o1, InputEdge o2) { return o1.getToIndex() - o2.getToIndex(); } @@ -72,13 +63,13 @@ public void buildBlocks() { - blocks = new Vector<InputBlock>(); + blocks = new Vector<>(); Node root = findRoot(); if (root == null) { return; } - Stack<Node> stack = new Stack<Node>(); - Set<Node> visited = new HashSet<Node>(); + Stack<Node> stack = new Stack<>(); + Set<Node> visited = new HashSet<>(); stack.add(root); int blockCount = 0; InputBlock rootBlock = null; @@ -179,7 +170,7 @@ } int z = 0; - blockIndex = new HashMap<InputBlock, Integer>(blocks.size()); + blockIndex = new HashMap<>(blocks.size()); for (InputBlock b : blocks) { blockIndex.put(b, z); z++; @@ -190,13 +181,14 @@ return n.getProperties().get("block"); } + @Override public Collection<InputBlock> schedule(InputGraph graph) { if (graph.getNodes().isEmpty()) { return Collections.emptyList(); } if (graph.getBlocks().size() > 0) { - Collection<InputNode> tmpNodes = new ArrayList<InputNode>(graph.getNodes()); + Collection<InputNode> tmpNodes = new ArrayList<>(graph.getNodes()); for (InputNode n : tmpNodes) { String block = getBlockName(n); if (graph.getBlock(n) == null) { @@ -206,8 +198,8 @@ } return graph.getBlocks(); } else { - nodes = new ArrayList<Node>(); - inputNodeToNode = new HashMap<InputNode, Node>(graph.getNodes().size()); + nodes = new ArrayList<>(); + inputNodeToNode = new HashMap<>(graph.getNodes().size()); this.graph = graph; buildUpGraph(); @@ -241,9 +233,9 @@ } // Mark all nodes reachable in backward traversal from root - Set<Node> reachable = new HashSet<Node>(); + Set<Node> reachable = new HashSet<>(); reachable.add(root); - Stack<Node> stack = new Stack<Node>(); + Stack<Node> stack = new Stack<>(); stack.push(root); while (!stack.isEmpty()) { Node cur = stack.pop(); @@ -255,7 +247,7 @@ } } - Set<Node> unscheduled = new HashSet<Node>(); + Set<Node> unscheduled = new HashSet<>(); for (Node n : this.nodes) { if (n.block == null && reachable.contains(n)) { unscheduled.add(n); @@ -265,7 +257,7 @@ while (unscheduled.size() > 0) { boolean progress = false; - Set<Node> newUnscheduled = new HashSet<Node>(); + Set<Node> newUnscheduled = new HashSet<>(); for (Node n : unscheduled) { InputBlock block = null; @@ -305,7 +297,7 @@ } } - Set<Node> curReachable = new HashSet<Node>(reachable); + Set<Node> curReachable = new HashSet<>(reachable); for (Node n : curReachable) { if (n.block != null) { for (Node s : n.succs) { @@ -320,7 +312,7 @@ private void markWithBlock(Node n, InputBlock b, Set<Node> reachable) { assert !reachable.contains(n); - Stack<Node> stack = new Stack<Node>(); + Stack<Node> stack = new Stack<>(); stack.push(n); n.block = b; b.addNode(n.inputNode.getId()); @@ -376,7 +368,7 @@ if (ba == bb) { return ba; } - Set<InputBlock> visited = new HashSet<InputBlock>(); + Set<InputBlock> visited = new HashSet<>(); while (ba != null) { visited.add(ba); ba = dominatorMap.get(ba); @@ -394,12 +386,12 @@ } public void buildDominators() { - dominatorMap = new HashMap<InputBlock, InputBlock>(graph.getBlocks().size()); + dominatorMap = new HashMap<>(graph.getBlocks().size()); if (blocks.size() == 0) { return; } - Vector<BlockIntermediate> intermediate = new Vector<BlockIntermediate>(graph.getBlocks().size()); - Map<InputBlock, BlockIntermediate> map = new HashMap<InputBlock, BlockIntermediate>(graph.getBlocks().size()); + Vector<BlockIntermediate> intermediate = new Vector<>(graph.getBlocks().size()); + Map<InputBlock, BlockIntermediate> map = new HashMap<>(graph.getBlocks().size()); int z = 0; for (InputBlock b : blocks) { BlockIntermediate bi = new BlockIntermediate(); @@ -410,16 +402,16 @@ bi.parent = -1; bi.label = z; bi.ancestor = -1; - bi.pred = new ArrayList<Integer>(); - bi.bucket = new ArrayList<Integer>(); + bi.pred = new ArrayList<>(); + bi.bucket = new ArrayList<>(); intermediate.add(bi); map.put(b, bi); z++; } - Stack<Integer> stack = new Stack<Integer>(); + Stack<Integer> stack = new Stack<>(); stack.add(0); - Vector<BlockIntermediate> array = new Vector<BlockIntermediate>(); + Vector<BlockIntermediate> array = new Vector<>(); intermediate.get(0).dominator = 0; int n = 0; @@ -597,7 +589,7 @@ inputNodeToNode.put(n, node); } - Map<Integer, List<InputEdge>> edgeMap = new HashMap<Integer, List<InputEdge>>(graph.getEdges().size()); + Map<Integer, List<InputEdge>> edgeMap = new HashMap<>(graph.getEdges().size()); for (InputEdge e : graph.getEdges()) { int to = e.getTo();
--- a/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsCategory.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsCategory.java Sun Jan 29 11:40:04 2012 +0100 @@ -41,14 +41,17 @@ return new ImageIcon(ImageUtilities.loadImage("com/sun/hotspot/igv/settings/settings.png")); } + @Override public String getCategoryName() { return NbBundle.getMessage(ViewOptionsCategory.class, "OptionsCategory_Name_View"); } + @Override public String getTitle() { return NbBundle.getMessage(ViewOptionsCategory.class, "OptionsCategory_Title_View"); } + @Override public OptionsPanelController create() { return new ViewOptionsPanelController(); }
--- a/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsPanelController.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsPanelController.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,40 +40,49 @@ private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); private boolean changed; + @Override public void update() { getPanel().load(); changed = false; } + @Override public void applyChanges() { getPanel().store(); changed = false; } + @Override public void cancel() { // need not do anything special, if no changes have been persisted yet } + @Override public boolean isValid() { return getPanel().valid(); } + @Override public boolean isChanged() { return changed; } + @Override public HelpCtx getHelpCtx() { return null; // new HelpCtx("...ID") if you have a help set } + @Override public JComponent getComponent(Lookup masterLookup) { return getPanel(); } + @Override public void addPropertyChangeListener(PropertyChangeListener l) { pcs.addPropertyChangeListener(l); } + @Override public void removePropertyChangeListener(PropertyChangeListener l) { pcs.removePropertyChangeListener(l); }
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.structuredtext" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.structuredtext.</description> - <import file="nbproject/build-impl.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/manifest.mf Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.structuredtext -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/structuredtext/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 -
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.structuredtext-impl" basedir=".."> - <fail message="Please build using Ant 1.7.1 or higher."> - <condition> - <not> - <antversion atleast="1.7.1"/> - </not> - </condition> - </fail> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="property"/> - <attribute name="value"/> - <sequential> - <property name="@{property}" value="@{value}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> - <condition> - <not> - <contains string="${cluster.path.evaluated}" substring="platform"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=216fc635 -nbproject/build-impl.xml.script.CRC32=6022dc85 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/platform.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -# Deprecated since 5.0u1; for compatibility with 5.0: -disabled.clusters=\ - apisupport1,\ - gsf1,\ - harness,\ - java2,\ - nb6.1,\ - profiler3 -disabled.modules=\ - org.apache.xml.resolver,\ - org.netbeans.api.debugger,\ - org.netbeans.api.xml,\ - org.netbeans.core.execution,\ - org.netbeans.core.ide,\ - org.netbeans.core.multiview,\ - org.netbeans.core.nativeaccess,\ - org.netbeans.core.output2,\ - org.netbeans.insane,\ - org.netbeans.lib.cvsclient,\ - org.netbeans.libs.commons_logging,\ - org.netbeans.libs.freemarker,\ - org.netbeans.libs.ini4j,\ - org.netbeans.libs.jna,\ - org.netbeans.libs.jsch,\ - org.netbeans.libs.jsr223,\ - org.netbeans.libs.lucene,\ - org.netbeans.libs.svnClientAdapter,\ - org.netbeans.libs.xerces,\ - org.netbeans.modules.applemenu,\ - org.netbeans.modules.autoupdate.services,\ - org.netbeans.modules.autoupdate.ui,\ - org.netbeans.modules.classfile,\ - org.netbeans.modules.core.kit,\ - org.netbeans.modules.db,\ - org.netbeans.modules.db.core,\ - org.netbeans.modules.db.drivers,\ - org.netbeans.modules.db.kit,\ - org.netbeans.modules.db.mysql,\ - org.netbeans.modules.db.sql.editor,\ - org.netbeans.modules.db.sql.visualeditor,\ - org.netbeans.modules.dbapi,\ - org.netbeans.modules.defaults,\ - org.netbeans.modules.diff,\ - org.netbeans.modules.editor.bookmarks,\ - org.netbeans.modules.editor.bracesmatching,\ - org.netbeans.modules.editor.codetemplates,\ - org.netbeans.modules.editor.completion,\ - org.netbeans.modules.editor.errorstripe,\ - org.netbeans.modules.editor.errorstripe.api,\ - org.netbeans.modules.editor.guards,\ - org.netbeans.modules.editor.highlights,\ - org.netbeans.modules.editor.macros,\ - org.netbeans.modules.editor.plain,\ - org.netbeans.modules.editor.plain.lib,\ - org.netbeans.modules.editor.structure,\ - org.netbeans.modules.extbrowser,\ - org.netbeans.modules.favorites,\ - org.netbeans.modules.gototest,\ - org.netbeans.modules.httpserver,\ - org.netbeans.modules.ide.kit,\ - org.netbeans.modules.image,\ - org.netbeans.modules.javahelp,\ - org.netbeans.modules.jumpto,\ - org.netbeans.modules.languages,\ - org.netbeans.modules.languages.bat,\ - org.netbeans.modules.languages.diff,\ - org.netbeans.modules.languages.manifest,\ - org.netbeans.modules.languages.sh,\ - org.netbeans.modules.lexer.editorbridge,\ - org.netbeans.modules.lexer.nbbridge,\ - org.netbeans.modules.localhistory,\ - org.netbeans.modules.masterfs,\ - org.netbeans.modules.mercurial,\ - org.netbeans.modules.progress.ui,\ - org.netbeans.modules.project.ant,\ - org.netbeans.modules.project.libraries,\ - org.netbeans.modules.projectui,\ - org.netbeans.modules.projectuiapi,\ - org.netbeans.modules.properties,\ - org.netbeans.modules.properties.syntax,\ - org.netbeans.modules.refactoring.api,\ - org.netbeans.modules.schema2beans,\ - org.netbeans.modules.sendopts,\ - org.netbeans.modules.server,\ - org.netbeans.modules.servletapi,\ - org.netbeans.modules.subversion,\ - org.netbeans.modules.tasklist.kit,\ - org.netbeans.modules.tasklist.projectint,\ - org.netbeans.modules.tasklist.todo,\ - org.netbeans.modules.tasklist.ui,\ - org.netbeans.modules.templates,\ - org.netbeans.modules.timers,\ - org.netbeans.modules.usersguide,\ - org.netbeans.modules.utilities,\ - org.netbeans.modules.utilities.project,\ - org.netbeans.modules.versioning,\ - org.netbeans.modules.versioning.system.cvss,\ - org.netbeans.modules.versioning.util,\ - org.netbeans.modules.web.flyingsaucer,\ - org.netbeans.modules.xml,\ - org.netbeans.modules.xml.axi,\ - org.netbeans.modules.xml.catalog,\ - org.netbeans.modules.xml.core,\ - org.netbeans.modules.xml.lexer,\ - org.netbeans.modules.xml.multiview,\ - org.netbeans.modules.xml.retriever,\ - org.netbeans.modules.xml.schema.completion,\ - org.netbeans.modules.xml.schema.model,\ - org.netbeans.modules.xml.tax,\ - org.netbeans.modules.xml.text,\ - org.netbeans.modules.xml.tools,\ - org.netbeans.modules.xml.wsdl.model,\ - org.netbeans.modules.xml.xam,\ - org.netbeans.modules.xml.xdm,\ - org.netbeans.modules.xsl,\ - org.netbeans.spi.debugger.ui,\ - org.netbeans.spi.editor.hints,\ - org.netbeans.spi.navigator,\ - org.netbeans.spi.palette,\ - org.netbeans.spi.tasklist,\ - org.netbeans.spi.viewmodel,\ - org.netbeans.swing.dirchooser,\ - org.openide.compat,\ - org.openide.util.enumerations -enabled.clusters=\ - ide9,\ - platform8 -nbjdk.active=default -nbplatform.active=default
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base> - <suite-component/> - <module-dependencies/> - <public-packages> - <package>com.sun.hotspot.igv.structuredtext</package> - <package>com.sun.hotspot.igv.structuredtext.services</package> - </public-packages> - </data> - </configuration> -</project>
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/suite.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=StructuredText
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import javax.swing.text.Style; -import javax.swing.text.StyleContext; - -/** - * - * @author Thomas - */ -public abstract class Element { - - private Set<Object> source; - private Style style; - private Style highlightedStyle; - - public Element() { - source = new HashSet<Object>(); - style = null; - highlightedStyle = null; - } - - public Style getStyle() { - return style; - } - - public Style getHighlightedStyle() { - return highlightedStyle; - } - - public void setStyle(Style style) { - this.style = style; - } - - public void setHighlightedStyle(Style style) { - this.highlightedStyle = style; - } - - public void setStyleRecursive(Style style) { - this.style = style; - } - - public void setHighlightedStyleRecursive(Style style) { - this.highlightedStyle = style; - } - - public Set<Object> getSource() { - return Collections.unmodifiableSet(source); - } - - public void addSource(Object o) { - source.add(o); - } - - public abstract void accept(ElementVisitor visitor); -}
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.swing.text.Style; - -/** - * - * @author Thomas - */ -public class MultiElement extends Element { - - private List<Element> children; - private String foldString; - - public MultiElement() { - this((String)null); - } - - public MultiElement(String foldString) { - this(foldString, null); - } - - public MultiElement(Style style) { - this(null, style); - } - - public MultiElement(String foldString, Style style) { - setStyle(style); - this.foldString = foldString; - children = new ArrayList<Element>(); - } - - public void print(String s) { - print(s, null); - } - - @Override - public void setStyleRecursive(Style style) { - super.setStyleRecursive(style); - for(Element elem : this.getChildren()) { - elem.setStyleRecursive(style); - } - } - - @Override - public void setHighlightedStyleRecursive(Style style) { - super.setStyleRecursive(style); - for(Element elem : this.getChildren()) { - elem.setHighlightedStyleRecursive(style); - } - } - - public void print(String s, Object source) { - if (s == null) { - s = ""; - } - SimpleElement elem = new SimpleElement(s); - if(source != null) { - elem.addSource(source); - } - addChild(elem); - } - - public void print(String s, Object source, int padding) { - if (s == null) { - s = ""; - } - StringBuilder sb = new StringBuilder(s); - while (sb.length() < padding) { - sb.insert(0, ' '); - } - print(sb.toString(), source); - } - - public void println() { - println(""); - } - - public void println(String s) { - print(s + "\n"); - } - - public void println(String s, Object source) { - print(s + "\n", source); - } - - - public void println(String s, Object source, int padding) { - print(s + "\n", source, padding); - } - - public void addChild(Element element) { - assert element != null; - this.children.add(element); - } - - public String getFoldString() { - return foldString; - } - - public void setFoldString(String s) { - this.foldString = s; - } - - public List<Element> getChildren() { - return Collections.unmodifiableList(children); - } - - public void accept(ElementVisitor visitor) { - visitor.visit(this); - } -}
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -/** - * - * @author Thomas - */ -public class Range { - - private int start; - private int length; - - public Range(int start, int length) { - this.start = start; - this.length = length; - } - - public int getStart() { - return start; - } - - public boolean overlaps(Range r2) { - if(start < r2.start) { - return start + length > r2.start; - } else { - return r2.start + r2.length > start; - } - } - - public int getLength() { - return length; - } - -}
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import javax.swing.text.Style; -import javax.swing.text.StyleContext; - -/** - * - * @author Thomas - */ -public class SimpleElement extends Element { - - public static final Element EMPTY = new SimpleElement(""); - public static final Element LN = new SimpleElement("\n"); - public static final Element TAB = new SimpleElement("\t"); - - private String text; - - public SimpleElement(String s) { - this(s, null); - } - - public SimpleElement(String s, Style style) { - setText(s); - setStyle(style); - assert text != null; - } - - private static String addPadding(String s, int minLength) { - - StringBuilder sb = new StringBuilder(s); - while(sb.length() < minLength) { - sb.insert(0, ' '); - } - return sb.toString(); - } - - public SimpleElement(String s, int length) { - this(addPadding(s, length)); - } - - - public String getText() { - return text; - } - - public void setText(String s) { - this.text = s; - } - - public void accept(ElementVisitor visitor) { - visitor.visit(this); - } -}
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.HashMap; -import java.util.Map; - - -/** - * - * @author Thomas - */ -public class StructuredText extends MultiElement { - - private String name; - - public StructuredText(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public Element findElementAt(final int searchIndex) { - - final Element[] result = new Element[1]; - this.accept(new ElementVisitor() { - - private int index; - - @Override - public void visit(MultiElement element) { - int startIndex = index; - super.visit(element); - } - - @Override - public void visit(SimpleElement element) { - if(searchIndex >= index && searchIndex < index + element.getText().length()) { - assert result[0] == null; - result[0] = element; - } - index += element.getText().length(); - } - }); - - return result[0]; - } - - public Map<Element, Range> calculateRanges() { - - final Map<Element, Range> result = new HashMap<Element, Range>(); - - this.accept(new ElementVisitor() { - - private int index; - - @Override - public void visit(MultiElement element) { - int startIndex = index; - super.visit(element); - result.put(element, new Range(startIndex, index - startIndex)); - } - - @Override - public void visit(SimpleElement element) { - result.put(element, new Range(index, element.getText().length())); - index += element.getText().length(); - } - }); - - - return result; - - } - - public String convertToString() { - final StringBuilder result = new StringBuilder(); - this.accept(new ElementVisitor() { - @Override - public void visit(SimpleElement element) { - result.append(element.getText()); - } - } - ); - return result.toString(); - } -}
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -/** - * - * @author thomas - */ -public interface ToolTipProvider { - - String getToolTip(); - -}
--- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext.services; - -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; - -/** - * - * @author Thomas - */ -public abstract class ElementVisitor { - - public void visit(MultiElement element) { - - for(Element e : element.getChildren()) { - e.accept(this); - } - } - public abstract void visit(SimpleElement element); -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/build.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- You may freely edit this file. See harness/README in the NetBeans platform --> -<!-- for some information on what you could do (e.g. targets to override). --> -<!-- If you delete this file and reopen the project it will be recreated. --> -<project name="com.sun.hotspot.igv.texteditor" default="netbeans" basedir="."> - <description>Builds, tests, and runs the project com.sun.hotspot.igv.texteditor.</description> - <import file="nbproject/build-impl.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/manifest.mf Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.texteditor -OpenIDE-Module-Layer: com/sun/hotspot/igv/texteditor/layer.xml -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/texteditor/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 -
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/build-impl.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** ---> -<project name="com.sun.hotspot.igv.texteditor-impl" basedir=".."> - <fail message="Please build using Ant 1.7.1 or higher."> - <condition> - <not> - <antversion atleast="1.7.1"/> - </not> - </condition> - </fail> - <property file="nbproject/private/suite-private.properties"/> - <property file="nbproject/suite.properties"/> - <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail> - <property file="${suite.dir}/nbproject/private/platform-private.properties"/> - <property file="${suite.dir}/nbproject/platform.properties"/> - <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property name="@{name}" value="${@{value}}"/> - </sequential> - </macrodef> - <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2"> - <attribute name="property"/> - <attribute name="value"/> - <sequential> - <property name="@{property}" value="@{value}"/> - </sequential> - </macrodef> - <property file="${user.properties.file}"/> - <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/> - <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness)."> - <condition> - <not> - <contains string="${cluster.path.evaluated}" substring="platform"/> - </not> - </condition> - </fail> - <import file="${harness.dir}/build.xml"/> -</project>
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/genfiles.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=ddc04434 -nbproject/build-impl.xml.script.CRC32=122053f6 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/platform.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -# Deprecated since 5.0u1; for compatibility with 5.0: -disabled.clusters=\ - apisupport1,\ - gsf1,\ - harness,\ - java2,\ - nb6.1,\ - profiler3 -disabled.modules=\ - org.apache.xml.resolver,\ - org.netbeans.api.debugger,\ - org.netbeans.api.xml,\ - org.netbeans.core.execution,\ - org.netbeans.core.ide,\ - org.netbeans.core.multiview,\ - org.netbeans.core.nativeaccess,\ - org.netbeans.core.output2,\ - org.netbeans.insane,\ - org.netbeans.lib.cvsclient,\ - org.netbeans.libs.commons_logging,\ - org.netbeans.libs.freemarker,\ - org.netbeans.libs.ini4j,\ - org.netbeans.libs.jna,\ - org.netbeans.libs.jsch,\ - org.netbeans.libs.jsr223,\ - org.netbeans.libs.lucene,\ - org.netbeans.libs.svnClientAdapter,\ - org.netbeans.libs.xerces,\ - org.netbeans.modules.applemenu,\ - org.netbeans.modules.autoupdate.services,\ - org.netbeans.modules.autoupdate.ui,\ - org.netbeans.modules.classfile,\ - org.netbeans.modules.core.kit,\ - org.netbeans.modules.db,\ - org.netbeans.modules.db.core,\ - org.netbeans.modules.db.drivers,\ - org.netbeans.modules.db.kit,\ - org.netbeans.modules.db.mysql,\ - org.netbeans.modules.db.sql.editor,\ - org.netbeans.modules.db.sql.visualeditor,\ - org.netbeans.modules.dbapi,\ - org.netbeans.modules.defaults,\ - org.netbeans.modules.diff,\ - org.netbeans.modules.editor.bookmarks,\ - org.netbeans.modules.editor.bracesmatching,\ - org.netbeans.modules.editor.codetemplates,\ - org.netbeans.modules.editor.completion,\ - org.netbeans.modules.editor.errorstripe,\ - org.netbeans.modules.editor.errorstripe.api,\ - org.netbeans.modules.editor.guards,\ - org.netbeans.modules.editor.highlights,\ - org.netbeans.modules.editor.macros,\ - org.netbeans.modules.editor.plain,\ - org.netbeans.modules.editor.plain.lib,\ - org.netbeans.modules.editor.structure,\ - org.netbeans.modules.extbrowser,\ - org.netbeans.modules.favorites,\ - org.netbeans.modules.gototest,\ - org.netbeans.modules.httpserver,\ - org.netbeans.modules.ide.kit,\ - org.netbeans.modules.image,\ - org.netbeans.modules.javahelp,\ - org.netbeans.modules.jumpto,\ - org.netbeans.modules.languages,\ - org.netbeans.modules.languages.bat,\ - org.netbeans.modules.languages.diff,\ - org.netbeans.modules.languages.manifest,\ - org.netbeans.modules.languages.sh,\ - org.netbeans.modules.lexer.editorbridge,\ - org.netbeans.modules.lexer.nbbridge,\ - org.netbeans.modules.localhistory,\ - org.netbeans.modules.masterfs,\ - org.netbeans.modules.mercurial,\ - org.netbeans.modules.progress.ui,\ - org.netbeans.modules.project.ant,\ - org.netbeans.modules.project.libraries,\ - org.netbeans.modules.projectui,\ - org.netbeans.modules.projectuiapi,\ - org.netbeans.modules.properties,\ - org.netbeans.modules.properties.syntax,\ - org.netbeans.modules.refactoring.api,\ - org.netbeans.modules.schema2beans,\ - org.netbeans.modules.sendopts,\ - org.netbeans.modules.server,\ - org.netbeans.modules.servletapi,\ - org.netbeans.modules.subversion,\ - org.netbeans.modules.tasklist.kit,\ - org.netbeans.modules.tasklist.projectint,\ - org.netbeans.modules.tasklist.todo,\ - org.netbeans.modules.tasklist.ui,\ - org.netbeans.modules.templates,\ - org.netbeans.modules.timers,\ - org.netbeans.modules.usersguide,\ - org.netbeans.modules.utilities,\ - org.netbeans.modules.utilities.project,\ - org.netbeans.modules.versioning,\ - org.netbeans.modules.versioning.system.cvss,\ - org.netbeans.modules.versioning.util,\ - org.netbeans.modules.web.flyingsaucer,\ - org.netbeans.modules.xml,\ - org.netbeans.modules.xml.axi,\ - org.netbeans.modules.xml.catalog,\ - org.netbeans.modules.xml.core,\ - org.netbeans.modules.xml.lexer,\ - org.netbeans.modules.xml.multiview,\ - org.netbeans.modules.xml.retriever,\ - org.netbeans.modules.xml.schema.completion,\ - org.netbeans.modules.xml.schema.model,\ - org.netbeans.modules.xml.tax,\ - org.netbeans.modules.xml.text,\ - org.netbeans.modules.xml.tools,\ - org.netbeans.modules.xml.wsdl.model,\ - org.netbeans.modules.xml.xam,\ - org.netbeans.modules.xml.xdm,\ - org.netbeans.modules.xsl,\ - org.netbeans.spi.debugger.ui,\ - org.netbeans.spi.editor.hints,\ - org.netbeans.spi.navigator,\ - org.netbeans.spi.palette,\ - org.netbeans.spi.tasklist,\ - org.netbeans.spi.viewmodel,\ - org.netbeans.swing.dirchooser,\ - org.openide.compat,\ - org.openide.util.enumerations -enabled.clusters=\ - ide9,\ - platform8 -nbjdk.active=default -nbplatform.active=default
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.apisupport.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> - <code-name-base>com.sun.hotspot.igv.texteditor</code-name-base> - <suite-component/> - <module-dependencies> - <dependency> - <code-name-base>com.sun.hotspot.igv.data</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.selectioncoordinator</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>com.sun.hotspot.igv.structuredtext</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>1.0</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.modules.editor</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>3</release-version> - <specification-version>1.42.2.3.9.2</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.modules.editor.deprecated.pre65formatting</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>0-1</release-version> - <specification-version>1.4.1.1.5.13.10</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.modules.editor.fold</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>1</release-version> - <specification-version>1.8</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.modules.editor.lib</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>3</release-version> - <specification-version>3.8.1.13.9</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.netbeans.modules.editor.lib2</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <release-version>1</release-version> - <specification-version>1.11.2.2</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.text</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>6.18</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>7.12.0.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.util.lookup</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>8.8.1</specification-version> - </run-dependency> - </dependency> - <dependency> - <code-name-base>org.openide.windows</code-name-base> - <build-prerequisite/> - <compile-dependency/> - <run-dependency> - <specification-version>6.20</specification-version> - </run-dependency> - </dependency> - </module-dependencies> - <public-packages> - <package>com.sun.hotspot.igv.texteditor</package> - </public-packages> - </data> - </configuration> -</project>
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/suite.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -suite.dir=${basedir}/..
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ - -OpenIDE-Module-Name=TextEditor
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,327 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.texteditor; - -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.Range; -import com.sun.hotspot.igv.structuredtext.ToolTipProvider; -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.AttributeSet; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; -import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory; -import org.netbeans.spi.editor.highlighting.HighlightsSequence; -import org.netbeans.spi.editor.highlighting.support.AbstractHighlightsContainer; - -/** - * - * @author Thomas - */ -public class SyntaxLayer extends AbstractHighlightsContainer implements ChangedListener<SelectionCoordinator> { - - private HighlightsLayerFactory.Context context; - - public SyntaxLayer(final HighlightsLayerFactory.Context context) { - this.context = context; - - context.getDocument().addDocumentListener(new DocumentListener() { - - public void insertUpdate(DocumentEvent arg0) { - update(); - } - - public void removeUpdate(DocumentEvent arg0) { - } - - public void changedUpdate(DocumentEvent arg0) { - } - }); - - SelectionCoordinator.getInstance().getSelectedChangedEvent().addListener(this); - SelectionCoordinator.getInstance().getHighlightedChangedEvent().addListener(this); - - context.getComponent().addMouseMotionListener(new MouseMotionListener() { - - public void mouseDragged(MouseEvent e) { - } - - public void mouseMoved(MouseEvent e) { - // [tw] hack to prevent sidebar mouse over - if (e.getPoint().getX() < 15) return; - - int index = context.getComponent().viewToModel(e.getPoint()); - Element elem = indexToElement(index); - if (elem != null) { - Set<Object> highlightedSource = new HashSet<Object>(elem.getSource()); - SelectionCoordinator.getInstance().setHighlightedObjects(highlightedSource); - context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } - } - }); - - context.getComponent().addMouseListener(new MouseListener() { - - public void mouseClicked(MouseEvent e) { - - int index = context.getComponent().viewToModel(e.getPoint()); - Element elem = indexToElement(index); - if (elem != null) { - Set<Object> selectedSource = new HashSet<Object>(elem.getSource()); - - for (Object o : selectedSource) { - if (o instanceof ToolTipProvider) { - String toolTip = ((ToolTipProvider) o).getToolTip(); - } - } - - if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) { - - SelectionCoordinator.getInstance().addAllSelected(selectedSource); - } else { - SelectionCoordinator.getInstance().setSelectedObjects(selectedSource); - } - context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } else { - context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); - - } - } - - public void mousePressed(MouseEvent e) { - } - - public void mouseReleased(MouseEvent e) { - } - - public void mouseEntered(MouseEvent e) { - } - - public void mouseExited(MouseEvent e) { - SelectionCoordinator.getInstance().setHighlightedObjects(new HashSet<Object>()); - } - }); - } - - public void changed(SelectionCoordinator source) { - update(); - } - - private void update() { - fireHighlightsChange(0, context.getDocument().getLength()); - } - - private Element indexToElement(int index) { - StructuredText text = (StructuredText) context.getDocument().getProperty(StructuredText.class); - if (text == null) { - return null; - } - return text.findElementAt(index); - } - - private static class HighlightsRange { - - private int start; - private int end; - private AttributeSet attributes; - - public HighlightsRange(int start, int length, AttributeSet attributes) { - this.start = start; - this.end = start + length; - this.attributes = attributes; - } - - public int getStart() { - return start; - } - - public int getEnd() { - return end; - } - - public AttributeSet getAttributes() { - return attributes; - } - } - - private static class HighlightsSequenceImpl implements HighlightsSequence { - - private List<HighlightsRange> ranges; - private int currentIndex; - - public HighlightsSequenceImpl() { - this(new ArrayList<HighlightsRange>()); - } - - public HighlightsSequenceImpl(List<HighlightsRange> ranges) { - this.ranges = ranges; - this.currentIndex = -1; - } - - public boolean moveNext() { - currentIndex++; - return currentIndex < ranges.size(); - } - - public int getStartOffset() { - return ranges.get(currentIndex).getStart(); - } - - public int getEndOffset() { - return ranges.get(currentIndex).getEnd(); - } - - public AttributeSet getAttributes() { - return ranges.get(currentIndex).getAttributes(); - } - } - - private boolean intersects(Set<Object> s1, Set<Object> s2) { - for (Object o : s1) { - if (s2.contains(o)) { - return true; - } - } - return false; - } - - public HighlightsSequence getHighlights(final int start, final int end) { - - StructuredText text = (StructuredText) context.getDocument().getProperty(StructuredText.class); - if (text == null) { - return new HighlightsSequenceImpl(); - } - final Map<Element, Range> ranges = text.calculateRanges(); - final List<HighlightsRange> highlightsRanges = new ArrayList<HighlightsRange>(); - final Range baseRange = new Range(start, end - start); - - text.accept(new ElementVisitor() { - - private Stack<Style> styleStack = new Stack<Style>(); - private Stack<Style> highlightedStyleStack = new Stack<Style>(); - private Stack<MultiElement> parentElements = new Stack<MultiElement>(); - - @Override - public void visit(MultiElement element) { - Style curStyle = element.getStyle(); - Style curHighlightedStyle = element.getHighlightedStyle(); - if(curStyle != null) { - styleStack.push(curStyle); - } - if (curHighlightedStyle != null) { - highlightedStyleStack.push(curHighlightedStyle); - } - parentElements.push(element); - super.visit(element); - if(curStyle != null) { - styleStack.pop(); - } - if (curHighlightedStyle != null) { - highlightedStyleStack.pop(); - } - parentElements.pop(); - } - - - @Override - public void visit(SimpleElement element) { - Range curRange = ranges.get(element); - if (baseRange.overlaps(curRange)) { - Style style = element.getStyle(); - if(style == null) { - if(styleStack.size() > 0) { - style = styleStack.peek(); - } else { - style = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); - StyleConstants.setBackground(style, Color.WHITE); - } - } - - - Style highlightedStyle = element.getHighlightedStyle(); - if (highlightedStyle == null) { - if (highlightedStyleStack.size() > 0) { - highlightedStyle = highlightedStyleStack.peek(); - } - } - - Set<Object> highlightedSource = SelectionCoordinator.getInstance().getHighlightedObjects(); - if (highlightedSource != null) { - - boolean doesIntersect = intersects(element.getSource(), highlightedSource); - for (MultiElement parentElement : parentElements) { - if (doesIntersect) { - break; - } - - doesIntersect = intersects(parentElement.getSource(), highlightedSource); - } - - if (doesIntersect) { - - if (highlightedStyle != null) { - style = highlightedStyle; - } else { - style = StyleContext.getDefaultStyleContext().addStyle(null, style); - Color bg = StyleConstants.getBackground(style); - Color fg = StyleConstants.getForeground(style); - StyleConstants.setBackground(style, new Color(255 - bg.getRed(), 255 - bg.getGreen(), 255 - bg.getBlue())); - StyleConstants.setForeground(style, new Color(255 - fg.getRed(), 255 - fg.getGreen(), 255 - fg.getBlue())); - } - } - } - - Set<Object> selectedSource = SelectionCoordinator.getInstance().getSelectedObjects(); - if (selectedSource != null && intersects(element.getSource(), selectedSource)) { - style = StyleContext.getDefaultStyleContext().addStyle(null, style); - StyleConstants.setBold(style, true); - } - - highlightsRanges.add(new HighlightsRange(curRange.getStart(), curRange.getLength(), style)); - } - } - }); - - return new HighlightsSequenceImpl(highlightsRanges); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditor.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.texteditor; - -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.awt.Component; -import java.util.HashSet; -import java.util.Set; -import javax.swing.JEditorPane; -import javax.swing.SwingUtilities; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Position; -import javax.swing.text.SimpleAttributeSet; -import org.netbeans.modules.editor.NbEditorDocument; -import org.netbeans.modules.editor.NbEditorUtilities; -import org.openide.text.Annotation; -import org.openide.text.Line; -import org.openide.util.Exceptions; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextEditor { - - private JEditorPane editorPane; - private Component component; - private Set<Annotation> addedAnnotations; - - public TextEditor() { - editorPane = new JEditorPane(); - component = createEditor(editorPane); - addedAnnotations = new HashSet<Annotation>(); - - } - - public Component getComponent() { - return component; - } - - public void setStructuredText(StructuredText text) { - assert text != null; - - setStructuredText(text, null); - } - - public void setStructuredText(final StructuredText text, final Element focusedElement) { - - assert text != null; - - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - Document doc = editorPane.getDocument(); - doc.putProperty(StructuredText.class, text); - - for (Annotation a : addedAnnotations) { - ((NbEditorDocument) editorPane.getDocument()).removeAnnotation(a); - } - - try { - editorPane.getDocument().remove(0, editorPane.getDocument().getLength()); - editorPane.getDocument().insertString(0, text.convertToString(), SimpleAttributeSet.EMPTY); - - text.accept(new ElementVisitor() { - - private int pos = 0; - - private void checkForFocus(Element element) { - if (element == focusedElement) { - editorPane.setCaretPosition(pos); - } - } - - @Override - public void visit(MultiElement element) { - super.visit(element); - checkForFocus(element); - } - - @Override - public void visit(SimpleElement element) { - checkForFocus(element); - for (Object o : element.getSource()) { - if (o instanceof Annotation) { - Annotation a = (Annotation) o; - final Line line = NbEditorUtilities.getLine(editorPane.getDocument(), pos, false); - - ((NbEditorDocument) editorPane.getDocument()).addAnnotation(new PositionImpl(pos), element.getText().length(), a); - addedAnnotations.add(a); - } - } - pos += element.getText().length(); - } - - class PositionImpl implements Position { - - private int position; - - public PositionImpl(int position) { - this.position = position; - } - - public int getOffset() { - return position; - } - } - }); - - } catch (BadLocationException ex) { - Exceptions.printStackTrace(ex); - } - - } - }); - - } - - private Component createEditor(JEditorPane pane) { - TextEditorKit kit = new TextEditorKit(); - pane.setEditable(false); - NbEditorDocument doc = (NbEditorDocument) kit.createDefaultDocument(); - pane.setEditorKit(kit); - pane.setDocument(doc); - return doc.createEditor(pane); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditorKit.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.texteditor; - -import java.util.ArrayList; -import java.util.List; -import javax.swing.Action; -import org.netbeans.editor.BaseDocument; -import org.netbeans.modules.editor.NbEditorKit; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextEditorKit extends NbEditorKit { - - public static final String MIME_TYPE = "text/text-igv"; - - /** - * Actions to be not available in the editor. - */ - private static final String[] ACTION_FILTER = { - NbEditorKit.shiftLineLeftAction, - NbEditorKit.shiftLineRightAction, - NbEditorKit.jumpListNextAction, - NbEditorKit.jumpListNextComponentAction, - NbEditorKit.jumpListPrevAction, - NbEditorKit.jumpListPrevComponentAction, - NbEditorKit.pasteAction, - NbEditorKit.removeLineAction, - NbEditorKit.cutAction, - NbEditorKit.findAction, - NbEditorKit.findNextAction, - NbEditorKit.findPreviousAction, - NbEditorKit.toggleHighlightSearchAction, - NbEditorKit.findSelectionAction, - "jump-list-last-edit" - }; - - @Override - protected Action[] createActions() { - Action[] actions = super.createActions(); - List<Action> returnedActions = new ArrayList<Action>(); - for(Action a : actions) { - System.out.println("action: " + a.getValue(Action.NAME)); - - boolean found = false; - for(String s : ACTION_FILTER) { - if(s.equals(a.getValue(Action.NAME))) { - found = true; - } - } - if(!found) { - returnedActions.add(a); - } - } - - Action[] result = new Action[returnedActions.size()]; - for(int i=0; i<returnedActions.size(); i++) { - result[i] = returnedActions.get(i); - } - - return result; - } - - @Override - protected void initDocument(BaseDocument doc) { - super.initDocument(doc); - System.out.println("Initializing document: " + doc); - - } - - @Override - public String getContentType() { - return MIME_TYPE; - } - - -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManager.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.texteditor; - -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import javax.swing.event.DocumentEvent; -import javax.swing.text.BadLocationException; -import org.netbeans.api.editor.fold.Fold; -import org.netbeans.spi.editor.fold.FoldHierarchyTransaction; -import org.netbeans.spi.editor.fold.FoldManager; -import org.netbeans.spi.editor.fold.FoldOperation; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.Range; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.logging.Logger; -import javax.swing.text.Document; -import org.netbeans.api.editor.fold.FoldType; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextFoldManager implements FoldManager { - - private FoldOperation operation; - private final FoldType defaultFoldType = new FoldType("default"); - private Set<Fold> currentFolds; - - public TextFoldManager() { - currentFolds = new HashSet<Fold>(); - } - - public void init(FoldOperation operation) { - this.operation = operation; - } - - public void initFolds(final FoldHierarchyTransaction transaction) { - } - - private void update(Document document, final FoldHierarchyTransaction transaction) { - - - StructuredText text = (StructuredText) document.getProperty(StructuredText.class); - if (text == null) { - // No StructuredText object behind the document object. - return; - } - - if(document.getLength() == 0) { - return; - } - - final Map<Element, Range> ranges = text.calculateRanges(); - currentFolds.clear(); - - text.accept(new ElementVisitor() { - @Override - public void visit(MultiElement element) { - super.visit(element); - Range curRange = ranges.get(element); - - if (element.getFoldString() != null) { - try { - Fold f = operation.addToHierarchy(defaultFoldType, element.getFoldString(), false, - curRange.getStart(), curRange.getStart() + curRange.getLength(), 0, 0, - null, transaction); - currentFolds.add(f); - } catch (BadLocationException ex) { - assert false : "Structured text not in sync with document content " + ex.getStackTrace(); - } - } - } - - @Override - public void visit(SimpleElement element) { - } - }); - } - - public void insertUpdate(DocumentEvent event, FoldHierarchyTransaction transaction) { - update(event.getDocument(), transaction); - } - - public void removeUpdate(DocumentEvent event, FoldHierarchyTransaction transaction) { - update(event.getDocument(), transaction); - } - - public void changedUpdate(DocumentEvent event, FoldHierarchyTransaction transaction) { -// update(event.getDocument(), transaction); - } - - public void removeEmptyNotify(Fold arg0) { - } - - public void removeDamagedNotify(Fold arg0) { - } - - public void expandNotify(Fold arg0) { - } - - public void release() { - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManagerFactory.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.texteditor; - -import org.netbeans.spi.editor.fold.FoldManager; -import org.netbeans.spi.editor.fold.FoldManagerFactory; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextFoldManagerFactory implements FoldManagerFactory{ - public FoldManager createFoldManager() { - return new TextFoldManager(); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextHighlightsLayerFactory.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.texteditor; - -import org.netbeans.spi.editor.highlighting.HighlightsLayer; -import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory; -import org.netbeans.spi.editor.highlighting.ZOrder; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextHighlightsLayerFactory implements HighlightsLayerFactory { - public HighlightsLayer[] createLayers(HighlightsLayerFactory.Context context) { - return new HighlightsLayer[] { - HighlightsLayer.create("com.sun.hotspot.igv.texteditor.SyntaxLayer", ZOrder.TOP_RACK, true, new SyntaxLayer(context)) - }; - } - -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextSideBarFactory.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.texteditor; - -import javax.swing.JComponent; -import javax.swing.text.JTextComponent; -import org.netbeans.editor.CodeFoldingSideBar; -import org.netbeans.editor.SideBarFactory; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextSideBarFactory implements SideBarFactory { - public JComponent createSideBar(JTextComponent text) { - return new CodeFoldingSideBar(text); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/layer.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> - - <folder name="Editors"> - <folder name="Preferences"/> - <folder name="text"> - <folder name="text-igv"> - <file name="EditorKit.instance"> - <attr name="instanceClass" stringvalue="com.sun.hotspot.igv.texteditor.TextEditorKit"/> - </file> - <folder name="FoldManager"> - <file name="com-sun-hotspot-igv-texteditor-TextFoldManagerFactory.instance"/> - </folder> - <folder name="Preferences"> - <file name="org-netbeans-modules-editor-preferences.xml" url="org-netbeans-modules-editor-preferences.xml"/> - </folder> - <folder name="SideBar"> - <file name="com-sun-hotspot-igv-texteditor-TextSideBarFactory.instance"> - <attr name="position" intvalue="1500"/> - </file> - </folder> - <file name="com-sun-hotspot-igv-texteditor-TextHighlightsLayerFactory.instance"/> - </folder> - </folder> - </folder> -</filesystem>
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/org-netbeans-modules-editor-preferences.xml Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -<?xml version="1.0"?> -<!-- -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. - - -The contents of this file are subject to the terms of either the GNU -General Public License Version 2 only ("GPL") or the Common -Development and Distribution License("CDDL") (collectively, the -"License"). You may not use this file except in compliance with the -License. You can obtain a copy of the License at -http://www.netbeans.org/cddl-gplv2.html -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the -specific language governing permissions and limitations under the -License. When distributing the software, include this License Header -Notice in each file and include the License file at -nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this -particular file as subject to the "Classpath" exception as provided -by Sun in the GPL Version 2 section of the License file that -accompanied this code. If applicable, add the following below the -License Header, with the fields enclosed by brackets [] replaced by -your own identifying information: -"Portions Copyrighted [year] [name of copyright owner]" - -Contributor(s): - -The Original Software is NetBeans. The Initial Developer of the Original -Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun -Microsystems, Inc. All Rights Reserved. - -If you wish your version of this file to be governed by only the CDDL -or only the GPL Version 2, indicate your decision by adding -"[Contributor] elects to include this software in this distribution -under the [CDDL or GPL Version 2] license." If you do not indicate a -single choice of license, a recipient has the option to distribute -your version of this file under either the CDDL, the GPL Version 2 or -to extend the choice of license to its licensees as provided above. -However, if you add GPL Version 2 code and therefore, elected the GPL -Version 2 license, then the option applies only if the new code is -made subject to such option by the copyright holder. ---> -<!DOCTYPE editor-preferences PUBLIC "-//NetBeans//DTD Editor Preferences 1.0//EN" "http://www.netbeans.org/dtds/EditorPreferences-1_0.dtd"> - -<editor-preferences> - <entry name="toolbarVisible" value="false" javaType="java.lang.Boolean" /> - <entry name="line-number-visible" value="false" javaType="java.lang.Boolean" /> - <entry name="code-folding-enable" value="true" javaType="java.lang.Boolean" /> - <entry name="status-bar-visible" value="false" javaType="java.lang.Boolean" /> - <entry name="text-limit-line-visible" value="false" javaType="java.lang.Boolean" /> -</editor-preferences>
--- a/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ColorIcon.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ColorIcon.java Sun Jan 29 11:40:04 2012 +0100 @@ -40,15 +40,18 @@ color = c; } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(color); g.fillRect(x, y, 16, 16); } + @Override public int getIconWidth() { return 16; } + @Override public int getIconHeight() { return 16; }
--- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,11 +25,7 @@ package com.sun.hotspot.igv.util; import java.awt.EventQueue; -import org.openide.util.ContextAwareAction; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.Utilities; +import org.openide.util.*; import org.openide.util.actions.CallableSystemAction; /** @@ -56,6 +52,7 @@ resultChanged(null); } + @Override public void resultChanged(LookupEvent e) { if (result.allItems().size() != 0) { update(result.allInstances().iterator().next()); @@ -71,6 +68,7 @@ // Ensure it's AWT event thread EventQueue.invokeLater(new Runnable() { + @Override public void run() { performAction(t); }
--- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSatelliteComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSatelliteComponent.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,11 +23,10 @@ */ package com.sun.hotspot.igv.util; -import org.netbeans.api.visual.widget.Scene; - -import javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.JComponent; +import org.netbeans.api.visual.widget.Scene; /** * @author David Kaspar @@ -118,27 +117,34 @@ } } + @Override public void mouseClicked(MouseEvent e) { } + @Override public void mousePressed(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseReleased(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseEntered(MouseEvent e) { } + @Override public void mouseExited(MouseEvent e) { } + @Override public void mouseDragged(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseMoved(MouseEvent e) { } @@ -170,26 +176,33 @@ } + @Override public void sceneRepaint() { } + @Override public void sceneValidating() { } + @Override public void sceneValidated() { } + @Override public void componentResized(ComponentEvent e) { repaint(); } + @Override public void componentMoved(ComponentEvent e) { repaint(); } + @Override public void componentShown(ComponentEvent e) { } + @Override public void componentHidden(ComponentEvent e) { } }
--- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/LookupHistory.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/LookupHistory.java Sun Jan 29 11:40:04 2012 +0100 @@ -36,7 +36,7 @@ */ public class LookupHistory { - private static Map<Class, LookupHistoryImpl> cache = new HashMap<Class, LookupHistoryImpl>(); + private static Map<Class, LookupHistoryImpl> cache = new HashMap<>(); private static class LookupHistoryImpl<T> implements LookupListener { @@ -55,6 +55,7 @@ return last; } + @Override public void resultChanged(LookupEvent ev) { T current = Utilities.actionsGlobalContext().lookup(klass); if (current != null) { @@ -65,7 +66,7 @@ public static <T> void init(Class<T> klass) { if (!cache.containsKey(klass)) { - cache.put(klass, new LookupHistoryImpl<T>(klass)); + cache.put(klass, new LookupHistoryImpl<>(klass)); } }
--- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,15 +25,7 @@ package com.sun.hotspot.igv.util; import com.sun.hotspot.igv.data.ChangedListener; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.RenderingHints; +import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -105,6 +97,7 @@ return d; } + @Override public void changed(RangeSliderModel source) { update(); } @@ -240,6 +233,7 @@ return false; } + @Override public void mouseDragged(MouseEvent e) { if (state == State.DragBar) { int firstX = this.getStartXPosition(model.getFirstPosition()); @@ -294,6 +288,7 @@ return result; } + @Override public void mouseMoved(MouseEvent e) { isOverBar = false; if (model == null) { @@ -313,6 +308,7 @@ repaint(); } + @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { // Double click @@ -321,6 +317,7 @@ } } + @Override public void mousePressed(MouseEvent e) { if (model == null) { return; @@ -341,6 +338,7 @@ tempModel = model.copy(); } + @Override public void mouseReleased(MouseEvent e) { if (model == null || tempModel == null) { return; @@ -350,9 +348,11 @@ tempModel = null; } + @Override public void mouseEntered(MouseEvent e) { } + @Override public void mouseExited(MouseEvent e) { isOverBar = false; repaint();
--- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSliderModel.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSliderModel.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,8 +24,8 @@ */ package com.sun.hotspot.igv.util; +import com.sun.hotspot.igv.data.ChangedEvent; import com.sun.hotspot.igv.data.ChangedEventProvider; -import com.sun.hotspot.igv.data.ChangedEvent; import java.awt.Color; import java.util.ArrayList; import java.util.Collections; @@ -65,14 +65,14 @@ public RangeSliderModel(List<String> positions) { assert positions.size() > 0; - this.changedEvent = new ChangedEvent<RangeSliderModel>(this); - this.colorChangedEvent = new ChangedEvent<RangeSliderModel>(this); + this.changedEvent = new ChangedEvent<>(this); + this.colorChangedEvent = new ChangedEvent<>(this); setPositions(positions); } protected void setPositions(List<String> positions) { this.positions = positions; - colors = new ArrayList<Color>(); + colors = new ArrayList<>(); for (int i = 0; i < positions.size(); i++) { colors.add(Color.black); } @@ -130,6 +130,7 @@ return colorChangedEvent; } + @Override public ChangedEvent<RangeSliderModel> getChangedEvent() { return changedEvent; }
--- a/src/share/tools/IdealGraphVisualizer/View/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,77 +23,32 @@ */ package com.sun.hotspot.igv.view; -import com.sun.hotspot.igv.view.widgets.BlockWidget; -import com.sun.hotspot.igv.view.widgets.LineWidget; -import com.sun.hotspot.igv.util.DoubleClickAction; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.hierarchicallayout.HierarchicalClusterLayoutManager; -import com.sun.hotspot.igv.hierarchicallayout.OldHierarchicalLayoutManager; -import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager; -import com.sun.hotspot.igv.view.widgets.FigureWidget; -import com.sun.hotspot.igv.layout.LayoutGraph; -import com.sun.hotspot.igv.data.services.Scheduler; import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.data.ControllableChangedListener; import com.sun.hotspot.igv.data.Pair; import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.graph.Block; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.Slot; +import com.sun.hotspot.igv.graph.*; +import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager; +import com.sun.hotspot.igv.layout.LayoutGraph; import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; import com.sun.hotspot.igv.util.ColorIcon; +import com.sun.hotspot.igv.util.DoubleClickAction; import com.sun.hotspot.igv.util.PropertiesSheet; import com.sun.hotspot.igv.view.actions.CustomizablePanAction; -import com.sun.hotspot.igv.view.widgets.InputSlotWidget; -import com.sun.hotspot.igv.view.widgets.OutputSlotWidget; -import com.sun.hotspot.igv.view.widgets.SlotWidget; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; +import com.sun.hotspot.igv.view.widgets.*; +import java.awt.*; +import java.awt.event.*; import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; +import java.util.*; +import javax.swing.*; import javax.swing.event.UndoableEditEvent; import javax.swing.undo.AbstractUndoableEdit; import javax.swing.undo.CannotRedoException; import javax.swing.undo.CannotUndoException; -import org.netbeans.api.visual.action.ActionFactory; -import org.netbeans.api.visual.action.PopupMenuProvider; -import org.netbeans.api.visual.action.RectangularSelectDecorator; -import org.netbeans.api.visual.action.RectangularSelectProvider; -import org.netbeans.api.visual.action.WidgetAction; +import org.netbeans.api.visual.action.*; import org.netbeans.api.visual.animator.SceneAnimator; import org.netbeans.api.visual.layout.LayoutFactory; -import org.netbeans.api.visual.model.ObjectScene; -import org.netbeans.api.visual.model.ObjectSceneEvent; -import org.netbeans.api.visual.model.ObjectSceneEventType; -import org.netbeans.api.visual.model.ObjectSceneListener; -import org.netbeans.api.visual.model.ObjectState; +import org.netbeans.api.visual.model.*; import org.netbeans.api.visual.widget.LayerWidget; import org.netbeans.api.visual.widget.Widget; import org.openide.awt.UndoRedo; @@ -150,12 +105,14 @@ private PopupMenuProvider popupMenuProvider = new PopupMenuProvider() { + @Override public JPopupMenu getPopupMenu(Widget widget, Point localLocation) { return DiagramScene.this.createPopupMenu(); } }; private RectangularSelectDecorator rectangularSelectDecorator = new RectangularSelectDecorator() { + @Override public Widget createSelectionWidget() { Widget widget = new Widget(DiagramScene.this); widget.setBorder(BorderFactory.createLineBorder(Color.black, 2)); @@ -185,6 +142,7 @@ return false; } + @Override public void zoomOut() { double zoom = getZoomFactor(); Point viewPosition = getScrollPane().getViewport().getViewPosition(); @@ -196,6 +154,7 @@ } } + @Override public void zoomIn() { double zoom = getZoomFactor(); @@ -209,6 +168,7 @@ } + @Override public void centerFigures(List<Figure> list) { boolean b = getUndoRedoEnabled(); @@ -218,7 +178,7 @@ } private Set<Object> getObjectsFromIdSet(Set<Object> set) { - Set<Object> selectedObjects = new HashSet<Object>(); + Set<Object> selectedObjects = new HashSet<>(); for (Figure f : getModel().getDiagramToView().getFigures()) { if (intersects(f.getSource().getSourceNodesAsSet(), set)) { selectedObjects.add(f); @@ -234,6 +194,7 @@ } private ControllableChangedListener<SelectionCoordinator> highlightedCoordinatorListener = new ControllableChangedListener<SelectionCoordinator>() { + @Override public void filteredChanged(SelectionCoordinator source) { DiagramScene.this.setHighlightedObjects(getObjectsFromIdSet(source.getHighlightedObjects())); DiagramScene.this.validate(); @@ -241,6 +202,7 @@ }; private ControllableChangedListener<SelectionCoordinator> selectedCoordinatorListener = new ControllableChangedListener<SelectionCoordinator>() { + @Override public void filteredChanged(SelectionCoordinator source) { DiagramScene.this.gotoSelection(source.getSelectedObjects()); DiagramScene.this.validate(); @@ -249,6 +211,7 @@ private RectangularSelectProvider rectangularSelectProvider = new RectangularSelectProvider() { + @Override public void performSelection(Rectangle rectangle) { if (rectangle.width < 0) { rectangle.x += rectangle.width; @@ -260,7 +223,7 @@ rectangle.height *= -1; } - Set<Object> selectedObjects = new HashSet<Object>(); + Set<Object> selectedObjects = new HashSet<>(); for (Figure f : getModel().getDiagramToView().getFigures()) { FigureWidget w = getWidget(f); if (w != null) { @@ -291,6 +254,7 @@ private MouseWheelListener mouseWheelListener = new MouseWheelListener() { + @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.isControlDown()) { DiagramScene.this.relayoutWithoutLayout(null); @@ -323,15 +287,19 @@ } private ObjectSceneListener selectionChangedListener = new ObjectSceneListener() { + @Override public void objectAdded(ObjectSceneEvent arg0, Object arg1) { } + @Override public void objectRemoved(ObjectSceneEvent arg0, Object arg1) { } + @Override public void objectStateChanged(ObjectSceneEvent e, Object o, ObjectState oldState, ObjectState newState) { } + @Override public void selectionChanged(ObjectSceneEvent e, Set<Object> oldSet, Set<Object> newSet) { DiagramScene scene = (DiagramScene) e.getObjectScene(); if (scene.isRebuilding()) { @@ -340,7 +308,7 @@ content.set(newSet, null); - Set<Integer> nodeSelection = new HashSet<Integer>(); + Set<Integer> nodeSelection = new HashSet<>(); for (Object o : newSet) { if (o instanceof Properties.Provider) { final Properties.Provider provider = (Properties.Provider) o; @@ -373,8 +341,9 @@ } + @Override public void highlightingChanged(ObjectSceneEvent e, Set<Object> oldSet, Set<Object> newSet) { - Set<Integer> nodeHighlighting = new HashSet<Integer>(); + Set<Integer> nodeHighlighting = new HashSet<>(); for (Object o : newSet) { if (o instanceof Figure) { nodeHighlighting.addAll(((Figure) o).getSource().getSourceNodesAsSet()); @@ -388,8 +357,9 @@ highlightedCoordinatorListener.setEnabled(true); } + @Override public void hoverChanged(ObjectSceneEvent e, Object oldObject, Object newObject) { - Set<Object> newHighlightedObjects = new HashSet<Object>(DiagramScene.this.getHighlightedObjects()); + Set<Object> newHighlightedObjects = new HashSet<>(DiagramScene.this.getHighlightedObjects()); if (oldObject != null) { newHighlightedObjects.remove(oldObject); } @@ -399,6 +369,7 @@ DiagramScene.this.setHighlightedObjects(newHighlightedObjects); } + @Override public void focusChanged(ObjectSceneEvent arg0, Object arg1, Object arg2) { } }; @@ -474,6 +445,7 @@ return scrollPane; } + @Override public Component getComponent() { return scrollPane; } @@ -486,6 +458,7 @@ final DiagramScene diagramScene = this; Action a = new AbstractAction() { + @Override public void actionPerformed(ActionEvent e) { diagramScene.gotoFigure(f); } @@ -497,13 +470,7 @@ name += " ("; - if (f.getCluster() != null) { - name += "B" + f.getCluster().toString(); - } if (!this.getWidget(f, FigureWidget.class).isVisible()) { - if (f.getCluster() != null) { - name += ", "; - } name += "hidden"; } name += ")"; @@ -529,21 +496,13 @@ rebuilding = true; - Collection<Object> objects = new ArrayList<Object>(this.getObjects()); + Collection<Object> objects = new ArrayList<>(this.getObjects()); for (Object o : objects) { this.removeObject(o); } Diagram d = getModel().getDiagramToView(); - if (d.getGraph().getBlocks().isEmpty()) { - Scheduler s = Lookup.getDefault().lookup(Scheduler.class); - d.getGraph().clearBlocks(); - s.schedule(d.getGraph()); - d.getGraph().ensureNodesInBlocks(); - d.updateBlocks(); - } - for (Figure f : d.getFigures()) { FigureWidget w = new FigureWidget(f, hoverAction, selectAction, this, mainLayer); w.getActions().addAction(ActionFactory.createPopupMenuAction(w)); @@ -569,15 +528,6 @@ sw.getActions().addAction(selectAction); } } - - if (getModel().getShowBlocks()) { - for (InputBlock bn : d.getGraph().getBlocks()) { - BlockWidget w = new BlockWidget(this, d, bn); - w.setVisible(false); - this.addObject(bn, w); - blockLayer.addChild(w); - } - } rebuilding = false; this.smallUpdate(true); @@ -613,7 +563,7 @@ Diagram diagram = getModel().getDiagramToView(); - HashSet<Figure> figures = new HashSet<Figure>(); + HashSet<Figure> figures = new HashSet<>(); for (Figure f : diagram.getFigures()) { FigureWidget w = getWidget(f); @@ -622,7 +572,7 @@ } } - HashSet<Connection> edges = new HashSet<Connection>(); + HashSet<Connection> edges = new HashSet<>(); for (Connection c : diagram.getConnections()) { if (isVisible(c)) { @@ -630,24 +580,12 @@ } } - if (getModel().getShowBlocks()) { - HierarchicalClusterLayoutManager m = new HierarchicalClusterLayoutManager(OldHierarchicalLayoutManager.Combine.SAME_OUTPUTS); - HierarchicalLayoutManager manager = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.SAME_OUTPUTS); - manager.setMaxLayerLength(9); - manager.setMinLayerDifference(3); - m.setManager(manager); - m.setSubManager(new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.SAME_OUTPUTS)); - m.doLayout(new LayoutGraph(edges, figures)); - - } else { - HierarchicalLayoutManager manager = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.SAME_OUTPUTS); - manager.setMaxLayerLength(10); - manager.doLayout(new LayoutGraph(edges, figures)); - } - + HierarchicalLayoutManager manager = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.SAME_OUTPUTS); + manager.setMaxLayerLength(10); + manager.doLayout(new LayoutGraph(edges, figures)); relayoutWithoutLayout(oldVisibleWidgets); } - private Set<Pair<Point, Point>> lineCache = new HashSet<Pair<Point, Point>>(); + private Set<Pair<Point, Point>> lineCache = new HashSet<>(); private void relayoutWithoutLayout(Set<Widget> oldVisibleWidgets) { @@ -681,17 +619,6 @@ } } - if (getModel().getShowBlocks()) { - for (Block b : diagram.getBlocks()) { - BlockWidget w = getWidget(b.getInputBlock()); - if (w != null && w.isVisible()) { - Rectangle r = b.getBounds(); - maxX = Math.max(maxX, r.x + r.width); - maxY = Math.max(maxY, r.y + r.height); - } - } - } - bottomRight.setPreferredLocation(new Point(maxX + BORDER_SIZE, maxY + BORDER_SIZE)); int offx = 0; int offy = 0; @@ -723,7 +650,7 @@ Set<Pair<Point, Point>> lastLineCache = lineCache; - lineCache = new HashSet<Pair<Point, Point>>(); + lineCache = new HashSet<>(); for (Figure f : diagram.getFigures()) { for (OutputSlot s : f.getOutputSlots()) { SceneAnimator anim = animator; @@ -748,29 +675,12 @@ } } - if (getModel().getShowBlocks()) { - for (Block b : diagram.getBlocks()) { - BlockWidget w = getWidget(b.getInputBlock()); - if (w != null && w.isVisible()) { - Point location = new Point(b.getBounds().x + offx2, b.getBounds().y + offy2); - Rectangle r = new Rectangle(location.x, location.y, b.getBounds().width, b.getBounds().height); - - if ((visibleFigureCount <= ANIMATION_LIMIT && oldVisibleWidgets != null && oldVisibleWidgets.contains(w))) { - animator.animatePreferredBounds(w, r); - } else { - w.setPreferredBounds(r); - animator.animatePreferredBounds(w, r); - } - } - } - } - this.validate(); } private final Point specialNullPoint = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); private void processOutputSlot(Set<Pair<Point, Point>> lastLineCache, OutputSlot s, List<Connection> connections, int controlPointIndex, Point lastPoint, LineWidget predecessor, int offx, int offy, SceneAnimator animator) { - Map<Point, List<Connection>> pointMap = new HashMap<Point, List<Connection>>(connections.size()); + Map<Point, List<Connection>> pointMap = new HashMap<>(connections.size()); for (Connection c : connections) { @@ -795,7 +705,7 @@ if (pointMap.containsKey(cur)) { pointMap.get(cur).add(c); } else { - List<Connection> newList = new ArrayList<Connection>(2); + List<Connection> newList = new ArrayList<>(2); newList.add(c); pointMap.put(cur, newList); } @@ -826,7 +736,7 @@ Point p1 = new Point(lastPoint.x + offx, lastPoint.y + offy); Point p2 = new Point(p.x + offx, p.y + offy); - Pair<Point, Point> curPair = new Pair<Point, Point>(p1, p2); + Pair<Point, Point> curPair = new Pair<>(p1, p2); SceneAnimator curAnimator = animator; if (lastLineCache.contains(curPair)) { curAnimator = null; @@ -844,6 +754,7 @@ } } + @Override public void setInteractionMode(InteractionMode mode) { panAction.setEnabled(mode == InteractionMode.PANNING); // When panAction is not enabled, it does not consume the event @@ -855,7 +766,7 @@ private Set<Connection> connections; public ConnectionSet(Collection<Connection> connections) { - connections = new HashSet<Connection>(connections); + connections = new HashSet<>(connections); } public Set<Connection> getConnectionSet() { @@ -868,6 +779,7 @@ return lookup; } + @Override public void initialize() { Figure f = getModel().getDiagramToView().getRootFigure(); if (f != null) { @@ -902,7 +814,7 @@ private Set<Object> idSetToObjectSet(Set<Object> ids) { - Set<Object> result = new HashSet<Object>(); + Set<Object> result = new HashSet<>(); for (Figure f : getModel().getDiagramToView().getFigures()) { if (DiagramScene.doesIntersect(f.getSource().getSourceNodesAsSet(), ids)) { result.add(f); @@ -920,7 +832,7 @@ public void gotoSelection(Set<Object> ids) { Rectangle overall = null; - Set<Integer> hiddenNodes = new HashSet<Integer>(this.getModel().getHiddenNodes()); + Set<Integer> hiddenNodes = new HashSet<>(this.getModel().getHiddenNodes()); hiddenNodes.removeAll(ids); this.getModel().showNot(hiddenNodes); @@ -988,8 +900,9 @@ } } + @Override public void setSelection(Collection<Figure> list) { - super.setSelectedObjects(new HashSet<Figure>(list)); + super.setSelectedObjects(new HashSet<>(list)); } private UndoRedo.Manager getUndoRedoManager() { @@ -1001,6 +914,7 @@ return undoRedoManager; } + @Override public UndoRedo getUndoRedo() { return getUndoRedoManager(); } @@ -1014,9 +928,9 @@ return true; } - public static boolean doesIntersect(Set s1, Set s2) { + public static boolean doesIntersect(Set<?> s1, Set<?> s2) { if (s1.size() > s2.size()) { - Set tmp = s1; + Set<?> tmp = s1; s1 = s2; s2 = tmp; } @@ -1030,11 +944,13 @@ return false; } + @Override public void componentHidden() { SelectionCoordinator.getInstance().getHighlightedChangedEvent().removeListener(highlightedCoordinatorListener); SelectionCoordinator.getInstance().getSelectedChangedEvent().removeListener(selectedCoordinatorListener); } + @Override public void componentShowing() { SelectionCoordinator.getInstance().getHighlightedChangedEvent().addListener(highlightedCoordinatorListener); SelectionCoordinator.getInstance().getSelectedChangedEvent().addListener(selectedCoordinatorListener); @@ -1043,12 +959,11 @@ private void updateHiddenNodes(Set<Integer> newHiddenNodes, boolean doRelayout) { System.out.println("newHiddenNodes: " + newHiddenNodes); - Set<InputBlock> visibleBlocks = new HashSet<InputBlock>(); Diagram diagram = getModel().getDiagramToView(); assert diagram != null; - Set<Widget> oldVisibleWidgets = new HashSet<Widget>(); + Set<Widget> oldVisibleWidgets = new HashSet<>(); for (Figure f : diagram.getFigures()) { FigureWidget w = getWidget(f); @@ -1057,15 +972,6 @@ } } - if (getModel().getShowBlocks()) { - for (InputBlock b : diagram.getGraph().getBlocks()) { - BlockWidget w = getWidget(b); - if (w.isVisible()) { - oldVisibleWidgets.add(w); - } - } - } - for (Figure f : diagram.getFigures()) { boolean hiddenAfter = doesIntersect(f.getSource().getSourceNodesAsSet(), newHiddenNodes); @@ -1074,9 +980,6 @@ if (!hiddenAfter) { // Figure is shown w.setVisible(true); - for (InputNode n : f.getSource().getSourceNodes()) { - visibleBlocks.add(diagram.getGraph().getBlock(n)); - } } else { // Figure is hidden w.setVisible(false); @@ -1084,11 +987,11 @@ } if (getModel().getShowNodeHull()) { - List<FigureWidget> boundaries = new ArrayList<FigureWidget>(); + List<FigureWidget> boundaries = new ArrayList<>(); for (Figure f : diagram.getFigures()) { FigureWidget w = getWidget(f); if (!w.isVisible()) { - Set<Figure> set = new HashSet<Figure>(f.getPredecessorSet()); + Set<Figure> set = new HashSet<>(f.getPredecessorSet()); set.addAll(f.getSuccessorSet()); boolean b = false; @@ -1102,9 +1005,6 @@ if (b) { w.setBoundary(true); - for (InputNode n : f.getSource().getSourceNodes()) { - visibleBlocks.add(diagram.getGraph().getBlock(n)); - } boundaries.add(w); } } @@ -1117,22 +1017,6 @@ } } - if (getModel().getShowBlocks()) { - for (InputBlock b : diagram.getGraph().getBlocks()) { - - boolean visibleAfter = visibleBlocks.contains(b); - - BlockWidget w = getWidget(b); - if (visibleAfter) { - // Block must be shown - w.setVisible(true); - } else { - // Block must be hidden - w.setVisible(false); - } - } - } - if (doRelayout) { relayout(oldVisibleWidgets); } @@ -1141,7 +1025,7 @@ } private void showFigure(Figure f) { - HashSet<Integer> newHiddenNodes = new HashSet<Integer>(getModel().getHiddenNodes()); + HashSet<Integer> newHiddenNodes = new HashSet<>(getModel().getHiddenNodes()); newHiddenNodes.removeAll(f.getSource().getSourceNodesAsSet()); updateHiddenNodes(newHiddenNodes, true); } @@ -1151,7 +1035,7 @@ } public void setSelectedObjects(Object... args) { - Set<Object> set = new HashSet<Object>(); + Set<Object> set = new HashSet<>(); for (Object o : args) { set.add(o); } @@ -1226,6 +1110,7 @@ SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { scene.setScrollPosition(oldScrollPosition); } @@ -1234,6 +1119,7 @@ scene.setUndoRedoEnabled(b); } + @Override public void changed(DiagramViewModel source) { scene.getModel().getViewChangedEvent().removeListener(this); if (oldModel.getHiddenNodes().equals(newModel.getHiddenNodes())) { @@ -1254,6 +1140,7 @@ } private final ChangedListener<DiagramViewModel> fullChange = new ChangedListener<DiagramViewModel>() { + @Override public void changed(DiagramViewModel source) { assert source == model : "Receive only changed event from current model!"; assert source != null; @@ -1262,6 +1149,7 @@ }; private final ChangedListener<DiagramViewModel> hiddenNodesChange = new ChangedListener<DiagramViewModel>() { + @Override public void changed(DiagramViewModel source) { assert source == model : "Receive only changed event from current model!"; assert source != null; @@ -1270,6 +1158,7 @@ }; private final ChangedListener<DiagramViewModel> selectionChange = new ChangedListener<DiagramViewModel>() { + @Override public void changed(DiagramViewModel source) { assert source == model : "Receive only changed event from current model!"; assert source != null;
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,24 +24,16 @@ */ package com.sun.hotspot.igv.view; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.*; import com.sun.hotspot.igv.difference.Difference; +import com.sun.hotspot.igv.filter.CustomFilter; import com.sun.hotspot.igv.filter.FilterChain; import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.data.ChangedEvent; -import com.sun.hotspot.igv.util.RangeSliderModel; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.filter.CustomFilter; import com.sun.hotspot.igv.graph.Figure; import com.sun.hotspot.igv.settings.Settings; +import com.sun.hotspot.igv.util.RangeSliderModel; import java.awt.Color; -import java.util.Collection; +import java.util.*; /** * @@ -63,10 +55,10 @@ private ChangedEvent<DiagramViewModel> viewChangedEvent; private ChangedEvent<DiagramViewModel> hiddenNodesChangedEvent; private ChangedEvent<DiagramViewModel> viewPropertiesChangedEvent; - private boolean showBlocks; private boolean showNodeHull; private ChangedListener<FilterChain> filterChainChangedListener = new ChangedListener<FilterChain>() { + @Override public void changed(FilterChain source) { diagramChanged(); } @@ -99,8 +91,6 @@ this.onScreenNodes = newModel.onScreenNodes; viewChanged |= (selectedNodes != newModel.selectedNodes); this.selectedNodes = newModel.selectedNodes; - viewPropertiesChanged |= (showBlocks != newModel.showBlocks); - this.showBlocks = newModel.showBlocks; viewPropertiesChanged |= (showNodeHull != newModel.showNodeHull); this.showNodeHull = newModel.showNodeHull; @@ -119,15 +109,6 @@ } } - public boolean getShowBlocks() { - return showBlocks; - } - - public void setShowBlocks(boolean b) { - showBlocks = b; - viewPropertiesChangedEvent.fire(); - } - public boolean getShowNodeHull() { return showNodeHull; } @@ -141,22 +122,21 @@ super(calculateStringList(g)); this.showNodeHull = true; - this.showBlocks = true; this.group = g; assert filterChain != null; this.filterChain = filterChain; assert sequenceFilterChain != null; this.sequenceFilterChain = sequenceFilterChain; - hiddenNodes = new HashSet<Integer>(); - onScreenNodes = new HashSet<Integer>(); - selectedNodes = new HashSet<Integer>(); + hiddenNodes = new HashSet<>(); + onScreenNodes = new HashSet<>(); + selectedNodes = new HashSet<>(); super.getChangedEvent().addListener(this); - diagramChangedEvent = new ChangedEvent<DiagramViewModel>(this); - viewChangedEvent = new ChangedEvent<DiagramViewModel>(this); - hiddenNodesChangedEvent = new ChangedEvent<DiagramViewModel>(this); - viewPropertiesChangedEvent = new ChangedEvent<DiagramViewModel>(this); + diagramChangedEvent = new ChangedEvent<>(this); + viewChangedEvent = new ChangedEvent<>(this); + hiddenNodesChangedEvent = new ChangedEvent<>(this); + viewPropertiesChangedEvent = new ChangedEvent<>(this); - groupChangedEvent = new ChangedEvent<DiagramViewModel>(this); + groupChangedEvent = new ChangedEvent<>(this); groupChangedEvent.addListener(groupChangedListener); groupChangedEvent.fire(); @@ -167,6 +147,7 @@ private Group oldGroup; + @Override public void changed(DiagramViewModel source) { if (oldGroup != null) { oldGroup.getChangedEvent().removeListener(groupContentChangedListener); @@ -177,6 +158,7 @@ }; private final ChangedListener<Group> groupContentChangedListener = new ChangedListener<Group>() { + @Override public void changed(Group source) { assert source == group; setPositions(calculateStringList(source)); @@ -214,7 +196,7 @@ public void setSelectedNodes(Set<Integer> nodes) { this.selectedNodes = nodes; - List<Color> colors = new ArrayList<Color>(); + List<Color> colors = new ArrayList<>(); for (String s : getPositions()) { colors.add(Color.black); } @@ -259,7 +241,7 @@ } public void showFigures(Collection<Figure> f) { - HashSet<Integer> newHiddenNodes = new HashSet<Integer>(getHiddenNodes()); + HashSet<Integer> newHiddenNodes = new HashSet<>(getHiddenNodes()); for (Figure fig : f) { newHiddenNodes.removeAll(fig.getSource().getSourceNodesAsSet()); } @@ -268,7 +250,7 @@ public Set<Figure> getSelectedFigures() { - Set<Figure> result = new HashSet<Figure>(); + Set<Figure> result = new HashSet<>(); for (Figure f : diagram.getFigures()) { for (InputNode node : f.getSource().getSourceNodes()) { if (getSelectedNodes().contains(node.getId())) { @@ -284,7 +266,7 @@ } public void showOnly(final Set<Integer> nodes) { - final HashSet<Integer> allNodes = new HashSet<Integer>(getGraphToView().getGroup().getAllNodes()); + final HashSet<Integer> allNodes = new HashSet<>(getGraphToView().getGroup().getAllNodes()); allNodes.removeAll(nodes); setHiddenNodes(allNodes); } @@ -331,7 +313,7 @@ } private static List<String> calculateStringList(Group g) { - List<String> result = new ArrayList<String>(); + List<String> result = new ArrayList<>(); for (InputGraph graph : g.getGraphs()) { result.add(graph.getName()); } @@ -365,14 +347,14 @@ if (diagram == null) { diagram = Diagram.createDiagram(getGraphToView(), Settings.get().get(Settings.NODE_TEXT, Settings.NODE_TEXT_DEFAULT)); getFilterChain().apply(diagram, getSequenceFilterChain()); - if (diagram.getGraph().getSourceGraphs() != null) { + if (getFirstPosition() != getSecondPosition()) { CustomFilter f = new CustomFilter( - "difference", "colorize('state', 'same', white);" + - "colorize('state', 'changed', orange);" + - "colorize('state', 'new', green);" + - "colorize('state', 'deleted', red);"); + "difference", "colorize('state', 'same', white);" + + "colorize('state', 'changed', orange);" + + "colorize('state', 'new', green);" + + "colorize('state', 'deleted', red);"); f.apply(diagram); - } + } } return diagram; @@ -390,13 +372,14 @@ return inputGraph; } + @Override public void changed(RangeSliderModel source) { inputGraph = null; diagramChanged(); } void setSelectedFigures(List<Figure> list) { - Set<Integer> newSelectedNodes = new HashSet<Integer>(); + Set<Integer> newSelectedNodes = new HashSet<>(); for (Figure f : list) { newSelectedNodes.addAll(f.getSource().getSourceNodesAsSet()); }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java Sun Jan 29 11:40:04 2012 +0100 @@ -25,8 +25,8 @@ package com.sun.hotspot.igv.view; import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.services.InputGraphProvider; -import com.sun.hotspot.igv.data.InputNode; import java.util.Set; /** @@ -41,10 +41,12 @@ this.editor = editor; } + @Override public InputGraph getGraph() { return editor.getDiagramModel().getGraphToView(); } + @Override public void setSelectedNodes(Set<InputNode> nodes) { editor.setSelectedNodes(nodes); }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,66 +24,34 @@ package com.sun.hotspot.igv.view; import com.sun.hotspot.igv.data.ChangedEvent; +import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.filter.FilterChain; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.view.actions.EnableBlockLayoutAction; -import com.sun.hotspot.igv.view.actions.ExpandPredecessorsAction; -import com.sun.hotspot.igv.view.actions.ExpandSuccessorsAction; -import com.sun.hotspot.igv.view.actions.ExtractAction; -import com.sun.hotspot.igv.view.actions.HideAction; -import com.sun.hotspot.igv.view.actions.NextDiagramAction; -import com.sun.hotspot.igv.view.actions.OverviewAction; -import com.sun.hotspot.igv.view.actions.PredSuccAction; -import com.sun.hotspot.igv.view.actions.PrevDiagramAction; -import com.sun.hotspot.igv.view.actions.ShowAllAction; -import com.sun.hotspot.igv.view.actions.ZoomInAction; -import com.sun.hotspot.igv.view.actions.ZoomOutAction; -import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Properties.PropertyMatcher; import com.sun.hotspot.igv.data.services.InputGraphProvider; +import com.sun.hotspot.igv.filter.FilterChain; import com.sun.hotspot.igv.filter.FilterChainProvider; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.Figure; import com.sun.hotspot.igv.graph.services.DiagramProvider; -import com.sun.hotspot.igv.util.RangeSlider; import com.sun.hotspot.igv.svg.BatikSVG; import com.sun.hotspot.igv.util.LookupHistory; -import com.sun.hotspot.igv.view.actions.PanModeAction; -import com.sun.hotspot.igv.view.actions.SelectionModeAction; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics2D; +import com.sun.hotspot.igv.util.RangeSlider; +import com.sun.hotspot.igv.view.actions.*; +import java.awt.*; import java.awt.event.HierarchyBoundsListener; import java.awt.event.HierarchyEvent; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; +import java.io.*; import java.util.List; -import java.util.Set; -import javax.swing.Action; -import javax.swing.Box; -import javax.swing.ButtonGroup; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JToggleButton; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; +import java.util.*; +import javax.swing.*; import javax.swing.border.Border; import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; import org.openide.actions.RedoAction; import org.openide.actions.UndoAction; import org.openide.awt.Toolbar; @@ -91,15 +59,14 @@ import org.openide.awt.UndoRedo; import org.openide.util.Lookup; import org.openide.util.NbBundle; +import org.openide.util.Utilities; +import org.openide.util.actions.Presenter; import org.openide.util.lookup.AbstractLookup; import org.openide.util.lookup.InstanceContent; import org.openide.util.lookup.ProxyLookup; import org.openide.windows.Mode; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; -import org.openide.NotifyDescriptor; -import org.openide.util.Utilities; -import org.openide.util.actions.Presenter; /** * @@ -110,7 +77,6 @@ private DiagramViewer scene; private InstanceContent content; private InstanceContent graphContent; - private EnableBlockLayoutAction blockLayoutAction; private OverviewAction overviewAction; private PredSuccAction predSuccAction; private SelectionModeAction selectionModeAction; @@ -127,6 +93,7 @@ private DiagramViewModel rangeSliderModel; private ExportCookie exportCookie = new ExportCookie() { + @Override public void export(File f) { Graphics2D svgGenerator = BatikSVG.createGraphicsObject(); @@ -161,16 +128,18 @@ private DiagramProvider diagramProvider = new DiagramProvider() { + @Override public Diagram getDiagram() { return getModel().getDiagramToView(); } + @Override public ChangedEvent<DiagramProvider> getChangedEvent() { return diagramChangedEvent; } }; - private ChangedEvent<DiagramProvider> diagramChangedEvent = new ChangedEvent<DiagramProvider>(diagramProvider); + private ChangedEvent<DiagramProvider> diagramChangedEvent = new ChangedEvent<>(diagramProvider); private void updateDisplayName() { @@ -249,12 +218,6 @@ toolBar.add(ShowAllAction.get(ZoomInAction.class)); toolBar.add(ShowAllAction.get(ZoomOutAction.class)); - blockLayoutAction = new EnableBlockLayoutAction(); - JToggleButton button = new JToggleButton(blockLayoutAction); - button.setSelected(true); - toolBar.add(button); - blockLayoutAction.addPropertyChangeListener(this); - overviewAction = new OverviewAction(); overviewButton = new JToggleButton(overviewAction); overviewButton.setSelected(false); @@ -262,7 +225,7 @@ overviewAction.addPropertyChangeListener(this); predSuccAction = new PredSuccAction(); - button = new JToggleButton(predSuccAction); + JToggleButton button = new JToggleButton(predSuccAction); button.setSelected(true); toolBar.add(button); predSuccAction.addPropertyChangeListener(this); @@ -309,14 +272,17 @@ scene.getComponent().addHierarchyBoundsListener(new HierarchyBoundsListener() { + @Override public void ancestorMoved(HierarchyEvent e) { } + @Override public void ancestorResized(HierarchyEvent e) { if (!notFirstTime && scene.getComponent().getBounds().width > 0) { notFirstTime = true; SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { EditorTopComponent.this.scene.initialize(); } @@ -333,9 +299,11 @@ } private KeyListener keyListener = new KeyListener() { + @Override public void keyTyped(KeyEvent e) { } + @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_S) { EditorTopComponent.this.overviewButton.setSelected(true); @@ -343,6 +311,7 @@ } } + @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_S) { EditorTopComponent.this.overviewButton.setSelected(false); @@ -443,9 +412,10 @@ private ChangedListener<DiagramViewModel> diagramChangedListener = new ChangedListener<DiagramViewModel>() { + @Override public void changed(DiagramViewModel source) { updateDisplayName(); - Collection<Object> list = new ArrayList<Object>(); + Collection<Object> list = new ArrayList<>(); list.add(new EditorInputGraphProvider(EditorTopComponent.this)); graphContent.set(list, null); diagramProvider.getChangedEvent().fire(); @@ -459,7 +429,7 @@ public void setSelection(PropertyMatcher matcher) { - Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(getModel().getDiagramToView().getFigures()); + Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<>(getModel().getDiagramToView().getFigures()); List<Figure> list = selector.selectMultiple(matcher); setSelectedFigures(list); } @@ -471,8 +441,8 @@ public void setSelectedNodes(Set<InputNode> nodes) { - List<Figure> list = new ArrayList<Figure>(); - Set<Integer> ids = new HashSet<Integer>(); + List<Figure> list = new ArrayList<>(); + Set<Integer> ids = new HashSet<>(); for (InputNode n : nodes) { ids.add(n.getId()); } @@ -489,6 +459,7 @@ setSelectedFigures(list); } + @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() == this.predSuccAction) { boolean b = (Boolean) predSuccAction.getValue(PredSuccAction.STATE); @@ -500,9 +471,6 @@ } else { showScene(); } - } else if (evt.getSource() == this.blockLayoutAction) { - boolean b = (Boolean) blockLayoutAction.getValue(EnableBlockLayoutAction.STATE); - this.getModel().setShowBlocks(b); } else if (evt.getSource() == this.selectionModeAction || evt.getSource() == this.panModeAction) { if (panModeAction.isSelected()) { scene.setInteractionMode(DiagramViewer.InteractionMode.PANNING); @@ -520,14 +488,14 @@ public void hideNodes() { Set<Integer> selectedNodes = this.getModel().getSelectedNodes(); - HashSet<Integer> nodes = new HashSet<Integer>(getModel().getHiddenNodes()); + HashSet<Integer> nodes = new HashSet<>(getModel().getHiddenNodes()); nodes.addAll(selectedNodes); this.getModel().showNot(nodes); } public void expandPredecessors() { Set<Figure> oldSelection = getModel().getSelectedFigures(); - Set<Figure> figures = new HashSet<Figure>(); + Set<Figure> figures = new HashSet<>(); for (Figure f : this.getDiagramModel().getDiagramToView().getFigures()) { boolean ok = false; @@ -552,7 +520,7 @@ public void expandSuccessors() { Set<Figure> oldSelection = getModel().getSelectedFigures(); - Set<Figure> figures = new HashSet<Figure>(); + Set<Figure> figures = new HashSet<>(); for (Figure f : this.getDiagramModel().getDiagramToView().getFigures()) { boolean ok = false;
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ExtendedSatelliteComponent.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ExtendedSatelliteComponent.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,11 +23,10 @@ */ package com.sun.hotspot.igv.view; -import org.netbeans.api.visual.widget.Scene; - -import javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.JComponent; +import org.netbeans.api.visual.widget.Scene; /** * @author David Kaspar @@ -48,6 +47,7 @@ addMouseMotionListener(this); } + @Override public void addNotify() { super.addNotify(); scene.addSceneListener(this); @@ -59,6 +59,7 @@ repaint(); } + @Override public void removeNotify() { scene.getView().removeComponentListener(this); scene.removeSceneListener(this); @@ -74,6 +75,7 @@ } } + @Override public void paint(Graphics g) { Graphics2D gr = (Graphics2D) g; super.paint(g); @@ -122,27 +124,34 @@ } } + @Override public void mouseClicked(MouseEvent e) { } + @Override public void mousePressed(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseReleased(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseEntered(MouseEvent e) { } + @Override public void mouseExited(MouseEvent e) { } + @Override public void mouseDragged(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseMoved(MouseEvent e) { } @@ -175,27 +184,34 @@ this.repaint(); } + @Override public void sceneRepaint() { //repaint (); } + @Override public void sceneValidating() { } + @Override public void sceneValidated() { } + @Override public void componentResized(ComponentEvent e) { repaint(); } + @Override public void componentMoved(ComponentEvent e) { repaint(); } + @Override public void componentShown(ComponentEvent e) { } + @Override public void componentHidden(ComponentEvent e) { } }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/GraphViewerImplementation.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/GraphViewerImplementation.java Sun Jan 29 11:40:04 2012 +0100 @@ -34,6 +34,7 @@ */ public class GraphViewerImplementation implements GraphViewer { + @Override public void view(InputGraph graph) { Diagram diagram = Diagram.createDiagram(graph, Settings.get().get(Settings.NODE_TEXT, Settings.NODE_TEXT_DEFAULT)); EditorTopComponent tc = new EditorTopComponent(diagram);
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java Sun Jan 29 11:40:04 2012 +0100 @@ -55,6 +55,7 @@ * @param request Search request object that contains information what to search for * @param response Search response object that stores search results. Note that it's important to react to return value of SearchResponse.addResult(...) method and stop computation if false value is returned. */ + @Override public void evaluate(SearchRequest request, SearchResponse response) { String query = request.getText(); if (query.trim().isEmpty()) { @@ -83,12 +84,13 @@ List<InputNode> matches = null; try { RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE); - Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<InputNode>(p.getGraph().getNodes()); + Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(p.getGraph().getNodes()); matches = selector.selectMultiple(matcher); } catch (Exception e) { final String msg = e.getMessage(); response.addResult(new Runnable() { + @Override public void run() { Message desc = new NotifyDescriptor.Message("An exception occurred during the search, " + "perhaps due to a malformed query string:\n" + msg, @@ -101,8 +103,9 @@ } if (matches != null) { - final Set<InputNode> set = new HashSet<InputNode>(matches); + final Set<InputNode> set = new HashSet<>(matches); response.addResult(new Runnable() { + @Override public void run() { final EditorTopComponent comp = EditorTopComponent.getActive(); if (comp != null) { @@ -117,10 +120,11 @@ // Single matches for (final InputNode n : matches) { response.addResult(new Runnable() { + @Override public void run() { final EditorTopComponent comp = EditorTopComponent.getActive(); if (comp != null) { - final Set<InputNode> tmpSet = new HashSet<InputNode>(); + final Set<InputNode> tmpSet = new HashSet<>(); tmpSet.add(n); comp.setSelectedNodes(tmpSet); comp.requestActive();
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/CustomizablePanAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/CustomizablePanAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -74,6 +74,7 @@ this.modifiersEx = modifiersEx; } + @Override protected boolean isLocked() { return scrollPane != null; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/EnableBlockLayoutAction.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.view.actions; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ImageIcon; -import org.openide.util.ImageUtilities; - -/** - * - * @author Thomas Wuerthinger - */ -public class EnableBlockLayoutAction extends AbstractAction { - - private boolean state; - public static final String STATE = "state"; - - public EnableBlockLayoutAction() { - state = true; - putValue(AbstractAction.SMALL_ICON, new ImageIcon(ImageUtilities.loadImage(iconResource()))); - putValue(STATE, true); - putValue(Action.SHORT_DESCRIPTION, "Cluster nodes into blocks"); - } - - public void actionPerformed(ActionEvent ev) { - this.state = !state; - this.putValue(STATE, state); - } - - protected String iconResource() { - return "com/sun/hotspot/igv/view/images/blocks.gif"; - } -}
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExpandPredecessorsAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExpandPredecessorsAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -33,6 +33,7 @@ */ public final class ExpandPredecessorsAction extends CallableSystemAction { + @Override public void performAction() { EditorTopComponent editor = EditorTopComponent.getActive(); if (editor != null) { @@ -40,6 +41,7 @@ } } + @Override public String getName() { return "Expand Above"; } @@ -49,6 +51,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExpandSuccessorsAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExpandSuccessorsAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -33,6 +33,7 @@ */ public final class ExpandSuccessorsAction extends CallableSystemAction { + @Override public void performAction() { EditorTopComponent editor = EditorTopComponent.getActive(); if (editor != null) { @@ -40,6 +41,7 @@ } } + @Override public String getName() { return "Expand Below"; } @@ -49,6 +51,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExportAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExportAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -32,12 +32,7 @@ import javax.swing.JFileChooser; import javax.swing.KeyStroke; import javax.swing.filechooser.FileFilter; -import org.openide.util.HelpCtx; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; +import org.openide.util.*; import org.openide.util.actions.CallableSystemAction; /** @@ -53,24 +48,28 @@ putValue(Action.SHORT_DESCRIPTION, "Export current graph as SVG file"); putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK)); lookup = Utilities.actionsGlobalContext(); - result = lookup.lookup(new Lookup.Template<ExportCookie>(ExportCookie.class)); + result = lookup.lookup(new Lookup.Template<>(ExportCookie.class)); result.addLookupListener(this); resultChanged(null); } + @Override public void resultChanged(LookupEvent e) { super.setEnabled(result.allInstances().size() > 0); } + @Override public void performAction() { JFileChooser fc = new JFileChooser(); fc.setFileFilter(new FileFilter() { + @Override public boolean accept(File f) { return true; } + @Override public String getDescription() { return "SVG files (*.svg)"; } @@ -97,6 +96,7 @@ } } + @Override public String getName() { return NbBundle.getMessage(ExportAction.class, "CTL_ExportAction"); } @@ -106,6 +106,7 @@ return "com/sun/hotspot/igv/view/images/export.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExtractAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExtractAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,6 +37,7 @@ */ public final class ExtractAction extends CallableSystemAction { + @Override public void performAction() { EditorTopComponent editor = EditorTopComponent.getActive(); if (editor != null) { @@ -49,6 +50,7 @@ putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK, false)); } + @Override public String getName() { return "Extract action"; } @@ -58,6 +60,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/HideAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/HideAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,6 +37,7 @@ */ public final class HideAction extends CallableSystemAction { + @Override public void performAction() { EditorTopComponent editor = EditorTopComponent.getActive(); if (editor != null) { @@ -49,6 +50,7 @@ putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK, false)); } + @Override public String getName() { return "Hide"; } @@ -58,6 +60,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/NextDiagramAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/NextDiagramAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,16 +23,12 @@ */ package com.sun.hotspot.igv.view.actions; -import com.sun.hotspot.igv.view.DiagramViewModel; import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.util.ContextAction; +import com.sun.hotspot.igv.view.DiagramViewModel; import javax.swing.Action; import javax.swing.ImageIcon; -import org.openide.util.HelpCtx; -import org.openide.util.ImageUtilities; -import org.openide.util.Lookup; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; +import org.openide.util.*; /** * @@ -51,10 +47,12 @@ putValue(Action.SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("com/sun/hotspot/igv/view/images/next_diagram.png"))); } + @Override public String getName() { return NbBundle.getMessage(NextDiagramAction.class, "CTL_NextDiagramAction"); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -96,10 +94,12 @@ return model.getSecondPosition() != model.getPositions().size() - 1; } + @Override public Action createContextAwareInstance(Lookup arg0) { return new NextDiagramAction(arg0); } + @Override public void changed(DiagramViewModel source) { update(source); }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/OverviewAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/OverviewAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -44,6 +44,7 @@ setState(false); } + @Override public void actionPerformed(ActionEvent ev) { setState(!state); }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PanModeAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PanModeAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -53,6 +53,7 @@ return "com/sun/hotspot/igv/view/images/pan_mode.png"; } + @Override public void actionPerformed(ActionEvent e) { } }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PredSuccAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PredSuccAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -45,6 +45,7 @@ putValue(Action.SHORT_DESCRIPTION, "Show neighboring nodes of fully visible nodes semi-transparent"); } + @Override public void actionPerformed(ActionEvent ev) { this.state = !state; this.putValue(STATE, state);
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PrevDiagramAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PrevDiagramAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -24,15 +24,11 @@ package com.sun.hotspot.igv.view.actions; import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.util.ContextAction; import com.sun.hotspot.igv.view.DiagramViewModel; -import com.sun.hotspot.igv.util.ContextAction; import javax.swing.Action; import javax.swing.ImageIcon; -import org.openide.util.HelpCtx; -import org.openide.util.ImageUtilities; -import org.openide.util.Lookup; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; +import org.openide.util.*; /** * @@ -51,10 +47,12 @@ putValue(Action.SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("com/sun/hotspot/igv/view/images/prev_diagram.png"))); } + @Override public String getName() { return NbBundle.getMessage(PrevDiagramAction.class, "CTL_PrevDiagramAction"); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -96,10 +94,12 @@ return model.getFirstPosition() != 0; } + @Override public Action createContextAwareInstance(Lookup arg0) { return new PrevDiagramAction(arg0); } + @Override public void changed(DiagramViewModel source) { update(source); }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/SelectionModeAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/SelectionModeAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -51,6 +51,7 @@ return "com/sun/hotspot/igv/view/images/selection_mode.png"; } + @Override public void actionPerformed(ActionEvent e) { } }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ShowAllAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ShowAllAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,7 +23,7 @@ */ package com.sun.hotspot.igv.view.actions; -import com.sun.hotspot.igv.view.*; +import com.sun.hotspot.igv.view.EditorTopComponent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import javax.swing.Action; @@ -37,6 +37,7 @@ */ public final class ShowAllAction extends CallableSystemAction { + @Override public void performAction() { EditorTopComponent editor = EditorTopComponent.getActive(); if (editor != null) { @@ -49,6 +50,7 @@ putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); } + @Override public String getName() { return "Show all"; } @@ -58,6 +60,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomInAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomInAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,6 +37,7 @@ */ public final class ZoomInAction extends CallableSystemAction { + @Override public void performAction() { EditorTopComponent editor = EditorTopComponent.getActive(); if (editor != null) { @@ -44,6 +45,7 @@ } } + @Override public String getName() { return "Zoom in"; } @@ -53,6 +55,7 @@ putValue(Action.SHORT_DESCRIPTION, "Zoom in"); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomOutAction.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomOutAction.java Sun Jan 29 11:40:04 2012 +0100 @@ -37,6 +37,7 @@ */ public final class ZoomOutAction extends CallableSystemAction { + @Override public void performAction() { EditorTopComponent editor = EditorTopComponent.getActive(); if (editor != null) { @@ -50,6 +51,7 @@ putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, Event.CTRL_MASK, false)); } + @Override public String getName() { return "Zoom out"; } @@ -59,6 +61,7 @@ super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/BlockWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.view.widgets; - -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.graph.Diagram; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.Stroke; -import java.awt.geom.Rectangle2D; -import org.netbeans.api.visual.widget.Scene; -import org.netbeans.api.visual.widget.Widget; - -/** - * - * @author Thomas Wuerthinger - */ -public class BlockWidget extends Widget { - - public static final int BORDER = 20; - public static final Color BACKGROUND_COLOR = new Color(235, 235, 255); - private static final Font titleFont = new Font("Serif", Font.PLAIN, 14).deriveFont(Font.BOLD); - private InputBlock blockNode; - private Diagram diagram; - - public BlockWidget(Scene scene, Diagram d, InputBlock blockNode) { - super(scene); - this.blockNode = blockNode; - this.diagram = d; - this.setBackground(BACKGROUND_COLOR); - this.setOpaque(true); - this.setCheckClipping(true); - } - - @Override - protected void paintWidget() { - super.paintWidget(); - Graphics2D g = this.getGraphics(); - Stroke old = g.getStroke(); - g.setColor(Color.BLUE); - Rectangle r = new Rectangle(this.getPreferredBounds()); - r.width--; - r.height--; - if (this.getBounds().width > 0 && this.getBounds().height > 0) { - g.setStroke(new BasicStroke(2)); - g.drawRect(r.x, r.y, r.width, r.height); - } - - Color titleColor = Color.BLACK; - g.setColor(titleColor); - g.setFont(titleFont); - - String s = "B" + blockNode.getName(); - Rectangle2D r1 = g.getFontMetrics().getStringBounds(s, g); - g.drawString(s, r.x + 5, r.y + (int) r1.getHeight()); - g.setStroke(old); - } -}
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/FigureWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/FigureWidget.java Sun Jan 29 11:40:04 2012 +0100 @@ -23,19 +23,13 @@ */ package com.sun.hotspot.igv.view.widgets; +import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.view.DiagramScene; +import com.sun.hotspot.igv.util.DoubleClickAction; import com.sun.hotspot.igv.util.DoubleClickHandler; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.util.DoubleClickAction; import com.sun.hotspot.igv.util.PropertiesSheet; -import java.awt.AlphaComposite; -import java.awt.Color; -import java.awt.Composite; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Point; -import java.awt.Rectangle; +import com.sun.hotspot.igv.view.DiagramScene; +import java.awt.*; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; @@ -47,10 +41,10 @@ import javax.swing.event.MenuListener; import org.netbeans.api.visual.action.PopupMenuProvider; import org.netbeans.api.visual.action.WidgetAction; +import org.netbeans.api.visual.layout.LayoutFactory; import org.netbeans.api.visual.model.ObjectState; +import org.netbeans.api.visual.widget.LabelWidget; import org.netbeans.api.visual.widget.Widget; -import org.netbeans.api.visual.layout.LayoutFactory; -import org.netbeans.api.visual.widget.LabelWidget; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; @@ -122,7 +116,7 @@ middleWidget.getActions().addAction(new DoubleClickAction(this)); middleWidget.setCheckClipping(true); - labelWidgets = new ArrayList<LabelWidget>(); + labelWidgets = new ArrayList<>(); String[] strings = figure.getLines(); @@ -228,6 +222,7 @@ return getProperties().get("name"); } + @Override public Properties getProperties() { return figure.getProperties(); } @@ -238,11 +233,6 @@ @Override protected void paintChildren() { - - if (diagramScene.getZoomFactor() < ZOOM_FACTOR && diagramScene.getModel().getShowBlocks()) { - return; - } - Composite oldComposite = null; if (boundary) { oldComposite = getScene().getGraphics().getComposite(); @@ -269,6 +259,7 @@ } } + @Override public JPopupMenu getPopupMenu(Widget widget, Point point) { JPopupMenu menu = diagramScene.createPopupMenu(); menu.addSeparator(); @@ -299,6 +290,7 @@ this.successors = successors; } + @Override public void menuSelected(MenuEvent e) { if (menu.getItemCount() > 0) { // already built before @@ -339,28 +331,31 @@ } } + @Override public void menuDeselected(MenuEvent e) { // ignore } + @Override public void menuCanceled(MenuEvent e) { // ignore } } + @Override public void handleDoubleClick(Widget w, WidgetAction.WidgetMouseEvent e) { if (diagramScene.isAllVisible()) { - final Set<Integer> hiddenNodes = new HashSet<Integer>(diagramScene.getModel().getGraphToView().getGroup().getAllNodes()); + final Set<Integer> hiddenNodes = new HashSet<>(diagramScene.getModel().getGraphToView().getGroup().getAllNodes()); hiddenNodes.removeAll(this.getFigure().getSource().getSourceNodesAsSet()); this.diagramScene.getModel().showNot(hiddenNodes); } else if (isBoundary()) { - final Set<Integer> hiddenNodes = new HashSet<Integer>(diagramScene.getModel().getHiddenNodes()); + final Set<Integer> hiddenNodes = new HashSet<>(diagramScene.getModel().getHiddenNodes()); hiddenNodes.removeAll(this.getFigure().getSource().getSourceNodesAsSet()); this.diagramScene.getModel().showNot(hiddenNodes); } else { - final Set<Integer> hiddenNodes = new HashSet<Integer>(diagramScene.getModel().getHiddenNodes()); + final Set<Integer> hiddenNodes = new HashSet<>(diagramScene.getModel().getHiddenNodes()); hiddenNodes.addAll(this.getFigure().getSource().getSourceNodesAsSet()); this.diagramScene.getModel().showNot(hiddenNodes); }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/InputSlotWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/InputSlotWidget.java Sun Jan 29 11:40:04 2012 +0100 @@ -53,6 +53,7 @@ return inputSlot; } + @Override protected int calculateSlotWidth() { List<InputSlot> slots = getSlot().getFigure().getInputSlots(); assert slots.contains(getSlot());
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,12 +28,7 @@ import com.sun.hotspot.igv.graph.InputSlot; import com.sun.hotspot.igv.graph.OutputSlot; import com.sun.hotspot.igv.view.DiagramScene; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Stroke; +import java.awt.*; import java.awt.geom.Line2D; import java.util.ArrayList; import java.util.HashSet; @@ -84,7 +79,7 @@ this.from = from; this.to = to; this.predecessor = predecessor; - this.successors = new ArrayList<LineWidget>(); + this.successors = new ArrayList<>(); if (predecessor != null) { predecessor.addSuccessor(this); } @@ -129,16 +124,19 @@ this.getActions().addAction(ActionFactory.createSelectAction(new SelectProvider() { + @Override public boolean isAimingAllowed(Widget arg0, Point arg1, boolean arg2) { return true; } + @Override public boolean isSelectionAllowed(Widget arg0, Point arg1, boolean arg2) { return true; } + @Override public void select(Widget arg0, Point arg1, boolean arg2) { - Set<Figure> set = new HashSet<Figure>(); + Set<Figure> set = new HashSet<>(); for (Connection c : LineWidget.this.connections) { set.add(c.getInputSlot().getFigure()); set.add(c.getOutputSlot().getFigure()); @@ -241,8 +239,8 @@ private void setHighlighted(boolean b) { this.highlighted = b; - Set<Object> highlightedObjects = new HashSet<Object>(scene.getHighlightedObjects()); - Set<Object> highlightedObjectsChange = new HashSet<Object>(); + Set<Object> highlightedObjects = new HashSet<>(scene.getHighlightedObjects()); + Set<Object> highlightedObjectsChange = new HashSet<>(); for (Connection c : connections) { highlightedObjectsChange.add(c.getInputSlot().getFigure()); highlightedObjectsChange.add(c.getInputSlot()); @@ -311,6 +309,7 @@ } } + @Override public JPopupMenu getPopupMenu(Widget widget, Point localLocation) { JPopupMenu menu = new JPopupMenu(); menu.add(scene.createGotoAction(outputSlot.getFigure())); @@ -324,14 +323,17 @@ final LineWidget w = this; menu.addPopupMenuListener(new PopupMenuListener() { + @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { w.setRecursivePopupVisible(true); } + @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { w.setRecursivePopupVisible(false); } + @Override public void popupMenuCanceled(PopupMenuEvent e) { } });
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/OutputSlotWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/OutputSlotWidget.java Sun Jan 29 11:40:04 2012 +0100 @@ -28,7 +28,6 @@ import com.sun.hotspot.igv.view.DiagramScene; import java.awt.Point; import java.util.List; -import org.netbeans.api.visual.widget.Scene; import org.netbeans.api.visual.widget.Widget; /** @@ -55,6 +54,7 @@ return outputSlot; } + @Override protected int calculateSlotWidth() { List<OutputSlot> slots = getSlot().getFigure().getOutputSlots();
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/SlotWidget.java Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/SlotWidget.java Sun Jan 29 11:40:04 2012 +0100 @@ -26,13 +26,11 @@ import com.sun.hotspot.igv.graph.Figure; import com.sun.hotspot.igv.graph.OutputSlot; import com.sun.hotspot.igv.graph.Slot; -import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; import com.sun.hotspot.igv.util.DoubleClickHandler; import com.sun.hotspot.igv.view.DiagramScene; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; -import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.util.HashSet; @@ -155,10 +153,11 @@ return getFigureWidget().getFigure().getWidth() / count; } + @Override public void handleDoubleClick(Widget w, WidgetAction.WidgetMouseEvent e) { - Set<Integer> hiddenNodes = new HashSet<Integer>(diagramScene.getModel().getHiddenNodes()); + Set<Integer> hiddenNodes = new HashSet<>(diagramScene.getModel().getHiddenNodes()); if (diagramScene.isAllVisible()) { - hiddenNodes = new HashSet<Integer>(diagramScene.getModel().getGraphToView().getGroup().getAllNodes()); + hiddenNodes = new HashSet<>(diagramScene.getModel().getGraphToView().getGroup().getAllNodes()); } boolean progress = false;
--- a/src/share/tools/IdealGraphVisualizer/nbproject/project.properties Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/nbproject/project.properties Sun Jan 29 11:40:04 2012 +0100 @@ -1,58 +1,44 @@ -app.icon=branding/core/core.jar/org/netbeans/core/startup/frame48.gif -app.name=idealgraphvisualizer -app.title=IdealGraphVisualizer -branding.token=${app.name} -modules=\ - ${project.com.sun.hotspot.igv.graph}:\ - ${project.com.sun.hotspot.igv.coordinator}:\ - ${project.com.sun.hotspot.igv.filter}:\ - ${project.com.sun.hotspot.igv.hierarchicallayout}:\ - ${project.com.sun.hotspot.igv.layout}:\ - ${project.com.sun.hotspot.igv.controlflow}:\ - ${project.com.sun.hotspot.igv.data}:\ - ${project.com.sun.hotspot.igv.view}:\ - ${project.com.sun.hotspot.igv.bytecodes}:\ - ${project.com.sun.hotspot.igv.difference}:\ - ${project.com.sun.hotspot.igv.settings}:\ - ${project.com.sun.hotspot.igv.util}:\ - ${project.com.sun.hotspot.igv.rhino}:\ - ${project.com.sun.hotspot.igv.svg}:\ - ${project.com.sun.hotspot.connection}:\ - ${project.com.sun.hotspot.igv.servercompilerscheduler}:\ - ${project.com.sun.hotspot.igv.filterwindow}:\ - ${project.com.sun.hotspot.igv.graphtotext}:\ - ${project.com.sun.hotspot.igv.java6scriptingproxy}:\ - ${project.com.sun.hotspot.igv.graphtexteditor}:\ - ${project.com.sun.hotspot.igv.structuredtext}:\ - ${project.com.sun.hotspot.igv.texteditor}:\ - ${project.com.sun.hotspot.igv.selectioncoordinator}:\ - ${project.com.sun.hotspot.igv.graal} -project.com.sun.hotspot.connection=NetworkConnection -project.com.sun.hotspot.igv.bytecodes=Bytecodes -project.com.sun.hotspot.igv.controlflow=ControlFlow -project.com.sun.hotspot.igv.coordinator=Coordinator -project.com.sun.hotspot.igv.data=Data -project.com.sun.hotspot.igv.difference=Difference -project.com.sun.hotspot.igv.filter=Filter -project.com.sun.hotspot.igv.filterwindow=FilterWindow -project.com.sun.hotspot.igv.graal=Graal -project.com.sun.hotspot.igv.graph=Graph -project.com.sun.hotspot.igv.graphtexteditor=GraphTextEditor -project.com.sun.hotspot.igv.graphtotext=GraphToText -project.com.sun.hotspot.igv.hierarchicallayout=HierarchicalLayout -project.com.sun.hotspot.igv.java6scriptingproxy=Java6ScriptingProxy -project.com.sun.hotspot.igv.layout=Layout -project.com.sun.hotspot.igv.rhino=RhinoScriptEngineProxy -project.com.sun.hotspot.igv.selectioncoordinator=SelectionCoordinator -project.com.sun.hotspot.igv.servercompilerscheduler=ServerCompiler -project.com.sun.hotspot.igv.settings=Settings -project.com.sun.hotspot.igv.structuredtext=StructuredText -project.com.sun.hotspot.igv.svg=BatikSVGProxy -project.com.sun.hotspot.igv.texteditor=TextEditor -project.com.sun.hotspot.igv.view=View -project.com.sun.hotspot.igv.util=Util - -# Disable assertions for RequestProcessor to prevent annoying messages in case -# of multiple SceneAnimator update tasks in the default RequestProcessor. -run.args.extra = -J-client -J-da:org.openide.util.RequestProcessor -debug.args.extra = -J-client -J-da:org.openide.util.RequestProcessor +app.icon=branding/core/core.jar/org/netbeans/core/startup/frame48.gif +app.name=idealgraphvisualizer +app.title=IdealGraphVisualizer +branding.token=${app.name} +modules=\ + ${project.com.sun.hotspot.igv.graph}:\ + ${project.com.sun.hotspot.igv.coordinator}:\ + ${project.com.sun.hotspot.igv.filter}:\ + ${project.com.sun.hotspot.igv.hierarchicallayout}:\ + ${project.com.sun.hotspot.igv.layout}:\ + ${project.com.sun.hotspot.igv.data}:\ + ${project.com.sun.hotspot.igv.view}:\ + ${project.com.sun.hotspot.igv.bytecodes}:\ + ${project.com.sun.hotspot.igv.difference}:\ + ${project.com.sun.hotspot.igv.settings}:\ + ${project.com.sun.hotspot.igv.util}:\ + ${project.com.sun.hotspot.igv.svg}:\ + ${project.com.sun.hotspot.connection}:\ + ${project.com.sun.hotspot.igv.servercompilerscheduler}:\ + ${project.com.sun.hotspot.igv.filterwindow}:\ + ${project.com.sun.hotspot.igv.selectioncoordinator}:\ + ${project.com.sun.hotspot.igv.graal} +project.com.sun.hotspot.connection=NetworkConnection +project.com.sun.hotspot.igv.bytecodes=Bytecodes +project.com.sun.hotspot.igv.coordinator=Coordinator +project.com.sun.hotspot.igv.data=Data +project.com.sun.hotspot.igv.difference=Difference +project.com.sun.hotspot.igv.filter=Filter +project.com.sun.hotspot.igv.filterwindow=FilterWindow +project.com.sun.hotspot.igv.graal=Graal +project.com.sun.hotspot.igv.graph=Graph +project.com.sun.hotspot.igv.hierarchicallayout=HierarchicalLayout +project.com.sun.hotspot.igv.layout=Layout +project.com.sun.hotspot.igv.selectioncoordinator=SelectionCoordinator +project.com.sun.hotspot.igv.servercompilerscheduler=ServerCompiler +project.com.sun.hotspot.igv.settings=Settings +project.com.sun.hotspot.igv.svg=BatikSVGProxy +project.com.sun.hotspot.igv.view=View +project.com.sun.hotspot.igv.util=Util + +# Disable assertions for RequestProcessor to prevent annoying messages in case +# of multiple SceneAnimator update tasks in the default RequestProcessor. +run.args.extra = -J-client -J-da:org.openide.util.RequestProcessor +debug.args.extra = -J-client -J-da:org.openide.util.RequestProcessor
--- a/src/share/vm/graal/graal_paths.hpp Sun Jan 29 11:27:18 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.cri"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.criutils"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asm"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.graph"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.nodes"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.compiler"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.java"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.printer"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.snippets"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.hotspot");
--- a/src/share/vm/prims/jni.cpp Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/vm/prims/jni.cpp Sun Jan 29 11:40:04 2012 +0100 @@ -5124,11 +5124,13 @@ *vm = (JavaVM *)(&main_vm); *(JNIEnv**)penv = thread->jni_environment(); +#ifdef GRAAL if (UseGraal) { GraalCompiler* compiler = GraalCompiler::instance(); ciObjectFactory::initialize(); compiler->initialize(); } +#endif // Tracks the time application was running before GC RuntimeService::record_application_start();
--- a/src/share/vm/runtime/arguments.cpp Sun Jan 29 11:27:18 2012 +0100 +++ b/src/share/vm/runtime/arguments.cpp Sun Jan 29 11:40:04 2012 +0100 @@ -2096,9 +2096,22 @@ } } if (PrintVMOptions) tty->print_cr("GRAAL=%s", graal_dir); - + SysClassPath scp_compiler(Arguments::get_sysclasspath()); -#include "graal/graal_paths.hpp" + struct dirent* dentry; + char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(graal_dir)); + errno = 0; + DIR* graal_dir_handle = os::opendir(graal_dir); + while ((dentry = os::readdir(graal_dir_handle, (struct dirent *)tdbuf)) != NULL) { + if (strcmp(dentry->d_name, ".") != 0 && strcmp(dentry->d_name, "..")) { + prepend_to_graal_classpath(scp_compiler, graal_dir, dentry->d_name); + if (PrintVMOptions) { + tty->print_cr("Adding project directory %s to bootclasspath", dentry->d_name); + } + } + } + os::closedir(graal_dir_handle); + FREE_C_HEAP_ARRAY(char, tdbuf); scp_compiler.expand_endorsed(); Arguments::set_compilerclasspath(scp_compiler.combined_path());