changeset 10661:b25a07ad3678

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 09 Jul 2013 01:27:40 +0200
parents 89efc9dd9f86 (diff) dad6e7ff1f93 (current diff)
children 4ef92b67aeae 41362ec88331
files
diffstat 6 files changed, 21 insertions(+), 167 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java	Mon Jul 08 14:49:05 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java	Tue Jul 09 01:27:40 2013 +0200
@@ -97,15 +97,16 @@
 
     @Override
     public Object execute(Object arg1, Object arg2, Object arg3) throws InvalidInstalledCodeException {
+        assert checkThreeObjectArgs();
+        return CompilerToVMImpl.executeCompiledMethodIntrinsic(arg1, arg2, arg3, this);
+    }
+
+    protected boolean checkThreeObjectArgs() {
         assert method.getSignature().getParameterCount(!Modifier.isStatic(method.getModifiers())) == 3;
         assert method.getSignature().getParameterKind(0) == Kind.Object;
         assert method.getSignature().getParameterKind(1) == Kind.Object;
         assert !Modifier.isStatic(method.getModifiers()) || method.getSignature().getParameterKind(2) == Kind.Object;
-        return executeHelper(arg1, arg2, arg3, this);
-    }
-
-    private static Object executeHelper(Object arg1, Object arg2, Object arg3, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException {
-        return CompilerToVMImpl.executeCompiledMethodIntrinsic(arg1, arg2, arg3, hotspotInstalledCode);
+        return true;
     }
 
     private boolean checkArgs(Object... args) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotNmethodExecuteNode.java	Mon Jul 08 14:49:05 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +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.graal.hotspot.nodes;
-
-import com.oracle.graal.api.code.CallingConvention.Type;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.replacements.nodes.*;
-
-public class HotSpotNmethodExecuteNode extends MacroNode implements Lowerable {
-
-    public HotSpotNmethodExecuteNode(Invoke invoke) {
-        super(invoke);
-    }
-
-    @Override
-    public void lower(LoweringTool tool, LoweringType loweringType) {
-        if (loweringType == LoweringType.AFTER_GUARDS) {
-
-            ValueNode hotspotNmethod = arguments.get(3);
-
-            ReadNode readNode = graph().add(new ReadNode(hotspotNmethod, 16, LocationIdentity.ANY_LOCATION, Kind.Long));
-            graph().addBeforeFixed(this, readNode);
-            readNode.setNullCheck(true);
-
-            int verifiedEntryOffset = HotSpotGraalRuntime.graalRuntime().getConfig().nmethodEntryOffset;
-            ReadNode readAddressNode = graph().add(new ReadNode(readNode, verifiedEntryOffset, LocationIdentity.ANY_LOCATION, Kind.Long));
-            graph().addBeforeFixed(this, readAddressNode);
-            readAddressNode.setNullCheck(true);
-
-            JavaType[] signatureTypes = new JavaType[getTargetMethod().getSignature().getParameterCount(false)];
-            for (int i = 0; i < signatureTypes.length; ++i) {
-                signatureTypes[i] = getTargetMethod().getSignature().getParameterType(i, getTargetMethod().getDeclaringClass());
-            }
-
-            IndirectCallTargetNode callTarget = graph().add(new IndirectCallTargetNode(readAddressNode, arguments, StampFactory.object(), signatureTypes, super.getTargetMethod(), Type.JavaCall));
-            InvokeNode invoke = graph().add(new InvokeNode(callTarget, super.getBci()));
-            invoke.setStateAfter(stateAfter());
-            graph().replaceFixedWithFixed(this, invoke);
-        }
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNmethodIntrinsics.java	Mon Jul 08 14:49:05 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2013, 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.replacements;
-
-import static com.oracle.graal.phases.GraalOptions.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.nodes.spi.*;
-
-@ServiceProvider(ReplacementsProvider.class)
-public class HotSpotNmethodIntrinsics implements ReplacementsProvider {
-
-    @Override
-    public void registerReplacements(MetaAccessProvider runtime, Replacements replacements, TargetDescription target) {
-        if (IntrinsifyInstalledCodeMethods.getValue()) {
-            replacements.registerSubstitutions(HotSpotNmethodSubstitutions.class);
-        }
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNmethodSubstitutions.java	Mon Jul 08 14:49:05 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2013, 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.replacements;
-
-import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.replacements.Snippet.Fold;
-
-@ClassSubstitution(HotSpotNmethod.class)
-public class HotSpotNmethodSubstitutions {
-
-    @MacroSubstitution(macro = HotSpotNmethodExecuteNode.class, isStatic = true)
-    public static native Object executeHelper(final Object arg1, final Object arg2, final Object arg3, HotSpotInstalledCode code);
-
-    @Fold
-    private static Class[] getSignature() {
-        return new Class[]{Object.class, Object.class, Object.class};
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Mon Jul 08 14:49:05 2013 -0700
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Tue Jul 09 01:27:40 2013 +0200
@@ -231,14 +231,12 @@
                     if (node == beginNode) {
                         loweringTool.setLastFixedNode(beginNode);
                     } else if (node instanceof Lowerable) {
-                        // Handles cases where there is a lowerable nodes scheduled before the begin
+                        // Handles cases where there are lowerable nodes scheduled before the begin
                         // node.
                         BeginNode newBegin = node.graph().add(new BeginNode());
                         beginNode.replaceAtPredecessor(newBegin);
                         newBegin.setNext(beginNode);
                         loweringTool.setLastFixedNode(newBegin);
-                    } else if (node == beginNode) {
-                        loweringTool.setLastFixedNode(beginNode);
                     } else {
                         continue;
                     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Mon Jul 08 14:49:05 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Tue Jul 09 01:27:40 2013 +0200
@@ -71,25 +71,29 @@
 
     @Override
     public Object call(PackedFrame caller, Arguments args) {
-        if (compiledMethod != null) {
+        if (CompilerDirectives.injectBranchProbability(CompilerDirectives.FASTPATH_PROBABILITY, compiledMethod != null)) {
             try {
                 return compiledMethod.execute(this, caller, args);
             } catch (InvalidInstalledCodeException ex) {
-                compiledMethod = null;
-                invokeCounter = invalidationReprofileCount;
-                if (TruffleFunctionInlining.getValue()) {
-                    originalInvokeCounter += invalidationReprofileCount;
-                }
-                if (TraceTruffleCompilation.getValue()) {
-                    OUT.printf("[truffle] invalidated %-48s |Alive %5.0fms\n", rootNode, (System.nanoTime() - timeCompilationFinished) / 1e6);
-                }
-                return call(caller, args);
+                return compiledCodeInvalidated(caller, args);
             }
         } else {
             return interpreterCall(caller, args);
         }
     }
 
+    protected Object compiledCodeInvalidated(PackedFrame caller, Arguments args) {
+        compiledMethod = null;
+        invokeCounter = invalidationReprofileCount;
+        if (TruffleFunctionInlining.getValue()) {
+            originalInvokeCounter += invalidationReprofileCount;
+        }
+        if (TraceTruffleCompilation.getValue()) {
+            OUT.printf("[truffle] invalidated %-48s |Alive %5.0fms\n", rootNode, (System.nanoTime() - timeCompilationFinished) / 1e6);
+        }
+        return call(caller, args);
+    }
+
     private Object interpreterCall(PackedFrame caller, Arguments args) {
         invokeCounter--;
         loopAndInvokeCounter--;