changeset 6489:1f0edd29cc66

defined new HotSpot specific interface extending the contract of a LIR generator moved creation of a tail-call LIR instruction behind this interface
author Doug Simon <doug.simon@oracle.com>
date Tue, 02 Oct 2012 17:22:22 +0200
parents b3a75a3d9e1b
children 9892bfd8a48f
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/HotSpotLIRGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java
diffstat 3 files changed, 53 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java	Tue Oct 02 16:48:54 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java	Tue Oct 02 17:22:22 2012 +0200
@@ -29,7 +29,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.target.amd64.*;
+import com.oracle.graal.hotspot.target.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
@@ -68,10 +68,9 @@
         for (int i = 0, slot = 0; i < cc.getArgumentCount(); i++, slot += FrameStateBuilder.stackSlots(frameState.localAt(slot).kind())) {
             parameters.add(frameState.localAt(slot));
         }
-        Value[] argList = gen.visitInvokeArguments(cc, parameters);
-
+        Value[] args = gen.visitInvokeArguments(cc, parameters);
         Value entry = gen.emitLoad(new Address(Kind.Long, gen.operand(target), config.nmethodEntryOffset), false);
-
-        gen.append(new AMD64TailcallOp(argList, entry));
+        HotSpotLIRGenerator hsgen = (HotSpotLIRGenerator) gen;
+        hsgen.emitTailcall(args, entry);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/HotSpotLIRGenerator.java	Tue Oct 02 17:22:22 2012 +0200
@@ -0,0 +1,42 @@
+/*
+ * 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 com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.gen.*;
+import com.oracle.graal.nodes.spi.*;
+
+/**
+ * This interface defines the contract a HotSpot backend LIR generator needs to fulfill
+ * in addition to abstract methods from {@link LIRGenerator} and {@link LIRGeneratorTool}.
+ */
+public interface HotSpotLIRGenerator {
+
+    /**
+     * Emits an operation to make a tail call.
+     *
+     * @param args the arguments of the call
+     * @param address the target address of the call
+     */
+    void emitTailcall(Value[] args, Value address);
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 16:48:54 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java	Tue Oct 02 17:22:22 2012 +0200
@@ -121,7 +121,7 @@
         return new HotSpotAMD64LIRGenerator(graph, runtime, target, frameMap, method, lir);
     }
 
-    static final class HotSpotAMD64LIRGenerator extends AMD64LIRGenerator {
+    static final class HotSpotAMD64LIRGenerator extends AMD64LIRGenerator implements HotSpotLIRGenerator {
 
         private HotSpotAMD64LIRGenerator(Graph graph, CodeCacheProvider runtime, TargetDescription target, FrameMap frameMap, ResolvedJavaMethod method, LIR lir) {
             super(graph, runtime, target, frameMap, method, lir);
@@ -159,6 +159,12 @@
         }
 
         @Override
+        public void emitTailcall(Value[] args, Value address) {
+            append(new AMD64TailcallOp(args, address));
+
+        }
+
+        @Override
         protected void emitPrologue() {
             super.emitPrologue();
             MethodEntryCounters.emitCounter(this, method);