changeset 4353:043bec543161

More work on debug framework. Removed concept of GraalContext.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 17 Jan 2012 23:35:21 +0100
parents 5a84f5548fc4
children 3abb137806c7
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalContext.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java
diffstat 17 files changed, 207 insertions(+), 327 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java	Tue Jan 17 23:35:21 2012 +0100
@@ -35,21 +35,20 @@
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure;
 import com.oracle.max.graal.compiler.schedule.*;
+import com.oracle.max.graal.debug.*;
 
 public class DataFlowAnalysis {
-    private final GraalContext context;
     private final LIR lir;
     private final RiRegisterConfig registerConfig;
 
-    public DataFlowAnalysis(GraalContext context, LIR lir, RiRegisterConfig registerConfig) {
-        this.context = context;
+    public DataFlowAnalysis(LIR lir, RiRegisterConfig registerConfig) {
         this.lir = lir;
         this.registerConfig = registerConfig;
     }
 
     public void execute() {
         numberInstructions();
-        context.observable.fireCompilationEvent("After instruction numbering", lir);
+        Debug.dump(lir, "After instruction numbering");
         backwardDataFlow();
     }
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java	Tue Jan 17 23:35:21 2012 +0100
@@ -39,20 +39,19 @@
 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;
 
-        this.dataFlow = new DataFlowAnalysis(context, lir, frameMap.registerConfig);
+        this.dataFlow = new DataFlowAnalysis(lir, frameMap.registerConfig);
         this.blockLocations = new LocationMap[lir.linearScanOrder().size()];
         this.moveResolver = new MoveResolverImpl(frameMap);
     }
@@ -137,18 +136,18 @@
         allocate();
         frameMap.finish();
 
-        context.observable.fireCompilationEvent("After spill all allocation", lir);
+        Debug.dump(lir, "After spill all allocation");
 
         ResolveDataFlow resolveDataFlow = new ResolveDataFlowImpl(lir, moveResolver);
         resolveDataFlow.execute();
 
-        context.observable.fireCompilationEvent("After resolve data flow", lir);
+        Debug.dump(lir, "After resolve data flow");
         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(true, lir, frameMap);
     }
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java	Tue Jan 17 23:35:21 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,7 +35,6 @@
 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.*;
@@ -46,8 +46,6 @@
 
 public class GraalCompiler {
 
-    public final GraalContext context;
-
     /**
      * The target that this compiler has been configured for.
      */
@@ -68,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;
@@ -84,121 +81,116 @@
         if (osrBCI != -1) {
             throw new CiBailout("No OSR supported");
         }
-        final CiTargetMethod[] result = new CiTargetMethod[1];
-        Debug.scope("CompileMethod", new Runnable() {
-                public void run() {
-                        TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method);
-                        CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null;
-                        LIR lir = emitHIR(graph, assumptions, plan);
+        return Debug.scope("CompileMethod", method, new Callable<CiTargetMethod>() {
+                public CiTargetMethod call() {
+                        final CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null;
+                        LIR lir = Debug.scope("EmitHIR", graph, new Callable<LIR>() {
+                            public LIR call() {
+                                return emitHIR(graph, assumptions, plan);
+                            }
+                        });
                         FrameMap frameMap = emitLIR(lir, graph, method);
-                        result[0] = emitCode(assumptions, method, lir, frameMap);
+                        return emitCode(assumptions, method, lir, frameMap);
                 }
-        }, method);
-        return result[0];
+        });
     }
 
     /**
      * 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");
+        }
 
-            if (graph.start().next() == null) {
-                plan.runPhases(PhasePosition.AFTER_PARSING, graph);
-                new DeadCodeEliminationPhase().apply(graph);
-            } else {
-                if (context.isObserved()) {
-                    context.observable.fireCompilationEvent("initial state", graph);
-                }
-            }
+        new PhiStampPhase().apply(graph);
 
-            new PhiStampPhase().apply(graph);
+        if (GraalOptions.ProbabilityAnalysis && graph.start().probability() == 0) {
+            new ComputeProbabilityPhase().apply(graph);
+        }
 
-            if (GraalOptions.ProbabilityAnalysis && graph.start().probability() == 0) {
-                new ComputeProbabilityPhase().apply(graph);
-            }
-
-            if (GraalOptions.Intrinsify) {
-                new IntrinsificationPhase(runtime).apply(graph);
-            }
+        if (GraalOptions.Intrinsify) {
+            new IntrinsificationPhase(runtime).apply(graph);
+        }
 
-            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);
+            new DeadCodeEliminationPhase().apply(graph);
+            new PhiStampPhase().apply(graph);
+        }
 
-            if (GraalOptions.OptCanonicalizer) {
-                new CanonicalizerPhase(target, runtime, assumptions).apply(graph);
-            }
+        if (GraalOptions.OptCanonicalizer) {
+            new CanonicalizerPhase(target, runtime, assumptions).apply(graph);
+        }
 
-            plan.runPhases(PhasePosition.HIGH_LEVEL, graph);
+        plan.runPhases(PhasePosition.HIGH_LEVEL, graph);
 
-            if (GraalOptions.OptLoops) {
-                graph.mark();
-                new FindInductionVariablesPhase().apply(graph);
-                if (GraalOptions.OptCanonicalizer) {
-                    new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
-                }
-                new SafepointPollingEliminationPhase().apply(graph);
+        if (GraalOptions.OptLoops) {
+            graph.mark();
+            new FindInductionVariablesPhase().apply(graph);
+            if (GraalOptions.OptCanonicalizer) {
+                new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
             }
+            new SafepointPollingEliminationPhase().apply(graph);
+        }
 
-            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);
+            new PhiStampPhase().apply(graph);
+            new CanonicalizerPhase(target, runtime, assumptions).apply(graph);
+        }
 
-            if (GraalOptions.OptGVN) {
-                new GlobalValueNumberingPhase().apply(graph);
-            }
+        if (GraalOptions.OptGVN) {
+            new GlobalValueNumberingPhase().apply(graph);
+        }
 
-            graph.mark();
-            new LoweringPhase(runtime).apply(graph);
-            new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
+        graph.mark();
+        new LoweringPhase(runtime).apply(graph);
+        new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
 
-            if (GraalOptions.OptLoops) {
-                graph.mark();
-                new RemoveInductionVariablesPhase().apply(graph);
-                if (GraalOptions.OptCanonicalizer) {
-                    new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
-                }
+        if (GraalOptions.OptLoops) {
+            graph.mark();
+            new RemoveInductionVariablesPhase().apply(graph);
+            if (GraalOptions.OptCanonicalizer) {
+                new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
             }
-
-            if (GraalOptions.Lower) {
-                new FloatingReadPhase().apply(graph);
-                if (GraalOptions.OptReadElimination) {
-                    new ReadEliminationPhase().apply(graph);
-                }
-            }
-            new RemovePlaceholderPhase().apply(graph);
-            new DeadCodeEliminationPhase().apply(graph);
+        }
 
-            plan.runPhases(PhasePosition.MID_LEVEL, graph);
-
-            plan.runPhases(PhasePosition.LOW_LEVEL, graph);
+        if (GraalOptions.Lower) {
+            new FloatingReadPhase().apply(graph);
+            if (GraalOptions.OptReadElimination) {
+                new ReadEliminationPhase().apply(graph);
+            }
+        }
+        new RemovePlaceholderPhase().apply(graph);
+        new DeadCodeEliminationPhase().apply(graph);
 
-            IdentifyBlocksPhase schedule = new IdentifyBlocksPhase(true, LIRBlock.FACTORY);
-            schedule.apply(graph);
+        plan.runPhases(PhasePosition.MID_LEVEL, graph);
 
-            if (context.isObserved()) {
-                context.observable.fireCompilationEvent("After IdentifyBlocksPhase", graph, schedule);
-            }
+        plan.runPhases(PhasePosition.LOW_LEVEL, graph);
+
+        final IdentifyBlocksPhase schedule = new IdentifyBlocksPhase(true, LIRBlock.FACTORY);
+        schedule.apply(graph);
 
-            List<Block> blocks = schedule.getBlocks();
-            NodeMap<LIRBlock> valueToBlock = new NodeMap<>(graph);
-            for (Block b : blocks) {
-                for (Node i : b.getInstructions()) {
-                    valueToBlock.set(i, (LIRBlock) b);
-                }
+        final List<Block> blocks = schedule.getBlocks();
+        final NodeMap<LIRBlock> valueToBlock = new NodeMap<>(graph);
+        for (Block b : blocks) {
+            for (Node i : b.getInstructions()) {
+                valueToBlock.set(i, (LIRBlock) b);
             }
-            LIRBlock startBlock = valueToBlock.get(graph.start());
-            assert startBlock != null;
-            assert startBlock.numberOfPreds() == 0;
+        }
+        final LIRBlock startBlock = valueToBlock.get(graph.start());
+        assert startBlock != null;
+        assert startBlock.numberOfPreds() == 0;
 
-            context.timers.startScope("Compute Linear Scan Order");
-            try {
+        return Debug.scope("Compute Linear Scan Order", new Callable<LIR>() {
+
+            @Override
+            public LIR call() {
                 ComputeLinearScanOrder clso = new ComputeLinearScanOrder(blocks.size(), schedule.loopCount(), startBlock);
                 List<LIRBlock> linearScanOrder = clso.linearScanOrder();
                 List<LIRBlock> codeEmittingOrder = clso.codeEmittingOrder();
@@ -209,36 +201,19 @@
                 }
 
                 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);
+                    lirGenerator = backend.newLIRGenerator(graph, frameMap, method, lir, xir);
 
                     for (LIRBlock b : lir.linearScanOrder()) {
                         lirGenerator.doBlock(b);
@@ -249,39 +224,18 @@
                             b.phis.fillInputs(lirGenerator);
                         }
                     }
-                } finally {
-                    context.timers.endScope();
-                }
 
-                if (context.isObserved()) {
-                    context.observable.fireCompilationEvent("After LIR generation", graph, lir, lirGenerator);
-                }
+                Debug.dump(lirGenerator, "After LIR generation");
                 if (GraalOptions.PrintLIR && !TTY.isSuppressed()) {
                     LIR.printLIR(lir.linearScanOrder());
                 }
 
                 if (GraalOptions.AllocSSA) {
-                    new SpillAllAllocator(context, lir, frameMap).execute();
+                    new SpillAllAllocator(lir, frameMap).execute();
                 } else {
-                    new LinearScan(context, target, method, graph, lir, lirGenerator, frameMap).allocate();
+                    new LinearScan(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);
-            }
-            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();
-        }
     }
 
     private TargetMethodAssembler createAssembler(FrameMap frameMap, LIR lir) {
@@ -293,26 +247,15 @@
     }
 
     public CiTargetMethod emitCode(CiAssumptions assumptions, RiResolvedMethod method, LIR lir, FrameMap frameMap) {
-        if (GraalOptions.GenLIR && GraalOptions.GenCode) {
-            context.timers.startScope("Create Code");
-            try {
-                TargetMethodAssembler tasm = createAssembler(frameMap, lir);
-                lir.emitCode(tasm);
+        TargetMethodAssembler tasm = createAssembler(frameMap, lir);
+        lir.emitCode(tasm);
 
-                CiTargetMethod targetMethod = tasm.finishTargetMethod(method, false);
-                if (assumptions != null && !assumptions.isEmpty()) {
-                    targetMethod.setAssumptions(assumptions);
-                }
-
-                if (context.isObserved()) {
-                    context.observable.fireCompilationEvent("After code generation", lir, targetMethod);
-                }
-                return targetMethod;
-            } finally {
-                context.timers.endScope();
-            }
+        CiTargetMethod targetMethod = tasm.finishTargetMethod(method, false);
+        if (assumptions != null && !assumptions.isEmpty()) {
+            targetMethod.setAssumptions(assumptions);
         }
 
-        return null;
+        Debug.dump(targetMethod, "After code generation");
+        return targetMethod;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalContext.java	Mon Jan 16 18:49:12 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +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();
-
-    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.Time) {
-                timers.print();
-            }
-        }
-    }
-}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Tue Jan 17 23:35:21 2012 +0100
@@ -126,8 +126,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            = ____;
     public static boolean AllowExplicitExceptionChecks       = true;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Tue Jan 17 23:35:21 2012 +0100
@@ -41,6 +41,7 @@
 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.*;
 
@@ -51,7 +52,6 @@
  */
 public final class LinearScan {
 
-    final GraalContext context;
     final CiTarget target;
     final RiMethod method;
     final LIR ir;
@@ -122,8 +122,7 @@
     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, StructuredGraph graph, LIR ir, LIRGenerator gen, FrameMap frameMap) {
         this.target = target;
         this.method = method;
         this.graph = graph;
@@ -1786,8 +1785,15 @@
         }
     }
 
+    private static final Debug.Timer timerLifetimeAnalysis = Debug.timer("LifetimeAnalysis");
+    private static final Debug.Timer timerLinearScan = Debug.timer("LinearScan");
+    private static final Debug.Timer timerLinearScanResolution = Debug.timer("LinearScanResolution");
+    private static final Debug.Timer timerDebugInfo = Debug.timer("DebugInfo");
+    private static final Debug.Timer timerControlFlowOptimizations = Debug.timer("ControlFlowOptimizations");
+
     public void allocate() {
-        context.timers.startScope("Lifetime Analysis");
+
+        timerLifetimeAnalysis.start();
         try {
             numberInstructions();
 
@@ -1799,27 +1805,27 @@
             buildIntervals();
             sortIntervalsBeforeAllocation();
         } finally {
-            context.timers.endScope();
+            timerLifetimeAnalysis.stop();
         }
 
-        context.timers.startScope("Linear Scan");
+        timerLinearScan.start();
         try {
             printIntervals("Before register allocation");
 
             allocateRegisters();
 
         } finally {
-            context.timers.endScope();
+            timerLinearScan.stop();
         }
 
-        context.timers.startScope("Resolution");
+        timerLinearScanResolution.start();
         try {
             resolveDataFlow();
         } finally {
-            context.timers.endScope();
+            timerLinearScanResolution.stop();
         }
 
-        context.timers.startScope("Create Debug Info");
+        timerDebugInfo.start();
         try {
             frameMap.finish();
 
@@ -1839,17 +1845,17 @@
                 verifyIntervals();
             }
         } finally {
-            context.timers.endScope();
+            timerDebugInfo.stop();
         }
 
-        context.timers.startScope("Control Flow Optimizations");
+        timerControlFlowOptimizations.start();
         try {
             printLir("After register number assignment", true);
             EdgeMoveOptimizer.optimize(ir.linearScanOrder());
             ControlFlowOptimizer.optimize(ir);
             printLir("After control flow optimization", false);
         } finally {
-            context.timers.endScope();
+            timerControlFlowOptimizations.stop();
         }
     }
 
@@ -1875,9 +1881,7 @@
             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) {
@@ -1888,9 +1892,7 @@
             TTY.println();
         }
 
-        if (context.isObserved()) {
-            context.observable.fireCompilationEvent(label, hirValid ? graph : null, ir);
-        }
+        Debug.dump(ir, label);
     }
 
     boolean verify() {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Tue Jan 17 23:35:21 2012 +0100
@@ -64,8 +64,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 +137,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;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Tue Jan 17 23:35:21 2012 +0100
@@ -42,7 +42,7 @@
     }
 
     public final void apply(final StructuredGraph graph) {
-        Debug.scope(name, new Runnable() { public void run() { Phase.this.run(graph); }});
+        Debug.scope(name, this, new Runnable() { public void run() { Phase.this.run(graph); }});
     }
 
     public final String getName() {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java	Tue Jan 17 23:35:21 2012 +0100
@@ -28,7 +28,6 @@
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
 import com.oracle.max.cri.xir.*;
-import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.gen.*;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.graph.*;
@@ -57,7 +56,7 @@
     }
 
     public abstract FrameMap newFrameMap(RiRegisterConfig registerConfig);
-    public abstract LIRGenerator newLIRGenerator(GraalContext context, Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir);
+    public abstract LIRGenerator newLIRGenerator(Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir);
     public abstract AbstractAssembler newAssembler(RiRegisterConfig registerConfig);
     public abstract CiXirAssembler newXirAssembler();
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java	Tue Jan 17 23:35:21 2012 +0100
@@ -27,7 +27,6 @@
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
 import com.oracle.max.cri.xir.*;
-import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.gen.*;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.target.*;
@@ -47,8 +46,8 @@
      * @return an appropriate LIR generator instance
      */
     @Override
-    public LIRGenerator newLIRGenerator(GraalContext context, Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) {
-        return new AMD64LIRGenerator(context, graph, runtime, target, frameMap, method, lir, xir);
+    public LIRGenerator newLIRGenerator(Graph graph, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir) {
+        return new AMD64LIRGenerator(graph, runtime, target, frameMap, method, lir, xir);
     }
 
     @Override
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Jan 17 23:35:21 2012 +0100
@@ -40,7 +40,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.util.*;
@@ -72,8 +71,8 @@
         StandardOpcode.XIR = AMD64XirOpcode.XIR;
     }
 
-    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();
     }
 
--- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java	Tue Jan 17 23:35:21 2012 +0100
@@ -26,6 +26,7 @@
 import com.oracle.max.graal.debug.internal.MetricImpl;
 import com.oracle.max.graal.debug.internal.TimerImpl;
 import java.util.Collections;
+import java.util.concurrent.*;
 
 
 public class Debug {
@@ -34,22 +35,38 @@
     public static boolean METER = false;
     public static boolean TIME = false;
 
-    public static void scope(String name, Runnable runnable, Object... context) {
+    public static void sandbox(String name, Runnable runnable) {
         if (SCOPE) {
-            DebugScope.getInstance().scope(name, runnable, false, context);
+            DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]);
         } else {
             runnable.run();
         }
     }
 
-    public static void sandbox(String name, Runnable runnable, Object... context) {
+    public static void scope(String name, Runnable runnable) {
+        scope(name, null, runnable);
+    }
+
+    public static <T> T scope(String name, Callable<T> callable) {
+        return scope(name, null, callable);
+    }
+
+    public static void scope(String name, Object context, Runnable runnable) {
         if (SCOPE) {
-            DebugScope.getInstance().scope(name, runnable, true, context);
+            DebugScope.getInstance().scope(name, runnable, null, false, new Object[]{context});
         } else {
             runnable.run();
         }
     }
 
+    public static <T> T scope(String name, Object context, Callable<T> callable) {
+        if (SCOPE) {
+            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 (LOG) {
             DebugScope.getInstance().log(msg, args);
--- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java	Tue Jan 17 23:35:21 2012 +0100
@@ -25,6 +25,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.concurrent.*;
 
 
 public final class DebugScope {
@@ -56,7 +57,7 @@
     public void log(String msg, Object... args) {
     }
 
-    public void scope(String newName, Runnable runnable, boolean sandbox, Object... newContext) {
+    public <T> T scope(String newName, Runnable runnable, Callable<T> callable, boolean sandbox, Object[] newContext) {
         DebugScope oldContext = getInstance();
         DebugScope newChild = null;
         if (sandbox) {
@@ -65,21 +66,28 @@
             oldContext.createChild(newName, newContext);
         }
         instance.set(newChild);
+        T result = null;
         try {
-            runnable.run();
-        } catch (Throwable t) {
-            interceptException(t);
-            throw t;
+            if (runnable != null) {
+                runnable.run();
+            }
+            if (callable != null) {
+                call(callable);
+            }
+        } catch (RuntimeException e) {
+            throw interceptException(e);
         } finally {
             instance.set(oldContext);
         }
+        return result;
     }
 
     public DebugValueMap getValueMap() {
         return valueMap;
     }
 
-    private void interceptException(Throwable t) {
+    private RuntimeException interceptException(RuntimeException e) {
+        return e;
     }
 
     long getCurrentValue(int index) {
@@ -136,5 +144,17 @@
             }
         };
     }
+
+    public static <T> T call(Callable<T> callable) {
+        try {
+            return callable.call();
+        } catch (Exception e) {
+            if (e instanceof RuntimeException) {
+                throw (RuntimeException) e;
+            } else {
+                throw new RuntimeException(e);
+            }
+        }
+    }
 }
 
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java	Tue Jan 17 23:35:21 2012 +0100
@@ -90,7 +90,6 @@
     private final CompilerToVM vmEntries;
     private final VMToCompiler vmExits;
 
-    private GraalContext context;
     private HotSpotRuntime runtime;
     private GraalCompiler compiler;
     private CiTarget target;
@@ -163,7 +162,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,9 +215,8 @@
     @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;
@@ -227,9 +225,10 @@
                 } else {
                     observer = new IdealGraphPrinterObserver(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort);
                 }
-                context.addCompilationObserver(observer);
+//                context.addCompilationObserver(observer);
+                // TODO(tw): Install observer.
             }
-            runtime = new HotSpotRuntime(context, config, this);
+            runtime = new HotSpotRuntime(config, this);
         }
         return runtime;
     }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Jan 17 23:35:21 2012 +0100
@@ -153,7 +153,8 @@
     }
 
     public void shutdownCompiler() throws Throwable {
-        compiler.getCompiler().context.print();
+//        compiler.getCompiler().context.print();
+        // TODO(tw): Print context results.
         compileQueue.shutdown();
     }
 
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java	Tue Jan 17 23:35:21 2012 +0100
@@ -48,14 +48,12 @@
  * CRI runtime implementation for the HotSpot VM.
  */
 public class HotSpotRuntime implements GraalRuntime {
-    final GraalContext context;
     final HotSpotVMConfig config;
     final HotSpotRegisterConfig regConfig;
     private final HotSpotRegisterConfig globalStubRegConfig;
     private final Compiler compiler;
 
-    public HotSpotRuntime(GraalContext context, HotSpotVMConfig config, Compiler compiler) {
-        this.context = context;
+    public HotSpotRuntime(HotSpotVMConfig config, Compiler compiler) {
         this.config = config;
         this.compiler = compiler;
         regConfig = new HotSpotRegisterConfig(config, false);
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java	Mon Jan 16 18:49:12 2012 +0100
+++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java	Tue Jan 17 23:35:21 2012 +0100
@@ -27,7 +27,6 @@
 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.*;
@@ -45,43 +44,29 @@
 
     public static void install(GraalRuntime runtime, CiTarget target, SnippetsInterface obj, boolean plotGraphs, PhasePlan plan) {
         Class<? extends SnippetsInterface> clazz = obj.getClass();
-        GraalContext context = new GraalContext("Installing Snippet");
         BoxingMethodPool pool = new BoxingMethodPool(runtime);
         if (clazz.isAnnotationPresent(ClassSubstitution.class)) {
-            installSubstitution(runtime, target, plotGraphs, plan, clazz, context, pool, clazz.getAnnotation(ClassSubstitution.class).value());
+            installSubstitution(runtime, target, plotGraphs, plan, clazz, pool, clazz.getAnnotation(ClassSubstitution.class).value());
         } else {
-            installSnippets(runtime, target, plotGraphs, plan, clazz, context, pool);
+            installSnippets(runtime, target, plotGraphs, 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, boolean plotGraphs, 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, plotGraphs, 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, boolean plotGraphs, PhasePlan plan, Class< ? extends SnippetsInterface> clazz,
                     BoxingMethodPool pool, Class<?> original) throws GraalInternalError {
         for (Method snippet : clazz.getDeclaredMethods()) {
             try {
@@ -94,39 +79,28 @@
                     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, plotGraphs, 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) {
+    private static StructuredGraph buildSnippetGraph(RiResolvedMethod snippetRiMethod, GraalRuntime runtime, CiTarget target, 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);
+        StructuredGraph graph = buildSnippetGraph(snippetRiMethod, runtime, target, 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, IdealGraphPrinterObserver observer) {
 
         GraphBuilderConfiguration config = GraphBuilderConfiguration.getDeoptFreeDefault();
         GraphBuilderPhase graphBuilder = new GraphBuilderPhase(runtime, config);
@@ -146,7 +120,7 @@
             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, observer);
                 }
                 InliningUtil.inline(invoke, targetGraph, true);
                 new CanonicalizerPhase(target, runtime, null).apply(graph);