changeset 3098:2fb14099d069

fix for unresolved exception bug, exactType and declaredType logic for inlining, more on escape analysis
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 29 Jun 2011 19:52:51 +0200
parents f34c90b89f54
children 28484c5f00d7
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionObject.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/NewInstance.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.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/phases/Phase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotField.java graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotTypeResolvedImpl.java graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotXirGenerator.java src/share/vm/graal/graalVMEntries.cpp
diffstat 15 files changed, 134 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java	Wed Jun 29 19:52:51 2011 +0200
@@ -123,7 +123,7 @@
         IdentifyBlocksPhase schedule = null;
         try {
             schedule = new IdentifyBlocksPhase(true);
-            schedule.apply(graph);
+            schedule.apply(graph, false);
         } catch (Throwable t) {
             // nothing to do here...
             //t.printStackTrace();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Wed Jun 29 19:52:51 2011 +0200
@@ -90,7 +90,7 @@
         //printGraph("After DeadCodeElimination", compilation.graph);
 
         if (GraalOptions.Inline) {
-            new InliningPhase(compilation, this, null, GraalOptions.TraceInlining).apply(compilation.graph);
+            new InliningPhase(compilation, this, null).apply(compilation.graph);
         }
 
         Graph graph = compilation.graph;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionObject.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionObject.java	Wed Jun 29 19:52:51 2011 +0200
@@ -29,9 +29,10 @@
 /**
  * The {@code ExceptionObject} instruction represents the incoming exception object to an exception handler.
  */
-public final class ExceptionObject extends FixedNodeWithNext {
+public final class ExceptionObject extends StateSplit {
 
     private static final int INPUT_COUNT = 0;
+
     private static final int SUCCESSOR_COUNT = 0;
 
     /**
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/NewInstance.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/NewInstance.java	Wed Jun 29 19:52:51 2011 +0200
@@ -125,7 +125,7 @@
             } else if (usage instanceof LoadField) {
                 LoadField x = (LoadField) usage;
                 assert x.object() == node;
-                return false;
+                return x.field().isResolved() == false;
             } else if (usage instanceof StoreField) {
                 StoreField x = (StoreField) usage;
                 return x.value() == node;
@@ -193,8 +193,8 @@
                 if (current instanceof LoadField) {
                     LoadField x = (LoadField) current;
                     if (x.object() == node) {
+                        assert fieldState.get(field) != null : field + ", " + ((AccessField) current).field() + ((AccessField) current).field().hashCode();
                         for (Node usage : new ArrayList<Node>(x.usages())) {
-                            assert fieldState.get(field) != null;
                             usage.inputs().replace(x, fieldState.get(field));
                         }
                         assert x.usages().size() == 0;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java	Wed Jun 29 19:52:51 2011 +0200
@@ -143,7 +143,11 @@
             }
             str.append(valueAt(i) == null ? "-" : valueAt(i).id());
         }
-        return "Phi: (" + str + ")";
+        if (isDead()) {
+            return "Phi: dead (" + str + ")";
+        } else {
+            return "Phi: (" + str + ")";
+        }
     }
 
     public void addInput(Node y) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java	Wed Jun 29 19:52:51 2011 +0200
@@ -310,7 +310,8 @@
                         }
                         break;
                     }
-                    new InliningPhase(compilation, ir, invokes, GraalOptions.TraceInlining).apply(graph);
+                    new InliningPhase(compilation, ir, invokes).apply(graph);
+                    new DeadCodeEliminationPhase().apply(graph);
                     exits.clear();
                     invokes.clear();
                 } while (iterations++ < 3);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Wed Jun 29 19:52:51 2011 +0200
@@ -436,12 +436,17 @@
             p.setStateAfter(frameState.duplicateWithoutStack(bci));
 
             Value currentExceptionObject;
+            ExceptionObject newObj = null;
             if (exceptionObject == null) {
-                currentExceptionObject = new ExceptionObject(graph);
+                newObj = new ExceptionObject(graph);
+                currentExceptionObject = newObj;
             } else {
                 currentExceptionObject = exceptionObject;
             }
             FrameState stateWithException = frameState.duplicateWithException(bci, currentExceptionObject);
+            if (newObj != null) {
+                newObj.setStateAfter(stateWithException);
+            }
             FixedNode target = createTarget(dispatchBlock, stateWithException);
             if (exceptionObject == null) {
                 ExceptionObject eObj = (ExceptionObject) currentExceptionObject;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Wed Jun 29 19:52:51 2011 +0200
@@ -39,7 +39,7 @@
 
 public class InliningPhase extends Phase {
 
-    public static HashMap<RiMethod, Integer> methodCount = new HashMap<RiMethod, Integer>();
+    public static final HashMap<RiMethod, Integer> methodCount = new HashMap<RiMethod, Integer>();
 
     private final GraalCompilation compilation;
     private final IR ir;
@@ -48,14 +48,12 @@
     private final Queue<RiMethod> methods = new ArrayDeque<RiMethod>();
 
     private int inliningSize;
-    private final boolean trace;
     private final Collection<Invoke> hints;
 
-    public InliningPhase(GraalCompilation compilation, IR ir, Collection<Invoke> hints, boolean trace) {
+    public InliningPhase(GraalCompilation compilation, IR ir, Collection<Invoke> hints) {
         this.compilation = compilation;
         this.ir = ir;
         this.hints = hints;
-        this.trace = trace;
     }
 
     private void addToQueue(Invoke invoke, RiMethod method) {
@@ -110,11 +108,10 @@
                     methodCount.put(method, methodCount.get(method) + 1);
                 }
             }
-            DeadCodeEliminationPhase dce = new DeadCodeEliminationPhase();
-            dce.apply(graph);
+            new DeadCodeEliminationPhase().apply(graph);
 
             if (inliningSize > GraalOptions.MaximumInstructionCount) {
-                if (trace) {
+                if (GraalOptions.TraceInlining) {
                     TTY.println("inlining stopped: MaximumInstructionCount reached");
                 }
                 break;
@@ -122,7 +119,7 @@
             ratio *= GraalOptions.MaximumInlineRatio;
         }
 
-        if (trace) {
+        if (GraalOptions.TraceInlining) {
             int inlined = 0;
             int duplicate = 0;
             for (Map.Entry<RiMethod, Integer> entry : methodCount.entrySet()) {
@@ -135,55 +132,84 @@
         }
     }
 
-    private void inlineInvoke(Invoke invoke, int iterations, float ratio) {
+    private boolean inlineInvoke(Invoke invoke, int iterations, float ratio) {
         RiMethod parent = invoke.stateAfter().method();
         RiTypeProfile profile = parent.typeProfile(invoke.bci);
         if (!checkInvokeConditions(invoke)) {
-            return;
+            return false;
         }
         if (invoke.opcode() == Bytecodes.INVOKESPECIAL || invoke.target.canBeStaticallyBound()) {
             if (checkTargetConditions(invoke.target, iterations) && checkSizeConditions(invoke.target, invoke, profile, ratio)) {
                 addToQueue(invoke, invoke.target);
+                return true;
+            }
+            return false;
+        }
+        if (invoke.receiver().exactType() != null) {
+            RiType exact = invoke.receiver().exactType();
+            assert exact.isSubtypeOf(invoke.target().holder()) : exact + " subtype of " + invoke.target().holder();
+            RiMethod resolved = exact.resolveMethodImpl(invoke.target());
+            if (checkTargetConditions(resolved, iterations) && checkSizeConditions(resolved, invoke, profile, ratio)) {
+                addToQueue(invoke, resolved);
+                return true;
+            }
+            return false;
+        }
+        RiType holder = invoke.target().holder();
+
+        if (invoke.receiver().declaredType() != null) {
+            RiType declared = invoke.receiver().declaredType();
+            // the invoke target might be more specific than the holder (happens after inlining: locals lose their declared type...)
+            // TODO (ls) fix this
+            if (declared.isResolved() && declared.isSubtypeOf(invoke.target().holder())) {
+                holder = declared;
+            }
+        }
+
+        RiMethod concrete = holder.uniqueConcreteMethod(invoke.target);
+        if (concrete != null) {
+            if (checkTargetConditions(concrete, iterations) && checkSizeConditions(concrete, invoke, profile, ratio)) {
+                if (GraalOptions.TraceInlining) {
+                    String targetName = CiUtil.format("%H.%n(%p):%r", invoke.target, false);
+                    String concreteName = CiUtil.format("%H.%n(%p):%r", concrete, false);
+                    TTY.println("recording concrete method assumption: %s -> %s", targetName, concreteName);
+                }
+                compilation.assumptions.recordConcreteMethod(invoke.target, concrete);
+                addToQueue(invoke, concrete);
+                return true;
+            }
+            return false;
+        }
+        if (profile != null && profile.probabilities != null && profile.probabilities.length > 0 && profile.morphism == 1) {
+            if (GraalOptions.InlineWithTypeCheck) {
+                // type check and inlining...
+                concrete = profile.types[0].resolveMethodImpl(invoke.target);
+                if (concrete != null && checkTargetConditions(concrete, iterations) && checkSizeConditions(concrete, invoke, profile, ratio)) {
+                    IsType isType = new IsType(invoke.receiver(), profile.types[0], compilation.graph);
+                    FixedGuard guard = new FixedGuard(graph);
+                    guard.setNode(isType);
+                    assert invoke.predecessors().size() == 1;
+                    invoke.predecessors().get(0).successors().replace(invoke, guard);
+                    guard.setNext(invoke);
+
+                    if (GraalOptions.TraceInlining) {
+                        TTY.println("inlining with type check, type probability: %5.3f", profile.probabilities[0]);
+                    }
+                    addToQueue(invoke, concrete);
+                    return true;
+                }
+                return false;
+            } else {
+                if (GraalOptions.TraceInlining) {
+                    TTY.println("not inlining %s because GraalOptions.InlineWithTypeCheck == false", methodName(invoke.target, invoke));
+                }
+                return false;
             }
         } else {
-            RiMethod concrete = invoke.target.holder().uniqueConcreteMethod(invoke.target);
-            if (concrete != null) {
-                if (checkTargetConditions(concrete, iterations) && checkSizeConditions(concrete, invoke, profile, ratio)) {
-                    if (trace) {
-                        String targetName = CiUtil.format("%H.%n(%p):%r", invoke.target, false);
-                        String concreteName = CiUtil.format("%H.%n(%p):%r", concrete, false);
-                        TTY.println("recording concrete method assumption: %s -> %s", targetName, concreteName);
-                    }
-                    compilation.assumptions.recordConcreteMethod(invoke.target, concrete);
-                    addToQueue(invoke, concrete);
-                }
-            } else if (profile != null && profile.probabilities != null && profile.probabilities.length > 0 && profile.morphism == 1) {
-                if (GraalOptions.InlineWithTypeCheck) {
-                    // type check and inlining...
-                    concrete = profile.types[0].resolveMethodImpl(invoke.target);
-                    if (concrete != null && checkTargetConditions(concrete, iterations) && checkSizeConditions(concrete, invoke, profile, ratio)) {
-                        IsType isType = new IsType(invoke.receiver(), profile.types[0], compilation.graph);
-                        FixedGuard guard = new FixedGuard(graph);
-                        guard.setNode(isType);
-                        assert invoke.predecessors().size() == 1;
-                        invoke.predecessors().get(0).successors().replace(invoke, guard);
-                        guard.setNext(invoke);
-
-                        if (trace) {
-                            TTY.println("inlining with type check, type probability: %5.3f", profile.probabilities[0]);
-                        }
-                        addToQueue(invoke, concrete);
-                    }
-                } else {
-                    if (trace) {
-                        TTY.println("not inlining %s because GraalOptions.InlineWithTypeCheck is false", methodName(invoke.target, invoke));
-                    }
-                }
-            } else {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because no monomorphic receiver could be found", methodName(invoke.target, invoke));
             }
-        }
+            return false;
         }
     }
 
@@ -202,31 +228,31 @@
 
     private boolean checkInvokeConditions(Invoke invoke) {
         if (invoke.stateAfter() == null) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because the invoke has no after state", methodName(invoke.target, invoke));
             }
             return false;
         }
         if (invoke.stateAfter().locksSize() > 0) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because of locks", methodName(invoke.target, invoke));
             }
             return false;
         }
         if (!invoke.target.isResolved()) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because the invoke target is unresolved", methodName(invoke.target, invoke));
             }
             return false;
         }
         if (invoke.predecessors().size() == 0) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because the invoke is dead code", methodName(invoke.target, invoke));
             }
             return false;
         }
         if (invoke.stateAfter() == null) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because of missing frame state", methodName(invoke.target, invoke));
             }
         }
@@ -235,31 +261,31 @@
 
     private boolean checkTargetConditions(RiMethod method, int iterations) {
         if (!method.isResolved()) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because it is unresolved", methodName(method));
             }
             return false;
         }
         if (Modifier.isNative(method.accessFlags())) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because it is a native method", methodName(method));
             }
             return false;
         }
         if (Modifier.isAbstract(method.accessFlags())) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because it is an abstract method", methodName(method));
             }
             return false;
         }
         if (!method.holder().isInitialized()) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because of non-initialized class", methodName(method));
             }
             return false;
         }
         if (method == compilation.method && iterations > GraalOptions.MaximumRecursiveInlineLevel) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because of recursive inlining limit", methodName(method));
             }
             return false;
@@ -273,7 +299,7 @@
             maximumSize = GraalOptions.MaximumFreqInlineSize;
         }
         if (method.codeSize() > maximumSize) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because of code size (size: %d, max size: %d)", methodName(method, invoke), method.codeSize(), GraalOptions.MaximumInlineSize);
             }
             return false;
@@ -297,12 +323,12 @@
             maximumSize = GraalOptions.MaximumFreqInlineSize;
         }
         if (method.codeSize() > maximumSize) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("not inlining %s because of code size (size: %d, max size: %d, ratio %5.3f, %s)", methodName(method, invoke), method.codeSize(), maximumSize, ratio, profile);
             }
             return false;
         }
-        if (trace) {
+        if (GraalOptions.TraceInlining) {
             TTY.println("inlining %s (size: %d, max size: %d, ratio %5.3f, %s)", methodName(method, invoke), method.codeSize(), maximumSize, ratio, profile);
         }
         return true;
@@ -318,12 +344,12 @@
         CompilerGraph graph;
         Object stored = GraphBuilderPhase.cachedGraphs.get(method);
         if (stored != null) {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("Reusing graph for %s, locals: %d, stack: %d", methodName(method, invoke), method.maxLocals(), method.maxStackSize());
             }
             graph = (CompilerGraph) stored;
         } else {
-            if (trace) {
+            if (GraalOptions.TraceInlining) {
                 TTY.println("Building graph for %s, locals: %d, stack: %d", methodName(method, invoke), method.maxLocals(), method.maxStackSize());
             }
             graph = new CompilerGraph(null);
@@ -369,7 +395,7 @@
             }
         }
 
-        if (trace) {
+        if (GraalOptions.TraceInlining) {
             TTY.println("inlining %s: %d frame states, %d nodes", methodName(method), frameStates.size(), nodes.size());
         }
 
@@ -458,7 +484,7 @@
             }
         }
 
-        if (trace) {
+        if (GraalOptions.TraceInlining) {
             ir.printGraph("After inlining " + CiUtil.format("%H.%n(%p):%r", method, false), compilation.graph);
         }
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Wed Jun 29 19:52:51 2011 +0200
@@ -48,6 +48,10 @@
     }
 
     public final void apply(Graph graph) {
+        apply(graph, true);
+    }
+
+    public final void apply(Graph graph, boolean plotOnError) {
         assert graph != null && (!shouldVerify || graph.verify());
 
         int startDeletedNodeCount = graph.getDeletedNodeCount();
@@ -66,13 +70,13 @@
             run(graph);
         } catch (AssertionError t) {
             GraalCompilation compilation = GraalCompilation.compilation();
-            if (compilation.compiler.isObserved() && this.getClass() != IdentifyBlocksPhase.class) {
+            if (compilation.compiler.isObserved() && plotOnError) {
                 compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, "AssertionError in " + getName(), graph, true, false, true));
             }
             throw t;
         } catch (RuntimeException t) {
             GraalCompilation compilation = GraalCompilation.compilation();
-            if (compilation.compiler.isObserved() && this.getClass() != IdentifyBlocksPhase.class) {
+            if (compilation.compiler.isObserved() && plotOnError) {
                 compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, "RuntimeException in " + getName(), graph, true, false, true));
             }
             throw t;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Wed Jun 29 19:52:51 2011 +0200
@@ -125,6 +125,7 @@
                         break;
                     }
                     currentNode = currentNode.singlePredecessor();
+                    assert !currentNode.isDeleted();
                 }
             }
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java	Wed Jun 29 19:52:51 2011 +0200
@@ -509,7 +509,7 @@
     }
 
     public FrameState duplicateWithoutStack(int bci) {
-        FrameState frameState = new FrameState(method, bci, locals, new Value[0], 0, locks, true, graph);
+        FrameState frameState = new FrameState(method, bci, locals, new Value[0], 0, locks, false, graph);
         frameState.setOuterFrameState(outerFrameState());
         return frameState;
     }
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotField.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotField.java	Wed Jun 29 19:52:51 2011 +0200
@@ -95,18 +95,18 @@
         return holder;
     }
 
-    @Override
-    public boolean equals(Object obj) {
-        if (obj instanceof HotSpotField) {
-            HotSpotField other = (HotSpotField) obj;
-            return other.offset == offset && other.holder.equals(holder());
-        }
-        return false;
-    }
+//    @Override
+//    public boolean equals(Object obj) {
+//        if (obj instanceof HotSpotField) {
+//            HotSpotField other = (HotSpotField) obj;
+//            return other.offset == offset && other.holder.equals(holder());
+//        }
+//        return false;
+//    }
 
     @Override
     public boolean isResolved() {
-        return offset != -1;
+        return holder.isResolved();
     }
 
     @Override
@@ -130,7 +130,7 @@
 
     @Override
     public String toString() {
-        return "HotSpotField<" + holder.name() + "." + name + ">";
+        return "HotSpotField<" + holder.name() + "." + name + ":" + offset + ">";
     }
 
 }
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotTypeResolvedImpl.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotTypeResolvedImpl.java	Wed Jun 29 19:52:51 2011 +0200
@@ -48,6 +48,7 @@
     private RiConstantPool pool;
     private RiType superType;
     private boolean superTypeSet;
+    private RiField[] fields;
 
     private HotSpotTypeResolvedImpl() {
         super(null);
@@ -224,6 +225,9 @@
 
     @Override
     public RiField[] fields() {
-        return compiler.getVMEntries().RiType_fields(this);
+        if (fields == null) {
+            fields = compiler.getVMEntries().RiType_fields(this);
+        }
+        return fields;
     }
 }
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotXirGenerator.java	Tue Jun 28 19:54:51 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotXirGenerator.java	Wed Jun 29 19:52:51 2011 +0200
@@ -1043,7 +1043,6 @@
            asm.pload(CiKind.Object, objHub, object, asm.i(config.hubOffset), false);
            // if we get an exact match: continue
            asm.jneq(slowPath, objHub, hub);
-           asm.shouldNotReachHere();
 
            // -- out of line -------------------------------------------------------
            asm.bindOutOfLine(slowPath);
--- a/src/share/vm/graal/graalVMEntries.cpp	Tue Jun 28 19:54:51 2011 +0200
+++ b/src/share/vm/graal/graalVMEntries.cpp	Wed Jun 29 19:52:51 2011 +0200
@@ -636,14 +636,14 @@
   TRACE_graal_3("VMEntries::RiType_fields");
   KlassHandle klass_handle;
   ciInstanceKlass* instance_klass;
+  objArrayHandle fieldsArray;
+  HandleMark hm;
   {
     VM_ENTRY_MARK;
     klass_handle = java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(klass));
-    instance_klass = (ciInstanceKlass*) CURRENT_ENV->get_object(klass_handle());
+    instance_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(klass_handle());
   }
   GrowableArray<ciField*>* fields = instance_klass->non_static_fields();
-
-  objArrayHandle fieldsArray;
   {
     VM_ENTRY_MARK;
     fieldsArray = oopFactory::new_objArray(SystemDictionary::RiField_klass(), fields->length(), CHECK_NULL);