changeset 4531:3a309467fc8e

Merge
author Christian Haeubl <christian.haeubl@oracle.com>
date Wed, 08 Feb 2012 21:15:00 -0800
parents 6c6cb7be1324 (diff) 681e969888a7 (current diff)
children 6dda62bf5be4
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/AssignRegisters.java 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/LinearScanAllocator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/ResolveDataFlow.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/alloc/util/IntervalPrinter.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/Location.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/LocationMap.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/MoveResolver.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/RegisterVerifier.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/ValueUtil.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LIRInsertionBuffer.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/ExceptionInfo.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/cfg/Block.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/cfg/BlockMap.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/cfg/CFGVerifier.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/cfg/ControlFlowGraph.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/cfg/Loop.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/FrameMap.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRDebugInfo.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRInstruction.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRPhiMapping.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRVerifier.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRXirInstruction.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LabelRef.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/StandardOp.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/Variable.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/observer/CompilationEvent.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/observer/CompilationObserver.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/observer/ObservableContext.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/observer/package-info.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Arithmetic.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Call.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Compare.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ControlFlow.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRInstruction.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Move.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64SlowPath.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveCookie.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/customLeftWsmode.xml src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.png src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.png src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.png src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.png src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/build-impl.xml src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.xml src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Bundle.properties src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/onlyControlFlow.filter src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/LookupHistory.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/BoundedZoomAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewer.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.form src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ExportCookie.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ExtendedSatelliteComponent.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/GraphViewerImplementation.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/CustomizablePanAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExportAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/NextDiagramAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/OverviewAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PanModeAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PrevDiagramAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/SelectionModeAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ShowAllAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomInAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomOutAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/export.png src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/next_diagram.png src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/prev_diagram.png src/share/vm/graal/graalCompilerToVM.cpp
diffstat 18 files changed, 215 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiExceptionSeen.java	Wed Feb 08 21:15:00 2012 -0800
@@ -0,0 +1,37 @@
+/*
+ * 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.cri.ri;
+
+
+/**
+ * Represents the three possibilities that an exception was seen at a specific BCI.
+ */
+public enum RiExceptionSeen {
+    TRUE,
+    FALSE,
+    UNKNOWN;
+
+    public static RiExceptionSeen get(boolean value) {
+        return value ? TRUE : FALSE;
+    }
+}
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java	Wed Feb 08 21:15:00 2012 -0800
@@ -50,10 +50,12 @@
     RiTypeProfile getTypeProfile(int bci);
 
     /**
-     * Returns true if the instruction at least once an exception was thrown at the given BCI.
-     * @return true if an exception was encountered during profiling, false otherwise.
+     * Returns information if the given BCI did ever throw an exception.
+     * @return @link{RiExceptionSeen.TRUE} if the instruction has thrown an exception at least once,
+     * @link{RiExceptionSeen.FALSE} if it never threw an exception, and @link{RiExceptionSeen.UNKNOWN}
+     * if this information was not recorded.
      */
-    boolean getExceptionSeen(int bci);
+    RiExceptionSeen getExceptionSeen(int bci);
 
     /**
      * Returns an estimate how often the current BCI was executed. Avoid comparing execution counts to each other,
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedMethod.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedMethod.java	Wed Feb 08 21:15:00 2012 -0800
@@ -49,6 +49,12 @@
     int codeSize();
 
     /**
+     * Gets the size of the compiled machine code.
+     * @return the size of the compiled machine code in bytes, or 0 if no compiled code exists.
+     */
+    int compiledCodeSize();
+
+    /**
      * Gets the symbol used to link this method if it is native, otherwise {@code null}.
      */
     String jniSymbol();
@@ -211,4 +217,9 @@
      * @return {@code true} if this method can be inlined
      */
     boolean canBeInlined();
+
+    /**
+     * Dumps the recorded profiling information to TTY.
+     */
+    void dumpProfile();
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Feb 08 21:15:00 2012 -0800
@@ -44,18 +44,23 @@
     public static boolean CacheGraphs                        = ____;
     public static boolean InlineMonomorphicCalls             = true;
     public static boolean InlinePolymorphicCalls             = true;
+    public static boolean InlineMegamorphicCalls             = true;
     public static int     InliningPolicy                     = 0;
-    public static int     MaximumInlineSize                  = 35;
-    public static int     MaximumFreqInlineSize              = 300;
-    public static float   NestedInliningSizeRatio            = 0.9f;
-    public static int     FreqInlineRatio                    = 20;
     public static int     MaximumTrivialSize                 = 6;
     public static int     MaximumInlineLevel                 = 30;
     public static int     MaximumDesiredSize                 = 6000;
+    // WeightBasedInliningPolicy (0)
     public static boolean ParseBeforeInlining                = ____;
     public static float   InliningSizePenaltyExp             = 20;
     public static float   MaximumInlineWeight                = 1.25f;
     public static float   InliningSizePenalty                = 1;
+    // StaticSizeBasedInliningPolicy (1), DynamicSizeBasedInliningPolicy (2), GreedySizeBasedInlining (3)
+    public static int     MaximumInlineSize                  = 35;
+    public static float   NestedInliningSizeRatio            = 0.9f;
+    public static float   BoostInliningForEscapeAnalysis     = 2f;
+    public static float   ProbabilityCapForInlining          = 1f;
+    public static int     MaximumGreedyInlineSize            = 250;
+    public static int     SmallCompiledCodeSize              = 1500;
 
     // escape analysis settings
     public static boolean EscapeAnalysis                     = true;
@@ -129,7 +134,7 @@
     public static int     MatureInvocationCount              = 100;
     public static boolean GenSafepoints                      = true;
     public static boolean GenLoopSafepoints                  = true;
-    public static boolean UseInstanceOfHints                 = true;
+    public static boolean UseTypeCheckHints                  = true;
 
     public static boolean GenAssertionCode                   = ____;
     public static boolean AlignCallsForPatching              = true;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Wed Feb 08 21:15:00 2012 -0800
@@ -191,7 +191,11 @@
         if (GraalOptions.InliningPolicy == 0) {
             return new WeightBasedInliningPolicy();
         } else if (GraalOptions.InliningPolicy == 1) {
-            return new SizeBasedInliningPolicy();
+            return new StaticSizeBasedInliningPolicy();
+        } else if (GraalOptions.InliningPolicy == 2) {
+            return new DynamicSizeBasedInliningPolicy();
+        } else if (GraalOptions.InliningPolicy == 3) {
+            return new GreedySizeBasedInliningPolicy();
         } else {
             GraalInternalError.shouldNotReachHere();
             return null;
@@ -272,14 +276,14 @@
         }
     }
 
-    private class SizeBasedInliningPolicy implements InliningPolicy {
+    private class StaticSizeBasedInliningPolicy implements InliningPolicy {
         @Override
         public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) {
+            double codeSize = method.codeSize();
             if (preferredInvoke) {
-                return method.codeSize() / 2;
-            } else {
-                return method.codeSize();
+                codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis;
             }
+            return codeSize;
         }
 
         @Override
@@ -288,4 +292,51 @@
             return info.weight <= maxSize;
         }
     }
+
+    private class DynamicSizeBasedInliningPolicy implements InliningPolicy {
+        @Override
+        public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) {
+            double codeSize = method.codeSize();
+            if (preferredInvoke) {
+                codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis;
+            }
+            return codeSize;
+        }
+
+        @Override
+        public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) {
+            assert GraalOptions.ProbabilityAnalysis;
+            if (info.compiledCodeSize() <= GraalOptions.SmallCompiledCodeSize) {
+                double inlineBoost = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability());
+                double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize;
+                maxSize = maxSize + maxSize * inlineBoost;
+                maxSize = Math.max(GraalOptions.MaximumTrivialSize, maxSize);
+                return info.weight <= maxSize;
+            }
+            return false;
+        }
+    }
+
+    private class GreedySizeBasedInliningPolicy implements InliningPolicy {
+        @Override
+        public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) {
+            double codeSize = method.codeSize();
+            if (preferredInvoke) {
+                codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis;
+            }
+            return codeSize;
+        }
+
+        @Override
+        public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) {
+            assert GraalOptions.ProbabilityAnalysis;
+            if (info.compiledCodeSize() <= GraalOptions.SmallCompiledCodeSize) {
+                double inlineRatio = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability());
+                double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumGreedyInlineSize * inlineRatio;
+                maxSize = Math.max(maxSize, GraalOptions.MaximumInlineSize);
+                return info.weight <= maxSize;
+            }
+            return false;
+        }
+    }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Wed Feb 08 21:15:00 2012 -0800
@@ -82,6 +82,8 @@
             this.level = level;
         }
 
+        public abstract int compiledCodeSize();
+
         @Override
         public int compareTo(InlineInfo o) {
             return (weight < o.weight) ? -1 : (weight > o.weight) ? 1 : 0;
@@ -128,6 +130,11 @@
         }
 
         @Override
+        public int compiledCodeSize() {
+            return concrete.compiledCodeSize();
+        }
+
+        @Override
         public String toString() {
             return "exact inlining " + CiUtil.format("%H.%n(%p):%r", concrete);
         }
@@ -153,6 +160,11 @@
         }
 
         @Override
+        public int compiledCodeSize() {
+            return concrete.compiledCodeSize();
+        }
+
+        @Override
         public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) {
             // receiver null check must be before the type check
             InliningUtil.receiverNullCheck(invoke);
@@ -206,6 +218,15 @@
         }
 
         @Override
+        public int compiledCodeSize() {
+            int result = 0;
+            for (RiResolvedMethod m: concretes) {
+                result += m.compiledCodeSize();
+            }
+            return result;
+        }
+
+        @Override
         public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) {
             int numberOfMethods = concretes.size();
             boolean hasReturnValue = invoke.node().kind() != CiKind.Void;
@@ -384,9 +405,12 @@
                 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
                 BeginNode exceptionEdge = invokeWithException.exceptionEdge();
                 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next();
+                FrameState stateAfter = exceptionObject.stateAfter();
 
                 BeginNode newExceptionEdge = (BeginNode) exceptionEdge.copyWithInputs();
                 ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs();
+                // set new state (pop old exception object, push new one)
+                newExceptionObject.setStateAfter(stateAfter.duplicateModified(stateAfter.bci, stateAfter.rethrowException(), CiKind.Object, newExceptionObject));
                 newExceptionEdge.setNext(newExceptionObject);
 
                 EndNode endNode = graph.add(new EndNode());
@@ -401,7 +425,7 @@
 
         @Override
         public String toString() {
-            StringBuilder builder = new StringBuilder(String.format("type-checked inlining of %d methods with %d type checks: ", concretes.size(), types.length));
+            StringBuilder builder = new StringBuilder(String.format("inlining %d methods with %d type checks: ", concretes.size(), types.length));
             for (int i = 0; i < concretes.size(); i++) {
                 builder.append(CiUtil.format("  %H.%n(%p):%r", concretes.get(i)));
             }
@@ -518,7 +542,7 @@
                     if (GraalOptions.InlineMonomorphicCalls) {
                         RiResolvedType type = types[0];
                         RiResolvedMethod concrete = type.resolveMethodImpl(callTarget.targetMethod());
-                        if (concrete != null && checkTargetConditions(concrete)) {
+                        if (checkTargetConditions(concrete)) {
                             double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke);
                             return new TypeGuardInlineInfo(invoke, weight, level, concrete, type);
                         }
@@ -530,7 +554,7 @@
                         return null;
                     }
                 } else {
-                    if (GraalOptions.InlinePolymorphicCalls) {
+                    if (GraalOptions.InlinePolymorphicCalls && notRecordedTypeProbability == 0 || GraalOptions.InlineMegamorphicCalls && notRecordedTypeProbability > 0) {
                         // TODO (ch) inlining of multiple methods should work differently
                         // 1. check which methods can be inlined
                         // 2. for those methods, use weight and probability to compute which of them should be inlined
@@ -556,7 +580,7 @@
                         double totalWeight = 0;
                         boolean canInline = true;
                         for (RiResolvedMethod concrete: concreteMethods) {
-                            if (concrete == null || !checkTargetConditions(concrete)) {
+                            if (!checkTargetConditions(concrete)) {
                                 canInline = false;
                                 break;
                             }
@@ -613,6 +637,10 @@
     }
 
     private static boolean checkTargetConditions(RiMethod method) {
+        if (method == null) {
+            Debug.log("method not resolved");
+            return false;
+        }
         if (!(method instanceof RiResolvedMethod)) {
             Debug.log("not inlining %s because it is unresolved", method.toString());
             return false;
@@ -738,6 +766,7 @@
                     frameState.replaceAndDelete(stateAfter);
                 } else if (frameState.bci == FrameState.AFTER_EXCEPTION_BCI) {
                     if (frameState.isAlive()) {
+                        // TODO (ch) it happens sometimes that we have a FrameState.AFTER_EXCEPTION_BCI but no stateAtExceptionEdge
                         assert stateAtExceptionEdge != null;
                         frameState.replaceAndDelete(stateAtExceptionEdge);
                     } else {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java	Wed Feb 08 21:15:00 2012 -0800
@@ -99,6 +99,8 @@
 
     boolean RiMethod_hasCompiledCode(HotSpotMethodResolved method);
 
+    int RiMethod_getCompiledCodeSize(HotSpotMethodResolved method);
+
     RiMethod getRiMethod(Method reflectionMethod);
 
     long getMaxCallTargetOffset(CiRuntimeCall rtcall);
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java	Wed Feb 08 21:15:00 2012 -0800
@@ -145,6 +145,9 @@
     public native boolean RiMethod_hasCompiledCode(HotSpotMethodResolved method);
 
     @Override
+    public native int RiMethod_getCompiledCodeSize(HotSpotMethodResolved method);
+
+    @Override
     public native long getMaxCallTargetOffset(CiRuntimeCall rtcall);
 
     @Override
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Wed Feb 08 21:15:00 2012 -0800
@@ -44,7 +44,8 @@
 
     // TODO (ch) use same logic as in NodeClass?
     private static final Unsafe unsafe = Unsafe.getUnsafe();
-    private static final HotSpotMethodDataAccessor NO_DATA_ACCESSOR = new NoMethodData();
+    private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(RiExceptionSeen.FALSE);
+    private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLE_ACCESSOR = new NoMethodData(RiExceptionSeen.UNKNOWN);
     private static final HotSpotVMConfig config;
     // sorted by tag
     private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = {
@@ -109,8 +110,12 @@
         return getData(position);
     }
 
-    public static HotSpotMethodDataAccessor getNoMethodData() {
-        return NO_DATA_ACCESSOR;
+    public static HotSpotMethodDataAccessor getNoDataNoExceptionAccessor() {
+        return NO_DATA_NO_EXCEPTION_ACCESSOR;
+    }
+
+    public static HotSpotMethodDataAccessor getNoDataExceptionPossibleAccessor() {
+        return NO_DATA_EXCEPTION_POSSIBLE_ACCESSOR;
     }
 
     private HotSpotMethodDataAccessor getData(int position) {
@@ -196,8 +201,8 @@
         }
 
         @Override
-        public boolean getExceptionSeen(HotSpotMethodData data, int position) {
-            return (getFlags(data, position) & EXCEPTIONS_MASK) != 0;
+        public RiExceptionSeen getExceptionSeen(HotSpotMethodData data, int position) {
+            return RiExceptionSeen.get((getFlags(data, position) & EXCEPTIONS_MASK) != 0);
         }
 
         @Override
@@ -233,8 +238,11 @@
         private static final int NO_DATA_TAG = 0;
         private static final int NO_DATA_SIZE = cellIndexToOffset(0);
 
-        protected NoMethodData() {
+        private final RiExceptionSeen exceptionSeen;
+
+        protected NoMethodData(RiExceptionSeen exceptionSeen) {
             super(NO_DATA_TAG, NO_DATA_SIZE);
+            this.exceptionSeen = exceptionSeen;
         }
 
         @Override
@@ -244,8 +252,8 @@
 
 
         @Override
-        public boolean getExceptionSeen(HotSpotMethodData data, int position) {
-            return false;
+        public RiExceptionSeen getExceptionSeen(HotSpotMethodData data, int position) {
+            return exceptionSeen;
         }
     }
 
@@ -363,7 +371,11 @@
             return createRiTypeProfile(sparseTypes, counts, totalCount, entries);
         }
 
-        protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position);
+        protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
+            // checkcast/aastore/instanceof profiling in the HotSpot template-based interpreter was adjusted so that the counter
+            // is incremented to indicate the polymorphic case instead of decrementing it for failed type checks
+            return getCounterValue(data, position);
+        }
 
         private static RiTypeProfile createRiTypeProfile(RiResolvedType[] sparseTypes, double[] counts, long totalCount, int entries) {
             RiResolvedType[] types;
@@ -410,12 +422,6 @@
         public int getExecutionCount(HotSpotMethodData data, int position) {
             return -1;
         }
-
-        @Override
-        protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
-            // TODO (ch) if types do not fit, profiling is skipped for typechecks
-            return 0;
-        }
     }
 
     private static class VirtualCallData extends AbstractTypeData {
@@ -437,11 +443,6 @@
             total += getCounterValue(data, position);
             return truncateLongToInt(total);
         }
-
-        @Override
-        protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
-            return getCounterValue(data, position);
-        }
     }
 
     private static class RetData extends CounterData {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java	Wed Feb 08 21:15:00 2012 -0800
@@ -51,6 +51,6 @@
     RiTypeProfile getTypeProfile(HotSpotMethodData data, int position);
     double getBranchTakenProbability(HotSpotMethodData data, int position);
     double[] getSwitchProbabilities(HotSpotMethodData data, int position);
-    boolean getExceptionSeen(HotSpotMethodData data, int position);
+    RiExceptionSeen getExceptionSeen(HotSpotMethodData data, int position);
     int getExecutionCount(HotSpotMethodData data, int position);
 }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Wed Feb 08 21:15:00 2012 -0800
@@ -178,6 +178,10 @@
         return compiler.getVMEntries().RiMethod_hasCompiledCode(this);
     }
 
+    public int compiledCodeSize() {
+        return compiler.getVMEntries().RiMethod_getCompiledCodeSize(this);
+    }
+
     @Override
     public RiResolvedType accessor() {
         return null;
@@ -242,8 +246,8 @@
                 TTY.println();
             }
 
-            if (profilingInfo.getExceptionSeen(i)) {
-                TTY.println("  exceptionSeen@%d: true", i);
+            if (profilingInfo.getExceptionSeen(i) != RiExceptionSeen.FALSE) {
+                TTY.println("  exceptionSeen@%d: %s", i, profilingInfo.getExceptionSeen(i).name());
             }
 
             RiTypeProfile typeProfile = profilingInfo.getTypeProfile(i);
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java	Wed Feb 08 21:15:00 2012 -0800
@@ -32,7 +32,7 @@
      *
      */
     private static final long serialVersionUID = 4357945025049704109L;
-    private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoMethodData();
+    private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoDataExceptionPossibleAccessor();
 
     public HotSpotNoProfilingInfo(Compiler compiler) {
         super(compiler);
@@ -54,7 +54,7 @@
     }
 
     @Override
-    public boolean getExceptionSeen(int bci) {
+    public RiExceptionSeen getExceptionSeen(int bci) {
         return noData.getExceptionSeen(null, -1);
     }
 
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java	Wed Feb 08 21:15:00 2012 -0800
@@ -66,7 +66,7 @@
     }
 
     @Override
-    public boolean getExceptionSeen(int bci) {
+    public RiExceptionSeen getExceptionSeen(int bci) {
         findBCI(bci, true);
         return dataAccessor.getExceptionSeen(methodData, position);
     }
@@ -95,6 +95,7 @@
             }
         }
 
+        boolean exceptionPossiblyNotRecorded = false;
         if (searchExtraData && methodData.hasExtraData()) {
             int currentPosition = methodData.getExtraDataBeginOffset();
             HotSpotMethodDataAccessor currentAccessor;
@@ -106,11 +107,11 @@
                 }
                 currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition);
             }
+
+            exceptionPossiblyNotRecorded = !methodData.isWithin(currentPosition);
         }
 
-        // TODO (ch) getExceptionSeen() should return UNKNOWN if not enough extra data
-
-        noDataFound();
+        noDataFound(exceptionPossiblyNotRecorded);
     }
 
     private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) {
@@ -123,8 +124,9 @@
         setCurrentData(data, pos);
     }
 
-    private void noDataFound() {
-        setCurrentData(HotSpotMethodData.getNoMethodData(), -1);
+    private void noDataFound(boolean exceptionPossible) {
+        HotSpotMethodDataAccessor accessor = exceptionPossible ? HotSpotMethodData.getNoDataNoExceptionAccessor() : HotSpotMethodData.getNoDataNoExceptionAccessor();
+        setCurrentData(accessor, -1);
     }
 
     private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java	Wed Feb 08 21:15:00 2012 -0800
@@ -1185,7 +1185,7 @@
            }
 
            asm.mov(checkHub, hub);
-           // if we get an exact match: continue
+           // if we get an exact match: continue.
            asm.jneq(falseSucc, objHub, checkHub);
 
            return asm.finishTemplate("typeCheck");
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java	Wed Feb 08 21:15:00 2012 -0800
@@ -388,7 +388,7 @@
             case PUTFIELD:
             case GETFIELD: {
                 if (GraalOptions.AllowExplicitExceptionChecks) {
-                    return profilingInfo.getExceptionSeen(bci);
+                    return profilingInfo.getExceptionSeen(bci) != RiExceptionSeen.FALSE;
                 }
             }
         }
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Wed Feb 08 19:25:29 2012 -0800
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Wed Feb 08 21:15:00 2012 -0800
@@ -323,7 +323,8 @@
         assert bci == FrameState.BEFORE_BCI || bci == bci() : "invalid bci";
 
         if (GraalOptions.UseExceptionProbability && method.invocationCount() > GraalOptions.MatureInvocationCount) {
-            if (bci != FrameState.BEFORE_BCI && exceptionObject == null && !profilingInfo.getExceptionSeen(bci)) {
+            // be conservative if information was not recorded (could result in endless recompiles otherwise)
+            if (bci != FrameState.BEFORE_BCI && exceptionObject == null && profilingInfo.getExceptionSeen(bci) == RiExceptionSeen.FALSE) {
                 return null;
             }
         }
@@ -691,7 +692,7 @@
     private static final RiResolvedType[] EMPTY_TYPE_ARRAY = new RiResolvedType[0];
 
     private RiResolvedType[] getTypeCheckHints(RiResolvedType type, int maxHints) {
-        if (!GraalOptions.UseInstanceOfHints || Util.isFinalClass(type)) {
+        if (!GraalOptions.UseTypeCheckHints || Util.isFinalClass(type)) {
             return new RiResolvedType[] {type};
         } else {
             RiResolvedType uniqueSubtype = type.uniqueConcreteSubtype();
--- a/src/cpu/x86/vm/interp_masm_x86_64.cpp	Wed Feb 08 19:25:29 2012 -0800
+++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp	Wed Feb 08 21:15:00 2012 -0800
@@ -1126,8 +1126,11 @@
                                         Register receiver, Register mdp,
                                         Register reg2, int start_row,
                                         Label& done, bool is_virtual_call) {
+  // change for GRAAL (use counter to indicate polymorphic case instead of failed typechecks)
+  bool use_counter_for_polymorphic_case = is_virtual_call || UseGraal;
+
   if (TypeProfileWidth == 0) {
-    if (is_virtual_call) {
+    if (use_counter_for_polymorphic_case) {
       increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
     }
     return;
@@ -1164,7 +1167,7 @@
       testptr(reg2, reg2);
       if (start_row == last_row) {
         // The only thing left to do is handle the null case.
-        if (is_virtual_call) {
+        if (use_counter_for_polymorphic_case) {
           jccb(Assembler::zero, found_null);
           // Receiver did not match any saved receiver and there is no empty row for it.
           // Increment total counter to indicate polymorphic case.
@@ -1297,7 +1300,8 @@
 
 
 void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) {
-  if (ProfileInterpreter && TypeProfileCasts) {
+  // changed for GRAAL (use counter to indicate polymorphism instead of failed typechecks)
+  if (ProfileInterpreter && TypeProfileCasts && !UseGraal) {
     Label profile_continue;
 
     // If no method data exists, go to profile_continue.
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed Feb 08 19:25:29 2012 -0800
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Feb 08 21:15:00 2012 -0800
@@ -239,6 +239,13 @@
   return getMethodFromHotSpotMethod(hotspot_method)->has_compiled_code();
 }
 
+// public native int RiMethod_getCompiledCodeSize(HotSpotMethodResolved method);
+JNIEXPORT jint JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_RiMethod_1getCompiledCodeSize(JNIEnv *env, jobject, jobject hotspot_method) {
+  TRACE_graal_3("CompilerToVM::RiMethod_getCompiledCodeSize");
+  nmethod* code = getMethodFromHotSpotMethod(hotspot_method)->code();
+  return code == NULL ? 0 : code->insts_size();
+}
+
 // public RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass);
 JNIEXPORT jobject JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve) {
   TRACE_graal_3("CompilerToVM::RiSignature_lookupType");
@@ -939,6 +946,7 @@
   {CC"HotSpotMethodData_isMature",        CC"("METHOD_DATA")Z",                       FN_PTR(HotSpotMethodData_1isMature)},
   {CC"RiMethod_invocationCount",          CC"("RESOLVED_METHOD")I",                   FN_PTR(RiMethod_1invocationCount)},
   {CC"RiMethod_hasCompiledCode",          CC"("RESOLVED_METHOD")Z",                   FN_PTR(RiMethod_1hasCompiledCode)},
+  {CC"RiMethod_getCompiledCodeSize",      CC"("RESOLVED_METHOD")I",                   FN_PTR(RiMethod_1getCompiledCodeSize)},
   {CC"RiSignature_lookupType",            CC"("STRING RESOLVED_TYPE"Z)"TYPE,          FN_PTR(RiSignature_1lookupType)},
   {CC"RiConstantPool_lookupConstant",     CC"("RESOLVED_TYPE"I)"OBJECT,               FN_PTR(RiConstantPool_1lookupConstant)},
   {CC"RiConstantPool_lookupMethod",       CC"("RESOLVED_TYPE"IB)"METHOD,              FN_PTR(RiConstantPool_1lookupMethod)},