# HG changeset patch # User Lukas Stadler # Date 1304604420 -7200 # Node ID 1c36b17f7ee0bd9d37a55e34f737c9cf4b365856 # Parent 4a4dab936c1e9a82170243a1dbf89ecd6a57ffe1 new node layout: AccessMonitor, Invoke diff -r 4a4dab936c1e -r 1c36b17f7ee0 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 05 15:49:48 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 05 16:07:00 2011 +0200 @@ -465,7 +465,7 @@ CiValue resultOperand = resultOperandFor(x.kind); CiCallingConvention cc = compilation.frameMap().getCallingConvention(x.signature(), JavaCall); List pointerSlots = new ArrayList(2); - List argList = visitInvokeArguments(cc, x.arguments(), pointerSlots); + List argList = visitInvokeArguments(cc, x, pointerSlots); if (C1XOptions.InvokeSnippetAfterArguments) { destinationAddress = emitXir(snippet, x, info.copy(), null, x.target(), false, pointerSlots); @@ -1434,11 +1434,12 @@ return new LIRDebugInfo(state, x.exceptionHandlers()); } - List visitInvokeArguments(CiCallingConvention cc, Value[] args, List pointerSlots) { + List visitInvokeArguments(CiCallingConvention cc, Invoke x, List pointerSlots) { // for each argument, load it into the correct location - List argList = new ArrayList(args.length); + List argList = new ArrayList(x.argumentCount()); int j = 0; - for (Value arg : args) { + for (int i = 0; i < x.argumentCount(); i++) { + Value arg = x.argument(i); if (arg != null) { CiValue operand = cc.locations[j++]; if (operand.isRegister()) { @@ -1456,7 +1457,7 @@ } if (arg.kind == CiKind.Object && pointerSlots != null) { - // This slot must be marked explicitedly in the pointer map. + // This slot must be marked explicitly in the pointer map. pointerSlots.add(slot); } } @@ -1600,7 +1601,7 @@ private CiValue emitInvokeKnown(RiMethod method, FrameState stateBefore, Value... args) { boolean isStatic = Modifier.isStatic(method.accessFlags()); - Invoke invoke = new Invoke(isStatic ? Bytecodes.INVOKESTATIC : Bytecodes.INVOKESPECIAL, method.signature().returnKind(), args, method, null, stateBefore); + Invoke invoke = new Invoke(isStatic ? Bytecodes.INVOKESTATIC : Bytecodes.INVOKESPECIAL, method.signature().returnKind(), args, method, null, stateBefore, null); visitInvoke(invoke); return invoke.operand(); } diff -r 4a4dab936c1e -r 1c36b17f7ee0 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 05 15:49:48 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 05 16:07:00 2011 +0200 @@ -901,7 +901,7 @@ private void appendInvoke(int opcode, RiMethod target, Value[] args, int cpi, RiConstantPool constantPool) { CiKind resultType = returnKind(target); - Value result = append(new Invoke(opcode, resultType.stackKind(), args, target, target.signature().returnType(compilation.method.holder()), null)); + Value result = append(new Invoke(opcode, resultType.stackKind(), args, target, target.signature().returnType(compilation.method.holder()), null, graph)); pushReturn(resultType, result); } @@ -1021,7 +1021,7 @@ lockAddress = new MonitorAddress(lockNumber); append(lockAddress); } - append(new MonitorExit(rootMethodSynchronizedObject, lockAddress, lockNumber, stateBefore)); + append(new MonitorExit(rootMethodSynchronizedObject, lockAddress, lockNumber, stateBefore, graph)); curState.unlock(); } append(new Return(x, !noSafepoints())); @@ -1041,7 +1041,7 @@ lockAddress = new MonitorAddress(lockNumber); append(lockAddress); } - MonitorEnter monitorEnter = new MonitorEnter(x, lockAddress, lockNumber, null); + MonitorEnter monitorEnter = new MonitorEnter(x, lockAddress, lockNumber, null, graph); appendWithoutOptimization(monitorEnter, bci); curState.lock(ir, x, lockNumber + 1); monitorEnter.setStateAfter(curState.immutableCopy(bci)); @@ -1058,7 +1058,7 @@ lockAddress = new MonitorAddress(lockNumber); append(lockAddress); } - appendWithoutOptimization(new MonitorExit(x, lockAddress, lockNumber, null), bci); + appendWithoutOptimization(new MonitorExit(x, lockAddress, lockNumber, null, graph), bci); curState.unlock(); killMemoryMap(); // prevent any optimizations across synchronization } diff -r 4a4dab936c1e -r 1c36b17f7ee0 graal/GraalCompiler/src/com/sun/c1x/ir/AccessMonitor.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessMonitor.java Thu May 05 15:49:48 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessMonitor.java Thu May 05 16:07:00 2011 +0200 @@ -22,32 +22,58 @@ */ package com.sun.c1x.ir; +import com.oracle.graal.graph.*; import com.sun.c1x.value.*; import com.sun.cri.ci.*; /** * The {@code AccessMonitor} instruction is the base class of both monitor acquisition and release. - * - * @author Ben L. Titzer */ public abstract class AccessMonitor extends StateSplit { - /** - * The object locked or unlocked by this instruction. - */ - private Value object; + private static final int INPUT_COUNT = 2; + private static final int INPUT_OBJECT = 0; + private static final int INPUT_LOCK_ADDRESS = 1; + + private static final int SUCCESSOR_COUNT = 0; + + @Override + protected int inputCount() { + return super.inputCount() + INPUT_COUNT; + } + + @Override + protected int successorCount() { + return super.successorCount() + SUCCESSOR_COUNT; + } /** - * The address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack. + * The instruction producing the object locked or unlocked by this instruction. */ - private Value lockAddress; + public Value object() { + return (Value) inputs().get(super.inputCount() + INPUT_OBJECT); + } + + public Value setObject(Value n) { + return (Value) inputs().set(super.inputCount() + INPUT_OBJECT, n); + } + + /** + * The instruction producing the address of the lock object. + */ + public Value lockAddress() { + return (Value) inputs().get(super.inputCount() + INPUT_LOCK_ADDRESS); + } + + public Value setLockAddress(Value n) { + return (Value) inputs().set(super.inputCount() + INPUT_LOCK_ADDRESS, n); + } /** * The lock number of this monitor access. */ public final int lockNumber; - /** * Creates a new AccessMonitor instruction. * @@ -55,33 +81,14 @@ * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack * @param stateBefore the state before executing the monitor operation * @param lockNumber the number of the lock being acquired - */ - public AccessMonitor(Value object, Value lockAddress, FrameState stateBefore, int lockNumber) { - super(CiKind.Illegal, stateBefore); - this.object = object; - this.lockAddress = lockAddress; - this.lockNumber = lockNumber; - } - - /** - * Gets the instruction producing the object locked or unlocked by this instruction. + * @param inputCount + * @param successorCount + * @param graph */ - public Value object() { - return object; - } - - /** - * Gets the instruction producing the address of the lock object. - */ - public Value lockAddress() { - return lockAddress; - } - - @Override - public void inputValuesDo(ValueClosure closure) { - object = closure.apply(object); - if (lockAddress != null) { - lockAddress = closure.apply(lockAddress); - } + public AccessMonitor(Value object, Value lockAddress, FrameState stateBefore, int lockNumber, int inputCount, int successorCount, Graph graph) { + super(CiKind.Illegal, stateBefore, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); + this.lockNumber = lockNumber; + setObject(object); + setLockAddress(lockAddress); } } diff -r 4a4dab936c1e -r 1c36b17f7ee0 graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Thu May 05 15:49:48 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Thu May 05 16:07:00 2011 +0200 @@ -22,6 +22,7 @@ */ package com.sun.c1x.ir; +import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; import com.sun.c1x.util.*; import com.sun.c1x.value.*; @@ -34,8 +35,38 @@ */ public final class Invoke extends StateSplit { + private final int argumentCount; + + private static final int SUCCESSOR_COUNT = 0; + + @Override + protected int inputCount() { + return super.inputCount() + argumentCount; + } + + @Override + protected int successorCount() { + return super.successorCount() + SUCCESSOR_COUNT; + } + + /** + * The list of instructions that produce input for this instruction. + */ + public Value argument(int index) { + assert index >= 0 && index < argumentCount; + return (Value) inputs().get(super.inputCount() + index); + } + + public Value setArgument(int index, Value n) { + assert index >= 0 && index < argumentCount; + return (Value) inputs().set(super.inputCount() + index, n); + } + + public int argumentCount() { + return argumentCount; + } + public final int opcode; - public final Value[] arguments; public final RiMethod target; public final RiType returnType; @@ -49,12 +80,16 @@ * @param target the target method being called * @param stateBefore the state before executing the invocation */ - public Invoke(int opcode, CiKind result, Value[] args, RiMethod target, RiType returnType, FrameState stateBefore) { - super(result, stateBefore); + public Invoke(int opcode, CiKind result, Value[] args, RiMethod target, RiType returnType, FrameState stateBefore, Graph graph) { + super(result, stateBefore, args.length, SUCCESSOR_COUNT, graph); this.opcode = opcode; - this.arguments = args; this.target = target; this.returnType = returnType; + + this.argumentCount = args.length; + for (int i = 0; i < args.length; i++) { + setArgument(i, args[i]); + } } /** @@ -85,7 +120,7 @@ */ public Value receiver() { assert !isStatic(); - return arguments[0]; + return argument(0); } /** @@ -97,14 +132,6 @@ } /** - * Gets the list of instructions that produce input for this instruction. - * @return the list of instructions that produce input - */ - public Value[] arguments() { - return arguments; - } - - /** * Checks whether this invocation has a receiver object. * @return {@code true} if this invocation has a receiver object; {@code false} otherwise, if this is a * static call @@ -114,17 +141,6 @@ } @Override - public void inputValuesDo(ValueClosure closure) { - for (int i = 0; i < arguments.length; i++) { - Value arg = arguments[i]; - if (arg != null) { - arguments[i] = closure.apply(arg); - assert arguments[i] != null; - } - } - } - - @Override public void accept(ValueVisitor v) { v.visitInvoke(this); } @@ -144,12 +160,11 @@ RiMethod target = target(); out.print(target.name()).print('('); - Value[] arguments = arguments(); - for (int i = argStart; i < arguments.length; i++) { + for (int i = argStart; i < argumentCount; i++) { if (i > argStart) { out.print(", "); } - out.print(arguments[i]); + out.print(argument(i)); } out.print(CiUtil.format(") [method: %H.%n(%p):%r]", target, false)); } diff -r 4a4dab936c1e -r 1c36b17f7ee0 graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java Thu May 05 15:49:48 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java Thu May 05 16:07:00 2011 +0200 @@ -22,16 +22,18 @@ */ package com.sun.c1x.ir; +import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; import com.sun.c1x.value.*; /** * The {@code MonitorEnter} instruction represents the acquisition of a monitor. - * - * @author Ben L. Titzer */ public final class MonitorEnter extends AccessMonitor { + private static final int INPUT_COUNT = 0; + private static final int SUCCESSOR_COUNT = 0; + private FrameState stateAfter; /** @@ -41,9 +43,10 @@ * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack * @param lockNumber the number of the lock * @param stateBefore the state before + * @param graph */ - public MonitorEnter(Value object, Value lockAddress, int lockNumber, FrameState stateBefore) { - super(object, lockAddress, stateBefore, lockNumber); + public MonitorEnter(Value object, Value lockAddress, int lockNumber, FrameState stateBefore, Graph graph) { + super(object, lockAddress, stateBefore, lockNumber, INPUT_COUNT, SUCCESSOR_COUNT, graph); } @Override diff -r 4a4dab936c1e -r 1c36b17f7ee0 graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java Thu May 05 15:49:48 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java Thu May 05 16:07:00 2011 +0200 @@ -22,16 +22,18 @@ */ package com.sun.c1x.ir; +import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; import com.sun.c1x.value.*; /** * The {@code MonitorExit} instruction represents a monitor release. - * - * @author Ben L. Titzer */ public final class MonitorExit extends AccessMonitor { + private static final int INPUT_COUNT = 0; + private static final int SUCCESSOR_COUNT = 0; + /** * Creates a new MonitorExit instruction. * @@ -39,9 +41,10 @@ * @param lockAddress the address of the on-stack lock object or {@code null} if the runtime does not place locks on the stack * @param lockNumber the number of the lock * @param stateBefore the state before executing this instruction + * @param graph */ - public MonitorExit(Value object, Value lockAddress, int lockNumber, FrameState stateBefore) { - super(object, lockAddress, stateBefore, lockNumber); + public MonitorExit(Value object, Value lockAddress, int lockNumber, FrameState stateBefore, Graph graph) { + super(object, lockAddress, stateBefore, lockNumber, INPUT_COUNT, SUCCESSOR_COUNT, graph); } @Override