changeset 9479:fd2e12d41d18

Merge
author Christian Wimmer <christian.wimmer@oracle.com>
date Wed, 01 May 2013 09:22:20 -0700
parents fb22b4d5f475 (current diff) 225fc5463430 (diff)
children d9fd6af5d200
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java
diffstat 14 files changed, 125 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Wed May 01 09:22:20 2013 -0700
@@ -25,7 +25,6 @@
 import static com.oracle.graal.amd64.AMD64.*;
 import static com.oracle.graal.compiler.amd64.AMD64LIRGenerator.*;
 import static com.oracle.graal.hotspot.amd64.AMD64HotSpotUnwindOp.*;
-import static com.oracle.graal.hotspot.nodes.IdentityHashCodeStubCall.*;
 import static com.oracle.graal.hotspot.nodes.MonitorEnterStubCall.*;
 import static com.oracle.graal.hotspot.nodes.MonitorExitStubCall.*;
 import static com.oracle.graal.hotspot.nodes.VMErrorNode.*;
@@ -106,11 +105,6 @@
                 /* arg1: format */                       Kind.Object,
                 /* arg2:  value */                       Kind.Long));
 
-        addRuntimeCall(IDENTITY_HASHCODE, config.identityHashCodeStub,
-                /*        temps */ null,
-                /*          ret */ rax.asValue(Kind.Int),
-                /* arg0:    obj */ javaCallingConvention(Kind.Object));
-
         addRuntimeCall(ENCRYPT_BLOCK, config.aescryptEncryptBlockStub,
                 /*        temps */ null,
                 /*          ret */ ret(Kind.Void),
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed May 01 09:22:20 2013 -0700
@@ -369,7 +369,6 @@
     public long logObjectStub;
     public long logPrintfStub;
     public int deoptReasonNone;
-    public long identityHashCodeStub;
     public long aescryptEncryptBlockStub;
     public long aescryptDecryptBlockStub;
     public long cipherBlockChainingEncryptAESCryptStub;
@@ -381,6 +380,7 @@
     public long registerFinalizerAddress;
     public long threadIsInterruptedAddress;
     public long stubPrintfAddress;
+    public long identityHashCodeAddress;
 
     public int deoptReasonNullCheck;
     public int deoptReasonRangeCheck;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed May 01 09:22:20 2013 -0700
@@ -30,11 +30,13 @@
 import static com.oracle.graal.graph.UnsafeAccess.*;
 import static com.oracle.graal.hotspot.HotSpotBackend.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
+import static com.oracle.graal.hotspot.nodes.IdentityHashCodeStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewArrayStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewMultiArrayStubCall.*;
 import static com.oracle.graal.hotspot.nodes.ThreadIsInterruptedStubCall.*;
 import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*;
+import static com.oracle.graal.hotspot.stubs.IdentityHashCodeStub.*;
 import static com.oracle.graal.hotspot.stubs.NewArrayStub.*;
 import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*;
 import static com.oracle.graal.hotspot.stubs.NewMultiArrayStub.*;
@@ -344,6 +346,16 @@
         addRuntimeCall(IC_MISS_HANDLER, config.inlineCacheMissStub,
                         /*           temps */ null,
                         /*             ret */ ret(Kind.Void));
+
+        addStubCall(IDENTITY_HASHCODE,
+                        /*          ret */ ret(Kind.Int),
+                        /* arg0:    obj */ javaCallingConvention(Kind.Object));
+
+        addCRuntimeCall(IDENTITY_HASH_CODE_C, config.identityHashCodeAddress,
+                        /*             ret */ ret(Kind.Int),
+                        /* arg0:    thread */ nativeCallingConvention(word,
+                        /* arg1:    object */                         Kind.Object));
+
         // @formatter:on
     }
 
@@ -441,6 +453,7 @@
         registerStub(new NewMultiArrayStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(NEW_MULTI_ARRAY)));
         registerStub(new RegisterFinalizerStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(REGISTER_FINALIZER)));
         registerStub(new ThreadIsInterruptedStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(THREAD_IS_INTERRUPTED)));
+        registerStub(new IdentityHashCodeStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(IDENTITY_HASHCODE)));
     }
 
     private void registerStub(Stub stub) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/IdentityHashCodeStubCall.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/IdentityHashCodeStubCall.java	Wed May 01 09:22:20 2013 -0700
@@ -27,12 +27,13 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 
 /**
- * Node implementing a call to HotSpot's {@code graal_identityhashcode} stub.
+ * Node implementing a call to {@link IdentityHashCodeStub}.
  */
 public class IdentityHashCodeStubCall extends DeoptimizingStubCall implements LIRGenLowerable {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/IdentityHashCodeStub.java	Wed May 01 09:22:20 2013 -0700
@@ -0,0 +1,58 @@
+/*
+ * 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.graal.hotspot.stubs;
+
+import static com.oracle.graal.hotspot.replacements.HotSpotSnippetUtils.*;
+
+import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor;
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.replacements.*;
+import com.oracle.graal.word.*;
+
+/**
+ * Stub called from {@link IdentityHashCodeStubCall}.
+ */
+public class IdentityHashCodeStub extends CRuntimeStub {
+
+    public IdentityHashCodeStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) {
+        super(runtime, replacements, target, linkage);
+    }
+
+    @Snippet
+    private static int identityHashCode(Object object) {
+        int result = identityHashCodeC(IDENTITY_HASH_CODE_C, thread(), object);
+        handlePendingException(false);
+        return result;
+    }
+
+    public static final Descriptor IDENTITY_HASH_CODE_C = descriptorFor(IdentityHashCodeStub.class, "identityHashCodeC", false);
+
+    @NodeIntrinsic(CRuntimeCall.class)
+    public static native int identityHashCodeC(@ConstantNodeParameter Descriptor identityHashCodeC, Word thread, Object object);
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Wed May 01 09:22:20 2013 -0700
@@ -65,8 +65,8 @@
         super(StampFactory.forVoid());
         this.condition = condition;
         this.falseSuccessor = falseSuccessor;
-        this.trueSuccessorProbability = trueSuccessorProbability;
         this.trueSuccessor = trueSuccessor;
+        setTrueSuccessorProbability(trueSuccessorProbability);
 
     }
 
@@ -117,11 +117,12 @@
         setFalseSuccessor(null);
         setTrueSuccessor(falseSucc);
         setFalseSuccessor(trueSucc);
-        trueSuccessorProbability = 1 - trueSuccessorProbability;
+        setTrueSuccessorProbability(1 - trueSuccessorProbability);
         return this;
     }
 
     public void setTrueSuccessorProbability(double prob) {
+        assert prob >= 0.0 && prob <= 1.0 : "Probability out of bounds: " + prob;
         trueSuccessorProbability = prob;
     }
 
@@ -189,8 +190,12 @@
                     intermediateBegin.setNext(this);
                     this.setFalseSuccessor(bothFalseBegin);
                     nextIf.setTrueSuccessorProbability(probabilityB);
-                    double newProbability = this.trueSuccessorProbability / (1.0 - probabilityB);
-                    this.setTrueSuccessorProbability(newProbability);
+                    if (probabilityB == 1.0) {
+                        this.setTrueSuccessorProbability(0.0);
+                    } else {
+                        double newProbability = this.trueSuccessorProbability / (1.0 - probabilityB);
+                        this.setTrueSuccessorProbability(Math.min(1.0, newProbability));
+                    }
                     return;
                 }
             }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Wed May 01 09:22:20 2013 -0700
@@ -335,21 +335,29 @@
     }
 
     private void computePostdominators() {
-        for (Block block : postOrder()) {
+        outer: for (Block block : postOrder()) {
             if (block.isLoopEnd()) {
                 // We do not want the loop header registered as the postdominator of the loop end.
                 continue;
             }
-            Block postdominator = null;
+            if (block.getSuccessorCount() == 0) {
+                // No successors => no postdominator.
+                continue;
+            }
+            Block firstSucc = block.getSuccessors().get(0);
+            if (block.getSuccessorCount() == 1) {
+                block.postdominator = firstSucc;
+                continue;
+            }
+            Block postdominator = firstSucc;
             for (Block sux : block.getSuccessors()) {
-                if (sux.isExceptionEntry()) {
-                    // We ignore exception handlers.
-                } else if (postdominator == null) {
-                    postdominator = sux;
-                } else {
-                    postdominator = commonPostdominator(postdominator, sux);
+                postdominator = commonPostdominator(postdominator, sux);
+                if (postdominator == null) {
+                    // There is a dead end => no postdominator available.
+                    continue outer;
                 }
             }
+            assert !block.getSuccessors().contains(postdominator) : "Block " + block + " has a wrong post dominator: " + postdominator;
             block.postdominator = postdominator;
         }
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java	Wed May 01 09:22:20 2013 -0700
@@ -52,6 +52,14 @@
         this.value = value;
         this.keySuccessors = keySuccessors;
         this.keyProbabilities = keyProbabilities;
+        assert assertProbabilities();
+    }
+
+    private boolean assertProbabilities() {
+        for (double d : keyProbabilities) {
+            assert d >= 0.0 : "Cannot have negative probabilities in switch node: " + d;
+        }
+        return true;
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/NodesToDoubles.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/NodesToDoubles.java	Wed May 01 09:22:20 2013 -0700
@@ -35,6 +35,7 @@
     }
 
     public void put(FixedNode n, double value) {
+        assert value >= 0.0;
         nodeProbabilities.put(n, value);
     }
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Wed May 01 09:22:20 2013 -0700
@@ -649,9 +649,16 @@
 
                     ValueNode firstMethodConstantNode = ConstantNode.forConstant(firstMethodConstant, runtime, graph);
                     constantMethods[i] = firstMethodConstantNode;
-                    probability[i] = concretesProbabilities.get(i);
+                    double concretesProbability = concretesProbabilities.get(i);
+                    assert concretesProbability >= 0.0;
+                    probability[i] = concretesProbability;
                     if (i > 0) {
-                        probability[i] /= (1.0 - probability[i - 1]);
+                        double prevProbability = probability[i - 1];
+                        if (prevProbability == 1.0) {
+                            probability[i] = 1.0;
+                        } else {
+                            probability[i] = Math.min(1.0, Math.max(0.0, probability[i] / (1.0 - prevProbability)));
+                        }
                     }
                 }
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java	Wed May 01 09:21:35 2013 -0700
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java	Wed May 01 09:22:20 2013 -0700
@@ -79,11 +79,6 @@
         }
     }
 
-    private static boolean isRelativeProbability(double prob) {
-        // 1.01 to allow for some rounding errors
-        return prob >= 0 && prob <= 1.01;
-    }
-
     public static class LoopInfo {
 
         public final LoopBeginNode loopBegin;
@@ -131,6 +126,7 @@
         public LoopInfo loopInfo;
 
         public Probability(double probability, HashSet<LoopInfo> loops) {
+            assert probability >= 0.0;
             this.probability = probability;
             this.loops = new HashSet<>(4);
             if (loops != null) {
@@ -174,7 +170,7 @@
                 }
                 loops = intersection;
                 mergeLoops.put(merge, new HashSet<>(intersection));
-                assert isRelativeProbability(probability) : probability;
+                probability = Math.max(0.0, probability);
             }
             return true;
         }
@@ -219,7 +215,10 @@
             } else {
                 assert pred instanceof ControlSplitNode;
                 ControlSplitNode x = (ControlSplitNode) pred;
-                probability *= x.probability(node);
+                double nodeProbability = x.probability(node);
+                assert nodeProbability >= 0.0 : "Node " + x + " provided negative probability for begin " + node + ": " + nodeProbability;
+                probability *= nodeProbability;
+                assert probability >= 0.0;
             }
         }
     }
--- a/src/cpu/x86/vm/graalRuntime_x86.cpp	Wed May 01 09:21:35 2013 -0700
+++ b/src/cpu/x86/vm/graalRuntime_x86.cpp	Wed May 01 09:22:20 2013 -0700
@@ -1038,20 +1038,6 @@
       break;
     }
 
-    case identity_hash_code_id: {
-      Register obj = j_rarg0; // Incoming
-      __ set_info("identity_hash_code", dont_gc_arguments);
-      __ enter();
-      OopMap* map = save_live_registers(sasm, 1);
-      int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, identity_hash_code), obj);
-      oop_maps = new OopMapSet();
-      oop_maps->add_gc_map(call_offset, map);
-      restore_live_registers_except_rax(sasm);
-      __ leave();
-      __ ret(0);
-      break;
-    }
-
     default:
       { GraalStubFrame f(sasm, "unimplemented entry", dont_gc_arguments);
         __ movptr(rax, (int)id);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed May 01 09:21:35 2013 -0700
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed May 01 09:22:20 2013 -0700
@@ -754,7 +754,6 @@
   set_address("wbPreCallStub", GraalRuntime::entry_for(GraalRuntime::wb_pre_call_id));
   set_address("wbPostCallStub", GraalRuntime::entry_for(GraalRuntime::wb_post_call_id));
 
-  set_address("identityHashCodeStub", GraalRuntime::entry_for(GraalRuntime::identity_hash_code_id));
   set_address("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub());
   set_address("handleExceptionStub", GraalRuntime::entry_for(GraalRuntime::handle_exception_nofpu_id));
   set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
@@ -788,6 +787,7 @@
   set_address("threadIsInterruptedAddress", GraalRuntime::thread_is_interrupted);
   set_address("uncommonTrapStub", SharedRuntime::deopt_blob()->uncommon_trap());
   set_address("stubPrintfAddress", GraalRuntime::stub_printf);
+  set_address("identityHashCodeAddress", GraalRuntime::identity_hash_code);
 
   set_int("deoptReasonNone", Deoptimization::Reason_none);
   set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check);
--- a/src/share/vm/graal/graalRuntime.hpp	Wed May 01 09:21:35 2013 -0700
+++ b/src/share/vm/graal/graalRuntime.hpp	Wed May 01 09:22:20 2013 -0700
@@ -95,7 +95,6 @@
   stub(log_object)              \
   stub(log_printf)              \
   stub(log_primitive)           \
-  stub(identity_hash_code)      \
   stub(wb_pre_call)             \
   stub(wb_post_call)             \
  last_entry(number_of_ids)
@@ -141,7 +140,6 @@
   static void wb_pre_call(JavaThread* thread, oopDesc* obj);
   static void wb_post_call(JavaThread* thread, oopDesc* obj, void* card);
 
-  static jint identity_hash_code(JavaThread* thread, oopDesc* objd);
 
   // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log
   enum {
@@ -157,6 +155,7 @@
   static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims);
   static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupte);
   static void stub_printf(jlong format, jlong v1, jlong v2, jlong v3);
+  static jint identity_hash_code(JavaThread* thread, oopDesc* objd);
   // initialization
   static void initialize(BufferBlob* blob);