# HG changeset patch # User Thomas Wuerthinger # Date 1373326060 -7200 # Node ID b25a07ad3678784d1b7cf224bd9b82a892a27791 # Parent 89efc9dd9f8664844e82ea7b710fe977bae75179# Parent dad6e7ff1f93a489eb53c74c16f244a6c18a2de8 Merge. diff -r dad6e7ff1f93 -r b25a07ad3678 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java --- 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) { diff -r dad6e7ff1f93 -r b25a07ad3678 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotNmethodExecuteNode.java --- 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); - } - } -} diff -r dad6e7ff1f93 -r b25a07ad3678 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNmethodIntrinsics.java --- 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); - } - } -} diff -r dad6e7ff1f93 -r b25a07ad3678 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNmethodSubstitutions.java --- 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}; - } - -} diff -r dad6e7ff1f93 -r b25a07ad3678 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java --- 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; } diff -r dad6e7ff1f93 -r b25a07ad3678 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- 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--;