# HG changeset patch # User Doug Simon # Date 1368478590 -7200 # Node ID a54720257b7665786ef36abb0729663725ca508b # Parent e897b58936aaea80607503a28ddd7cca0bd55a38 replaced MonitorEnterStub and MonitorExitStub with use of RuntimeCallStub diff -r e897b58936aa -r a54720257b76 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Mon May 13 19:02:32 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Mon May 13 22:56:30 2013 +0200 @@ -46,8 +46,6 @@ import static com.oracle.graal.hotspot.stubs.LogObjectStub.*; import static com.oracle.graal.hotspot.stubs.LogPrimitiveStub.*; import static com.oracle.graal.hotspot.stubs.LogPrintfStub.*; -import static com.oracle.graal.hotspot.stubs.MonitorEnterStub.*; -import static com.oracle.graal.hotspot.stubs.MonitorExitStub.*; import static com.oracle.graal.hotspot.stubs.NewArrayStub.*; import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*; import static com.oracle.graal.hotspot.stubs.NewMultiArrayStub.*; @@ -375,28 +373,6 @@ /* temps */ null, /* ret */ ret(Kind.Void)); - addStubCall(MONITORENTER, - /* ret */ ret(Kind.Void), - /* arg0: object */ javaCallingConvention(Kind.Object, - /* arg1: lock */ word)); - - addCRuntimeCall(MONITORENTER_C, config.monitorenterAddress, - /* ret */ ret(Kind.Void), - /* arg0: thread */ nativeCallingConvention(word, - /* arg1: object */ Kind.Object, - /* arg1: lock */ word)); - - addStubCall(MONITOREXIT, - /* ret */ ret(Kind.Void), - /* arg0: object */ javaCallingConvention(Kind.Object, - /* arg1: lock */ word)); - - addCRuntimeCall(MONITOREXIT_C, config.monitorexitAddress, - /* ret */ ret(Kind.Void), - /* arg0: thread */ nativeCallingConvention(word, - /* arg1: object */ Kind.Object, - /* arg1: lock */ word)); - addStubCall(VM_ERROR, /* ret */ ret(Kind.Void), /* arg0: where */ javaCallingConvention(Kind.Object, @@ -548,8 +524,6 @@ link(new UnwindExceptionToCallerStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(UNWIND_EXCEPTION_TO_CALLER))); link(new VerifyOopStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(VERIFY_OOP))); link(new OSRMigrationEndStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(OSR_MIGRATION_END))); - link(new MonitorEnterStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITORENTER))); - link(new MonitorExitStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITOREXIT))); link(new LogPrimitiveStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(LOG_PRIMITIVE))); link(new LogObjectStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(LOG_OBJECT))); link(new LogPrintfStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(LOG_PRINTF))); @@ -561,6 +535,8 @@ linkRuntimeCall(REGISTER_FINALIZER, config.registerFinalizerAddress, replacements); linkRuntimeCall(CREATE_NULL_POINTER_EXCEPTION, config.createNullPointerExceptionAddress, replacements); linkRuntimeCall(CREATE_OUT_OF_BOUNDS_EXCEPTION, config.createOutOfBoundsExceptionAddress, replacements); + linkRuntimeCall(MONITORENTER, config.monitorenterAddress, replacements); + linkRuntimeCall(MONITOREXIT, config.monitorexitAddress, replacements); } private static void link(Stub stub) { diff -r e897b58936aa -r a54720257b76 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorEnterStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorEnterStubCall.java Mon May 13 19:02:32 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorEnterStubCall.java Mon May 13 22:56:30 2013 +0200 @@ -31,7 +31,7 @@ import com.oracle.graal.word.*; /** - * Node implementing a call to HotSpot's {@code graal_monitorenter} stub. + * Node implementing a call to {@code GraalRuntime::monitorenter}. */ public class MonitorEnterStubCall extends DeoptimizingStubCall implements LIRGenLowerable { @@ -52,5 +52,5 @@ } @NodeIntrinsic - public static native void call(Object hub, Word lock); + public static native void call(Object object, Word lock); } diff -r e897b58936aa -r a54720257b76 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java Mon May 13 19:02:32 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java Mon May 13 22:56:30 2013 +0200 @@ -32,7 +32,7 @@ import com.oracle.graal.word.*; /** - * Node implementing a call to HotSpot's {@code graal_monitorexit} stub. + * Node implementing a call to {@code GraalRuntime::monitorexit}. */ public class MonitorExitStubCall extends DeoptimizingStubCall implements LIRGenLowerable { @@ -56,5 +56,5 @@ } @NodeIntrinsic - public static native void call(Object hub, @ConstantNodeParameter int lockDepth); + public static native void call(Object object, @ConstantNodeParameter int lockDepth); } diff -r e897b58936aa -r a54720257b76 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorEnterStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorEnterStub.java Mon May 13 19:02:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * 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.HotSpotReplacementsUtil.*; -import static com.oracle.graal.hotspot.stubs.StubUtil.*; - -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 MonitorEnterStubCall}. - */ -public class MonitorEnterStub extends CRuntimeStub { - - public MonitorEnterStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { - super(runtime, replacements, target, linkage); - } - - @Snippet - private static void monitorenter(Object object, Word lock) { - monitorenterC(MONITORENTER_C, thread(), object, lock); - StubUtil.handlePendingException(false); - } - - public static final Descriptor MONITORENTER_C = descriptorFor(MonitorEnterStub.class, "monitorenterC", false); - - @NodeIntrinsic(CRuntimeCall.class) - public static native void monitorenterC(@ConstantNodeParameter Descriptor monitorenterC, Word thread, Object object, Word lock); -} diff -r e897b58936aa -r a54720257b76 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorExitStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/MonitorExitStub.java Mon May 13 19:02:32 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * 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.HotSpotReplacementsUtil.*; -import static com.oracle.graal.hotspot.stubs.StubUtil.*; - -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 MonitorExitStubCall}. - */ -public class MonitorExitStub extends CRuntimeStub { - - public MonitorExitStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { - super(runtime, replacements, target, linkage); - } - - @Snippet - private static void monitorexit(Object object, Word lock) { - monitorexitC(MONITOREXIT_C, thread(), object, lock); - } - - public static final Descriptor MONITOREXIT_C = descriptorFor(MonitorExitStub.class, "monitorexitC", false); - - @NodeIntrinsic(CRuntimeCall.class) - public static native void monitorexitC(@ConstantNodeParameter Descriptor monitorexitC, Word thread, Object object, Word lock); -} diff -r e897b58936aa -r a54720257b76 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/RuntimeCallStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/RuntimeCallStub.java Mon May 13 19:02:32 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/RuntimeCallStub.java Mon May 13 22:56:30 2013 +0200 @@ -50,7 +50,7 @@ import com.oracle.graal.word.phases.*; /** - * Base class for a stub that calls into a HotSpot C/C++ runtime function using the native + * A stub that calls into a HotSpot C/C++ runtime function using the native * {@link CallingConvention}. */ public class RuntimeCallStub extends Stub { @@ -98,7 +98,11 @@ Class[] argumentTypes = d.getArgumentTypes(); JavaType[] parameterTypes = new JavaType[argumentTypes.length]; for (int i = 0; i < parameterTypes.length; ++i) { - parameterTypes[i] = runtime.lookupJavaType(argumentTypes[i]); + if (WordBase.class.isAssignableFrom(argumentTypes[i])) { + parameterTypes[i] = runtime.lookupJavaType(wordKind().toJavaClass()); + } else { + parameterTypes[i] = runtime.lookupJavaType(argumentTypes[i]); + } } TargetDescription target = graalRuntime().getTarget(); JavaType returnType = runtime.lookupJavaType(d.getResultType()); diff -r e897b58936aa -r a54720257b76 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon May 13 19:02:32 2013 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon May 13 22:56:30 2013 +0200 @@ -26,6 +26,7 @@ import static com.oracle.graal.api.code.TypeCheckHints.*; import static com.oracle.graal.api.meta.DeoptimizationReason.*; import static com.oracle.graal.bytecode.Bytecodes.*; +import static com.oracle.graal.java.GraphBuilderPhase.RuntimeCalls.*; import static java.lang.reflect.Modifier.*; import java.lang.reflect.*; @@ -940,7 +941,7 @@ ValueNode exception = ConstantNode.forObject(cachedNullPointerException, runtime, currentGraph); trueSucc.setNext(handleException(exception, bci())); } else { - RuntimeCallNode call = currentGraph.add(new RuntimeCallNode(RuntimeCalls.CREATE_NULL_POINTER_EXCEPTION)); + RuntimeCallNode call = currentGraph.add(new RuntimeCallNode(CREATE_NULL_POINTER_EXCEPTION)); call.setStateAfter(frameState.create(bci())); trueSucc.setNext(call); call.setNext(handleException(call, bci())); @@ -966,7 +967,7 @@ ValueNode exception = ConstantNode.forObject(cachedArrayIndexOutOfBoundsException, runtime, currentGraph); falseSucc.setNext(handleException(exception, bci())); } else { - RuntimeCallNode call = currentGraph.add(new RuntimeCallNode(RuntimeCalls.CREATE_OUT_OF_BOUNDS_EXCEPTION, index)); + RuntimeCallNode call = currentGraph.add(new RuntimeCallNode(CREATE_OUT_OF_BOUNDS_EXCEPTION, index)); call.setStateAfter(frameState.create(bci())); falseSucc.setNext(call); call.setNext(handleException(call, bci()));