# HG changeset patch # User Doug Simon # Date 1349179116 -7200 # Node ID 62878ae057a542646092273bba1a291048fd218a # Parent d93bff9fecb6a15c265390bc5663e70c5a6a2971 added support for temps in LIR call instructions diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Oct 02 13:58:36 2012 +0200 @@ -697,8 +697,7 @@ CallingConvention cc = frameMap.registerConfig.getCallingConvention(callTarget.callType(), x.node().kind(), signature, target(), false); frameMap.callsMethod(cc); - List argList = visitInvokeArguments(cc, callTarget.arguments()); - Value[] parameters = argList.toArray(new Value[argList.size()]); + Value[] parameters = visitInvokeArguments(cc, callTarget.arguments()); LIRFrameState callState = null; if (x.stateAfter() != null) { @@ -708,9 +707,9 @@ Value result = cc.getReturn(); if (callTarget instanceof DirectCallTargetNode) { - emitDirectCall((DirectCallTargetNode) callTarget, result, parameters, callState); + emitDirectCall((DirectCallTargetNode) callTarget, result, parameters, cc.getTemporaries(), callState); } else if (callTarget instanceof IndirectCallTargetNode) { - emitIndirectCall((IndirectCallTargetNode) callTarget, result, parameters, callState); + emitIndirectCall((IndirectCallTargetNode) callTarget, result, parameters, cc.getTemporaries(), callState); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -720,11 +719,11 @@ } } - protected abstract void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, LIRFrameState callState); + protected abstract void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState); - protected abstract void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, LIRFrameState callState); + protected abstract void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState); - protected abstract void emitCall(Object targetMethod, Value result, List arguments, Value targetAddress, LIRFrameState info); + protected abstract void emitCall(Object targetMethod, Value result, Value[] arguments, Value[] temps, Value targetAddress, LIRFrameState info); private static Value toStackKind(Value value) { if (value.getKind().stackKind() != value.getKind()) { @@ -740,21 +739,21 @@ return value; } - public List visitInvokeArguments(CallingConvention cc, Iterable arguments) { + public Value[] visitInvokeArguments(CallingConvention cc, Collection arguments) { // for each argument, load it into the correct location - List argList = new ArrayList<>(); + Value[] result = new Value[arguments.size()]; int j = 0; for (ValueNode arg : arguments) { if (arg != null) { - Value operand = toStackKind(cc.getArgument(j++)); + Value operand = toStackKind(cc.getArgument(j)); emitMove(operand(arg), operand); - argList.add(operand); - + result[j] = operand; + j++; } else { throw GraalInternalError.shouldNotReachHere("I thought we no longer have null entries for two-slot types..."); } } - return argList; + return result; } @@ -774,9 +773,7 @@ emitMove(arg, loc); argLocations[i] = loc; } - List argumentList = Arrays.asList(argLocations); - - emitCall(target, cc.getReturn(), argumentList, Constant.forLong(0), info); + emitCall(target, cc.getReturn(), argLocations, cc.getTemporaries(), Constant.forLong(0), info); if (isLegal(cc.getReturn())) { return emitMove(cc.getReturn()); @@ -796,7 +793,7 @@ CallingConvention cc = frameMap.registerConfig.getCallingConvention(RuntimeCall, x.kind(), x.call().getArgumentKinds(), target(), false); frameMap.callsMethod(cc); Value resultOperand = cc.getReturn(); - List argList = visitInvokeArguments(cc, x.arguments()); + Value[] args = visitInvokeArguments(cc, x.arguments()); LIRFrameState info = null; FrameState stateAfter = x.stateAfter(); @@ -820,7 +817,7 @@ info = state(); } - emitCall(x.call(), resultOperand, argList, Constant.forLong(0), info); + emitCall(x.call(), resultOperand, args, cc.getTemporaries(), Constant.forLong(0), info); if (isLegal(resultOperand)) { setResult(x, emitMove(resultOperand)); @@ -970,9 +967,7 @@ emitMove(arg, loc); argLocations[i] = loc; } - List argumentList = Arrays.asList(argLocations); - - emitCall(runtimeCall, cc.getReturn(), argumentList, Constant.forLong(0), info); + emitCall(runtimeCall, cc.getReturn(), argLocations, cc.getTemporaries(), Constant.forLong(0), info); return cc.getReturn(); } diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java Tue Oct 02 13:58:36 2012 +0200 @@ -27,8 +27,6 @@ import static com.oracle.graal.lir.amd64.AMD64Arithmetic.*; import static com.oracle.graal.lir.amd64.AMD64Compare.*; -import java.util.*; - import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; @@ -545,24 +543,24 @@ } @Override - protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, LIRFrameState callState) { - append(new DirectCallOp(callTarget.target(), result, parameters, callState)); + protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { + append(new DirectCallOp(callTarget.target(), result, parameters, temps, callState)); } @Override - protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, LIRFrameState callState) { + protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { // The current register allocator cannot handle variables at call sites, need a fixed register. Value targetAddress = AMD64.rax.asValue(); emitMove(operand(callTarget.computedAddress()), targetAddress); - append(new IndirectCallOp(callTarget.target(), result, parameters, targetAddress, callState)); + append(new IndirectCallOp(callTarget.target(), result, parameters, temps, targetAddress, callState)); } @Override - protected void emitCall(Object targetMethod, Value result, List arguments, Value targetAddress, LIRFrameState info) { + protected void emitCall(Object targetMethod, Value result, Value[] arguments, Value[] temps, Value targetAddress, LIRFrameState info) { if (isConstant(targetAddress)) { - append(new DirectCallOp(targetMethod, result, arguments.toArray(new Value[arguments.size()]), info)); + append(new DirectCallOp(targetMethod, result, arguments, temps, info)); } else { - append(new IndirectCallOp(targetMethod, result, arguments.toArray(new Value[arguments.size()]), targetAddress, info)); + append(new IndirectCallOp(targetMethod, result, arguments, temps, targetAddress, info)); } } diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Tue Oct 02 13:58:36 2012 +0200 @@ -68,7 +68,7 @@ for (int i = 0, slot = 0; i < cc.getArgumentCount(); i++, slot += FrameStateBuilder.stackSlots(frameState.localAt(slot).kind())) { parameters.add(frameState.localAt(slot)); } - List argList = gen.visitInvokeArguments(cc, parameters); + Value[] argList = gen.visitInvokeArguments(cc, parameters); Value entry = gen.emitLoad(new Address(Kind.Long, gen.operand(target), config.nmethodEntryOffset), false); diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64DirectCallOp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64DirectCallOp.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64DirectCallOp.java Tue Oct 02 13:58:36 2012 +0200 @@ -58,8 +58,8 @@ private final InvokeKind invokeKind; - AMD64DirectCallOp(Object targetMethod, Value result, Value[] parameters, LIRFrameState state, InvokeKind invokeKind, LIR lir) { - super(targetMethod, result, parameters, state); + AMD64DirectCallOp(Object targetMethod, Value result, Value[] parameters, Value[] temps, LIRFrameState state, InvokeKind invokeKind, LIR lir) { + super(targetMethod, result, parameters, temps, state); this.invokeKind = invokeKind; if (invokeKind == Static || invokeKind == Special) { diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64IndirectCallOp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64IndirectCallOp.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64IndirectCallOp.java Tue Oct 02 13:58:36 2012 +0200 @@ -51,8 +51,8 @@ @Use({REG}) protected Value methodOop; - AMD64IndirectCallOp(Object targetMethod, Value result, Value[] parameters, Value methodOop, Value targetAddress, LIRFrameState state) { - super(targetMethod, result, parameters, targetAddress, state); + AMD64IndirectCallOp(Object targetMethod, Value result, Value[] parameters, Value[] temps, Value methodOop, Value targetAddress, LIRFrameState state) { + super(targetMethod, result, parameters, temps, targetAddress, state); this.methodOop = methodOop; } diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64TailcallOp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64TailcallOp.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64TailcallOp.java Tue Oct 02 13:58:36 2012 +0200 @@ -24,8 +24,6 @@ import static com.oracle.graal.api.code.ValueUtil.*; -import java.util.*; - import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.lir.LIRInstruction.Opcode; @@ -41,9 +39,9 @@ @Use protected Value target; @Alive protected Value[] parameters; - public AMD64TailcallOp(List parameters, Value target) { + public AMD64TailcallOp(Value[] parameters, Value target) { this.target = target; - this.parameters = parameters.toArray(new Value[parameters.size()]); + this.parameters = parameters; } @Override diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java Tue Oct 02 13:58:36 2012 +0200 @@ -24,10 +24,10 @@ import static com.oracle.graal.api.code.CallingConvention.Type.*; import static com.oracle.graal.api.code.ValueUtil.*; +import static com.oracle.graal.api.meta.Value.*; import static com.oracle.max.asm.target.amd64.AMD64.*; import java.lang.reflect.*; -import java.util.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -85,8 +85,7 @@ } CallingConvention cc = frameMap.registerConfig.getCallingConvention(CallingConvention.Type.JavaCall, Kind.Void, sig, target(), false); - List argList = visitInvokeArguments(cc, i.arguments); - Value[] parameters = argList.toArray(new Value[argList.size()]); + Value[] parameters = visitInvokeArguments(cc, i.arguments); append(new AMD64BreakpointOp(parameters)); } @@ -109,17 +108,17 @@ } @Override - protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, LIRFrameState callState) { - append(new AMD64DirectCallOp(callTarget.target(), result, parameters, callState, ((HotSpotDirectCallTargetNode) callTarget).invokeKind(), lir)); + protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { + append(new AMD64DirectCallOp(callTarget.target(), result, parameters, temps, callState, ((HotSpotDirectCallTargetNode) callTarget).invokeKind(), lir)); } @Override - protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, LIRFrameState callState) { + protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { Value methodOop = AMD64.rbx.asValue(); emitMove(operand(((HotSpotIndirectCallTargetNode) callTarget).methodOop()), methodOop); Value targetAddress = AMD64.rax.asValue(); emitMove(operand(callTarget.computedAddress()), targetAddress); - append(new AMD64IndirectCallOp(callTarget.target(), result, parameters, methodOop, targetAddress, callState)); + append(new AMD64IndirectCallOp(callTarget.target(), result, parameters, temps, methodOop, targetAddress, callState)); } } diff -r d93bff9fecb6 -r 62878ae057a5 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Tue Oct 02 13:48:16 2012 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Tue Oct 02 13:58:36 2012 +0200 @@ -28,7 +28,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.LIRInstruction.Opcode; +import com.oracle.graal.lir.LIRInstruction.*; import com.oracle.graal.lir.asm.*; import com.oracle.max.asm.target.amd64.*; @@ -38,15 +38,18 @@ public static class DirectCallOp extends AMD64LIRInstruction implements StandardOp.CallOp { @Def({REG, ILLEGAL}) protected Value result; @Use({REG, STACK}) protected Value[] parameters; + @Temp protected Value[] temps; @State protected LIRFrameState state; protected final Object targetMethod; - public DirectCallOp(Object targetMethod, Value result, Value[] parameters, LIRFrameState state) { + public DirectCallOp(Object targetMethod, Value result, Value[] parameters, Value[] temps, LIRFrameState state) { this.targetMethod = targetMethod; this.result = result; this.parameters = parameters; this.state = state; + this.temps = temps; + assert temps != null; } @Override @@ -70,16 +73,19 @@ @Def({REG, ILLEGAL}) protected Value result; @Use({REG, STACK}) protected Value[] parameters; @Use({REG}) protected Value targetAddress; + @Temp protected Value[] temps; @State protected LIRFrameState state; protected final Object targetMethod; - public IndirectCallOp(Object targetMethod, Value result, Value[] parameters, Value targetAddress, LIRFrameState state) { + public IndirectCallOp(Object targetMethod, Value result, Value[] parameters, Value[] temps, Value targetAddress, LIRFrameState state) { this.targetMethod = targetMethod; this.result = result; this.parameters = parameters; this.targetAddress = targetAddress; this.state = state; + this.temps = temps; + assert temps != null; } @Override