changeset 9506:6703dca691d7

Restructure register zapping.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 02 May 2013 14:12:10 +0200
parents d48b7a4b93e9
children 3df71c132731
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java
diffstat 2 files changed, 30 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Thu May 02 11:53:04 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Thu May 02 14:12:10 2013 +0200
@@ -227,19 +227,21 @@
         return result;
     }
 
+    protected AMD64ZapRegistersOp emitZapRegisters(Register[] zappedRegisters, Constant[] zapValues) {
+        AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappedRegisters, zapValues);
+        append(zap);
+        return zap;
+    }
+
     protected boolean zapRegisters() {
         Register[] zappedRegisters = frameMap.registerConfig.getAllocatableRegisters();
-        AMD64LIRInstruction[] zappingMoves = new AMD64LIRInstruction[zappedRegisters.length];
+        Constant[] zapValues = new Constant[zappedRegisters.length];
         for (int i = 0; i < zappedRegisters.length; i++) {
             PlatformKind kind = target.arch.getLargestStorableKind(zappedRegisters[i].getRegisterCategory());
             assert kind != Kind.Illegal;
-
-            RegisterValue register = zappedRegisters[i].asValue(kind);
-            zappingMoves[i] = createMove(register, zapValueForKind(kind));
+            zapValues[i] = zapValueForKind(kind);
         }
-        AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappingMoves);
-        append(zap);
-        calleeSaveInfo.put(currentRuntimeCallInfo, zap);
+        calleeSaveInfo.put(currentRuntimeCallInfo, emitZapRegisters(zappedRegisters, zapValues));
         return true;
     }
 
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java	Thu May 02 11:53:04 2013 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java	Thu May 02 14:12:10 2013 +0200
@@ -22,13 +22,15 @@
  */
 package com.oracle.graal.lir.amd64;
 
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.LIRInstruction.Opcode;
-import com.oracle.graal.lir.StandardOp.MoveOp;
 import com.oracle.graal.lir.asm.*;
 
 /**
@@ -38,19 +40,26 @@
 public final class AMD64ZapRegistersOp extends AMD64RegistersPreservationOp {
 
     /**
-     * The move instructions for zapping the registers.
+     * The registers that are zapped.
      */
-    protected final AMD64LIRInstruction[] zappingMoves;
+    protected final Register[] zappedRegisters;
 
-    public AMD64ZapRegistersOp(AMD64LIRInstruction[] zappingMoves) {
-        this.zappingMoves = zappingMoves;
+    /**
+     * The garbage values that are written to the registers.
+     */
+    @Use({CONST}) protected Constant[] zapValues;
+
+    public AMD64ZapRegistersOp(Register[] zappedRegisters, Constant[] zapValues) {
+        this.zappedRegisters = zappedRegisters;
+        this.zapValues = zapValues;
     }
 
     @Override
     public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-        for (AMD64LIRInstruction zappingMove : zappingMoves) {
-            if (zappingMove != null) {
-                zappingMove.emitCode(tasm, masm);
+        for (int i = 0; i < zappedRegisters.length; i++) {
+            if (zappedRegisters[i] != null) {
+                RegisterValue registerValue = zappedRegisters[i].asValue(zapValues[i].getPlatformKind());
+                AMD64Move.move(tasm, masm, registerValue, zapValues[i]);
             }
         }
     }
@@ -60,11 +69,10 @@
      */
     @Override
     public void update(Set<Register> ignored, DebugInfo debugInfo, FrameMap frameMap) {
-        for (int i = 0; i < zappingMoves.length; i++) {
-            if (zappingMoves[i] != null) {
-                Register register = ValueUtil.asRegister(((MoveOp) zappingMoves[i]).getResult());
-                if (ignored.contains(register)) {
-                    zappingMoves[i] = null;
+        for (int i = 0; i < zappedRegisters.length; i++) {
+            if (zappedRegisters[i] != null) {
+                if (ignored.contains(zappedRegisters[i])) {
+                    zappedRegisters[i] = null;
                 }
             }
         }