# HG changeset patch # User Thomas Wuerthinger # Date 1305803391 -7200 # Node ID 95e2aa413d951115d0cc5c251281a067be8505d1 # Parent a0dd2b907806c18b46cf87ca07b545159654dd2e# Parent fb4cc981259189cb4906f41362d61f27503baa7f Merge. diff -r a0dd2b907806 -r 95e2aa413d95 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 13:09:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Thu May 19 13:09:51 2011 +0200 @@ -876,7 +876,7 @@ @Override public void visitDeoptimize(Deoptimize deoptimize) { - DeoptimizationStub stub = new DeoptimizationStub(deoptimize.stateBefore()); + DeoptimizationStub stub = new DeoptimizationStub(lastState); addDeoptimizationStub(stub); lir.branch(Condition.TRUE, stub.label, stub.info); } diff -r a0dd2b907806 -r 95e2aa413d95 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 19 13:09:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 19 13:09:51 2011 +0200 @@ -344,7 +344,7 @@ dispatchEntry.appendNext(end, handler.handlerBCI()); dispatchEntry.setEnd(end); } else { - Deoptimize deopt = new Deoptimize(graph, null); + Deoptimize deopt = new Deoptimize(graph); dispatchEntry.appendNext(deopt, bci); Goto end = new Goto(successor, null, graph); deopt.appendNext(end, bci); @@ -395,7 +395,7 @@ } else if (dispatchEntry.next() instanceof Deoptimize) { // deoptimizing handler Deoptimize deopt = (Deoptimize) dispatchEntry.next(); - deopt.setStateBefore(mergedState.duplicate(bci)); + //deopt.setStateBefore(mergedState.duplicate(bci)); dispatchEntry.end().setStateAfter(mergedState.duplicate(bci)); updateDispatchChain(dispatchEntry.end().blockSuccessor(0), mergedState, bci); } else if (dispatchEntry.next() instanceof Unwind) { @@ -440,7 +440,7 @@ // this is a load of class constant which might be unresolved RiType riType = (RiType) con; if (!riType.isResolved()) { - append(new Deoptimize(graph, frameState.create(bci()))); + append(new Deoptimize(graph)); frameState.push(CiKind.Object, append(Constant.forObject(null, graph))); } else { frameState.push(CiKind.Object, append(new Constant(riType.getEncoding(Representation.JavaClass), graph))); @@ -653,36 +653,37 @@ int cpi = stream().readCPI(); RiType type = constantPool().lookupType(cpi, CHECKCAST); boolean isInitialized = type.isResolved(); - Value typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi, frameState); - CheckCast c = new CheckCast(type, typeInstruction, frameState.apop(), graph); - frameState.apush(append(c)); + Value typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi); + Value object = frameState.apop(); + if (typeInstruction != null) { + frameState.apush(append(new CheckCast(type, typeInstruction, object, graph))); + } else { + frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); + } } private void genInstanceOf() { int cpi = stream().readCPI(); RiType type = constantPool().lookupType(cpi, INSTANCEOF); boolean isInitialized = type.isResolved(); - //System.out.println("instanceof : type.isResolved() = " + type.isResolved() + "; type.isInitialized() = " + type.isInitialized()); - Value typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi, frameState); - Instruction result; + Value typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi); Value object = frameState.apop(); if (typeInstruction != null) { - result = new InstanceOf(type, typeInstruction, object, graph); + frameState.ipush(append(new InstanceOf(type, typeInstruction, object, graph))); } else { - result = Constant.forInt(0, graph); + frameState.ipush(appendConstant(CiConstant.INT_0)); } - frameState.ipush(append(result)); } void genNewInstance(int cpi) { RiType type = constantPool().lookupType(cpi, NEW); - FrameState stateBefore = null; - if (!type.isResolved()) { - stateBefore = frameState.create(bci()); + if (type.isResolved()) { + NewInstance n = new NewInstance(type, cpi, constantPool(), graph); + frameState.apush(append(n)); + } else { + append(new Deoptimize(graph)); + frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); } - NewInstance n = new NewInstance(type, cpi, constantPool(), graph); - n.setStateBefore(stateBefore); - frameState.apush(append(n)); } private void genNewTypeArray(int typeCode) { @@ -694,51 +695,54 @@ private void genNewObjectArray(int cpi) { RiType type = constantPool().lookupType(cpi, ANEWARRAY); - FrameState stateBefore = null; - if (!type.isResolved()) { - stateBefore = frameState.create(bci()); + Value length = frameState.ipop(); + if (type.isResolved()) { + NewArray n = new NewObjectArray(type, length, graph); + frameState.apush(append(n)); + } else { + append(new Deoptimize(graph)); + frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); } - NewArray n = new NewObjectArray(type, frameState.ipop(), graph); - frameState.apush(append(n)); - n.setStateBefore(stateBefore); + } private void genNewMultiArray(int cpi) { RiType type = constantPool().lookupType(cpi, MULTIANEWARRAY); - FrameState stateBefore = null; - if (!type.isResolved()) { - stateBefore = frameState.create(bci()); - } int rank = stream().readUByte(bci() + 3); Value[] dims = new Value[rank]; for (int i = rank - 1; i >= 0; i--) { dims[i] = frameState.ipop(); } - NewArray n = new NewMultiArray(type, dims, cpi, constantPool(), graph); - frameState.apush(append(n)); - n.setStateBefore(stateBefore); + if (type.isResolved()) { + NewArray n = new NewMultiArray(type, dims, cpi, constantPool(), graph); + frameState.apush(append(n)); + } else { + append(new Deoptimize(graph)); + frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); + } } private void genGetField(int cpi, RiField field) { - // Must copy the state here, because the field holder must still be on the stack. - FrameState stateBefore = null; - if (!field.isResolved()) { - stateBefore = frameState.create(bci()); + CiKind kind = field.kind(); + Value receiver = frameState.apop(); + if (field.isResolved()) { + LoadField load = new LoadField(receiver, field, graph); + appendOptimizedLoadField(kind, load); + } else { + append(new Deoptimize(graph)); + frameState.push(kind.stackKind(), append(Constant.defaultForKind(kind, graph))); } - LoadField load = new LoadField(frameState.apop(), field, stateBefore, graph); - appendOptimizedLoadField(field.kind(), load); } private void genPutField(int cpi, RiField field) { - // Must copy the state here, because the field holder must still be on the stack. - FrameState stateBefore = null; - if (!field.isResolved()) { - stateBefore = frameState.create(bci()); + Value value = frameState.pop(field.kind().stackKind()); + Value receiver = frameState.apop(); + if (field.isResolved()) { + StoreField store = new StoreField(receiver, field, value, graph); + appendOptimizedStoreField(store); + } else { + append(new Deoptimize(graph)); } - Value value = frameState.pop(field.kind().stackKind()); - StoreField store = new StoreField(frameState.apop(), field, value, graph); - appendOptimizedStoreField(store); - store.setStateBefore(stateBefore); } private void genGetStatic(int cpi, RiField field) { @@ -751,35 +755,35 @@ if (constantValue != null) { frameState.push(constantValue.kind.stackKind(), appendConstant(constantValue)); } else { - FrameState stateBefore = frameState.create(bci()); - Value container = genTypeOrDeopt(RiType.Representation.StaticFields, holder, isInitialized, cpi, frameState); - if (container == null) { - container = Constant.forObject(null, graph); + Value container = genTypeOrDeopt(RiType.Representation.StaticFields, holder, isInitialized, cpi); + CiKind kind = field.kind(); + if (container != null) { + LoadField load = new LoadField(container, field, graph); + appendOptimizedLoadField(kind, load); + } else { + append(new Deoptimize(graph)); + frameState.push(kind.stackKind(), append(Constant.defaultForKind(kind, graph))); } - LoadField load = new LoadField(container, field, stateBefore, graph); - appendOptimizedLoadField(field.kind(), load); } } private void genPutStatic(int cpi, RiField field) { RiType holder = field.holder(); - FrameState stateBefore = frameState.create(bci()); - Value container = genTypeOrDeopt(RiType.Representation.StaticFields, holder, field.isResolved(), cpi, frameState); + Value container = genTypeOrDeopt(RiType.Representation.StaticFields, holder, field.isResolved(), cpi); Value value = frameState.pop(field.kind().stackKind()); if (container != null) { StoreField store = new StoreField(container, field, value, graph); appendOptimizedStoreField(store); - if (!field.isResolved()) { - store.setStateBefore(stateBefore); - } + } else { + append(new Deoptimize(graph)); } } - private Value genTypeOrDeopt(RiType.Representation representation, RiType holder, boolean initialized, int cpi, FrameStateAccess stateBefore) { + private Value genTypeOrDeopt(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { if (initialized) { return appendConstant(holder.getEncoding(representation)); } else { - append(new Deoptimize(graph, stateBefore.duplicate(bci()))); + append(new Deoptimize(graph)); return null; } } @@ -801,7 +805,7 @@ // Re-use the same resolution code as for accessing a static field. Even though // the result of resolution is not used by the invocation (only the side effect // of initialization is required), it can be commoned with static field accesses. - genTypeOrDeopt(RiType.Representation.StaticFields, holder, isInitialized, cpi, frameState); + genTypeOrDeopt(RiType.Representation.StaticFields, holder, isInitialized, cpi); } Value[] args = frameState.popArguments(target.signature().argumentSlots(false)); appendInvoke(INVOKESTATIC, target, args, cpi, constantPool); @@ -1035,8 +1039,8 @@ append(new LookupSwitch(frameState.ipop(), list, keys, stateBefore, graph)); } - private Value appendConstant(CiConstant type) { - return appendWithBCI(new Constant(type, graph), bci()); + private Value appendConstant(CiConstant constant) { + return appendWithBCI(new Constant(constant, graph), bci()); } private Value append(Instruction x) { diff -r a0dd2b907806 -r 95e2aa413d95 graal/GraalCompiler/src/com/sun/c1x/ir/Constant.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Constant.java Thu May 19 13:09:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Constant.java Thu May 19 13:09:51 2011 +0200 @@ -129,6 +129,30 @@ return new Constant(CiConstant.forWord(val), graph); } + public static Constant defaultForKind(CiKind kind, Graph graph) { + switch(kind) { + case Boolean: + return Constant.forBoolean(false, graph); + case Byte: + case Char: + case Short: + case Int: + return Constant.forInt(0, graph); + case Double: + return Constant.forDouble(0.0, graph); + case Float: + return Constant.forFloat(0.0f, graph); + case Long: + return Constant.forLong(0L, graph); + case Object: + return Constant.forObject(null, graph); + case Word: + return Constant.forWord(0L, graph); + default: + return null; + } + } + @Override public String toString() { return super.toString() + "(" + value + ")"; diff -r a0dd2b907806 -r 95e2aa413d95 graal/GraalCompiler/src/com/sun/c1x/ir/Deoptimize.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Deoptimize.java Thu May 19 13:09:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Deoptimize.java Thu May 19 13:09:51 2011 +0200 @@ -24,7 +24,6 @@ import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; -import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -33,9 +32,8 @@ */ public class Deoptimize extends Instruction { - private static final int INPUT_COUNT = 1; + private static final int INPUT_COUNT = 0; private static final int SUCCESSOR_COUNT = 0; - private static final int INPUT_STATE_BEFORE = 0; /** * @param kind @@ -43,30 +41,8 @@ * @param successorCount * @param graph */ - public Deoptimize(Graph graph, FrameState stateBefore) { + public Deoptimize(Graph graph) { super(CiKind.Illegal, INPUT_COUNT, SUCCESSOR_COUNT, graph); - this.setStateBefore(stateBefore); - } - - @Override - protected int inputCount() { - return super.inputCount() + INPUT_COUNT; - } - - @Override - protected int successorCount() { - return super.successorCount() + SUCCESSOR_COUNT; - } - - /** - * The state for this instruction. - */ - public FrameState stateBefore() { - return (FrameState) inputs().get(super.inputCount() + INPUT_STATE_BEFORE); - } - - public FrameState setStateBefore(FrameState n) { - return (FrameState) inputs().set(super.inputCount() + INPUT_STATE_BEFORE, n); } @Override diff -r a0dd2b907806 -r 95e2aa413d95 graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java Thu May 19 13:09:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java Thu May 19 13:09:51 2011 +0200 @@ -24,7 +24,6 @@ import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; -import com.sun.c1x.value.*; import com.sun.cri.ci.*; import com.sun.cri.ri.*; @@ -45,9 +44,8 @@ * @param graph * @param isLoaded indicates if the class is loaded */ - public LoadField(Value object, RiField field, FrameState stateBefore, Graph graph) { + public LoadField(Value object, RiField field, Graph graph) { super(field.kind().stackKind(), object, field, INPUT_COUNT, SUCCESSOR_COUNT, graph); - this.setStateBefore(stateBefore); } /** diff -r a0dd2b907806 -r 95e2aa413d95 graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java --- a/graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java Thu May 19 13:09:37 2011 +0200 +++ b/graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java Thu May 19 13:09:51 2011 +0200 @@ -185,24 +185,6 @@ } }; - private SimpleTemplates resolveClassTemplates = new SimpleTemplates(UNRESOLVED) { - - @Override - protected XirTemplate create(CiXirAssembler asm, long flags) { - XirOperand result = asm.restart(CiKind.Word); - if (is(UNRESOLVED, flags)) { - UnresolvedClassPatching patching = new UnresolvedClassPatching(asm, result, config); - patching.emitInline(); - // -- out of line ------------------------------------------------------- - patching.emitOutOfLine(); - } else { - XirOperand type = asm.createConstantInputParameter("type", CiKind.Object); - asm.mov(result, type); - } - return asm.finishTemplate(is(UNRESOLVED, flags) ? "resolve class (unresolved)" : "resolve class"); - } - }; - private SimpleTemplates invokeInterfaceTemplates = new SimpleTemplates(NULL_CHECK) { @Override @@ -360,20 +342,13 @@ } }; - private KindTemplates getFieldTemplates = new KindTemplates(NULL_CHECK, UNRESOLVED) { + private KindTemplates getFieldTemplates = new KindTemplates(NULL_CHECK) { @Override protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { XirOperand result = asm.restart(kind); XirParameter object = asm.createInputParameter("object", CiKind.Object); - if (is(UNRESOLVED, flags)) { - UnresolvedFieldPatching fieldPatching = new UnresolvedFieldPatching(asm, object, result, false, is(NULL_CHECK, flags), config); - fieldPatching.emitInline(); - // -- out of line ------------------------------------------------------- - fieldPatching.emitOutOfLine(); - return asm.finishTemplate("getfield<" + kind + ">"); - } XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); if (is(NULL_CHECK, flags)) { asm.nop(1); @@ -400,21 +375,13 @@ } }; - private KindTemplates putFieldTemplates = new KindTemplates(WRITE_BARRIER, NULL_CHECK, UNRESOLVED) { + private KindTemplates putFieldTemplates = new KindTemplates(WRITE_BARRIER, NULL_CHECK) { @Override protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { asm.restart(CiKind.Void); XirParameter object = asm.createInputParameter("object", CiKind.Object); XirParameter value = asm.createInputParameter("value", kind); - - if (is(UNRESOLVED, flags)) { - UnresolvedFieldPatching fieldPatching = new UnresolvedFieldPatching(asm, object, value, true, is(NULL_CHECK, flags), config); - fieldPatching.emitInline(); - // -- out of line ------------------------------------------------------- - fieldPatching.emitOutOfLine(); - return asm.finishTemplate("putfield<" + kind + ">"); - } XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); if (kind == CiKind.Object) { verifyPointer(asm, value); @@ -484,26 +451,6 @@ } }; - private SimpleTemplates newInstanceUnresolvedTemplates = new SimpleTemplates() { - - @Override - protected XirTemplate create(CiXirAssembler asm, long flags) { - XirOperand result = asm.restart(CiKind.Word); - XirOperand arg = asm.createRegisterTemp("runtime call argument", CiKind.Object, AMD64.rdx); - - UnresolvedClassPatching patching = new UnresolvedClassPatching(asm, arg, config); - - patching.emitInline(); - useRegisters(asm, AMD64.rbx, AMD64.rcx, AMD64.rsi, AMD64.rax); - asm.callRuntime(config.unresolvedNewInstanceStub, result); - - // -- out of line ------------------------------------------------------- - patching.emitOutOfLine(); - - return asm.finishTemplate("new instance"); - } - }; - private SimpleTemplates newObjectArrayCloneTemplates = new SimpleTemplates() { @Override @@ -524,12 +471,12 @@ } }; - private SimpleTemplates newObjectArrayTemplates = new SimpleTemplates(UNRESOLVED) { + private SimpleTemplates newObjectArrayTemplates = new SimpleTemplates() { @Override protected XirTemplate create(CiXirAssembler asm, long flags) { emitNewTypeArray(asm, flags, CiKind.Object, config.useFastNewObjectArray, config.newObjectArrayStub); - return asm.finishTemplate(is(UNRESOLVED, flags) ? "newObjectArray (unresolved)" : "newObjectArray"); + return asm.finishTemplate("newObjectArray"); } }; @@ -548,15 +495,7 @@ XirOperand temp3 = asm.createRegisterTemp("temp3", CiKind.Word, AMD64.rdi); XirOperand size = asm.createRegisterTemp("size", CiKind.Int, AMD64.rsi); - UnresolvedClassPatching patching = null; - if (is(UNRESOLVED, flags)) { - // insert the patching code for class resolving - the hub will end up in "hub" - patching = new UnresolvedClassPatching(asm, hub, config); - patching.emitInline(); - } else { - asm.mov(hub, asm.createConstantInputParameter("hub", CiKind.Object)); - } - + asm.mov(hub, asm.createConstantInputParameter("hub", CiKind.Object)); asm.mov(length, lengthParam); if (useFast) { @@ -619,10 +558,6 @@ } else { asm.callRuntime(slowPathStub, result); } - - if (patching != null) { - patching.emitOutOfLine(); - } } private KindTemplates newTypeArrayTemplates = new KindTemplates() { @@ -633,7 +568,7 @@ } }; - private final IndexTemplates multiNewArrayTemplate = new IndexTemplates(UNRESOLVED) { + private final IndexTemplates multiNewArrayTemplate = new IndexTemplates() { @Override protected XirTemplate create(CiXirAssembler asm, long flags, int dimensions) { @@ -649,42 +584,23 @@ asm.pstore(CiKind.Int, sizes, asm.i(i * target.sizeInBytes(CiKind.Int)), length, false); } - UnresolvedClassPatching patching = null; - if (is(UNRESOLVED, flags)) { - // insert the patching code for class resolving - the hub will end up in "hub" - patching = new UnresolvedClassPatching(asm, hub, config); - patching.emitInline(); - } else { - asm.mov(hub, asm.createConstantInputParameter("hub", CiKind.Object)); - } + asm.mov(hub, asm.createConstantInputParameter("hub", CiKind.Object)); asm.mov(rank, asm.i(dimensions)); useRegisters(asm, AMD64.rax); asm.callRuntime(config.newMultiArrayStub, result); - if (is(UNRESOLVED, flags)) { - patching.emitOutOfLine(); - } - return asm.finishTemplate(is(UNRESOLVED, flags) ? "multiNewArray" + dimensions + " (unresolved)" : "multiNewArray" + dimensions); + return asm.finishTemplate("multiNewArray" + dimensions); } }; - private SimpleTemplates checkCastTemplates = new SimpleTemplates(NULL_CHECK, UNRESOLVED) { + private SimpleTemplates checkCastTemplates = new SimpleTemplates(NULL_CHECK) { @Override protected XirTemplate create(CiXirAssembler asm, long flags) { asm.restart(); XirParameter object = asm.createInputParameter("object", CiKind.Object); final XirOperand hub; - final UnresolvedClassPatching patching; - if (is(UNRESOLVED, flags)) { - hub = asm.createTemp("hub", CiKind.Object); - // insert the patching code for class resolving - the hub will end up in "hub" - patching = new UnresolvedClassPatching(asm, hub, config); - patching.emitInline(); - } else { - hub = asm.createConstantInputParameter("hub", CiKind.Object); - patching = null; - } + hub = asm.createConstantInputParameter("hub", CiKind.Object); XirOperand objHub = asm.createTemp("objHub", CiKind.Object); @@ -711,31 +627,18 @@ asm.callRuntime(CiRuntimeCall.Deoptimize, null); asm.shouldNotReachHere(); - if (is(UNRESOLVED, flags)) { - patching.emitOutOfLine(); - } - return asm.finishTemplate(object, "instanceof"); } }; - private SimpleTemplates instanceOfTemplates = new SimpleTemplates(NULL_CHECK, UNRESOLVED) { + private SimpleTemplates instanceOfTemplates = new SimpleTemplates(NULL_CHECK) { @Override protected XirTemplate create(CiXirAssembler asm, long flags) { XirOperand result = asm.restart(CiKind.Boolean); XirParameter object = asm.createInputParameter("object", CiKind.Object); final XirOperand hub; - final UnresolvedClassPatching patching; - if (is(UNRESOLVED, flags)) { - hub = asm.createTemp("hub", CiKind.Object); - // insert the patching code for class resolving - the hub will end up in "hub" - patching = new UnresolvedClassPatching(asm, hub, config); - patching.emitInline(); - } else { - hub = asm.createConstantInputParameter("hub", CiKind.Object); - patching = null; - } + hub = asm.createConstantInputParameter("hub", CiKind.Object); XirOperand objHub = asm.createTemp("objHub", CiKind.Object); @@ -759,10 +662,6 @@ checkSubtype(asm, result, objHub, hub); asm.jmp(end); - if (is(UNRESOLVED, flags)) { - patching.emitOutOfLine(); - } - return asm.finishTemplate("instanceof"); } }; @@ -1143,11 +1042,7 @@ @Override public XirSnippet genResolveClass(XirSite site, RiType type, Representation rep) { - assert rep == Representation.ObjectHub || rep == Representation.StaticFields || rep == Representation.JavaClass : "unexpected representation: " + rep; - if (type.isResolved()) { - return new XirSnippet(resolveClassTemplates.get(site), XirArgument.forObject(type.getEncoding(rep).asObject())); - } - return new XirSnippet(resolveClassTemplates.get(site, UNRESOLVED)); + throw new CiBailout("Xir ResolveClass not available"); } @Override @@ -1187,10 +1082,8 @@ @Override public XirSnippet genGetField(XirSite site, XirArgument object, RiField field) { - if (field.isResolved()) { - return new XirSnippet(getFieldTemplates.get(site, field.kind()), object, XirArgument.forInt(((HotSpotField) field).offset())); - } - return new XirSnippet(getFieldTemplates.get(site, field.kind(), UNRESOLVED), object); + assert field.isResolved(); + return new XirSnippet(getFieldTemplates.get(site, field.kind()), object, XirArgument.forInt(((HotSpotField) field).offset())); } @Override @@ -1200,44 +1093,34 @@ @Override public XirSnippet genPutField(XirSite site, XirArgument object, RiField field, XirArgument value) { - if (field.isResolved()) { - return new XirSnippet(putFieldTemplates.get(site, field.kind()), object, value, XirArgument.forInt(((HotSpotField) field).offset())); - } - return new XirSnippet(putFieldTemplates.get(site, field.kind(), UNRESOLVED), object, value); + assert field.isResolved(); + return new XirSnippet(putFieldTemplates.get(site, field.kind()), object, value, XirArgument.forInt(((HotSpotField) field).offset())); } @Override public XirSnippet genGetStatic(XirSite site, XirArgument object, RiField field) { - if (field.isResolved()) { - return new XirSnippet(getFieldTemplates.get(site, field.kind()), object, XirArgument.forInt(((HotSpotField) field).offset())); - } - return new XirSnippet(getFieldTemplates.get(site, field.kind(), UNRESOLVED), object); + assert field.isResolved(); + return new XirSnippet(getFieldTemplates.get(site, field.kind()), object, XirArgument.forInt(((HotSpotField) field).offset())); } @Override public XirSnippet genPutStatic(XirSite site, XirArgument object, RiField field, XirArgument value) { - if (field.isResolved()) { - return new XirSnippet(putFieldTemplates.get(site, field.kind()), object, value, XirArgument.forInt(((HotSpotField) field).offset())); - } - return new XirSnippet(putFieldTemplates.get(site, field.kind(), UNRESOLVED), object, value); + assert field.isResolved(); + return new XirSnippet(putFieldTemplates.get(site, field.kind()), object, value, XirArgument.forInt(((HotSpotField) field).offset())); } @Override public XirSnippet genNewInstance(XirSite site, RiType type) { - if (type.isResolved()) { - int instanceSize = ((HotSpotTypeResolved) type).instanceSize(); - return new XirSnippet(newInstanceTemplates.get(site, instanceSize), XirArgument.forObject(type)); - } - return new XirSnippet(newInstanceUnresolvedTemplates.get(site)); + assert type.isResolved(); + int instanceSize = ((HotSpotTypeResolved) type).instanceSize(); + return new XirSnippet(newInstanceTemplates.get(site, instanceSize), XirArgument.forObject(type)); } @Override public XirSnippet genNewArray(XirSite site, XirArgument length, CiKind elementKind, RiType componentType, RiType arrayType) { if (elementKind == CiKind.Object) { - if (arrayType.isResolved()) { - return new XirSnippet(newObjectArrayTemplates.get(site), length, XirArgument.forObject(arrayType)); - } - return new XirSnippet(newObjectArrayTemplates.get(site, UNRESOLVED), length); + assert arrayType.isResolved(); + return new XirSnippet(newObjectArrayTemplates.get(site), length, XirArgument.forObject(arrayType)); } assert arrayType == null; arrayType = compiler.getVMEntries().getPrimitiveArrayType(elementKind); @@ -1251,28 +1134,22 @@ @Override public XirSnippet genNewMultiArray(XirSite site, XirArgument[] lengths, RiType type) { - if (type.isResolved()) { - XirArgument[] params = Arrays.copyOf(lengths, lengths.length + 1); - params[lengths.length] = XirArgument.forObject(type); - return new XirSnippet(multiNewArrayTemplate.get(site, lengths.length), params); - } - return new XirSnippet(multiNewArrayTemplate.get(site, lengths.length, UNRESOLVED), lengths); + assert type.isResolved(); + XirArgument[] params = Arrays.copyOf(lengths, lengths.length + 1); + params[lengths.length] = XirArgument.forObject(type); + return new XirSnippet(multiNewArrayTemplate.get(site, lengths.length), params); } @Override public XirSnippet genCheckCast(XirSite site, XirArgument receiver, XirArgument hub, RiType type) { - if (type.isResolved()) { - return new XirSnippet(checkCastTemplates.get(site), receiver, hub); - } - return new XirSnippet(checkCastTemplates.get(site, UNRESOLVED), receiver); + assert type.isResolved(); + return new XirSnippet(checkCastTemplates.get(site), receiver, hub); } @Override public XirSnippet genInstanceOf(XirSite site, XirArgument object, XirArgument hub, RiType type) { - if (type.isResolved()) { - return new XirSnippet(instanceOfTemplates.get(site), object, hub); - } - return new XirSnippet(instanceOfTemplates.get(site, UNRESOLVED), object); + assert type.isResolved(); + return new XirSnippet(instanceOfTemplates.get(site), object, hub); } @Override @@ -1320,137 +1197,6 @@ return templates; } - private static class UnresolvedClassPatching { - - private final XirLabel patchSite; - private final XirLabel replacement; - private final XirLabel patchStub; - private final CiXirAssembler asm; - private final HotSpotVMConfig config; - private final XirOperand arg; - private State state; - - private enum State { - New, Inline, Finished - } - - public UnresolvedClassPatching(CiXirAssembler asm, XirOperand arg, HotSpotVMConfig config) { - this.asm = asm; - this.arg = arg; - this.config = config; - patchSite = asm.createInlineLabel("patch site"); - replacement = asm.createOutOfLineLabel("replacement"); - patchStub = asm.createOutOfLineLabel("patch stub"); - - state = State.New; - } - - public void emitInline() { - assert state == State.New; - - asm.bindInline(patchSite); - asm.mark(MARK_DUMMY_OOP_RELOCATION); - - asm.jmp(patchStub); - - // TODO: make this more generic & safe - this is needed to create space for patching - asm.nop(5); - - state = State.Inline; - } - - public void emitOutOfLine() { - assert state == State.Inline; - - asm.bindOutOfLine(replacement); - XirMark begin = asm.mark(null); - asm.mov(arg, asm.createConstant(CiConstant.NULL_OBJECT)); - XirMark end = asm.mark(null); - // make this piece of data look like an instruction - asm.rawBytes(new byte[] {(byte) 0xb8, 0, 0, 0x05, 0}); - asm.mark(MARK_KLASS_PATCHING, begin, end); - asm.bindOutOfLine(patchStub); - asm.callRuntime(config.loadKlassStub, null); - asm.jmp(patchSite); - - state = State.Finished; - } - } - - private static class UnresolvedFieldPatching { - - private final XirLabel patchSite; - private final XirLabel replacement; - private final XirLabel patchStub; - private final CiXirAssembler asm; - private final HotSpotVMConfig config; - private State state; - private final XirOperand receiver; - private final XirOperand value; - private final boolean put; - private final boolean nullCheck; - - private enum State { - New, Inline, Finished - } - - public UnresolvedFieldPatching(CiXirAssembler asm, XirOperand receiver, XirOperand value, boolean put, boolean nullCheck, HotSpotVMConfig config) { - this.asm = asm; - this.receiver = receiver; - this.value = value; - this.put = put; - this.nullCheck = nullCheck; - this.config = config; - patchSite = asm.createInlineLabel("patch site"); - replacement = asm.createOutOfLineLabel("replacement"); - patchStub = asm.createOutOfLineLabel("patch stub"); - - state = State.New; - } - - public void emitInline() { - assert state == State.New; - if (nullCheck) { - asm.nop(1); - } - asm.bindInline(patchSite); - asm.mark(MARK_DUMMY_OOP_RELOCATION); - if (nullCheck) { - asm.mark(MARK_IMPLICIT_NULL); - } - asm.safepoint(); - asm.jmp(patchStub); - - // TODO: make this more generic & safe - this is needed to create space for patching - asm.nop(5); - - state = State.Inline; - } - - public void emitOutOfLine() { - assert state == State.Inline; - - asm.bindOutOfLine(replacement); - XirMark begin = asm.mark(null); - if (put) { - asm.pstore(value.kind, receiver, asm.i(Integer.MAX_VALUE), value, false); - } else { - asm.pload(value.kind, value, receiver, asm.i(Integer.MAX_VALUE), false); - } - XirMark end = asm.mark(null); - // make this piece of data look like an instruction - asm.rawBytes(new byte[] {(byte) 0xb8, 0, 0, 0x05, 0}); - asm.mark(MARK_ACCESS_FIELD_PATCHING, begin, end); - asm.bindOutOfLine(patchStub); - asm.callRuntime(config.accessFieldStub, null); - asm.jmp(patchSite); - - // Check if we need NOP instructions like in C1 to "not destroy the world". - - state = State.Finished; - } - } - private void verifyPointer(CiXirAssembler asm, XirOperand pointer) { if (config.verifyPointers) { // The verify pointer stub wants the argument in a fixed register. diff -r a0dd2b907806 -r 95e2aa413d95 graal/GraalRuntime/src/com/oracle/graal/runtime/TemplateFlag.java --- a/graal/GraalRuntime/src/com/oracle/graal/runtime/TemplateFlag.java Thu May 19 13:09:37 2011 +0200 +++ b/graal/GraalRuntime/src/com/oracle/graal/runtime/TemplateFlag.java Thu May 19 13:09:51 2011 +0200 @@ -23,7 +23,7 @@ package com.oracle.graal.runtime; enum TemplateFlag { - NULL_CHECK, UNRESOLVED, READ_BARRIER, WRITE_BARRIER, STORE_CHECK, BOUNDS_CHECK, GIVEN_LENGTH, INPUTS_DIFFERENT, INPUTS_SAME, STATIC_METHOD, SYNCHRONIZED; + NULL_CHECK, READ_BARRIER, WRITE_BARRIER, STORE_CHECK, BOUNDS_CHECK, GIVEN_LENGTH, INPUTS_DIFFERENT, INPUTS_SAME, STATIC_METHOD, SYNCHRONIZED; private static final long FIRST_FLAG = 0x0000000100000000L; public static final long FLAGS_MASK = 0x0000FFFF00000000L;