Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.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 | 50b181d88c9f |
children | 0ea5f12e873a |
comparison
equal
deleted
inserted
replaced
2670:50b181d88c9f | 2671:d8601d421b96 |
---|---|
208 | 208 |
209 public ArrayList<DeoptimizationStub> deoptimizationStubs() { | 209 public ArrayList<DeoptimizationStub> deoptimizationStubs() { |
210 return deoptimizationStubs; | 210 return deoptimizationStubs; |
211 } | 211 } |
212 | 212 |
213 private void addDeoptimizationStub(DeoptimizationStub stub) { | |
214 if (deoptimizationStubs == null) { | |
215 deoptimizationStubs = new ArrayList<LIRGenerator.DeoptimizationStub>(); | |
216 } | |
217 deoptimizationStubs.add(stub); | |
218 } | |
219 | |
213 public static class DeoptimizationStub { | 220 public static class DeoptimizationStub { |
214 public final Label label = new Label(); | 221 public final Label label = new Label(); |
215 public final LIRDebugInfo info; | 222 public final LIRDebugInfo info; |
216 | 223 |
217 public DeoptimizationStub(FrameState state) { | 224 public DeoptimizationStub(FrameState state) { |
296 javaIndex += kind.jvmSlots; | 303 javaIndex += kind.jvmSlots; |
297 } | 304 } |
298 } | 305 } |
299 | 306 |
300 @Override | 307 @Override |
301 public void visitResolveClass(ResolveClass i) { | |
302 LIRDebugInfo info = stateFor(i); | |
303 XirSnippet snippet = xir.genResolveClass(site(i), i.type, i.portion); | |
304 emitXir(snippet, i, info, null, true); | |
305 } | |
306 | |
307 @Override | |
308 public void visitCheckCast(CheckCast x) { | 308 public void visitCheckCast(CheckCast x) { |
309 XirArgument obj = toXirArgument(x.object()); | 309 XirArgument obj = toXirArgument(x.object()); |
310 XirSnippet snippet = xir.genCheckCast(site(x), obj, toXirArgument(x.targetClassInstruction()), x.targetClass()); | 310 XirSnippet snippet = xir.genCheckCast(site(x), obj, toXirArgument(x.targetClassInstruction()), x.targetClass()); |
311 emitXir(snippet, x, stateFor(x), null, true); | 311 emitXir(snippet, x, stateFor(x), null, true); |
312 } | 312 } |
445 | 445 |
446 lir.cmp(i.condition(), left, right); | 446 lir.cmp(i.condition(), left, right); |
447 lir.cmove(i.condition(), tVal, fVal, reg); | 447 lir.cmove(i.condition(), tVal, fVal, reg); |
448 } | 448 } |
449 | 449 |
450 protected FrameState stateBeforeInvoke(Invoke invoke) { | 450 protected FrameState stateBeforeInvokeReturn(Invoke invoke) { |
451 Value[] args = new Value[invoke.argumentCount()]; | |
452 for (int i = 0; i < invoke.argumentCount(); i++) { | |
453 args[i] = invoke.argument(i); | |
454 } | |
455 return invoke.stateAfter().duplicateModified(invoke.bci(), invoke.kind/*, args*/); | 451 return invoke.stateAfter().duplicateModified(invoke.bci(), invoke.kind/*, args*/); |
456 } | 452 } |
457 | 453 |
458 protected FrameState stateBeforeInvokeWithArguments(Invoke invoke) { | 454 protected FrameState stateBeforeInvokeWithArguments(Invoke invoke) { |
459 Value[] args = new Value[invoke.argumentCount()]; | 455 Value[] args = new Value[invoke.argumentCount()]; |
465 | 461 |
466 @Override | 462 @Override |
467 public void visitInvoke(Invoke x) { | 463 public void visitInvoke(Invoke x) { |
468 RiMethod target = x.target(); | 464 RiMethod target = x.target(); |
469 LIRDebugInfo info = stateFor(x, stateBeforeInvokeWithArguments(x)); | 465 LIRDebugInfo info = stateFor(x, stateBeforeInvokeWithArguments(x)); |
470 LIRDebugInfo info2 = stateFor(x, stateBeforeInvoke(x)); | 466 LIRDebugInfo info2 = stateFor(x, stateBeforeInvokeReturn(x)); |
471 | 467 |
472 XirSnippet snippet = null; | 468 XirSnippet snippet = null; |
473 | 469 |
474 int opcode = x.opcode(); | 470 int opcode = x.opcode(); |
475 XirArgument receiver; | 471 XirArgument receiver; |
883 CiCallingConvention callingConvention = compilation.frameMap().getCallingConvention(new CiKind[]{CiKind.Object}, RuntimeCall); | 879 CiCallingConvention callingConvention = compilation.frameMap().getCallingConvention(new CiKind[]{CiKind.Object}, RuntimeCall); |
884 CiValue argumentOperand = callingConvention.locations[0]; | 880 CiValue argumentOperand = callingConvention.locations[0]; |
885 lir.move(exceptionOpr, argumentOperand); | 881 lir.move(exceptionOpr, argumentOperand); |
886 | 882 |
887 lir.throwException(CiValue.IllegalValue, argumentOperand, info); | 883 lir.throwException(CiValue.IllegalValue, argumentOperand, info); |
884 } | |
885 | |
886 @Override | |
887 public void visitDeoptimize(Deoptimize deoptimize) { | |
888 DeoptimizationStub stub = new DeoptimizationStub(deoptimize.stateBefore()); | |
889 addDeoptimizationStub(stub); | |
890 lir.branch(Condition.TRUE, stub.label, stub.info); | |
888 } | 891 } |
889 | 892 |
890 private void blockDoEpilog(BlockBegin block) { | 893 private void blockDoEpilog(BlockBegin block) { |
891 if (C1XOptions.PrintIRWithLIR) { | 894 if (C1XOptions.PrintIRWithLIR) { |
892 TTY.println(); | 895 TTY.println(); |