Mercurial > hg > graal-jvmci-8
changeset 9508:2b7857aaa1c0
Merge.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 02 May 2013 16:30:31 +0200 |
parents | 3df71c132731 (diff) 106f0a0acafa (current diff) |
children | 688219709f7b |
files | graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/nodes/MaterializeObjectNode.java |
diffstat | 4 files changed, 80 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Tue Apr 30 17:29:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu May 02 16:30:31 2013 +0200 @@ -186,6 +186,16 @@ super.emitCall(callTarget, result, arguments, temps, info); } + protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlot[] savedRegisterLocations) { + AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations); + append(save); + return save; + } + + protected void emitRestoreRegisters(AMD64SaveRegistersOp save) { + append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save)); + } + @Override public Variable emitCall(RuntimeCallTarget callTarget, CallingConvention cc, DeoptimizingNode info, Value... args) { Stub stub = runtime().asStub(method); @@ -198,20 +208,13 @@ if (stub.preservesRegisters()) { Register[] savedRegisters = frameMap.registerConfig.getAllocatableRegisters(); savedRegisterLocations = new StackSlot[savedRegisters.length]; - AMD64LIRInstruction[] savingMoves = new AMD64LIRInstruction[savedRegisters.length]; - AMD64LIRInstruction[] restoringMoves = new AMD64LIRInstruction[savedRegisters.length]; for (int i = 0; i < savedRegisters.length; i++) { PlatformKind kind = target.arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory()); assert kind != Kind.Illegal; StackSlot spillSlot = frameMap.allocateSpillSlot(kind); savedRegisterLocations[i] = spillSlot; - - RegisterValue register = savedRegisters[i].asValue(kind); - savingMoves[i] = createMove(spillSlot, register); - restoringMoves[i] = createMove(register, spillSlot); } - save = new AMD64SaveRegistersOp(savingMoves, restoringMoves, savedRegisterLocations); - append(save); + save = emitSaveRegisters(savedRegisters, savedRegisterLocations); } append(new AMD64HotSpotCRuntimeCallPrologueOp()); } @@ -224,7 +227,7 @@ assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo); calleeSaveInfo.put(currentRuntimeCallInfo, save); - append(new AMD64RestoreRegistersOp(savedRegisterLocations.clone(), save)); + emitRestoreRegisters(save); } else { assert zapRegisters(); } @@ -233,19 +236,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/AMD64RestoreRegistersOp.java Tue Apr 30 17:29:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java Thu May 02 16:30:31 2013 +0200 @@ -33,7 +33,7 @@ * Restores registers from stack slots. */ @Opcode("RESTORE_REGISTER") -public final class AMD64RestoreRegistersOp extends AMD64LIRInstruction { +public class AMD64RestoreRegistersOp extends AMD64LIRInstruction { /** * The slots from which the registers are restored. @@ -50,11 +50,21 @@ this.save = save; } + protected Register[] getSavedRegisters() { + return save.savedRegisters; + } + + protected void restoreRegister(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Register register, StackSlot input) { + RegisterValue result = register.asValue(input.getKind()); + AMD64Move.move(tasm, masm, result, input); + } + @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - for (AMD64LIRInstruction restoringMove : save.restoringMoves) { - if (restoringMove != null) { - restoringMove.emitCode(tasm, masm); + Register[] savedRegisters = getSavedRegisters(); + for (int i = 0; i < savedRegisters.length; i++) { + if (savedRegisters[i] != null) { + restoreRegister(tasm, masm, savedRegisters[i], slots[i]); } } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Tue Apr 30 17:29:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Thu May 02 16:30:31 2013 +0200 @@ -30,45 +30,47 @@ 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.*; /** * Saves registers to stack slots. */ @Opcode("SAVE_REGISTER") -public final class AMD64SaveRegistersOp extends AMD64RegistersPreservationOp { +public class AMD64SaveRegistersOp extends AMD64RegistersPreservationOp { /** - * The move instructions for saving the registers. + * The registers (potentially) saved by this operation. */ - protected final AMD64LIRInstruction[] savingMoves; - - /** - * The move instructions for restoring the registers. - */ - protected final AMD64LIRInstruction[] restoringMoves; + protected final Register[] savedRegisters; /** * The slots to which the registers are saved. */ @Def(STACK) protected final StackSlot[] slots; - public AMD64SaveRegistersOp(AMD64LIRInstruction[] savingMoves, AMD64LIRInstruction[] restoringMoves, StackSlot[] slots) { - this.savingMoves = savingMoves; - this.restoringMoves = restoringMoves; + public AMD64SaveRegistersOp(Register[] savedRegisters, StackSlot[] slots) { + this.savedRegisters = savedRegisters; this.slots = slots; } + protected void saveRegister(TargetMethodAssembler tasm, AMD64MacroAssembler masm, StackSlot result, Register register) { + RegisterValue input = register.asValue(result.getKind()); + AMD64Move.move(tasm, masm, result, input); + } + @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - for (AMD64LIRInstruction savingMove : savingMoves) { - if (savingMove != null) { - savingMove.emitCode(tasm, masm); + for (int i = 0; i < savedRegisters.length; i++) { + if (savedRegisters[i] != null) { + saveRegister(tasm, masm, slots[i], savedRegisters[i]); } } } + public StackSlot[] getSlots() { + return slots; + } + /** * Prunes the set of registers saved by this operation to exclude those in {@code ignored} and * updates {@code debugInfo} with a {@linkplain DebugInfo#getCalleeSaveInfo() description} of @@ -77,12 +79,10 @@ @Override public void update(Set<Register> ignored, DebugInfo debugInfo, FrameMap frameMap) { int preserved = 0; - for (int i = 0; i < savingMoves.length; i++) { - if (savingMoves[i] != null) { - Register register = ValueUtil.asRegister(((MoveOp) savingMoves[i]).getInput()); - if (ignored.contains(register)) { - savingMoves[i] = null; - restoringMoves[i] = null; + for (int i = 0; i < savedRegisters.length; i++) { + if (savedRegisters[i] != null) { + if (ignored.contains(savedRegisters[i])) { + savedRegisters[i] = null; } else { preserved++; } @@ -92,9 +92,9 @@ Register[] keys = new Register[preserved]; int[] values = new int[keys.length]; int mapIndex = 0; - for (int i = 0; i < savingMoves.length; i++) { - if (savingMoves[i] != null) { - keys[mapIndex] = ValueUtil.asRegister(((MoveOp) savingMoves[i]).getInput()); + for (int i = 0; i < savedRegisters.length; i++) { + if (savedRegisters[i] != null) { + keys[mapIndex] = savedRegisters[i]; values[mapIndex] = frameMap.indexForStackSlot(slots[i]); mapIndex++; }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Tue Apr 30 17:29:33 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Thu May 02 16:30:31 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; } } }