changeset 5247:62bbfd78c703

removed mechanism for lowering ExceptionObjectNode via substitution; only LIR lowering by the runtime is now supported
author Doug Simon <doug.simon@oracle.com>
date Tue, 17 Apr 2012 22:24:14 +0200
parents 8bf2c37c46c4
children 066f1687ba24
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObjectNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotMethodResolvedImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java
diffstat 8 files changed, 17 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Tue Apr 17 13:52:38 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Tue Apr 17 22:24:14 2012 +0200
@@ -585,11 +585,6 @@
     }
 
     @Override
-    public void visitExceptionObject(ExceptionObjectNode x) {
-        throw new GraalInternalError("Runtime must provide lowering for " + x);
-    }
-
-    @Override
     public void visitReturn(ReturnNode x) {
         CiValue operand = CiValue.IllegalValue;
         if (!x.kind().isVoid()) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Tue Apr 17 13:52:38 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Tue Apr 17 22:24:14 2012 +0200
@@ -27,10 +27,12 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.cfg.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.max.cri.ri.*;
 
+/**
+ * Processes all {@link Lowerable} nodes to do their lowering.
+ */
 public class LoweringPhase extends Phase {
 
     private final GraalRuntime runtime;
@@ -68,8 +70,7 @@
         };
         for (Node node : processed) {
             if (node instanceof Lowerable) {
-                // TODO (dnsimon) is it safe to replace ExceptionObjectNode with HotSpotExceptionObjectNode?
-                assert !(node instanceof FixedNode) || node instanceof ExceptionObjectNode || node.predecessor() == null;
+                assert !(node instanceof FixedNode) || node.predecessor() == null;
                 ((Lowerable) node).lower(loweringTool);
             }
         }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Apr 17 13:52:38 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Apr 17 22:24:14 2012 +0200
@@ -74,7 +74,7 @@
 /**
  * This class implements the X86-specific portion of the LIR generator.
  */
-public class AMD64LIRGenerator extends LIRGenerator {
+public abstract class AMD64LIRGenerator extends LIRGenerator {
 
     private static final CiRegisterValue RAX_I = AMD64.rax.asValue(CiKind.Int);
     private static final CiRegisterValue RAX_L = AMD64.rax.asValue(CiKind.Long);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotExceptionObjectNode.java	Tue Apr 17 13:52:38 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, 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.nodes;
-
-import static com.oracle.max.asm.target.amd64.AMD64.*;
-
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.max.cri.ci.*;
-
-public final class HotSpotExceptionObjectNode extends ExceptionObjectNode {
-
-    @Override
-    public void generate(LIRGeneratorTool gen) {
-        HotSpotVMConfig config = CompilerImpl.getInstance().getConfig();
-        CiRegisterValue thread = r15.asValue();
-        CiAddress exceptionAddress = new CiAddress(CiKind.Object, thread, config.threadExceptionOopOffset);
-        CiAddress pcAddress = new CiAddress(CiKind.Long, thread, config.threadExceptionPcOffset);
-        CiValue exception = gen.emitLoad(exceptionAddress, false);
-        gen.emitStore(exceptionAddress, CiConstant.NULL_OBJECT, false);
-        gen.emitStore(pcAddress, CiConstant.LONG_0, false);
-        gen.setResult(this, exception);
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Tue Apr 17 13:52:38 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Tue Apr 17 22:24:14 2012 +0200
@@ -357,9 +357,6 @@
     public boolean canBeInlined() {
         return canBeInlined;
     }
-    public void neverInline() {
-        this.canBeInlined = false;
-    }
 
     @Override
     public int vtableEntryOffset() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Tue Apr 17 13:52:38 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Tue Apr 17 22:24:14 2012 +0200
@@ -28,7 +28,6 @@
 import java.util.*;
 
 import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.phases.*;
 import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.compiler.target.*;
@@ -45,7 +44,10 @@
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.max.cri.ci.*;
-import com.oracle.max.cri.ci.CiTargetMethod.*;
+import com.oracle.max.cri.ci.CiTargetMethod.Call;
+import com.oracle.max.cri.ci.CiTargetMethod.DataPatch;
+import com.oracle.max.cri.ci.CiTargetMethod.Mark;
+import com.oracle.max.cri.ci.CiTargetMethod.Safepoint;
 import com.oracle.max.cri.ci.CiUtil.RefMapFormatter;
 import com.oracle.max.cri.ri.*;
 import com.oracle.max.cri.ri.RiType.Representation;
@@ -60,16 +62,6 @@
     private final HotSpotRegisterConfig globalStubRegConfig;
     private final Compiler compiler;
 
-    /**
-     * System-property defined constant to select mechanism for specific lowering of an ExceptionObjectNode.
-     * By default, the override of {@link LIRGenerator#visitExceptionObject} in {@link HotSpotAMD64Backend}
-     * is used. This seems to work. The alternative is to replace ExceptionObjecNode with
-     * {@link HotSpotExceptionObjectNode} in {@link LoweringPhase}. This does not seem work - it crashes
-     * the Eclipse DaCapo benchmark. Once it is understood why the latter happens, a permanent choice
-     * can be made as to which lowering mechanism to use.
-     */
-    private static final boolean UseHotSpotExceptionObjectNode = Boolean.getBoolean("UseHotSpotExceptionObjectNode");
-
     public HotSpotRuntime(HotSpotVMConfig config, Compiler compiler) {
         this.config = config;
         this.compiler = compiler;
@@ -400,12 +392,6 @@
             ReadNode memoryRead = graph.add(new ReadNode(objectClassNode.object(), location, StampFactory.objectNonNull()));
             memoryRead.setGuard((GuardNode) tool.createGuard(graph.unique(new NullCheckNode(objectClassNode.object(), false)), RiDeoptReason.NullCheckException, RiDeoptAction.InvalidateReprofile, StructuredGraph.INVALID_GRAPH_ID));
             graph.replaceFixed(objectClassNode, memoryRead);
-        } else if (n instanceof ExceptionObjectNode) {
-            if (UseHotSpotExceptionObjectNode) {
-                ExceptionObjectNode exceptionObjectNode = (ExceptionObjectNode) n;
-                HotSpotExceptionObjectNode exceptionObject = graph.add(new HotSpotExceptionObjectNode());
-                graph.replaceFixedWithFixed(exceptionObjectNode, exceptionObject);
-            }
         } else {
             assert false : "Node implementing Lowerable not handled: " + n;
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Tue Apr 17 13:52:38 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Tue Apr 17 22:24:14 2012 +0200
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.nodes.java;
 
-import com.oracle.graal.cri.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
@@ -32,7 +31,7 @@
 /**
  * The {@code ExceptionObject} instruction represents the incoming exception object to an exception handler.
  */
-public class ExceptionObjectNode extends AbstractStateSplit implements Lowerable, LIRLowerable, MemoryCheckpoint {
+public class ExceptionObjectNode extends AbstractStateSplit implements LIRLowerable, MemoryCheckpoint {
 
     /**
      * Constructs a new ExceptionObject instruction.
@@ -42,12 +41,13 @@
     }
 
     @Override
-    public void lower(CiLoweringTool tool) {
-        tool.getRuntime().lower(this, tool);
+    public void generate(LIRGeneratorTool gen) {
+        gen.visitExceptionObject(this);
     }
 
     @Override
-    public void generate(LIRGeneratorTool gen) {
-        gen.visitExceptionObject(this);
+    public boolean verify() {
+        assertTrue(stateAfter() != null, "an exception handler needs a frame state");
+        return super.verify();
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Tue Apr 17 13:52:38 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Tue Apr 17 22:24:14 2012 +0200
@@ -101,7 +101,8 @@
     public abstract void visitCompareAndSwap(CompareAndSwapNode i);
 
     // Functionality that is currently implemented in XIR.
-    // These methods will go away eventually when lowering is done via snippets in the front end.
+    // Some of these methods will go away when lowering is done via snippets in the front end.
+    // The remainder will define the contract a runtime specific backend must provide.
     public abstract void visitCheckCast(CheckCastNode i);
     public abstract void visitMonitorEnter(MonitorEnterNode i);
     public abstract void visitMonitorExit(MonitorExitNode i);