Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2600:f1bc67c2d453
new node layout: TypeCheck, RegisterFinalizer, Invoke, NewArray, NullCheck
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Thu, 05 May 2011 16:32:20 +0200 |
parents | 1c36b17f7ee0 |
children | 0c6564c254af |
comparison
equal
deleted
inserted
replaced
2596:1c36b17f7ee0 | 2600:f1bc67c2d453 |
---|---|
421 | 421 |
422 if (con instanceof RiType) { | 422 if (con instanceof RiType) { |
423 // this is a load of class constant which might be unresolved | 423 // this is a load of class constant which might be unresolved |
424 RiType riType = (RiType) con; | 424 RiType riType = (RiType) con; |
425 if (!riType.isResolved() || C1XOptions.TestPatching) { | 425 if (!riType.isResolved() || C1XOptions.TestPatching) { |
426 push(CiKind.Object, append(new ResolveClass(riType, RiType.Representation.JavaClass, null))); | 426 push(CiKind.Object, append(new ResolveClass(riType, RiType.Representation.JavaClass, null, graph))); |
427 } else { | 427 } else { |
428 push(CiKind.Object, append(new Constant(riType.getEncoding(Representation.JavaClass), graph))); | 428 push(CiKind.Object, append(new Constant(riType.getEncoding(Representation.JavaClass), graph))); |
429 } | 429 } |
430 } else if (con instanceof CiConstant) { | 430 } else if (con instanceof CiConstant) { |
431 CiConstant constant = (CiConstant) con; | 431 CiConstant constant = (CiConstant) con; |
641 void genCheckCast() { | 641 void genCheckCast() { |
642 int cpi = stream().readCPI(); | 642 int cpi = stream().readCPI(); |
643 RiType type = constantPool().lookupType(cpi, CHECKCAST); | 643 RiType type = constantPool().lookupType(cpi, CHECKCAST); |
644 boolean isInitialized = !C1XOptions.TestPatching && type.isResolved() && type.isInitialized(); | 644 boolean isInitialized = !C1XOptions.TestPatching && type.isResolved() && type.isInitialized(); |
645 Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi); | 645 Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi); |
646 CheckCast c = new CheckCast(type, typeInstruction, apop(), null); | 646 CheckCast c = new CheckCast(type, typeInstruction, apop(), null, graph); |
647 apush(append(c)); | 647 apush(append(c)); |
648 checkForDirectCompare(c); | 648 checkForDirectCompare(c); |
649 } | 649 } |
650 | 650 |
651 void genInstanceOf() { | 651 void genInstanceOf() { |
652 int cpi = stream().readCPI(); | 652 int cpi = stream().readCPI(); |
653 RiType type = constantPool().lookupType(cpi, INSTANCEOF); | 653 RiType type = constantPool().lookupType(cpi, INSTANCEOF); |
654 boolean isInitialized = !C1XOptions.TestPatching && type.isResolved() && type.isInitialized(); | 654 boolean isInitialized = !C1XOptions.TestPatching && type.isResolved() && type.isInitialized(); |
655 Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi); | 655 Value typeInstruction = genResolveClass(RiType.Representation.ObjectHub, type, isInitialized, cpi); |
656 InstanceOf i = new InstanceOf(type, typeInstruction, apop(), null); | 656 InstanceOf i = new InstanceOf(type, typeInstruction, apop(), null, graph); |
657 ipush(append(i)); | 657 ipush(append(i)); |
658 checkForDirectCompare(i); | 658 checkForDirectCompare(i); |
659 } | 659 } |
660 | 660 |
661 private void checkForDirectCompare(TypeCheck check) { | 661 private void checkForDirectCompare(TypeCheck check) { |
666 } | 666 } |
667 | 667 |
668 void genNewInstance(int cpi) { | 668 void genNewInstance(int cpi) { |
669 FrameState stateBefore = curState.immutableCopy(bci()); | 669 FrameState stateBefore = curState.immutableCopy(bci()); |
670 RiType type = constantPool().lookupType(cpi, NEW); | 670 RiType type = constantPool().lookupType(cpi, NEW); |
671 NewInstance n = new NewInstance(type, cpi, constantPool(), stateBefore); | 671 NewInstance n = new NewInstance(type, cpi, constantPool(), stateBefore, graph); |
672 if (memoryMap != null) { | 672 if (memoryMap != null) { |
673 memoryMap.newInstance(n); | 673 memoryMap.newInstance(n); |
674 } | 674 } |
675 apush(append(n)); | 675 apush(append(n)); |
676 } | 676 } |
677 | 677 |
678 void genNewTypeArray(int typeCode) { | 678 void genNewTypeArray(int typeCode) { |
679 FrameState stateBefore = curState.immutableCopy(bci()); | 679 FrameState stateBefore = curState.immutableCopy(bci()); |
680 CiKind kind = CiKind.fromArrayTypeCode(typeCode); | 680 CiKind kind = CiKind.fromArrayTypeCode(typeCode); |
681 RiType elementType = compilation.runtime.asRiType(kind); | 681 RiType elementType = compilation.runtime.asRiType(kind); |
682 apush(append(new NewTypeArray(ipop(), elementType, stateBefore))); | 682 apush(append(new NewTypeArray(ipop(), elementType, stateBefore, graph))); |
683 } | 683 } |
684 | 684 |
685 void genNewObjectArray(int cpi) { | 685 void genNewObjectArray(int cpi) { |
686 RiType type = constantPool().lookupType(cpi, ANEWARRAY); | 686 RiType type = constantPool().lookupType(cpi, ANEWARRAY); |
687 FrameState stateBefore = curState.immutableCopy(bci()); | 687 FrameState stateBefore = curState.immutableCopy(bci()); |
688 NewArray n = new NewObjectArray(type, ipop(), stateBefore); | 688 NewArray n = new NewObjectArray(type, ipop(), stateBefore, graph); |
689 apush(append(n)); | 689 apush(append(n)); |
690 } | 690 } |
691 | 691 |
692 void genNewMultiArray(int cpi) { | 692 void genNewMultiArray(int cpi) { |
693 RiType type = constantPool().lookupType(cpi, MULTIANEWARRAY); | 693 RiType type = constantPool().lookupType(cpi, MULTIANEWARRAY); |
695 int rank = stream().readUByte(bci() + 3); | 695 int rank = stream().readUByte(bci() + 3); |
696 Value[] dims = new Value[rank]; | 696 Value[] dims = new Value[rank]; |
697 for (int i = rank - 1; i >= 0; i--) { | 697 for (int i = rank - 1; i >= 0; i--) { |
698 dims[i] = ipop(); | 698 dims[i] = ipop(); |
699 } | 699 } |
700 NewArray n = new NewMultiArray(type, dims, stateBefore, cpi, constantPool()); | 700 NewArray n = new NewMultiArray(type, dims, stateBefore, cpi, constantPool(), graph); |
701 apush(append(n)); | 701 apush(append(n)); |
702 } | 702 } |
703 | 703 |
704 void genGetField(int cpi, RiField field) { | 704 void genGetField(int cpi, RiField field) { |
705 // Must copy the state here, because the field holder must still be on the stack. | 705 // Must copy the state here, because the field holder must still be on the stack. |
742 private Value genResolveClass(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { | 742 private Value genResolveClass(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { |
743 Value holderInstr; | 743 Value holderInstr; |
744 if (initialized) { | 744 if (initialized) { |
745 holderInstr = appendConstant(holder.getEncoding(representation)); | 745 holderInstr = appendConstant(holder.getEncoding(representation)); |
746 } else { | 746 } else { |
747 holderInstr = append(new ResolveClass(holder, representation, null)); | 747 holderInstr = append(new ResolveClass(holder, representation, null, graph)); |
748 } | 748 } |
749 return holderInstr; | 749 return holderInstr; |
750 } | 750 } |
751 | 751 |
752 private void appendOptimizedStoreField(StoreField store) { | 752 private void appendOptimizedStoreField(StoreField store) { |
999 } | 999 } |
1000 } | 1000 } |
1001 | 1001 |
1002 if (needsCheck) { | 1002 if (needsCheck) { |
1003 // append a call to the finalizer registration | 1003 // append a call to the finalizer registration |
1004 append(new RegisterFinalizer(curState.loadLocal(0), curState.immutableCopy(bci()))); | 1004 append(new RegisterFinalizer(curState.loadLocal(0), curState.immutableCopy(bci()), graph)); |
1005 C1XMetrics.InlinedFinalizerChecks++; | 1005 C1XMetrics.InlinedFinalizerChecks++; |
1006 } | 1006 } |
1007 } | 1007 } |
1008 | 1008 |
1009 void genReturn(Value x) { | 1009 void genReturn(Value x) { |