changeset 6481:6977b54ddba8

modified Monitor[Enter|Exit]StubCall nodes to use information provided by the (platform independent) backend instead of AMD64 specific nodes for linking the stub calls
author Doug Simon <doug.simon@oracle.com>
date Tue, 02 Oct 2012 14:17:40 +0200
parents 3da20c99bc10
children f0db2c717f6e
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorEnterStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64MonitorEnterStubCallOp.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64MonitorExitStubCallOp.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java
diffstat 5 files changed, 17 insertions(+), 199 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorEnterStubCall.java	Tue Oct 02 14:14:26 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorEnterStubCall.java	Tue Oct 02 14:17:40 2012 +0200
@@ -22,21 +22,16 @@
  */
 package com.oracle.graal.hotspot.nodes;
 
-import static com.oracle.graal.hotspot.target.amd64.AMD64MonitorEnterStubCallOp.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.hotspot.target.amd64.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.target.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.snippets.*;
 
 /**
  * Node implementing a call to HotSpot's {@code graal_monitorenter} stub.
- *
- * @see AMD64MonitorEnterStubCallOp
  */
 public class MonitorEnterStubCall extends FixedWithNextNode implements LIRGenLowerable {
 
@@ -51,11 +46,9 @@
 
     @Override
     public void generate(LIRGenerator gen) {
-        RegisterValue objectFixed = OBJECT.asValue(Kind.Object);
-        RegisterValue lockFixed = LOCK.asValue(gen.target().wordKind);
-        gen.emitMove(gen.operand(lock), lockFixed);
-        gen.emitMove(gen.operand(object), objectFixed);
-        gen.append(new AMD64MonitorEnterStubCallOp(objectFixed, lockFixed, gen.state()));
+        HotSpotBackend backend = (HotSpotBackend) HotSpotGraalRuntime.getInstance().getCompiler().backend;
+        HotSpotStub stub = backend.getStub("monitorenter");
+        gen.emitCall(stub.address, stub.cc, true, gen.operand(object), gen.operand(lock));
     }
 
     @NodeIntrinsic
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java	Tue Oct 02 14:14:26 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java	Tue Oct 02 14:17:40 2012 +0200
@@ -22,20 +22,15 @@
  */
 package com.oracle.graal.hotspot.nodes;
 
-import static com.oracle.graal.hotspot.target.amd64.AMD64MonitorEnterStubCallOp.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.hotspot.target.amd64.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.target.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 
 /**
  * Node implementing a call to HotSpot's {@code graal_monitorexit} stub.
- *
- * @see AMD64MonitorExitStubCallOp
  */
 public class MonitorExitStubCall extends FixedWithNextNode implements LIRGenLowerable {
 
@@ -48,12 +43,9 @@
 
     @Override
     public void generate(LIRGenerator gen) {
-        RegisterValue objectFixed = OBJECT.asValue(Kind.Object);
-        RegisterValue lockFixed = LOCK.asValue(gen.target().wordKind);
-        // The register allocator cannot handle stack -> register moves so we use an LEA here
-        gen.emitMove(gen.emitLea(gen.peekLock()), lockFixed);
-        gen.emitMove(gen.operand(object), objectFixed);
-        gen.append(new AMD64MonitorExitStubCallOp(objectFixed, lockFixed, gen.state()));
+        HotSpotBackend backend = (HotSpotBackend) HotSpotGraalRuntime.getInstance().getCompiler().backend;
+        HotSpotStub stub = backend.getStub("monitorexit");
+        gen.emitCall(stub.address, stub.cc, true, gen.operand(object), gen.emitLea(gen.peekLock()));
     }
 
     @NodeIntrinsic
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64MonitorEnterStubCallOp.java	Tue Oct 02 14:14:26 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +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.target.amd64;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.hotspot.snippets.HotSpotSnippetUtils.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.LIRInstruction.Opcode;
-import com.oracle.graal.lir.amd64.*;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.max.asm.target.amd64.*;
-
-/**
- * LIR instruction for calling HotSpot's {@code graal_monitorenter} stub.
- */
-@Opcode("MONITORENTER_STUB")
-public class AMD64MonitorEnterStubCallOp extends AMD64LIRInstruction {
-
-    /**
-     * The stub expects the object in the first stub ABI register.
-     */
-    public static final Register OBJECT = getStubParameterRegister(0);
-
-    /**
-     * The stub expects the lock in the second stub ABI register.
-     */
-    public static final Register LOCK = getStubParameterRegister(1);
-
-    /**
-     * The stub uses RAX, RBX and the first two ABI parameter registers.
-     */
-    public static final Register[] TEMPS = {AMD64.rax, AMD64.rbx};
-
-    @Use protected Value object;
-    @Use protected Value lock;
-    @Temp protected Value[] temps;
-
-    @State protected LIRFrameState state;
-
-    public AMD64MonitorEnterStubCallOp(Value object, Value lock, LIRFrameState state) {
-        this.object = object;
-        this.lock = lock;
-        this.temps = new Value[TEMPS.length];
-        for (int i = 0; i < temps.length; i++) {
-            temps[i] = TEMPS[i].asValue(Kind.Long);
-        }
-        this.state = state;
-    }
-
-    @Override
-    public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-        HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig();
-        long stub = config.fastMonitorEnterStub;
-        AMD64Call.directCall(tasm, masm, stub, state);
-    }
-
-    @Override
-    protected void verify() {
-        super.verify();
-        assert asRegister(object) == OBJECT : "stub expects object in " + OBJECT;
-        assert asRegister(lock) == LOCK : "stub expect lock in " + LOCK;
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64MonitorExitStubCallOp.java	Tue Oct 02 14:14:26 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +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.target.amd64;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.hotspot.snippets.HotSpotSnippetUtils.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.LIRInstruction.Opcode;
-import com.oracle.graal.lir.amd64.*;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.max.asm.target.amd64.*;
-
-/**
- * LIR instruction for calling HotSpot's {@code graal_monitorexit} stub.
- */
-@Opcode("MONITOREXIT_STUB")
-public class AMD64MonitorExitStubCallOp extends AMD64LIRInstruction {
-
-    /**
-     * The stub expects the object in the first stub ABI register.
-     */
-    public static final Register OBJECT = getStubParameterRegister(0);
-
-    /**
-     * The stub expects the lock in the second stub ABI register.
-     */
-    public static final Register LOCK = getStubParameterRegister(1);
-
-    /**
-     * The stub uses RAX, RBX and the first two ABI parameter registers.
-     */
-    public static final Register[] TEMPS = {AMD64.rax, AMD64.rbx};
-
-    @Use protected Value object;
-    @Use protected Value lock;
-    @Temp protected Value[] temps;
-
-    @State protected LIRFrameState state;
-
-    public AMD64MonitorExitStubCallOp(Value object, Value lock, LIRFrameState state) {
-        this.object = object;
-        this.lock = lock;
-        this.temps = new Value[TEMPS.length];
-        for (int i = 0; i < temps.length; i++) {
-            temps[i] = TEMPS[i].asValue(Kind.Long);
-        }
-        this.state = state;
-    }
-
-    @Override
-    public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-        HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig();
-        long stub = config.fastMonitorExitStub;
-        AMD64Call.directCall(tasm, masm, stub, state);
-    }
-
-    @Override
-    protected void verify() {
-        super.verify();
-        assert asRegister(object) == OBJECT : "stub expects object in " + OBJECT;
-        assert asRegister(lock) == LOCK : "stub expect lock in " + LOCK;
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 14:14:26 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 14:17:40 2012 +0200
@@ -24,6 +24,7 @@
 
 import static com.oracle.graal.api.code.CallingConvention.Type.*;
 import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.api.meta.Value.*;
 import static com.oracle.max.asm.target.amd64.AMD64.*;
 
 import java.lang.reflect.*;
@@ -56,6 +57,12 @@
 
     public HotSpotAMD64Backend(CodeCacheProvider runtime, TargetDescription target) {
         super(runtime, target);
+        HotSpotRuntime hs = (HotSpotRuntime) runtime;
+        HotSpotVMConfig c = hs.config;
+        Kind word = target.wordKind;
+
+        addStub("monitorenter", c.fastMonitorEnterStub, cc(temps(rax, rbx), IllegalValue, reg("object", rsi, Kind.Object), reg("lock", rdx, word)));
+        addStub("monitorexit", c.fastMonitorExitStub, cc(temps(rax, rbx), IllegalValue, reg("object", rsi, Kind.Object), reg("lock", rdx, word)));
     }
 
     @Override