changeset 6484:90b12b6af72a

modified NewMultiArrayStubCall to use information provided by the (platform independent) backend instead of AMD64 specific nodes for linking the stub call
author Doug Simon <doug.simon@oracle.com>
date Tue, 02 Oct 2012 15:20:07 +0200
parents e11b2c8f374b
children 4c246719138e
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64NewMultiArrayStubCallOp.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java
diffstat 3 files changed, 11 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java	Tue Oct 02 15:03:07 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java	Tue Oct 02 15:20:07 2012 +0200
@@ -22,14 +22,11 @@
  */
 package com.oracle.graal.hotspot.nodes;
 
-import static com.oracle.graal.hotspot.target.amd64.AMD64NewMultiArrayStubCallOp.*;
-
-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.*;
-import com.oracle.graal.hotspot.target.amd64.*;
+import com.oracle.graal.hotspot.target.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
@@ -65,16 +62,9 @@
 
     @Override
     public void generate(LIRGenerator gen) {
-        RegisterValue hubFixed = HUB.asValue(Kind.Object);
-        RegisterValue resultFixed = RESULT.asValue(Kind.Object);
-        RegisterValue rankFixed = RANK.asValue(Kind.Int);
-        RegisterValue dimsFixed = DIMS.asValue(gen.target().wordKind);
-        gen.emitMove(gen.operand(hub), hubFixed);
-        gen.emitMove(gen.operand(dims), dimsFixed);
-        gen.emitMove(Constant.forInt(rank), rankFixed);
-        LIRFrameState state = gen.state();
-        gen.append(new AMD64NewMultiArrayStubCallOp(resultFixed, hubFixed, rankFixed, dimsFixed, state));
-        Variable result = gen.emitMove(resultFixed);
+        HotSpotBackend backend = (HotSpotBackend) HotSpotGraalRuntime.getInstance().getCompiler().backend;
+        HotSpotStub stub = backend.getStub("new_multi_array");
+        Variable result = gen.emitCall(stub.address, stub.cc, true, gen.operand(hub), Constant.forInt(rank), gen.operand(dims));
         gen.setResult(this, result);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64NewMultiArrayStubCallOp.java	Tue Oct 02 15:03:07 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +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 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.*;
-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 new_multi_array} stub. This stub is declared in c1_Runtime1.hpp
- * and implemented in Runtime1::generate_code_for() which is located in c1_Runtime1_x86.cpp.
- */
-@Opcode("NEW_MULTI_ARRAY_STUB")
-public class AMD64NewMultiArrayStubCallOp extends AMD64LIRInstruction {
-
-    /**
-     * The stub places the result in RAX.
-     */
-    public static final Register RESULT = AMD64.rax;
-
-    /**
-     * The stub expects the hub in RAX.
-     */
-    public static final Register HUB = AMD64.rax;
-
-    /**
-     * The stub expects the rank in RBX.
-     */
-    public static final Register RANK = AMD64.rbx;
-
-    /**
-     * The stub expects the dimensions in RCX.
-     */
-    public static final Register DIMS = AMD64.rcx;
-
-    @Def protected Value result;
-    @Use protected Value hub;
-    @Use protected Value rank;
-    @Use protected Value dims;
-
-    @State protected LIRFrameState state;
-
-    public AMD64NewMultiArrayStubCallOp(Value result, Value hub, Value rank, Value dims, LIRFrameState state) {
-        this.result = result;
-        this.hub = hub;
-        this.rank = rank;
-        this.dims = dims;
-        this.state = state;
-    }
-
-    @Override
-    public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-        HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig();
-        long stub = config.newMultiArrayStub;
-        AMD64Call.directCall(tasm, masm, stub, state);
-    }
-
-    @Override
-    protected void verify() {
-        super.verify();
-        assert asRegister(hub) == HUB : "stub expects hub in " + HUB;
-        assert asRegister(rank) == RANK : "stub expect rank in " + RANK;
-        assert asRegister(dims) == DIMS : "stub expect dims in " + DIMS;
-        assert asRegister(result) == RESULT : "stub places result in " + RESULT;
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 15:03:07 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 15:20:07 2012 +0200
@@ -89,6 +89,13 @@
                 /*        temps */ null,
                 /*          ret */ rax.asValue(Kind.Object),
                 /* arg0:    hub */ rdx.asValue(Kind.Object));
+
+        addStub("new_multi_array", c.newMultiArrayStub,
+                        /*        temps */ null,
+                        /*          ret */ rax.asValue(Kind.Object),
+                        /* arg0:    hub */ rax.asValue(Kind.Object),
+                        /* arg1:   rank */ rbx.asValue(Kind.Int),
+                        /* arg2:   dims */ rcx.asValue(word));
     }
 
     @Override