# HG changeset patch # User Gilles Duboscq # Date 1305278365 -7200 # Node ID 98447ab8bd83d29c258e78fdabe26c5e6f349088 # Parent 35453d725a2aa4d0ca82e0f207a2d5d165ee5de8 Create less nodes in case of Deopt diff -r 35453d725a2a -r 98447ab8bd83 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Thu May 12 17:57:58 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Fri May 13 11:19:25 2011 +0200 @@ -540,8 +540,14 @@ RiType type = constantPool().lookupType(cpi, CHECKCAST); 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)); + Instruction result; + Value object = frameState.apop(); + if (typeInstruction != null) { + result = new CheckCast(type, typeInstruction, object, graph); + } else { + result = Constant.forObject(null, graph); + } + frameState.apush(append(result)); } private void genInstanceOf() { @@ -550,8 +556,14 @@ 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)); + Instruction result; + Value object = frameState.apop(); + if (typeInstruction != null) { + result = new InstanceOf(type, typeInstruction, object, graph); + } else { + result = Constant.forInt(0, graph); + } + frameState.ipush(append(result)); } void genNewInstance(int cpi) { @@ -605,9 +617,8 @@ if (!field.isResolved()) { stateBefore = frameState.create(bci()); } - LoadField load = new LoadField(frameState.apop(), field, graph); + LoadField load = new LoadField(frameState.apop(), field, stateBefore, graph); appendOptimizedLoadField(field.kind(), load); - load.setStateBefore(stateBefore); } private void genPutField(int cpi, RiField field) { @@ -634,9 +645,11 @@ frameState.push(constantValue.kind.stackKind(), appendConstant(constantValue)); } else { Value container = genTypeOrDeopt(RiType.Representation.StaticFields, holder, isInitialized, cpi, stateBefore); - LoadField load = new LoadField(container, field, graph); + if (container == null) { + container = Constant.forObject(null, graph); + } + LoadField load = new LoadField(container, field, stateBefore, graph); appendOptimizedLoadField(field.kind(), load); - load.setStateBefore(stateBefore); } } @@ -645,22 +658,22 @@ 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); - if (!field.isResolved()) { - store.setStateBefore(stateBefore); + if (container != null) { + StoreField store = new StoreField(container, field, value, graph); + appendOptimizedStoreField(store); + if (!field.isResolved()) { + store.setStateBefore(stateBefore); + } } } private Value genTypeOrDeopt(RiType.Representation representation, RiType holder, boolean initialized, int cpi, FrameState stateBefore) { - Value holderInstr; if (initialized) { - holderInstr = appendConstant(holder.getEncoding(representation)); + return appendConstant(holder.getEncoding(representation)); } else { append(new Deoptimize(graph, stateBefore)); - holderInstr = append(Constant.forObject(null, graph)); + return null; } - return holderInstr; } private void appendOptimizedStoreField(StoreField store) { diff -r 35453d725a2a -r 98447ab8bd83 graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java Thu May 12 17:57:58 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LoadField.java Fri May 13 11:19:25 2011 +0200 @@ -24,6 +24,7 @@ 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.*; @@ -44,8 +45,9 @@ * @param graph * @param isLoaded indicates if the class is loaded */ - public LoadField(Value object, RiField field, Graph graph) { + public LoadField(Value object, RiField field, FrameState stateBefore, Graph graph) { super(field.kind().stackKind(), object, field, INPUT_COUNT, SUCCESSOR_COUNT, graph); + this.setStateBefore(stateBefore); } /**