changeset 9454:85a836bcd796

renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
author Doug Simon <doug.simon@oracle.com>
date Tue, 30 Apr 2013 20:09:29 +0200
parents cdc839f22a23
children 62af2ee39bc5
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RuntimeCallTarget.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java
diffstat 7 files changed, 31 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RuntimeCallTarget.java	Tue Apr 30 20:07:53 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RuntimeCallTarget.java	Tue Apr 30 20:09:29 2013 +0200
@@ -115,5 +115,11 @@
 
     Descriptor getDescriptor();
 
-    boolean preservesRegisters();
+    /**
+     * Determines if the target routine destroys all registers.
+     * 
+     * @return {@code true} if the register allocator must save all live registers around a call to
+     *         this target
+     */
+    boolean destroysRegisters();
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Apr 30 20:07:53 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Apr 30 20:09:29 2013 +0200
@@ -413,7 +413,7 @@
      */
     boolean hasCall(int opId) {
         assert isEven(opId) : "opId not even";
-        return instructionForId(opId).hasCall();
+        return instructionForId(opId).destroysCallerSavedRegisters();
     }
 
     /**
@@ -1181,7 +1181,7 @@
                 final int opId = op.id();
 
                 // add a temp range for each register if operation destroys caller-save registers
-                if (op.hasCall()) {
+                if (op.destroysCallerSavedRegisters()) {
                     for (Register r : callerSaveRegs) {
                         if (attributes(r).isAllocatable()) {
                             addTemp(r.asValue(), opId, RegisterPriority.None, Kind.Illegal);
@@ -1681,7 +1681,7 @@
             // before we've consumed the inputs.
             if (op.id() < interval.currentTo()) {
                 // caller-save registers must not be included into oop-maps at calls
-                assert !op.hasCall() || !isRegister(operand) || !isCallerSave(operand) : "interval is in a caller-save register at a call . register will be overwritten";
+                assert !op.destroysCallerSavedRegisters() || !isRegister(operand) || !isCallerSave(operand) : "interval is in a caller-save register at a call . register will be overwritten";
 
                 frameMap.setReference(interval.location(), registerRefMap, frameRefMap);
 
@@ -1703,7 +1703,7 @@
     }
 
     private void computeDebugInfo(IntervalWalker iw, final LIRInstruction op, LIRFrameState info) {
-        BitSet registerRefMap = op.hasCall() ? null : frameMap.initRegisterRefMap();
+        BitSet registerRefMap = op.destroysCallerSavedRegisters() ? null : frameMap.initRegisterRefMap();
         BitSet frameRefMap = frameMap.initFrameRefMap();
         computeOopMap(iw, op, registerRefMap, frameRefMap);
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java	Tue Apr 30 20:07:53 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java	Tue Apr 30 20:09:29 2013 +0200
@@ -248,7 +248,7 @@
             // check if input operands are correct
             op.forEachInput(useProc);
             // invalidate all caller save registers at calls
-            if (op.hasCall()) {
+            if (op.destroysCallerSavedRegisters()) {
                 for (Register r : allocator.frameMap.registerConfig.getCallerSaveRegisters()) {
                     statePut(inputState, r.asValue(), null);
                 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java	Tue Apr 30 20:07:53 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java	Tue Apr 30 20:09:29 2013 +0200
@@ -117,9 +117,18 @@
     }
 
     @Override
-    public boolean preservesRegisters() {
-        assert address != 0;
-        return true;
+    public boolean destroysRegisters() {
+        if (isCRuntimeCall) {
+            // Even though most native ABIs define some callee saved registers,
+            // for simplicity we force the register allocator to save all live
+            // registers across a C runtime call as such calls are only made from
+            // compiled stubs which a) are slow path and b) will typically only
+            // have very few live registers across a C runtime call
+            return true;
+        }
+        // This is a call to a compiled (or assembler) stub which saves
+        // all registers (apart from its temporaries)
+        return false;
     }
 
     /**
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Tue Apr 30 20:07:53 2013 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Tue Apr 30 20:09:29 2013 +0200
@@ -51,7 +51,7 @@
         }
 
         @Override
-        public boolean hasCall() {
+        public boolean destroysCallerSavedRegisters() {
             return true;
         }
     }
@@ -112,8 +112,8 @@
         }
 
         @Override
-        public boolean hasCall() {
-            return !callTarget.preservesRegisters();
+        public boolean destroysCallerSavedRegisters() {
+            return callTarget.destroysRegisters();
         }
     }
 
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java	Tue Apr 30 20:07:53 2013 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java	Tue Apr 30 20:09:29 2013 +0200
@@ -244,7 +244,7 @@
     }
 
     public final boolean hasOperands() {
-        return instructionClass.hasOperands() || hasState() || hasCall();
+        return instructionClass.hasOperands() || hasState() || destroysCallerSavedRegisters();
     }
 
     public final boolean hasState() {
@@ -252,10 +252,9 @@
     }
 
     /**
-     * Returns true when this instruction is a call instruction that destroys all caller-saved
-     * registers.
+     * Determines if this instruction destroys all caller-saved registers..
      */
-    public boolean hasCall() {
+    public boolean destroysCallerSavedRegisters() {
         return false;
     }
 
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java	Tue Apr 30 20:07:53 2013 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java	Tue Apr 30 20:09:29 2013 +0200
@@ -138,7 +138,7 @@
                 curInstruction = op;
 
                 op.forEachInput(useProc);
-                if (op.hasCall()) {
+                if (op.destroysCallerSavedRegisters()) {
                     for (Register register : frameMap.registerConfig.getCallerSaveRegisters()) {
                         curRegistersLive[register.number] = null;
                     }