changeset 6479:e8be2bb3760e

introduced platform independent HotSpotBackend to manage stub linkage information
author Doug Simon <doug.simon@oracle.com>
date Tue, 02 Oct 2012 14:03:42 +0200
parents 62878ae057a5
children 3da20c99bc10
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/HotSpotBackend.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java
diffstat 3 files changed, 140 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotStub.java	Tue Oct 02 14:03:42 2012 +0200
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+import com.oracle.graal.api.code.*;
+
+/**
+ * The details required to link a call to a HotSpot stub.
+ */
+public class HotSpotStub {
+
+    /**
+     * The name of the stub. This is for informational purposes only.
+     */
+    public final String name;
+
+    /**
+     * The entry point address of the stub.
+     */
+    public final long address;
+
+    /**
+     * Where the stub gets its arguments and where it places its result.
+     */
+    public final CallingConvention cc;
+
+    public HotSpotStub(String name, long address, CallingConvention cc) {
+        this.address = address;
+        this.name = name;
+        this.cc = cc;
+    }
+
+    @Override
+    public String toString() {
+        return name + "@0x" + Long.toHexString(address) + ":" + cc;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/HotSpotBackend.java	Tue Oct 02 14:03:42 2012 +0200
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.hotspot.*;
+
+/**
+ * HotSpot specific backend.
+ */
+public abstract class HotSpotBackend extends Backend {
+
+    private final Map<String, HotSpotStub> stubsMap = new HashMap<>();
+
+    public HotSpotBackend(CodeCacheProvider runtime, TargetDescription target) {
+        super(runtime, target);
+    }
+
+    /**
+     * Gets the linkage information for a global stub.
+     */
+    public HotSpotStub getStub(String name) {
+        HotSpotStub stub = stubsMap.get(name);
+        assert stub != null : "no stub named " + name;
+        return stub;
+    }
+
+    /**
+     * Registers the details for linking a global stub.
+     */
+    protected HotSpotStub addStub(String name, long address, CallingConvention cc) {
+        HotSpotStub stub = new HotSpotStub(name, address, cc);
+        stubsMap.put(name, stub);
+        return stub;
+    }
+
+    protected static Value reg(@SuppressWarnings("unused") String name, Register reg, Kind kind) {
+        return reg.asValue(kind);
+    }
+
+    protected static Register[] temps(Register... regs) {
+        return regs;
+    }
+
+    protected static CallingConvention cc(Value ret, Value... args) {
+        return new CallingConvention(0, ret, args);
+    }
+
+    protected static CallingConvention cc(Register[] tempRegs, Value ret, Value... args) {
+        Value[] temps = new Value[tempRegs.length];
+        for (int i = 0; i < temps.length; i++) {
+            temps[i] = tempRegs[i].asValue();
+        }
+        return new CallingConvention(temps, 0, ret, args);
+    }
+
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 13:58:36 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 14:03:42 2012 +0200
@@ -24,7 +24,6 @@
 
 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.*;
@@ -33,7 +32,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.gen.*;
-import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.compiler.target.amd64.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
@@ -41,6 +39,7 @@
 import com.oracle.graal.hotspot.counters.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.hotspot.target.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
@@ -53,7 +52,7 @@
 /**
  * HotSpot AMD64 specific backend.
  */
-public class HotSpotAMD64Backend extends Backend {
+public class HotSpotAMD64Backend extends HotSpotBackend {
 
     public HotSpotAMD64Backend(CodeCacheProvider runtime, TargetDescription target) {
         super(runtime, target);