Mercurial > hg > truffle
diff graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2671:d8601d421b96
New Deoptimize node, remove ResolveClass node and replace it with deoptimization
author | Gilles Duboscq <gilles.duboscq@oracle.com> |
---|---|
date | Thu, 12 May 2011 17:17:50 +0200 |
parents | 405e7947a940 |
children | 98447ab8bd83 bcd20d26d52d |
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 12 17:00:09 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 12 17:17:50 2011 +0200 @@ -243,7 +243,7 @@ List<ExceptionHandler> handleException(Instruction x, int bci) { if (!hasHandler()) { - return Util.uncheckedCast(Collections.EMPTY_LIST); + return ExceptionHandler.ZERO_HANDLERS; } ArrayList<ExceptionHandler> exceptionHandlers = new ArrayList<ExceptionHandler>(); @@ -330,8 +330,8 @@ // this is a load of class constant which might be unresolved RiType riType = (RiType) con; if (!riType.isResolved()) { - ResolveClass rc = new ResolveClass(riType, RiType.Representation.JavaClass, graph, frameState.create(bci())); - frameState.push(CiKind.Object, append(rc)); + append(new Deoptimize(graph, frameState.create(bci()))); + frameState.push(CiKind.Object, append(Constant.forObject(null, graph))); } else { frameState.push(CiKind.Object, append(new Constant(riType.getEncoding(Representation.JavaClass), graph))); } @@ -538,8 +538,8 @@ private void genCheckCast() { int cpi = stream().readCPI(); RiType type = constantPool().lookupType(cpi, CHECKCAST); - boolean isInitialized = type.isResolved() && type.isInitialized(); - Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi); + boolean isInitialized = type.isResolved(); + Value typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, type, isInitialized, cpi, frameState.create(bci())); CheckCast c = new CheckCast(type, typeInstruction, frameState.apop(), graph); frameState.apush(append(c)); } @@ -547,8 +547,9 @@ private void genInstanceOf() { int cpi = stream().readCPI(); RiType type = constantPool().lookupType(cpi, INSTANCEOF); - boolean isInitialized = type.isResolved() && type.isInitialized(); - Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi); + 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.create(bci())); InstanceOf i = new InstanceOf(type, typeInstruction, frameState.apop(), graph); frameState.ipush(append(i)); } @@ -625,16 +626,14 @@ RiType holder = field.holder(); boolean isInitialized = field.isResolved(); CiConstant constantValue = null; - FrameState stateBefore = null; + FrameState stateBefore = frameState.create(bci()); if (isInitialized) { constantValue = field.constantValue(null); - } else { - stateBefore = frameState.create(bci()); } if (constantValue != null) { frameState.push(constantValue.kind.stackKind(), appendConstant(constantValue)); } else { - Value container = genResolveClass(RiType.Representation.StaticFields, holder, field.isResolved(), cpi); + Value container = genTypeOrDeopt(RiType.Representation.StaticFields, holder, isInitialized, cpi, stateBefore); LoadField load = new LoadField(container, field, graph); appendOptimizedLoadField(field.kind(), load); load.setStateBefore(stateBefore); @@ -643,24 +642,23 @@ private void genPutStatic(int cpi, RiField field) { RiType holder = field.holder(); - FrameState stateBefore = null; - if (!field.isResolved()) { - stateBefore = frameState.create(bci()); - } - Value container = genResolveClass(RiType.Representation.StaticFields, holder, field.isResolved(), cpi); + FrameState stateBefore = frameState.create(bci()); + Value container = genTypeOrDeopt(RiType.Representation.StaticFields, holder, field.isResolved(), cpi, stateBefore); Value value = frameState.pop(field.kind().stackKind()); StoreField store = new StoreField(container, field, value, graph); appendOptimizedStoreField(store); - store.setStateBefore(stateBefore); + if (!field.isResolved()) { + store.setStateBefore(stateBefore); + } } - private Value genResolveClass(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { + private Value genTypeOrDeopt(RiType.Representation representation, RiType holder, boolean initialized, int cpi, FrameState stateBefore) { Value holderInstr; if (initialized) { holderInstr = appendConstant(holder.getEncoding(representation)); } else { - ResolveClass rc = new ResolveClass(holder, representation, graph, frameState.create(bci())); - holderInstr = append(rc); + append(new Deoptimize(graph, stateBefore)); + holderInstr = append(Constant.forObject(null, graph)); } return holderInstr; } @@ -682,7 +680,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. - genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi); + genTypeOrDeopt(RiType.Representation.StaticFields, holder, isInitialized, cpi, frameState.create(bci())); } Value[] args = frameState.popArguments(target.signature().argumentSlots(false)); appendInvoke(INVOKESTATIC, target, args, cpi, constantPool); @@ -812,9 +810,7 @@ if (needsCheck) { // append a call to the finalizer registration - RegisterFinalizer r = new RegisterFinalizer(frameState.loadLocal(0), graph); - append(r); - r.setStateBefore(frameState.create(bci())); + append(new RegisterFinalizer(frameState.loadLocal(0), frameState.create(bci()), graph)); C1XMetrics.InlinedFinalizerChecks++; } }