# HG changeset patch # User Andreas Woess # Date 1327833604 -3600 # Node ID 9f8e4aeec1a9b7095721d940bf1d7e929cacfb9a # Parent b197bbb58d2fa05725cdb055e954c9ab90353c6d# Parent 3b776fb6ffd945b47638e20293e78b06cede2630 Merge diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiResult.java --- 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; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/LinearScanAllocator.java --- 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); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java --- 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); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/IntervalPrinter.java --- 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()); +// } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java --- 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() { + public CiTargetMethod call() { + final CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null; + final LIR lir = Debug.scope("FrontEnd", graph, new Callable() { + public LIR call() { + return emitHIR(graph, assumptions, plan); + } + }); + final FrameMap frameMap = Debug.scope("BackEnd", lir, new Callable() { + public FrameMap call() { + return emitLIR(lir, graph, method); + } + }); + return Debug.scope("CodeGen", frameMap, new Callable() { + 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 blocks = schedule.getBlocks(); + final NodeMap 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 blocks = schedule.getBlocks(); - NodeMap 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() { - context.timers.startScope("Compute Linear Scan Order"); - try { + @Override + public LIR call() { ComputeLinearScanOrder clso = new ComputeLinearScanOrder(blocks.size(), schedule.loopCount(), startBlock); List linearScanOrder = clso.linearScanOrder(); List 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; } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalContext.java --- 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(); - } - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java --- 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 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 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 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"); - } -} - diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java --- 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; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalTimers.java --- 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: - * - *
- * GraalTimers.startScope("name");
- * try {
- *      ...
- * } finally {
- *      GraalTimers.endScope();
- * }
- * 
- */ -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 subNames = new ArrayList<>(); - public final ArrayList 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 times, Map 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 currentScope = new ThreadLocal() { - - @Override - protected TimingScope initialValue() { - TimingScope scope = new TimingScope(rootScope); - rootScope.subNames.add(Thread.currentThread().getName()); - rootScope.subScopes.add(scope); - return scope; - } - }; - - private ThreadLocal currentLevel = new ThreadLocal() { - @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 times = new TreeMap<>(); - TreeMap 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)); - } - } - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java --- 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 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 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java --- 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; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java --- 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 exceptionInfoList; private int lastSafepointPos; - private final GraalContext context; - - public TargetMethodAssembler(GraalContext context, CiTarget target, RiRuntime runtime, FrameMap frameMap, List slowPaths, AbstractAssembler asm) { - this.context = context; + public TargetMethodAssembler(CiTarget target, RiRuntime runtime, FrameMap frameMap, List 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java --- 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]; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java --- 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 linearScanOrder, List codeEmittingOrder, NodeMap valueToBlock, int loopCount) { + public LIR(LIRBlock startBlock, List linearScanOrder, List codeEmittingOrder, NodeMap 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; + } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/CanonicalizerPhase.java --- 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: diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java --- 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; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java --- 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; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java --- 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) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/FloatingReadPhase.java --- 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 otherMap = otherMemoryMap.map; for (Map.Entry 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 blocks = s.getBlocks(); // Process blocks (predecessors first). @@ -343,15 +328,6 @@ modifiedValues.get(loop).add(locationIdentity); } - private static void print(LoopInfo loopInfo, HashMap> 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 nodeToLoop) { if (nodeToLoop.get(begin) != null) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java --- 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); } } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java --- 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 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 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 { diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java --- 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(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java --- 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() { diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/PhasePlan.java --- 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); } } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java --- 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()); } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java --- 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(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java --- 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(); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOp.java --- 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()); - } } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java --- 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() { + @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; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java --- /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 scope(String name, Callable 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 scope(String name, Object context, Callable 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 context() { + if (ENABLED) { + return DebugScope.getInstance().getCurrentContext(); + } else { + return Collections.emptyList(); + } + } + + @SuppressWarnings("unchecked") + public static List contextSnapshot(Class clazz) { + if (ENABLED) { + List 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; } + }; +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugConfig.java --- /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 dumpHandlers(); +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugDumpHandler.java --- /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); +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugMetric.java --- /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); +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugTimer.java --- /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(); +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java --- /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 instanceTL = new ThreadLocal<>(); + private static ThreadLocal configTL = new ThreadLocal<>(); + private static ThreadLocal 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 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 scope(String newName, Runnable runnable, Callable 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 executeScope(Runnable runnable, Callable 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() { + + @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 getCurrentContext() { + return new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + + 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 call(Callable 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; + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugValue.java --- /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; + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugValueMap.java --- /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 topLevelMaps = new ArrayList<>(); + + private long[] values; + private List 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 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 getTopLevelMaps() { + return topLevelMaps; + } + + public void normalize() { + if (this.hasChildren()) { + Map 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 oldChildren = new ArrayList<>(this.children); + this.children.clear(); + for (DebugValueMap map : oldChildren) { + mergeWith(map); + } + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/KeyRegistry.java --- /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 keyMap = new HashMap<>(); + private static List 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 getDebugValues() { + return Collections.unmodifiableList(debugValues); + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/MetricImpl.java --- /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); + } + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/TimerCloseable.java --- /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(); +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/TimerImpl.java --- /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; + } + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Node.java --- 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}.
@@ -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("}"); + } + } + } + } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotDebugConfig.java --- /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 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 dumpHandlers() { + return dumpHandlers; + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/HotSpotOptions.java --- 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) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java --- 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(), daemonThreadFactory); + compileQueue = new ThreadPoolExecutor(GraalOptions.Threads, GraalOptions.Threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), 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 topLevelMaps = DebugValueMap.getTopLevelMaps(); + List 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 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) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java --- 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; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/IfNode.java --- 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.*; diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/BasicIdealGraphPrinter.java --- 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(""); } - public void beginGroup() { + protected void beginGroup() { stream.println(""); } - public void beginMethod(String name, String shortName, int bci) { + protected void beginMethod(String name, String shortName, int bci) { stream.printf(" %n", escape(name), escape(shortName), bci); } - public void beginBytecodes() { + protected void beginBytecodes() { stream.println(" \n"); } - public void endMethod() { + protected void endMethod() { stream.println(" "); } - public void beginGraph(String title) { + protected void beginGraph(String title) { stream.printf(" %n", escape(title)); } - public void beginProperties() { + protected void beginProperties() { stream.print(""); } - public void printProperty(String name, String value) { + protected void printProperty(String name, String value) { stream.printf("

%s

", escape(name), escape(value)); } - public void endProperties() { + protected void endProperties() { stream.print("
"); } - public void printProperties(Map properties) { + protected void printProperties(Map properties) { beginProperties(); for (Entry entry : properties.entrySet()) { printProperty(entry.getKey(), entry.getValue()); @@ -158,19 +162,19 @@ endProperties(); } - public void beginNodes() { + protected void beginNodes() { stream.println(" "); } - public void beginNode(String id) { + protected void beginNode(String id) { stream.printf(" ", escape(id)); } - public void endNode() { + protected void endNode() { stream.println(" "); } - public void printNode(String id, Map properties) { + protected void printNode(String id, Map properties) { beginNode(id); if (properties != null) { printProperties(properties); @@ -178,81 +182,87 @@ endNode(); } - public void endNodes() { + protected void endNodes() { stream.println(" "); } - public void beginEdges() { + protected void beginEdges() { stream.println(" "); } - public void printEdge(Edge edge) { + protected void printEdge(Edge edge) { stream.printf(" %n", escape(edge.from), edge.fromIndex, escape(edge.to), edge.toIndex, escape(edge.label)); } - public void endEdges() { + protected void endEdges() { stream.println(" "); } - public void beginControlFlow() { + protected void beginControlFlow() { stream.println(" "); } - public void beginBlock(String name) { + protected void beginBlock(String name) { stream.printf(" %n", escape(name)); } - public void beginSuccessors() { + protected void beginSuccessors() { stream.println(" "); } - public void printSuccessor(String name) { + protected void printSuccessor(String name) { stream.printf(" %n", escape(name)); } - public void endSuccessors() { + protected void endSuccessors() { stream.println(" "); } - public void beginBlockNodes() { + protected void beginBlockNodes() { stream.println(" "); } - public void printBlockNode(String nodeId) { + protected void printBlockNode(String nodeId) { stream.printf(" %n", escape(nodeId)); } - public void endBlockNodes() { + protected void endBlockNodes() { stream.println(" "); } - public void endBlock() { + protected void endBlock() { stream.println(" "); } - public void endControlFlow() { + protected void endControlFlow() { stream.println(" "); } - public void endGraph() { + protected void endGraph() { stream.println("
"); } /** * Ends the current group. */ - public void endGroup() { + protected void endGroup() { stream.println("
"); } /** * Finishes the graph document and flushes the output stream. */ - public void end() { + protected void end() { stream.println("
"); flush(); } + + public boolean isValid() { + return !stream.checkError(); + } + + private static String escape(String s) { StringBuilder str = null; for (int i = 0; i < s.length(); i++) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java --- 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()); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinter.java --- 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 Ideal Graph Visualizer. */ -class IdealGraphPrinter { - - private final BasicIdealGraphPrinter printer; - private final HashSet> omittedClasses = new HashSet<>(); - private final Set 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 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 edges = printNodes(graph, shortNames, schedule == null ? null : schedule.getNodeToBlock()); - printer.endNodes(); + beginNodes(); + List 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 printNodes(Graph graph, boolean shortNames, NodeMap nodeToBlock) { + private List printNodes(Graph graph, NodeMap nodeToBlock, Set noBlockNodes) { ArrayList edges = new ArrayList<>(); NodeMap>> colors = graph.createNodeMap(); NodeMap>> colorsToString = graph.createNodeMap(); NodeMap> 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 entry : debugObjects.entrySet()) { -// String name = entry.getKey(); -// Object obj = entry.getValue(); -// if (obj instanceof NodeMap) { -// Map colorNumbers = new HashMap(); -// int nextColor = 0; -// NodeMap map = (NodeMap) obj; -// for (Entry 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> nodeColors = colors.get(node); -// if (nodeColors == null) { -// nodeColors = new HashSet>(); -// colors.put(node, nodeColors); -// } -// nodeColors.add(new SimpleImmutableEntry(name + "Color", colorNumber)); -// Set> nodeColorStrings = colorsToString.get(node); -// if (nodeColorStrings == null) { -// nodeColorStrings = new HashSet>(); -// colorsToString.put(node, nodeColorStrings); -// } -// nodeColorStrings.add(new SimpleImmutableEntry(name, color.toString())); -// } -// } else if (obj instanceof NodeBitMap) { -// NodeBitMap bitmap = (NodeBitMap) obj; -// for (Node node : bitmap) { -// Set nodeBits = bits.get(node); -// if (nodeBits == null) { -// nodeBits = new HashSet(); -// 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 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 color : nodeColors) { String name = color.getKey(); Integer value = color.getValue(); - printer.printProperty(name, Integer.toString(value)); + printProperty(name, Integer.toString(value)); } } Set> nodeColorStrings = colorsToString.get(node); @@ -259,24 +163,24 @@ for (Entry color : nodeColorStrings) { String name = color.getKey(); String value = color.getValue(); - printer.printProperty(name, value); + printProperty(name, value); } } Set nodeBits = bits.get(node); if (nodeBits != null) { for (String bit : nodeBits) { - printer.printProperty(bit, "true"); + printProperty(bit, "true"); } } for (Entry 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 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 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 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(); } } - } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterDumpHandler.java --- /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 Ideal Graph Visualizer. + */ +public class IdealGraphPrinterDumpHandler implements DebugDumpHandler { + + private static final String DEFAULT_FILE_NAME = "output.igv.xml"; + + private IdealGraphPrinter printer; + private List 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 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(); + + } +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterObserver.java --- 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 Ideal Graph Visualizer. - */ -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 context = new ThreadLocal() { - @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(); - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/GraalIntrinsics.java --- 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)); } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java --- 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 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/BoxingEliminationTest.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java --- 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); } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/EscapeAnalysisTest.java --- 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()); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/GraphTest.java --- 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); - } - } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/IfBoxingEliminationTest.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/IfCanonicalizerTest.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/NestedLoopTest.java --- 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"); } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/PhiCreationTests.java --- 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()); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/ScalarTypeSystemTest.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/StraighteningTest.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 mx.bat --- 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 %* diff -r b197bbb58d2f -r 9f8e4aeec1a9 mx.cmd --- /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 %* diff -r b197bbb58d2f -r 9f8e4aeec1a9 mx/commands.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') diff -r b197bbb58d2f -r 9f8e4aeec1a9 mx/projects --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 mxtool/mx.py --- 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, ''): diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java --- 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 selector = new Properties.PropertySelector(graph.getNodes()); + Properties.PropertySelector selector = new Properties.PropertySelector<>(graph.getNodes()); StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue); List nodeList = selector.selectMultiple(matcher); if (nodeList.size() > 0) { - nodes = new LinkedHashSet(); + nodes = new LinkedHashSet<>(); for (InputNode n : nodeList) { nodes.add(n); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java --- 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(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java --- 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 tpl = new Lookup.Template(InputGraphProvider.class); + Lookup.Template 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) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java --- 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)}; diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.controlflow. - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf --- 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 - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/build-impl.xml --- 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 @@ - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/platform.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.controlflow - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.hierarchicallayout - - - - 1.0 - - - - com.sun.hotspot.igv.layout - - - - 1.0 - - - - com.sun.hotspot.igv.util - - - - 1.0 - - - - org.jdesktop.layout - - - - 1 - 1.16.1 - - - - org.netbeans.api.visual - - - - 2.9 - - - - org.openide.util - - - - 8.14.1 - - - - org.openide.util.lookup - - - - 8.6.1 - - - - org.openide.windows - - - - 6.16 - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/suite.properties --- 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}/.. diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java --- 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 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(); - } - - 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 p) { - this.points = p; - } - - @Override - public List getControlPoints() { - return points; - } - - @Override - public String toString() { - return "Connection[ " + from.toString() + " - " + to.toString() + "]"; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java --- 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); - } - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java --- 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(); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java --- 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 implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider { - - private HashSet 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(); - - 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 blocks = new ArrayList(this.getNodes()); - for (InputBlock b : blocks) { - removeNode(b); - } - - ArrayList edges = new ArrayList(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 layout = new HierarchicalGraphLayout();//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 inputNodes = new HashSet(); - 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))); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form --- 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 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java --- 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. - */ - // //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) - ); - }// //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 tpl = new Lookup.Template(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(); - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentSettings.xml --- 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 @@ - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentWstcref.xml --- 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 @@ - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java --- 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; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java --- 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 extends GraphLayout { - - 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 getControlPoints() { - return new ArrayList(); - } - - public void setControlPoints(List list) { - // Do nothing for now - } - } - - private class VertexWrapper implements Vertex { - - private N node; - private UniversalGraph graph; - private Port slot; - private Point position; - - public VertexWrapper(N node, UniversalGraph 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 graph) { - - Set links = new LinkedHashSet(); - Set vertices = new LinkedHashSet(); - Map vertexMap = new HashMap(); - - 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 graph, Collection nodes) { - throw new UnsupportedOperationException(); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/layer.xml --- 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.coordinator - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.difference - - - - 1.0 - - - - com.sun.hotspot.igv.settings - - - - 1.0 - - - - com.sun.hotspot.igv.util - - - - 1.0 - - - - org.netbeans.api.progress - - - - 1 - 1.23.1 - - - - org.openide.actions - - - - 6.21.1 - - - - org.openide.awt - - - - 7.30.1 - - - - org.openide.dialogs - - - - 7.18.1 - - - - org.openide.explorer - - - - 6.34.1 - - - - org.openide.filesystems - - - - 7.46.1 - - - - org.openide.loaders - - - - 7.20.1 - - - - org.openide.nodes - - - - 7.20.1 - - - - org.openide.util - - - - 8.14.1 - - - - org.openide.util.lookup - - - - 8.6.1 - - - - org.openide.windows - - - - 6.39.1 - - - - - - - + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.coordinator + + + + com.sun.hotspot.igv.connection + + + + 1.0 + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.difference + + + + 1.0 + + + + com.sun.hotspot.igv.settings + + + + 1.0 + + + + com.sun.hotspot.igv.util + + + + 1.0 + + + + org.netbeans.api.progress + + + + 1 + 1.23.1 + + + + org.openide.actions + + + + 6.21.1 + + + + org.openide.awt + + + + 7.30.1 + + + + org.openide.dialogs + + + + 7.18.1 + + + + org.openide.explorer + + + + 6.34.1 + + + + org.openide.filesystems + + + + 7.46.1 + + + + org.openide.loaders + + + + 7.20.1 + + + + org.openide.nodes + + + + 7.20.1 + + + + org.openide.util + + + + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 + + + + org.openide.windows + + + + 6.39.1 + + + + + + + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java --- 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>> structure; - private List subFolders; private FolderChildren children; - private static class FolderChildren extends Children.Keys>> implements ChangedListener { + private static class FolderChildren extends Children.Keys implements ChangedListener { - private FolderNode parent; - private List 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(); + public FolderChildren(Folder folder) { + this.folder = folder; + folder.getChangedEvent().addListener(this); } @Override - protected Node[] createNodes(Pair> p) { - - for(Group g : registeredGroups) { - g.getChangedEvent().removeListener(this); - } - registeredGroups.clear(); - - if (p.getLeft().length() == 0) { - - List curNodes = new ArrayList(); - 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> 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 subFolders, List 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 oldSubFolders, final List 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 oldSubFolders, List groups) { + public void init(String name, List groups) { this.setDisplayName(name); - this.organizer = organizer; - this.subFolders = new ArrayList(oldSubFolders); - if (name.length() > 0) { - this.subFolders.add(name); - } - structure = organizer.organize(subFolders, groups); - assert structure != null; children.addNotify(); for (Group g : groups) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java --- 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>> organize(List subFolders, List groups) { - - List>> result = new ArrayList>>(); - - if (subFolders.size() == 0) { - Map> map = new HashMap>(groups.size()); - for (Group g : groups) { - Integer cur = g.getGraphsCount(); - if (!map.containsKey(cur)) { - map.put(cur, new ArrayList()); - } - map.get(cur).add(g); - } - - SortedSet keys = new TreeSet(map.keySet()); - for (Integer i : keys) { - result.add(new Pair>("Graph count " + i, map.get(i))); - } - - } else if (subFolders.size() == 1) { - for (Group g : groups) { - List children = new ArrayList(); - children.add(g); - Pair> p = new Pair>(); - p.setLeft(g.getName()); - p.setRight(children); - result.add(p); - } - } else if (subFolders.size() == 2) { - result.add(new Pair>("", groups)); - } - - return result; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java --- 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)); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form --- 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 @@ - + + + + - - - - - - - - - - - - - - - + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java --- 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(), document.getGroups()); + root = new FolderNode(document); manager.setRootContext(root); ((BeanTreeView) this.treeView).setRootVisible(false); - document.getChangedEvent().addListener(new ChangedListener() { - - 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 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(), 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 @@ // //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); }// //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 } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml --- 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 @@ - + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java --- 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>> organize(List subFolders, List groups) { - List>> result = new ArrayList>>(); - if (groups.size() == 1 && subFolders.size() > 0) { - result.add(new Pair>("", groups)); - } else { - for (Group g : groups) { - Pair> p = new Pair>(); - p.setLeft(g.getName()); - p.setRight(Arrays.asList(g)); - result.add(p); - } - } - return result; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java --- 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); } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java --- 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); } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java --- 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(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java --- 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; diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java --- 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 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 organizersCollection = Lookup.getDefault().lookupAll(GroupOrganizer.class); - - List organizers = new ArrayList(organizersCollection); - Collections.sort(organizers, new Comparator() { - public int compare(GroupOrganizer a, GroupOrganizer b) { - return a.getName().compareTo(b.getName()); - } - }); - - map = new HashMap(); - - 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; - } - -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java --- 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 l) { l.changed(object); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java --- 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(); + listener = new ArrayList<>(); fireEvents = true; } @@ -55,7 +55,7 @@ public void fire() { if(fireEvents) { - List tmpList = new ArrayList(listener); + List tmpList = new ArrayList<>(listener); for (L l : tmpList) { fire(l); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Folder.java --- /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 getElements(); + void removeElement(FolderElement element); + void addElement(FolderElement group); + ChangedEvent getChangedEvent(); +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/FolderElement.java --- /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); +} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java --- 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 { +public class GraphDocument extends Properties.Entity implements ChangedEventProvider, Folder { - private List groups; + private List elements; private ChangedEvent changedEvent; public GraphDocument() { - groups = new ArrayList(); - changedEvent = new ChangedEvent(this); + elements = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); } public void clear() { - groups.clear(); + elements.clear(); getChangedEvent().fire(); } + @Override public ChangedEvent getChangedEvent() { return changedEvent; } - public List 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 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(); + } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java --- 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 { +public class Group extends Properties.Entity implements ChangedEventProvider, Folder, FolderElement { + private final List elements; private final List graphs; private InputMethod method; - private String assembly; private transient ChangedEvent changedEvent; - private transient boolean complete = true; + private Folder parent; - public Group() { - graphs = Collections.synchronizedList(new ArrayList()); - changedEvent = new ChangedEvent(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 getChangedEvent() { return changedEvent; } - public List getGraphs() { - return Collections.unmodifiableList(graphs); + @Override + public List getElements() { + return Collections.unmodifiableList(elements); } public int getGraphsCount() { - return graphs.size(); + return elements.size(); } - - public List getGraphListCopy() { - synchronized (graphs) { - return new ArrayList(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 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 getAllNodes() { - Set result = new HashSet(); - synchronized (graphs) { - for (InputGraph g : graphs) { + Set 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 getGraphs() { + return graphs; + } + + @Override + public void setParent(Folder parent) { + this.parent = parent; } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java --- 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 s = new HashSet(); + final HashSet 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(); - successors = new LinkedHashSet(2); + nodes = new ArrayList<>(); + successors = new LinkedHashSet<>(2); } public String getName() { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java --- 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 OUTGOING_COMPARATOR = new Comparator(){ + @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 INGOING_COMPARATOR = new Comparator(){ + @Override public int compare(InputEdge o1, InputEdge o2) { if(o1.getToIndex() == o2.getToIndex()) { return o1.getFrom() - o2.getFrom(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java --- 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 nodes; private Set edges; - private Group parent; + private Folder parent; + private Group parentGroup; private Map blocks; private Set blockEdges; private Map nodeToBlock; - private Pair sourceGraphs; - private int parentIndex; - public static InputGraph createWithoutGroup(String name, Pair sourceGraphs) { - return new InputGraph(-1, null, name, sourceGraphs); - } - - InputGraph(int parentIndex, Group parent, String name, Pair sourceGraphs) { - this.parentIndex = parentIndex; - this.parent = parent; - this.sourceGraphs = sourceGraphs; + public InputGraph(String name) { setName(name); - nodes = new LinkedHashMap(); - edges = new LinkedHashSet(); - blocks = new LinkedHashMap(); - blockEdges = new LinkedHashSet(); - nodeToBlock = new LinkedHashMap(); + 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 getSourceGraphs() { - return sourceGraphs; - } public List findRootNodes() { - List result = new ArrayList(); - Set nonRoot = new HashSet(); + List result = new ArrayList<>(); + Set nonRoot = new HashSet<>(); for(InputEdge curEdges : getEdges()) { nonRoot.add(curEdges.getTo()); } @@ -102,7 +82,7 @@ public Map> findAllOutgoingEdges() { - Map> result = new HashMap>(getNodes().size()); + Map> result = new HashMap<>(getNodes().size()); for(InputNode n : this.getNodes()) { result.put(n, new ArrayList()); } @@ -125,7 +105,7 @@ public Map> findAllIngoingEdges() { - Map> result = new HashMap>(getNodes().size()); + Map> result = new HashMap<>(getNodes().size()); for(InputNode n : this.getNodes()) { result.put(n, new ArrayList()); } @@ -147,7 +127,7 @@ } public List findOutgoingEdges(InputNode n) { - List result = new ArrayList(); + List result = new ArrayList<>(); for(InputEdge e : this.edges) { if(e.getFrom() == n.getId()) { @@ -177,7 +157,7 @@ public void ensureNodesInBlocks() { InputBlock noBlock = null; - Set scheduledNodes = new HashSet(); + Set scheduledNodes = new HashSet<>(); for (InputBlock b : getBlocks()) { for (InputNode n : b.getNodes()) { @@ -213,27 +193,18 @@ } public InputGraph getNext() { - List list = parent.getGraphs(); - if (parentIndex == list.size() - 1) { - return null; - } else { - return list.get(parentIndex + 1); - } + return parentGroup.getNext(this); } public InputGraph getPrev() { - List 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 getBlockEdges() { return Collections.unmodifiableSet(blockEdges); } + + @Override + public Folder getParent() { + return parent; + } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java --- 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(); - bytecodes = new ArrayList(); + inlined = new ArrayList<>(); + bytecodes = new ArrayList<>(); } public List getBytecodes() { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java --- 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 COMPARATOR = new Comparator() { + @Override public int compare(InputNode o1, InputNode o2) { return o1.getId() - o2.getId(); } @@ -42,6 +43,7 @@ public static Comparator getPropertyComparator(final String propertyName) { return new Comparator() { + @Override public int compare(InputNode o1, InputNode o2) { int i1 = 0; diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java --- 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 pairs = new ArrayList(); + List 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() { + @Override public int compare(String[] o1, String[] o2) { assert o1.length == 2; assert o2.length == 2; @@ -294,7 +297,7 @@ } public List selectMultiple(PropertyMatcher matcher) { - List result = new ArrayList(); + List 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 iterator() { return new PropertiesIterator(); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java --- 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 set; public Source() { - sourceNodes = new ArrayList(1); - set = new LinkedHashSet(1); + sourceNodes = new ArrayList<>(1); + set = new LinkedHashSet<>(1); } public List getSourceNodes() { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java --- 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 xmlDocument = new TopElementHandler(); - private boolean difference; + private TopElementHandler xmlDocument = new TopElementHandler<>(); + private Map differenceEncoding = new HashMap<>(); + private Map lastParsedGraph = new HashMap<>(); private GroupCallback groupCallback; - private HashMap idCache = new HashMap(); - private ArrayList> blockConnections = new ArrayList>(); + private HashMap idCache = new HashMap<>(); + private ArrayList> 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; } }; // - private ElementHandler groupHandler = new XMLParser.ElementHandler(GROUP_ELEMENT) { + private ElementHandler groupHandler = new XMLParser.ElementHandler(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 assemblyHandler = new XMLParser.HandoverElementHandler(ASSEMBLY_ELEMENT, true) { - - @Override - protected void end(String text) throws SAXException { - getParentObject().setAssembly(text); - } - }; // private ElementHandler methodHandler = new XMLParser.ElementHandler(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 @@ } }; // - private HandoverElementHandler inlinedHandler = new XMLParser.HandoverElementHandler(INLINE_ELEMENT); + private HandoverElementHandler inlinedHandler = new XMLParser.HandoverElementHandler<>(INLINE_ELEMENT); // private ElementHandler inlinedMethodHandler = new XMLParser.ElementHandler(METHOD_ELEMENT) { @@ -208,16 +201,14 @@ // private ElementHandler graphHandler = new XMLParser.ElementHandler(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 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); + } + }); } }; // - private HandoverElementHandler nodesHandler = new HandoverElementHandler(NODES_ELEMENT); + private HandoverElementHandler nodesHandler = new HandoverElementHandler<>(NODES_ELEMENT); // - private HandoverElementHandler controlFlowHandler = new HandoverElementHandler(CONTROL_FLOW_ELEMENT); + private HandoverElementHandler controlFlowHandler = new HandoverElementHandler<>(CONTROL_FLOW_ELEMENT); // private ElementHandler blockHandler = new ElementHandler(BLOCK_ELEMENT) { @@ -302,7 +300,7 @@ } }; // - private HandoverElementHandler blockNodesHandler = new HandoverElementHandler(NODES_ELEMENT); + private HandoverElementHandler blockNodesHandler = new HandoverElementHandler<>(NODES_ELEMENT); // private ElementHandler blockNodeHandler = new ElementHandler(NODE_ELEMENT) { @@ -321,14 +319,14 @@ } }; // - private HandoverElementHandler successorsHandler = new HandoverElementHandler(SUCCESSORS_ELEMENT); + private HandoverElementHandler successorsHandler = new HandoverElementHandler<>(SUCCESSORS_ELEMENT); // private ElementHandler successorHandler = new ElementHandler(SUCCESSOR_ELEMENT) { @Override protected InputBlock start() throws SAXException { String name = readRequiredAttribute(BLOCK_NAME_PROPERTY); - blockConnections.add(new Pair(getParentObject().getName(), name)); + blockConnections.add(new Pair<>(getParentObject().getName(), name)); return getParentObject(); } }; @@ -365,7 +363,7 @@ } }; // - private HandoverElementHandler edgesHandler = new HandoverElementHandler(EDGES_ELEMENT); + private HandoverElementHandler edgesHandler = new HandoverElementHandler<>(EDGES_ELEMENT); // Local class for edge elements private class EdgeElementHandler extends ElementHandler { @@ -431,14 +429,20 @@ } }; // - private HandoverElementHandler propertiesHandler = new HandoverElementHandler(PROPERTIES_ELEMENT); + private HandoverElementHandler propertiesHandler = new HandoverElementHandler<>(PROPERTIES_ELEMENT); // private HandoverElementHandler groupPropertiesHandler = new HandoverElementHandler(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 { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java --- 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 removed = new HashSet(); - Set equal = new HashSet(); + Set removed = new HashSet<>(); + Set equal = new HashSet<>(); if (previous != null) { for (InputNode n : previous.getNodes()) { @@ -143,8 +143,8 @@ writer.endTag(); writer.startTag(Parser.EDGES_ELEMENT); - Set removedEdges = new HashSet(); - Set equalEdges = new HashSet(); + Set removedEdges = new HashSet<>(); + Set equalEdges = new HashSet<>(); if (previous != null) { for (InputEdge e : previous.getEdges()) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java --- 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 { private String name; - private T object; + private Stack object = new Stack<>(); private Attributes attr; private StringBuilder currentText; private ParseMonitor monitor; private HashMap> hashtable; private boolean needsText; - private ElementHandler parentElement; + private Stack> parentElement = new Stack<>(); + private Stack

parentObject = new Stack<>(); public ElementHandler(String name) { this(name, false); } public ElementHandler 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>(); + 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(); + 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 { } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java --- 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(); + 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(); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java --- 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>> organize(List subFolders, List groups); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java --- 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); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java --- 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 e = new ChangedEvent(5); + ChangedEvent e = new ChangedEvent<>(5); final int[] fireCount = new int[1]; e.addListener(new ChangedListener() { + @Override public void changed(Integer s) { assertEquals(s.intValue(), 5); fireCount[0]++; diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java --- 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.*; /** * diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java --- 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)); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java --- 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 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> 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> 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()); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java --- 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.*; /** * diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java --- 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 c = new ArrayList(); + final Collection 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 sel = new PropertySelector(c); + final PropertySelector sel = new PropertySelector<>(c); final StringPropertyMatcher matcher1 = new StringPropertyMatcher("p2", "2"); assertTrue(sel.selectMultiple(matcher1).size() == 2); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java --- 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.*; /** * diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java --- 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(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(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(Arrays.asList(1, 2))); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1, 2))); } } \ No newline at end of file diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java --- 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()); } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java --- 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java --- 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 keyMapB = new HashMap(b.getNodes().size()); + Map keyMapB = new HashMap<>(b.getNodes().size()); for (InputNode n : b.getNodes()) { Integer key = n.getId(); assert !keyMapB.containsKey(key); keyMapB.put(key, n); } - Set pairs = new HashSet(); + Set 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(a, b)); + InputGraph graph = new InputGraph(a.getName() + ", " + b.getName()); + g.addElement(graph); - Map blocksMap = new HashMap(); + Map 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> aEdges = new HashSet>(); + Set> aEdges = new HashSet<>(); for (InputBlockEdge edge : a.getBlockEdges()) { - aEdges.add(new Pair(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 pair = new Pair(from.getName(), to.getName()); + Pair 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 nodesA = new HashSet(a.getNodes()); - Set nodesB = new HashSet(b.getNodes()); + Set nodesA = new HashSet<>(a.getNodes()); + Set nodesB = new HashSet<>(b.getNodes()); - Map inputNodeMap = new HashMap(pairs.size()); + Map inputNodeMap = new HashMap<>(pairs.size()); for (NodePair p : pairs) { InputNode n = p.getLeft(); assert nodesA.contains(n); @@ -209,7 +198,7 @@ Collection edgesA = a.getEdges(); Collection edgesB = b.getEdges(); - Set newEdges = new HashSet(); + Set newEdges = new HashSet<>(); for (InputEdge e : edgesA) { int from = e.getFrom(); @@ -291,9 +280,9 @@ private static InputGraph createDiff(InputGraph a, InputGraph b) { - Set matched = new HashSet(); + Set matched = new HashSet<>(); - Set pairs = new HashSet(); + Set pairs = new HashSet<>(); for (InputNode n : a.getNodes()) { String s = n.getProperties().get(MAIN_PROPERTY); if (s == null) { @@ -312,7 +301,7 @@ } } - Set selectedPairs = new HashSet(); + Set selectedPairs = new HashSet<>(); while (pairs.size() > 0) { double min = Double.MAX_VALUE; @@ -330,7 +319,7 @@ } else { selectedPairs.add(minPair); - Set toRemove = new HashSet(); + Set toRemove = new HashSet<>(); for (NodePair p : pairs) { if (p.getLeft() == minPair.getLeft() || p.getRight() == minPair.getRight()) { toRemove.add(p); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java --- 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 getChangedEvent() { return changedEvent; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java --- 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(); + colorRules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector

selector = new Properties.PropertySelector
(diagram.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(diagram.getFigures()); for (ColorRule rule : colorRules) { if (rule.getSelector() != null) { List
figures = rule.getSelector().selected(diagram); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java --- 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(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector
selector = new Properties.PropertySelector
(diagram.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(diagram.getFigures()); for (CombineRule r : rules) { List
list = selector.selectMultiple(r.getFirstMatcher()); - Set
figuresToRemove = new HashSet
(); + Set
figuresToRemove = new HashSet<>(); for (Figure f : list) { - List
successors = new ArrayList
(f.getSuccessors()); + List
successors = new ArrayList<>(f.getSuccessors()); if (r.isReversed()) { if (successors.size() == 1) { Figure succ = successors.get(0); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ConnectionFilter.java --- 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(); + connectionStyleRules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector
selector = new Properties.PropertySelector
(diagram.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(diagram.getFigures()); for (ConnectionStyleRule rule : connectionStyleRules) { List
figures = null; if (rule.getSelector() != null) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java --- 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 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); + } } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EdgeColorIndexFilter.java --- 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
figures = d.getFigures(); for (Figure f : figures) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Filter.java --- 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 getChangedEvent(); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java --- 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 changedEvent; private ChangedListener changedListener = new ChangedListener() { + @Override public void changed(Filter source) { changedEvent.fire(); } }; public FilterChain() { - filters = new ArrayList(); - changedEvent = new ChangedEvent(this); + filters = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); } public FilterChain(FilterChain f) { - this.filters = new ArrayList(f.filters); - changedEvent = new ChangedEvent(this); + this.filters = new ArrayList<>(f.filters); + changedEvent = new ChangedEvent<>(this); } + @Override public ChangedEvent getChangedEvent() { return changedEvent; } @@ -72,7 +74,7 @@ } public void apply(Diagram d, FilterChain sequence) { - List applied = new ArrayList(); + List applied = new ArrayList<>(); for (Filter f : sequence.getFilters()) { if (filters.contains(f)) { f.apply(d); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterSetting.java --- 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(); + filters = new HashSet<>(); } public Set getFilters() { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/GradientColorFilter.java --- 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)) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/NullScriptEngine.java --- 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) { - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveFilter.java --- 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(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { for (RemoveRule r : rules) { List
selected = r.getSelector().selected(diagram); - Set
toRemove = new HashSet
(selected); + Set
toRemove = new HashSet<>(selected); if (r.getRemoveOrphans()) { boolean changed; diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java --- 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(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { for (RemoveInputsRule r : rules) { @@ -57,7 +54,7 @@ List
list = r.getSelector().selected(diagram); for (Figure f : list) { int z = 0; - List last = new ArrayList(); + List last = new ArrayList<>(); for (InputSlot is : f.getInputSlots()) { if (z >= r.getStartingIndex() && z <= r.getEndIndex() && is.getConnections().size() > 0) { StringBuilder sb = new StringBuilder(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java --- 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 toRemove = new ArrayList(); + List toRemove = new ArrayList<>(); for (Connection c : is.getConnections()) { if (c.getOutputSlot().getFigure() == f) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ScriptEngineAbstraction.java --- 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); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java --- 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
list = selector.selected(d); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/UnconnectedSlotFilter.java --- 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
figures = d.getFigures(); for (Figure f : figures) { - List remove = new ArrayList(); + List remove = new ArrayList<>(); if (removeInputs) { for (InputSlot is : f.getInputSlots()) { if (is.getConnections().isEmpty()) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java --- 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 createList() { + JList tmpList = super.createList(); tmpList.setCellRenderer(new CheckRenderer(tmpList)); return tmpList; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNode.java --- 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(this); + selectionChangedEvent = new ChangedEvent<>(this); selected = false; enabled = true; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java --- 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 { - private JList list; + private JList list; private Color startBackground; - public CheckRenderer(final JList list) { + public CheckRenderer(final JList 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 list, Object value, final int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index); this.setSelected(node.isSelected()); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterChainProviderImplementation.java --- 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(); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java --- 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 { private Filter filter; - private Lookup.Result result; + private Lookup.Result result; public FilterNode(Filter filter) { this(filter, new InstanceContent()); @@ -62,6 +62,7 @@ this.filter = filter; filter.getChangedEvent().addListener(new ChangedListener() { + @Override public void changed(Filter source) { update(); } @@ -69,7 +70,7 @@ update(); - Lookup.Template tpl = new Lookup.Template(FilterChain.class); + Lookup.Template 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)); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form --- 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 @@ + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java --- 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 result; private JComboBox comboBox; private List filterSettings; private FilterSetting customFilterSetting = new FilterSetting("-- Custom --"); private ChangedEvent 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 toRemove = new ArrayList(); + List 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() { + @Override public int compare(FilterSetting o1, FilterSetting o2) { return o1.getName().compareTo(o2.getName()); } @@ -270,8 +244,9 @@ private class FilterChildren extends Children.Keys implements ChangedListener { - private HashMap nodeHash = new HashMap(); + private HashMap 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() { + @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(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(); + 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 customFilters = new ArrayList(); - HashMap afterMap = new HashMap(); - Set enabledSet = new HashSet(); - HashMap map = new HashMap(); + List customFilters = new ArrayList<>(); + HashMap afterMap = new HashMap<>(); + Set enabledSet = new HashSet<>(); + HashMap 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 copiedList = new ArrayList(customFilters); + List 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 tpl = new Lookup.Template(FilterChain.class); + Lookup.Template 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)); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/FilterAction.java --- 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(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterDownAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterUpAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/NewFilterAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterSettingsAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/SaveFilterSettingsAction.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.graal. - - + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.graal. + + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/nbproject/build-impl.xml --- 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 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.graal - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.filter - - - - 1.0 - - - - com.sun.hotspot.igv.graph - - - - 1.0 - - - - com.sun.hotspot.igv.graphtotext - - - - 1.0 - - - - com.sun.hotspot.igv.structuredtext - - - - 1.0 - - - - - - - + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.graal + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.filter + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + + + + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/GraalGraphToTextConverter.java --- 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> map; - private Map> incomingEdges; - private Map> outgoingEdges; - private InputGraph graph; - - private Collection sortNodes(Collection nodes) { - List result = new ArrayList(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
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; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalCFGFilter.java --- 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
figuresToRemove = new HashSet
(); - Set connectionsToRemove = new HashSet(); + Set
figuresToRemove = new HashSet<>(); + Set connectionsToRemove = new HashSet<>(); for (Figure f : d.getFigures()) { final String prop = f.getProperties().get("probability"); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalColoringFilter.java --- 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
figures = d.getFigures(); int colors = 0; diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java --- 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
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); } } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/AndSelector.java --- 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
selected(Diagram d) { List
l1 = selector1.selected(d); List
l2 = selector2.selected(d); - List
result = new ArrayList
(); + List
result = new ArrayList<>(); for (Figure f : l2) { if (l1.contains(f)) { result.add(f); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java --- 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 getSuccessors() { - Set succs = new HashSet(); - 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(); - } -} - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java --- 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(); + 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 getControlPoints() { return controlPoints; } + @Override public void setControlPoints(List list) { controlPoints = list; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java --- 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
figures; - private Map blocks; private InputGraph graph; private int curId; private String nodeText; @@ -65,38 +53,20 @@ } private Diagram() { - figures = new ArrayList
(); - blocks = new LinkedHashMap(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 getBlocks() { - return Collections.unmodifiableCollection(blocks.values()); - } - public Diagram getPrev() { return Diagram.createDiagram(graph.getPrev(), nodeText); } @@ -119,7 +89,7 @@ } public Map> calcSourceToFigureRelation() { - Map> map = new HashMap>(); + Map> map = new HashMap<>(); for(InputNode node : this.getGraph().getNodes()) { map.put(node, new HashSet
()); @@ -143,10 +113,8 @@ d.graph = graph; d.nodeText = nodeText; - d.updateBlocks(); - Collection nodes = graph.getNodes(); - Hashtable figureHash = new Hashtable(); + Hashtable figureHash = new Hashtable<>(); for (InputNode n : nodes) { Figure f = d.createFigure(); f.getSource().addSourceNode(n); @@ -194,7 +162,7 @@ freeFigure(f); } - ArrayList
newFigures = new ArrayList
(); + ArrayList
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 inputSlots = new ArrayList(succ.getInputSlots()); + List inputSlots = new ArrayList<>(succ.getInputSlots()); for (InputSlot s : inputSlots) { succ.removeInputSlot(s); } - List outputSlots = new ArrayList(succ.getOutputSlots()); + List outputSlots = new ArrayList<>(succ.getOutputSlots()); for (OutputSlot s : outputSlots) { succ.removeOutputSlot(s); } @@ -239,7 +207,7 @@ public Set getConnections() { - Set connections = new HashSet(); + Set connections = new HashSet<>(); for (Figure f : figures) { for (InputSlot s : f.getInputSlots()) { @@ -251,7 +219,7 @@ } public Figure getRootFigure() { - Properties.PropertySelector
selector = new Properties.PropertySelector
(figures); + Properties.PropertySelector
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
figuresSorted = new ArrayList
(tmpFigures); + List
figuresSorted = new ArrayList<>(tmpFigures); Collections.sort(figuresSorted, new Comparator
() { + @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
getRootFigures() { - ArrayList
rootFigures = new ArrayList
(); + ArrayList
rootFigures = new ArrayList<>(); for (Figure f : figures) { if (f.getPredecessors().size() == 0) { rootFigures.add(f); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java --- 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 List getAllBefore(List inputList, T tIn) { - List result = new ArrayList(); + List 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(5); - outputSlots = new ArrayList(1); - predecessors = new ArrayList
(6); - successors = new ArrayList
(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
getPredecessorSet() { - Set
result = new HashSet
(); + Set
result = new HashSet<>(); for (Figure f : getPredecessors()) { result.add(f); } @@ -159,7 +148,7 @@ } public Set
getSuccessorSet() { - Set
result = new HashSet
(); + Set
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 connections = new ArrayList(s.getConnections()); + List connections = new ArrayList<>(s.getConnections()); for (Connection c : connections) { c.remove(); } @@ -251,7 +243,7 @@ } public Set getSlots() { - Set result = new HashSet(); + Set 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 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())); + } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java --- 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 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); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InvertSelector.java --- 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
selected(Diagram d) { - List
result = new ArrayList
(); + List
result = new ArrayList<>(); List
otherResult = selector.selected(d); for (Figure f : d.getFigures()) { if (!otherResult.contains(f)) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/MatcherSelector.java --- 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
selected(Diagram d) { - Properties.PropertySelector
selector = new Properties.PropertySelector
(d.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(d.getFigures()); List
list = selector.selectMultiple(matcher); return list; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OrSelector.java --- 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
selected(Diagram d) { List
l1 = selector1.selected(d); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java --- 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) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/PredecessorSelector.java --- 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
selected(Diagram d) { List
inner = innerSelector.selected(d); - List
result = new ArrayList
(); + List
result = new ArrayList<>(); for (Figure f : d.getFigures()) { boolean saved = false; for (Figure f2 : f.getSuccessors()) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java --- 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(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 slotIndexComparator = new Comparator() { + @Override public int compare(Slot o1, Slot o2) { return o1.wantedIndex - o2.wantedIndex; } }; public static final Comparator slotFigureComparator = new Comparator() { + @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 connectionsCopy = new ArrayList(this.connections); + List connectionsCopy = new ArrayList<>(this.connections); for (Connection c : connectionsCopy) { c.remove(); } } + @Override public Vertex getVertex() { return figure; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/SuccessorSelector.java --- 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
selected(Diagram d) { List
inner = innerSelector.selected(d); - List
result = new ArrayList
(); + List
result = new ArrayList<>(); for (Figure f : d.getFigures()) { boolean saved = false; for (Figure f2 : f.getPredecessors()) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.graphtexteditor. - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/manifest.mf --- 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 - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/build-impl.xml --- 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 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.graphtexteditor - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.graph - - - - 1.0 - - - - com.sun.hotspot.igv.graphtotext - - - - 1.0 - - - - com.sun.hotspot.igv.selectioncoordinator - - - - 1.0 - - - - com.sun.hotspot.igv.structuredtext - - - - 1.0 - - - - com.sun.hotspot.igv.texteditor - - - - 1.0 - - - - com.sun.hotspot.igv.util - - - - 1.0 - - - - org.netbeans.modules.diff - - - - 1 - 1.32.1.42.1 - - - - org.openide.util - - - - 7.12.0.1 - - - - org.openide.util.lookup - - - - 8.6.1 - - - - org.openide.windows - - - - 6.20 - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/suite.properties --- 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}/.. diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java --- 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(); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form --- 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 @@ - - -
- - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java --- 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 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 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 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 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 diagramChangedListener = new ChangedListener() { - - 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. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { - - setLayout(new java.awt.BorderLayout()); - }// //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 tpl = new Lookup.Template(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(); - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml --- 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 @@ - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml --- 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 @@ - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml --- 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.graphtotext. - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/manifest.mf --- 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 - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/build-impl.xml --- 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 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/platform.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.graphtotext - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.graph - - - - 1.0 - - - - com.sun.hotspot.igv.structuredtext - - - - 1.0 - - - - - com.sun.hotspot.igv.graphtotext - com.sun.hotspot.igv.graphtotext.services - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/suite.properties --- 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}/.. diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java --- 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 visitorMap; - private InputGraph graph; - private Diagram diagram; - - public BFSGraphToTextConverter(GraphToTextVisitor visitor) { - this.visitor = visitor; - visitorMap = new HashMap(); - } - - 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 path) { - return chooseVisitor(visitor, node).cyclicVisit(node, path); - } - - private Element visit(GraphToTextVisitor visitor, InputNode node, List path, List> 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> outgoing = graph.findAllOutgoingEdges(); - Map> pathMap = new HashMap>(); - Queue queue = new LinkedList(); - List rootNodes = graph.findRootNodes(); - queue.addAll(rootNodes); - for(InputNode node : rootNodes) { - pathMap.put(node, new ArrayList()); - } - - Set visited = new HashSet(); - visited.addAll(rootNodes); - - Set fullEdges = new HashSet(); - List visitOrder = new ArrayList(); - while(!queue.isEmpty()) { - - InputNode current = queue.remove(); - visitOrder.add(current); - List path = pathMap.get(current); - - List 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 curPath = new ArrayList(path); - curPath.add(e); - pathMap.put(dest, curPath); - fullEdges.add(e); - } - } - } - - - - Map fullVisitCache = new HashMap(); - for(int i=visitOrder.size() - 1; i>=0; i--) { - InputNode current = visitOrder.get(i); - List path = pathMap.get(current); - List edges = outgoing.get(current); - List> list = new ArrayList>(); - for(InputEdge e : edges) { - if(fullEdges.contains(e)) { - assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - list.add(new Pair(e, fullVisitCache.get(graph.getNode(e.getTo())))); - } else { -// assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - List curPath = new ArrayList(path); - curPath.add(e); - list.add(new Pair(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; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java --- 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 path) { - return SimpleElement.EMPTY; - } - - public Element visit(InputNode node, List path, List> children) { - return cyclicVisit(node, path); - } - -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java --- 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); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java --- 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 path); - Element visit(InputNode node, List path, List> children); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterEdge.java --- 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 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 p) { - this.points = p; - } - - public List getControlPoints() { - return points; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterIngoingConnection.java --- 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 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(); - - 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 p) { - this.controlPoints = p; - } - - public List getControlPoints() { - return controlPoints; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterInputSlotNode.java --- 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()); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java --- 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 subNodes; - private Dimension size; - private Point position; - private Set 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(); - this.subEdges = new HashSet(); - 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 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 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 points = new ArrayList(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 arr = e.getControlPoints(); - ArrayList newArr = new ArrayList(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 getSubNodes() { - return subNodes; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutgoingConnection.java --- 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 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(); - - outputSlot = c.getFrom(); - inputSlot = outputSlotNode.getInputSlot(); - } - - public Port getTo() { - return inputSlot; - } - - public Port getFrom() { - return outputSlot; - } - - public void setControlPoints(List p) { - this.intermediatePoints = p; - } - - public List getControlPoints() { - return intermediatePoints; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java --- 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()); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.java --- 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; } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Graph.java --- 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> nodeList; public Graph() { - nodes = new HashMap>(); - edges = new HashMap>(); - nodeList = new ArrayList>(); + nodes = new HashMap<>(); + edges = new HashMap<>(); + nodeList = new ArrayList<>(); } public Node createNode(N data, Object key) { - Node n = new Node(this, data); + Node n = new Node<>(this, data); assert key == null || !nodes.containsKey(key); if (key != null) { nodes.put(key, n); @@ -58,7 +52,7 @@ } public Edge createEdge(Node source, Node dest, E data, Object key) { - Edge e = new Edge(this, source, dest, data); + Edge e = new Edge<>(this, source, dest, data); source.addOutEdge(e); dest.addInEdge(e); if (key != null) { @@ -114,7 +108,7 @@ public List> getNodesWithInDegree(int x, boolean countSelfLoops) { - List> result = new ArrayList>(); + List> result = new ArrayList<>(); for (Node n : getNodes()) { if (n.getInDegree(countSelfLoops) == x) { result.add(n); @@ -126,7 +120,7 @@ } private void markReachable(Node startingNode) { - ArrayList> arr = new ArrayList>(); + ArrayList> arr = new ArrayList<>(); arr.add(startingNode); for (Node n : getNodes()) { n.setReachable(false); @@ -151,7 +145,7 @@ n.setActive(false); } - Queue> queue = new LinkedList>(); + Queue> queue = new LinkedList<>(); queue.add(startingNode); startingNode.setVisited(true); int layer = 0; diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java --- 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(), new HashSet(), new HashSet()); - } - - public void setSubManager(LayoutManager manager) { - this.subManager = manager; - } - - public void setManager(LayoutManager manager) { - this.manager = manager; - } - - public void doLayout(LayoutGraph graph, Set firstLayerHint, Set lastLayerHint, Set importantLinks) { - - assert graph.verify(); - - HashMap> lists = new HashMap>(); - HashMap> listsConnection = new HashMap>(); - HashMap> clusterInputSlotHash = new HashMap>(); - HashMap> clusterOutputSlotHash = new HashMap>(); - - HashMap clusterNodes = new HashMap(); - HashMap> clusterInputSlotSet = new HashMap>(); - HashMap> clusterOutputSlotSet = new HashMap>(); - Set clusterEdges = new HashSet(); - Set interClusterEdges = new HashSet(); - HashMap linkClusterOutgoingConnection = new HashMap(); - HashMap linkInterClusterConnection = new HashMap(); - HashMap linkClusterIngoingConnection = new HashMap(); - Set clusterNodeSet = new HashSet(); - - Set cluster = graph.getClusters(); - int z = 0; - for (Cluster c : cluster) { - lists.put(c, new ArrayList()); - listsConnection.put(c, new ArrayList()); - clusterInputSlotHash.put(c, new HashMap()); - clusterOutputSlotHash.put(c, new HashMap()); - clusterOutputSlotSet.put(c, new TreeSet()); - clusterInputSlotSet.put(c, new TreeSet()); - 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()); - n.updateSize(); - } - - Set 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(), new HashSet(), 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 points = new ArrayList(); - - points.addAll(conn1.getControlPoints()); - points.addAll(conn2.getControlPoints()); - points.addAll(conn3.getControlPoints()); - - l.setControlPoints(points); - } - } - } - - public void doRouting(LayoutGraph graph) { - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java --- 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 preds = new ArrayList(); - public List succs = new ArrayList(); - public HashMap outOffsets = new HashMap(); - public HashMap inOffsets = new HashMap(); + public List preds = new ArrayList<>(); + public List succs = new ArrayList<>(); + public HashMap outOffsets = new HashMap<>(); + public HashMap 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(); + this.linksToFollow = new HashSet<>(); } public int getMaxLayerLength() { @@ -189,11 +179,13 @@ minLayerDifference = v; } + @Override public void doLayout(LayoutGraph graph) { doLayout(graph, new HashSet(), new HashSet(), new HashSet()); } + @Override public void doLayout(LayoutGraph graph, Set firstLayerHint, Set lastLayerHint, Set importantLinks) { this.importantLinks = importantLinks; @@ -201,14 +193,14 @@ this.firstLayerHint = firstLayerHint; this.lastLayerHint = lastLayerHint; - vertexToLayoutNode = new HashMap(); - reversedLinks = new HashSet(); - reversedLinkStartPoints = new HashMap>(); - reversedLinkEndPoints = new HashMap>(); - bottomEdgeHash = new HashMap(); - nodes = new ArrayList(); - splitStartPoints = new HashMap>(); - splitEndPoints = new HashMap>(); + 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 tmpArr = new ArrayList(); + ArrayList 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 vertexPositions = new HashMap(); - HashMap> linkPositions = new HashMap>(); + HashMap vertexPositions = new HashMap<>(); + HashMap> 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 points = new ArrayList(); + ArrayList 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 points = new ArrayList(); + ArrayList 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 nodes = new ArrayList(); - public HashSet succs = new HashSet(); - public HashSet preds = new HashSet(); + public ArrayList nodes = new ArrayList<>(); + public HashSet succs = new HashSet<>(); + public HashSet preds = new HashSet<>(); public Region region; } private static final Comparator segmentComparator = new Comparator() { + @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 segments = new TreeSet(segmentComparator); - public HashSet succs = new HashSet(4); - public HashSet preds = new HashSet(4); + public SortedSet segments = new TreeSet<>(segmentComparator); + public HashSet succs = new HashSet<>(4); + public HashSet preds = new HashSet<>(4); } private static final Comparator regionComparator = new Comparator() { + @Override public int compare(Region r1, Region r2) { return r1.minOrderNumber - r2.minOrderNumber; } }; private static final Comparator nodePositionComparator = new Comparator() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { return n1.pos - n2.pos; } }; private static final Comparator nodeProcessingDownComparator = new Comparator() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { if (n1.vertex == null) { if (n2.vertex == null) { @@ -546,6 +542,7 @@ }; private static final Comparator nodeProcessingUpComparator = new Comparator() { + @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[] space; private ArrayList[] 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(); - downProcessingOrder[i] = new ArrayList(); - upProcessingOrder[i] = new ArrayList(); + 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 space; public NodeRow(ArrayList space) { - treeSet = new TreeSet(nodePositionComparator); + treeSet = new TreeSet<>(nodePositionComparator); this.space = space; } @@ -755,351 +753,9 @@ treeSet.add(n); } } - - private class AssignXCoordinates extends AlgorithmPart { - - HashMap hashMap = new HashMap(); - ArrayList segments = new ArrayList(); - - 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 queue = new LinkedList(); - - int index = 0; - ArrayList newList = new ArrayList(); - 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 regions = new TreeSet(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 reversedRegions = new ArrayList(); - 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 arr = new ArrayList(); - 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 crossingNodeComparator = new Comparator() { + @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(); + layers[i] = new ArrayList<>(); } } + @Override protected void run() { createLayers(); // Generate initial ordering - HashSet visited = new HashSet(); + HashSet 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 visited = new HashSet(); + HashSet 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 comparator = new Comparator() { + @Override public int compare(LayoutEdge e1, LayoutEdge e2) { return e1.to.layer - e2.to.layer; } }; - HashMap> portHash = new HashMap>(); - ArrayList currentNodes = new ArrayList(nodes); + HashMap> portHash = new HashMap<>(); + ArrayList currentNodes = new ArrayList<>(nodes); for (LayoutNode n : currentNodes) { portHash.clear(); - ArrayList succs = new ArrayList(n.succs); - HashMap topNodeHash = new HashMap(); - HashMap> bottomNodeHash = new HashMap>(); + ArrayList succs = new ArrayList<>(n.succs); + HashMap topNodeHash = new HashMap<>(); + HashMap> 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(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 currentNodes = new ArrayList(nodes); + ArrayList 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 currentNodes = new ArrayList(nodes); + ArrayList 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 insertOrder = new ArrayList(); + List insertOrder = new ArrayList<>(); - HashSet set = new HashSet(); + HashSet set = new HashSet<>(); for (LayoutNode n : nodes) { if (n.preds.size() == 0) { set.add(n); @@ -1626,8 +1292,8 @@ } int z = minLayerDifference; - HashSet newSet = new HashSet(); - HashSet failed = new HashSet(); + HashSet newSet = new HashSet<>(); + HashSet failed = new HashSet<>(); while (!set.isEmpty()) { newSet.clear(); @@ -1718,11 +1384,12 @@ private HashSet visited; private HashSet active; + @Override protected void run() { // Remove self-edges for (LayoutNode node : nodes) { - ArrayList succs = new ArrayList(node.succs); + ArrayList 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(); - active = new HashSet(); + visited = new HashSet<>(); + active = new HashSet<>(); for (LayoutNode node : nodes) { DFS(node); } @@ -1759,7 +1426,7 @@ for (LayoutNode node : nodes) { - SortedSet reversedDown = new TreeSet(); + SortedSet reversedDown = new TreeSet<>(); for (LayoutEdge e : node.succs) { if (reversedLinks.contains(e.link)) { @@ -1770,9 +1437,9 @@ SortedSet reversedUp = null; if (reversedDown.size() == 0) { - reversedUp = new TreeSet(Collections.reverseOrder()); + reversedUp = new TreeSet<>(Collections.reverseOrder()); } else { - reversedUp = new TreeSet(); + 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 reversedSuccs = new ArrayList(); + ArrayList reversedSuccs = new ArrayList<>(); for (LayoutEdge e : node.succs) { if (e.relativeFrom == pos && reversedLinks.contains(e.link)) { reversedSuccs.add(e); @@ -1794,7 +1461,7 @@ } } - ArrayList startPoints = new ArrayList(); + ArrayList 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 reversedPreds = new ArrayList(); + ArrayList 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 endPoints = new ArrayList(); + ArrayList endPoints = new ArrayList<>(); if (reversedDown.size() == 0) { @@ -1885,7 +1552,7 @@ return; } - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.push(startNode); while (!stack.empty()) { @@ -1902,7 +1569,7 @@ visited.add(node); active.add(node); - ArrayList succs = new ArrayList(node.succs); + ArrayList 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 curVisited = new HashSet(); - Queue queue = new LinkedList(); + HashSet curVisited = new HashSet<>(); + Queue queue = new LinkedList<>(); for (LayoutEdge e : n.succs) { LayoutNode s = e.to; queue.add(s); @@ -1981,6 +1648,7 @@ } private Comparator linkComparator = new Comparator() { + @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 vertices = new ArrayList(graph.getVertices()); + List vertices = new ArrayList<>(graph.getVertices()); Collections.sort(vertices); for (Vertex v : vertices) { @@ -2018,7 +1687,7 @@ } // Set up edges - List links = new ArrayList(graph.getLinks()); + List 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 } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/InterClusterConnection.java --- 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 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(); - } - - public ClusterOutputSlotNode getOutputSlotNode() { - return outputSlotNode; - } - - public Port getTo() { - return inputSlot; - } - - public Port getFrom() { - return outputSlot; - } - - public void setControlPoints(List p) { - this.intermediatePoints = p; - } - - public List getControlPoints() { - return intermediatePoints; - } - - @Override - public String toString() { - return "InterClusterConnection[from=" + getFrom() + ", to=" + getTo() + "]"; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Node.java --- 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 graph, N data) { setData(data); this.graph = graph; - inEdges = new ArrayList>(); - outEdges = new ArrayList>(); + inEdges = new ArrayList<>(); + outEdges = new ArrayList<>(); } protected void addInEdge(Edge e) { @@ -125,7 +125,7 @@ } public List> getSuccessors() { - ArrayList> succ = new ArrayList>(); + ArrayList> succ = new ArrayList<>(); for (Edge e : getOutEdges()) { Node n = e.getDest(); if (!succ.contains(n)) { @@ -136,7 +136,7 @@ } public List> getPredecessors() { - ArrayList> pred = new ArrayList>(); + ArrayList> pred = new ArrayList<>(); for (Edge e : getInEdges()) { Node n = e.getSource(); if (!pred.contains(n)) { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java --- 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 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(); - 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 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 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 startPoints; - private List 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(); - endPoints = new ArrayList(); - this.important = true; - } - - public boolean isImportant() { - return important; - } - - public void setImportant(boolean b) { - this.important = b; - } - - public List getStartPoints() { - return startPoints; - } - - public List getEndPoints() { - return endPoints; - } - - public List getAbsoluteEndPoints() { - if (endPoints.size() == 0) { - return endPoints; - } - - List result = new ArrayList(); - 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 getAbsoluteStartPoints() { - if (startPoints.size() == 0) { - return startPoints; - } - - List result = new ArrayList(); - 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 graph; - private Map> 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 nodes, List edges) { - public void doLayout(LayoutGraph layoutGraph) { - doLayout(layoutGraph, new HashSet(), new HashSet()); - } - - public void doLayout(LayoutGraph layoutGraph, Set firstLayerHint, Set lastLayerHint) { - doLayout(layoutGraph, firstLayerHint, lastLayerHint, new HashSet()); - } - - public void doLayout(LayoutGraph layoutGraph, Set firstLayerHint, Set lastLayerHint, Set 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>(); - - graph = new Graph(); - - Set> rootNodes = new HashSet>(); - Set startRootVertices = new HashSet(); - - for (Vertex v : layoutGraph.getVertices()) { - if (v.isRoot()) { - startRootVertices.add(v); - } - } - - rootVertexTiming.start(); - Set rootVertices = layoutGraph.findRootVertices(startRootVertices); - rootVertexTiming.stop(); - - - for (Vertex node : layoutGraph.getVertices()) { - - NodeData data = new NodeData(node); - Node n = graph.createNode(data, node); - nodeMap.put(node, n); - - if (rootVertices.contains(node)) { - rootNodes.add(n); - } - } - - Set links = layoutGraph.getLinks(); - Link[] linkArr = new Link[links.size()]; - links.toArray(linkArr); - - List linkList = new ArrayList(); - for (Link l : linkArr) { - linkList.add(l); - } - - createEdgesTiming.start(); - Collections.sort(linkList, new Comparator() { - - 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 n : graph.getNodes()) { - List> edges = new ArrayList>(n.getOutEdges()); - Collections.sort(edges, new Comparator>() { - - public int compare(Edge o1, Edge o2) { - return o2.getData().getRelativeEnd().x - o1.getData().getRelativeEnd().x; - } - }); - - - for (Edge e : edges) { - - if (e.getData().isReversed()) { - e.getSource().getData().addReversedEndEdge(e); - } - } - } - - for (Node n : graph.getNodes()) { - List> edges = new ArrayList>(n.getInEdges()); - Collections.sort(edges, new Comparator>() { - - public int compare(Edge o1, Edge o2) { - return o2.getData().getRelativeStart().x - o1.getData().getRelativeStart().x; - } - }); - - - for (Edge 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 n : graph.getNodes()) { - // maxLayer = Math.max(maxLayer, n.getData().getLayer()); - //} - - - @SuppressWarnings("unchecked") - ArrayList> layers[] = (ArrayList>[]) new ArrayList[maxLayer + 1]; - int layerSizes[] = new int[maxLayer + 1]; - for (int i = 0; i < maxLayer + 1; i++) { - layers[i] = new ArrayList>(); - } - - for (Node 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 n : graph.getNodes()) { - if (!n.getData().isDummy()) { - - Vertex node = n.getData().getNode(); - node.setPosition(new Point(n.getData().getX(), n.getData().getY())); - } - } - - for (Node n : graph.getNodes()) { - if (!n.getData().isDummy()) { - - Vertex node = n.getData().getNode(); - - List> outEdges = n.getOutEdges(); - for (Edge e : outEdges) { - Node succ = e.getDest(); - if (succ.getData().isDummy()) { - //PositionedEdge edge = succ.getData().getEdge(); - List points = new ArrayList(); - assignToRealObjects(layerSizes, succ, points); - } else { - List points = new ArrayList(); - - 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 cur, List points) { - assert cur.getData().isDummy(); - - ArrayList otherPoints = new ArrayList(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 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 middlePoints = new ArrayList(otherPoints); - if (cur.getOutEdges().get(i).getData().isReversed()) { - Collections.reverse(middlePoints); - } - - ArrayList copy = new ArrayList(); - 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 e : graph.getEdges()) { - if (e.getSource().getData().getLayer() != e.getDest().getData().getLayer() - 1) { - return false; - } - } - - return true; - } - - private void insertDummyNodes(ArrayList> layers[]) { - - int sum = 0; - List> nodes = new ArrayList>(graph.getNodes()); - int edgeCount = 0; - int innerMostLoop = 0; - - for (Node n : nodes) { - List> edges = new ArrayList>(n.getOutEdges()); - for (Edge e : edges) { - - edgeCount++; - Link edge = e.getData().getEdge(); - Node destNode = e.getDest(); - Node lastNode = n; - Edge lastEdge = e; - - boolean searchForNode = (combine != Combine.NONE); - for (int i = n.getData().getLayer() + 1; i < destNode.getData().getLayer(); i++) { - - Node foundNode = null; - if (searchForNode) { - for (Node 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 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> layers[], int layerSizes[]) { - int cur = 0; - for (int i = 0; i < layers.length; i++) { - int maxHeight = 0; - for (Node n : layers[i]) { - maxHeight = Math.max(maxHeight, n.getData().getHeight()); - } - - layerSizes[i] = maxHeight; - for (Node n : layers[i]) { - int curCoordinate = cur + (maxHeight - n.getData().getHeight()) / 2; - n.getData().setLayerCoordinate(curCoordinate); - } - cur += maxHeight + layerOffset; - - } - } - - private void assignCoordinates(ArrayList> layers[]) { - - for (int i = 0; i < layers.length; i++) { - ArrayList> curArray = layers[i]; - int curY = 0; - for (Node 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>() { - - public int compare(Node o1, Node 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 n : graph.getNodes()) { - min = Math.min(min, n.getData().getCoordinate()); - } - - for (Node n : graph.getNodes()) { - n.getData().setCoordinate(n.getData().getCoordinate() - min); - } - - } - - private void optimizeMedian(ArrayList> layers[]) { - - // Downsweep - for (int i = 1; i < layers.length; i++) { - - ArrayList> processingList = layers[i]; - ArrayList> alreadyAssigned = new ArrayList>(); - for (Node n : processingList) { - - - ArrayList> preds = new ArrayList>(n.getPredecessors()); - int pos = n.getData().getCoordinate(); - if (preds.size() > 0) { - - Collections.sort(preds, new Comparator>() { - - public int compare(Node o1, Node 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> processingList = layers[i]; - ArrayList> alreadyAssigned = new ArrayList>(); - for (Node n : processingList) { - - ArrayList> succs = new ArrayList>(n.getSuccessors()); - int pos = n.getData().getCoordinate(); - if (succs.size() > 0) { - - Collections.sort(succs, new Comparator>() { - - public int compare(Node o1, Node 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 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 n, Node succ) { - - if (n.getData().isDummy() && succ.getData().isDummy()) { - return 0; - } - - int pos = 0; - int pos2 = 0; - ArrayList coords2 = new ArrayList(); - ArrayList coords = new ArrayList(); - /*if(!n.getData().isDummy())*/ { - for (Edge 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 n1, Node n2) { - return intersect(n1.getData().getCoordinate(), n1.getData().getWidth() + OFFSET, n2.getData().getCoordinate(), n2.getData().getWidth() + OFFSET); - } - - private void tryAdding(List> alreadyAssigned, Node node, int pos) { - - boolean doesIntersect = false; - node.getData().setCoordinate(pos); - for (Node 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 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 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 curNode = alreadyAssigned.get(i); - Node 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> nodes, Node node) { - - for (Node n1 : nodes) { - if (intersect(n1, node)) { - return true; - } - } - - return false; - } - - private int evaluateSolution() { - - int sum = 0; - for (Edge e : graph.getEdges()) { - Node source = e.getSource(); - Node dest = e.getDest(); - int offset = 0; - offset = Math.abs(source.getData().getCoordinate() - dest.getData().getCoordinate()); - sum += offset; - } - - return sum; - } - - private void crossingReduction(ArrayList> layers[]) { - - for (int i = 0; i < layers.length - 1; i++) { - - ArrayList> curNodes = layers[i]; - ArrayList> nextNodes = layers[i + 1]; - for (Node n : curNodes) { - for (Node succ : n.getSuccessors()) { - if (ASSERT) { - assert nextNodes.contains(succ); - } - nextNodes.remove(succ); - nextNodes.add(succ); - } - } - - } - - } - - private void removeCycles(Set> rootNodes) { - final List> reversedEdges = new ArrayList>(); - - - int removedCount = 0; - int reversedCount = 0; - - Graph.DFSTraversalVisitor visitor = graph.new DFSTraversalVisitor() { - - @Override - public boolean visitEdge(Edge 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> nodes = new HashSet>(); - nodes.addAll(rootNodes); - - assert nodes.size() > 0; - - this.graph.traverseDFS(nodes, visitor); - - for (Edge 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> rootNodes, Set firstLayerHints, - Set lastLayerHints) { - this.maxLayerTemp = -1; - for (Node n : graph.getNodes()) { - n.getData().setLayer(-1); - } - - Graph.BFSTraversalVisitor traverser = graph.new BFSTraversalVisitor() { - - @Override - public void visitNode(Node n, int depth) { - if (depth > n.getData().getLayer()) { - n.getData().setLayer(depth); - maxLayerTemp = Math.max(maxLayerTemp, depth); - } - } - }; - - for (Node 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 e : graph.getEdges()) { - Node source = e.getSource(); - Node dest = e.getDest(); - - - if (source.getData().getLayer() >= dest.getData().getLayer()) { - return false; - } - } - int maxLayer = 0; - for (Node 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 n : graph.getNodes()) { - countPerLayer[n.getData().getLayer()]++; - } - - if (TRACE) { - System.out.println("Number of layers: " + maxLayer); - } - return true; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.java6scriptingproxy. - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/manifest.mf --- 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 - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/build-impl.xml --- 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 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.java6scriptingproxy - - - - com.sun.hotspot.igv.filter - - - - 1.0 - - - - com.sun.hotspot.igv.graph - - - - 1.0 - - - - - com.sun.hotspot.igv.java6scriptingproxy - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/suite.properties --- 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}/.. diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java --- 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(); - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Layout/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java --- 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 { - - public Cluster getOuter(); - - public void setBounds(Rectangle r); - - public Set getSuccessors(); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java --- 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(); - portLinks = new HashMap>(links.size()); - inputPorts = new HashMap>(links.size()); - outputPorts = new HashMap>(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 hashSet = new HashSet(3); + HashSet hashSet = new HashSet<>(3); portLinks.put(p, hashSet); } @@ -152,7 +148,7 @@ // whole graph is visited. public Set findRootVertices(Set startingRoots) { - Set notRootSet = new HashSet(); + Set notRootSet = new HashSet<>(); for (Vertex v : startingRoots) { if (!notRootSet.contains(v)) { markNotRoot(notRootSet, v, v); @@ -174,7 +170,7 @@ } } - Set result = new HashSet(); + Set result = new HashSet<>(); for (Vertex v : tmpVertices) { if (!notRootSet.contains(v)) { result.add(v); @@ -187,16 +183,4 @@ public Set findRootVertices() { return findRootVertices(new HashSet()); } - - public SortedSet getClusters() { - - SortedSet clusters = new TreeSet(); - for (Vertex v : getVertices()) { - if (v.getCluster() != null) { - clusters.add(v.getCluster()); - } - } - - return clusters; - } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Link.java --- 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 getControlPoints(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Vertex.java --- 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 { - public Cluster getCluster(); - public Dimension getSize(); public Point getPosition(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/NetworkConnection/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupReceiver --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java --- 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); - } - }); - } } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.rhino. - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/manifest.mf --- 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 - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml --- 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 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.rhino - - - - com.sun.hotspot.igv.filter - - - - 1.0 - - - - com.sun.hotspot.igv.graph - - - - 1.0 - - - - - com.sun.hotspot.igv.rhino - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/suite.properties --- 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}/.. diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java --- 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, "", 1, null); - } finally { - // Exit from the context. - context_exit.invoke(null, (Object[]) null); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml --- 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 @@ - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java --- 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(this); - highlightedChangedEvent = new ChangedEvent(this); - selectedObjects = new HashSet(); - highlightedObjects = new HashSet(); + selectedChangedEvent = new ChangedEvent<>(this); + highlightedChangedEvent = new ChangedEvent<>(this); + selectedObjects = new HashSet<>(); + highlightedObjects = new HashSet<>(); } public Set getSelectedObjects() { diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.servercompiler - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.graph - - - - 1.0 - - - - com.sun.hotspot.igv.graphtotext - - - - 1.0 - - - - com.sun.hotspot.igv.structuredtext - - - - 1.0 - - - - - - - + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.servercompiler + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + + + + diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java --- 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>> organize(List subFolders, List groups) { - - List>> result = new ArrayList>>(); - - 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 children = new ArrayList(); - children.add(g); - Pair> p = new Pair>(); - p.setLeft(reducedNameProvider.getName(g)); - p.setRight(children); - result.add(p); - } - } else { - result.add(new Pair>("", groups)); - } - - return result; - } - - private void buildResult(List>> result, List groups, NameProvider provider) { - HashMap> map = new HashMap>(groups.size()); - for (Group g : groups) { - String s = provider.getName(g); - - if (!map.containsKey(s)) { - List list = new ArrayList(); - Pair> pair = new Pair>(s, list); - result.add(pair); - map.put(s, list); - } - - List curList = map.get(s); - curList.add(g); - } - - Collections.sort(result, new Comparator>>() { - - public int compare(Pair> a, Pair> 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 = ""; - - 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 = ""; - - 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; - } - }; -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerGraphToTextConverter.java --- 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> map; - private Map> ingoingEdges; - private Map> outgoingEdges; - private InputGraph graph; - - private Collection sortNodes(Collection nodes) { - List result = new ArrayList(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(graph.getNodes()).selectSingle(MATCHER) != null; - } - - private Color calcColor(InputNode node) { - Set
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; - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java --- 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 succs = new HashSet(); - public List preds = new ArrayList(); + public Set succs = new HashSet<>(); + public List preds = new ArrayList<>(); public InputBlock block; public boolean isBlockProjection; public boolean isBlockStart; @@ -65,6 +55,7 @@ private InputBlock[][] commonDominator; private static final Comparator edgeComparator = new Comparator() { + @Override public int compare(InputEdge o1, InputEdge o2) { return o1.getToIndex() - o2.getToIndex(); } @@ -72,13 +63,13 @@ public void buildBlocks() { - blocks = new Vector(); + blocks = new Vector<>(); Node root = findRoot(); if (root == null) { return; } - Stack stack = new Stack(); - Set visited = new HashSet(); + Stack stack = new Stack<>(); + Set visited = new HashSet<>(); stack.add(root); int blockCount = 0; InputBlock rootBlock = null; @@ -179,7 +170,7 @@ } int z = 0; - blockIndex = new HashMap(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 schedule(InputGraph graph) { if (graph.getNodes().isEmpty()) { return Collections.emptyList(); } if (graph.getBlocks().size() > 0) { - Collection tmpNodes = new ArrayList(graph.getNodes()); + Collection 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(); - inputNodeToNode = new HashMap(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 reachable = new HashSet(); + Set reachable = new HashSet<>(); reachable.add(root); - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.push(root); while (!stack.isEmpty()) { Node cur = stack.pop(); @@ -255,7 +247,7 @@ } } - Set unscheduled = new HashSet(); + Set 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 newUnscheduled = new HashSet(); + Set newUnscheduled = new HashSet<>(); for (Node n : unscheduled) { InputBlock block = null; @@ -305,7 +297,7 @@ } } - Set curReachable = new HashSet(reachable); + Set 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 reachable) { assert !reachable.contains(n); - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.push(n); n.block = b; b.addNode(n.inputNode.getId()); @@ -376,7 +368,7 @@ if (ba == bb) { return ba; } - Set visited = new HashSet(); + Set visited = new HashSet<>(); while (ba != null) { visited.add(ba); ba = dominatorMap.get(ba); @@ -394,12 +386,12 @@ } public void buildDominators() { - dominatorMap = new HashMap(graph.getBlocks().size()); + dominatorMap = new HashMap<>(graph.getBlocks().size()); if (blocks.size() == 0) { return; } - Vector intermediate = new Vector(graph.getBlocks().size()); - Map map = new HashMap(graph.getBlocks().size()); + Vector intermediate = new Vector<>(graph.getBlocks().size()); + Map 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(); - bi.bucket = new ArrayList(); + bi.pred = new ArrayList<>(); + bi.bucket = new ArrayList<>(); intermediate.add(bi); map.put(b, bi); z++; } - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.add(0); - Vector array = new Vector(); + Vector array = new Vector<>(); intermediate.get(0).dominator = 0; int n = 0; @@ -597,7 +589,7 @@ inputNodeToNode.put(n, node); } - Map> edgeMap = new HashMap>(graph.getEdges().size()); + Map> edgeMap = new HashMap<>(graph.getEdges().size()); for (InputEdge e : graph.getEdges()) { int to = e.getTo(); diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsCategory.java --- 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(); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsPanelController.java --- 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); } diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.structuredtext. - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/manifest.mf --- 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 - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/build-impl.xml --- 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 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/platform.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.structuredtext - - - - com.sun.hotspot.igv.structuredtext - com.sun.hotspot.igv.structuredtext.services - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/suite.properties --- 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}/.. diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java --- 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 source; - private Style style; - private Style highlightedStyle; - - public Element() { - source = new HashSet(); - 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 getSource() { - return Collections.unmodifiableSet(source); - } - - public void addSource(Object o) { - source.add(o); - } - - public abstract void accept(ElementVisitor visitor); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java --- 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 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(); - } - - 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 getChildren() { - return Collections.unmodifiableList(children); - } - - public void accept(ElementVisitor visitor) { - visitor.visit(this); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java --- 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; - } - -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java --- 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); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java --- 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 calculateRanges() { - - final Map result = new HashMap(); - - 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(); - } -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java --- 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(); - -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java --- 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); -} diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/build.xml --- 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 @@ - - - - - - Builds, tests, and runs the project com.sun.hotspot.igv.texteditor. - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/manifest.mf --- 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 - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/build-impl.xml --- 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 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/genfiles.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/platform.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.xml --- 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 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.texteditor - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.selectioncoordinator - - - - 1.0 - - - - com.sun.hotspot.igv.structuredtext - - - - 1.0 - - - - org.netbeans.modules.editor - - - - 3 - 1.42.2.3.9.2 - - - - org.netbeans.modules.editor.deprecated.pre65formatting - - - - 0-1 - 1.4.1.1.5.13.10 - - - - org.netbeans.modules.editor.fold - - - - 1 - 1.8 - - - - org.netbeans.modules.editor.lib - - - - 3 - 3.8.1.13.9 - - - - org.netbeans.modules.editor.lib2 - - - - 1 - 1.11.2.2 - - - - org.openide.text - - - - 6.18 - - - - org.openide.util - - - - 7.12.0.1 - - - - org.openide.util.lookup - - - - 8.8.1 - - - - org.openide.windows - - - - 6.20 - - - - - com.sun.hotspot.igv.texteditor - - - - diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/suite.properties --- 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}/.. diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties --- 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 diff -r b197bbb58d2f -r 9f8e4aeec1a9 src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java --- 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 { - - 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 highlightedSource = new HashSet(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 selectedSource = new HashSet(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()); - } - }); - } - - 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 ranges; - private int currentIndex; - - public HighlightsSequenceImpl() { - this(new ArrayList()); - } - - public HighlightsSequenceImpl(List 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 s1, Set 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 ranges = text.calculateRanges(); - final List highlightsRanges = new ArrayList(); - final Range baseRange = new Range(start, end - start); - - text.accept(new ElementVisitor() { - - private Stack