Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2538:e1ba5a93e997
Clean up on Value class and LIRGenerator/LIRItem-related things.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 20:13:54 +0200 |
parents | 4a016ff4d2df |
children | 3fc322165071 |
comparison
equal
deleted
inserted
replaced
2537:4a016ff4d2df | 2538:e1ba5a93e997 |
---|---|
689 private void checkForDirectCompare(TypeCheck check) { | 689 private void checkForDirectCompare(TypeCheck check) { |
690 RiType type = check.targetClass(); | 690 RiType type = check.targetClass(); |
691 if (!type.isResolved() || type.isArrayClass()) { | 691 if (!type.isResolved() || type.isArrayClass()) { |
692 return; | 692 return; |
693 } | 693 } |
694 if (assumeLeafClass(type)) { | |
695 check.setDirectCompare(); | |
696 } | |
697 } | 694 } |
698 | 695 |
699 void genNewInstance(int cpi) { | 696 void genNewInstance(int cpi) { |
700 FrameState stateBefore = curState.immutableCopy(bci()); | 697 FrameState stateBefore = curState.immutableCopy(bci()); |
701 RiType type = constantPool().lookupType(cpi, NEW); | 698 RiType type = constantPool().lookupType(cpi, NEW); |
734 | 731 |
735 void genGetField(int cpi, RiField field) { | 732 void genGetField(int cpi, RiField field) { |
736 // Must copy the state here, because the field holder must still be on the stack. | 733 // Must copy the state here, because the field holder must still be on the stack. |
737 FrameState stateBefore = curState.immutableCopy(bci()); | 734 FrameState stateBefore = curState.immutableCopy(bci()); |
738 boolean isLoaded = !C1XOptions.TestPatching && field.isResolved(); | 735 boolean isLoaded = !C1XOptions.TestPatching && field.isResolved(); |
739 LoadField load = new LoadField(apop(), field, false, stateBefore, isLoaded); | 736 LoadField load = new LoadField(apop(), field, stateBefore, isLoaded); |
740 appendOptimizedLoadField(field.kind(), load); | 737 appendOptimizedLoadField(field.kind(), load); |
741 } | 738 } |
742 | 739 |
743 void genPutField(int cpi, RiField field) { | 740 void genPutField(int cpi, RiField field) { |
744 // Must copy the state here, because the field holder must still be on the stack. | 741 // Must copy the state here, because the field holder must still be on the stack. |
745 FrameState stateBefore = curState.immutableCopy(bci()); | 742 FrameState stateBefore = curState.immutableCopy(bci()); |
746 boolean isLoaded = !C1XOptions.TestPatching && field.isResolved(); | 743 boolean isLoaded = !C1XOptions.TestPatching && field.isResolved(); |
747 Value value = pop(field.kind().stackKind()); | 744 Value value = pop(field.kind().stackKind()); |
748 appendOptimizedStoreField(new StoreField(apop(), field, value, false, stateBefore, isLoaded)); | 745 appendOptimizedStoreField(new StoreField(apop(), field, value, stateBefore, isLoaded)); |
749 } | 746 } |
750 | 747 |
751 void genGetStatic(int cpi, RiField field) { | 748 void genGetStatic(int cpi, RiField field) { |
752 RiType holder = field.holder(); | 749 RiType holder = field.holder(); |
753 boolean isInitialized = !C1XOptions.TestPatching && field.isResolved() && holder.isResolved() && holder.isInitialized(); | 750 boolean isInitialized = !C1XOptions.TestPatching && field.isResolved() && holder.isResolved() && holder.isInitialized(); |
757 } | 754 } |
758 if (constantValue != null) { | 755 if (constantValue != null) { |
759 push(constantValue.kind.stackKind(), appendConstant(constantValue)); | 756 push(constantValue.kind.stackKind(), appendConstant(constantValue)); |
760 } else { | 757 } else { |
761 Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi); | 758 Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi); |
762 LoadField load = new LoadField(container, field, true, null, isInitialized); | 759 LoadField load = new LoadField(container, field, null, isInitialized); |
763 appendOptimizedLoadField(field.kind(), load); | 760 appendOptimizedLoadField(field.kind(), load); |
764 } | 761 } |
765 } | 762 } |
766 | 763 |
767 void genPutStatic(int cpi, RiField field) { | 764 void genPutStatic(int cpi, RiField field) { |
768 RiType holder = field.holder(); | 765 RiType holder = field.holder(); |
769 boolean isInitialized = !C1XOptions.TestPatching && field.isResolved() && holder.isResolved() && holder.isInitialized(); | 766 boolean isInitialized = !C1XOptions.TestPatching && field.isResolved() && holder.isResolved() && holder.isInitialized(); |
770 Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi); | 767 Value container = genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi); |
771 Value value = pop(field.kind().stackKind()); | 768 Value value = pop(field.kind().stackKind()); |
772 StoreField store = new StoreField(container, field, value, true, null, isInitialized); | 769 StoreField store = new StoreField(container, field, value, null, isInitialized); |
773 appendOptimizedStoreField(store); | 770 appendOptimizedStoreField(store); |
774 } | 771 } |
775 | 772 |
776 private Value genResolveClass(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { | 773 private Value genResolveClass(RiType.Representation representation, RiType holder, boolean initialized, int cpi) { |
777 Value holderInstr; | 774 Value holderInstr; |
822 genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi); | 819 genResolveClass(RiType.Representation.StaticFields, holder, isInitialized, cpi); |
823 } | 820 } |
824 | 821 |
825 Value[] args = curState.popArguments(target.signature().argumentSlots(false)); | 822 Value[] args = curState.popArguments(target.signature().argumentSlots(false)); |
826 if (!tryInline(target, args)) { | 823 if (!tryInline(target, args)) { |
827 appendInvoke(INVOKESTATIC, target, args, true, cpi, constantPool); | 824 appendInvoke(INVOKESTATIC, target, args, cpi, constantPool); |
828 } | 825 } |
829 } | 826 } |
830 | 827 |
831 void genInvokeInterface(RiMethod target, int cpi, RiConstantPool constantPool) { | 828 void genInvokeInterface(RiMethod target, int cpi, RiConstantPool constantPool) { |
832 Value[] args = curState.popArguments(target.signature().argumentSlots(true)); | 829 Value[] args = curState.popArguments(target.signature().argumentSlots(true)); |
922 } else if (C1XOptions.PrintAssumptions) { | 919 } else if (C1XOptions.PrintAssumptions) { |
923 TTY.println("Could not make leaf type assumption for type " + klass); | 920 TTY.println("Could not make leaf type assumption for type " + klass); |
924 } | 921 } |
925 } | 922 } |
926 // devirtualization failed, produce an actual invokevirtual | 923 // devirtualization failed, produce an actual invokevirtual |
927 appendInvoke(opcode, target, args, false, cpi, constantPool); | 924 appendInvoke(opcode, target, args, cpi, constantPool); |
928 } | 925 } |
929 | 926 |
930 private CiKind returnKind(RiMethod target) { | 927 private CiKind returnKind(RiMethod target) { |
931 return target.signature().returnKind(); | 928 return target.signature().returnKind(); |
932 } | 929 } |
933 | 930 |
934 private void invokeDirect(RiMethod target, Value[] args, RiType knownHolder, int cpi, RiConstantPool constantPool) { | 931 private void invokeDirect(RiMethod target, Value[] args, RiType knownHolder, int cpi, RiConstantPool constantPool) { |
935 if (!tryInline(target, args)) { | 932 if (!tryInline(target, args)) { |
936 // could not optimize or inline the method call | 933 // could not optimize or inline the method call |
937 appendInvoke(INVOKESPECIAL, target, args, false, cpi, constantPool); | 934 appendInvoke(INVOKESPECIAL, target, args, cpi, constantPool); |
938 } | 935 } |
939 } | 936 } |
940 | 937 |
941 private void appendInvoke(int opcode, RiMethod target, Value[] args, boolean isStatic, int cpi, RiConstantPool constantPool) { | 938 private void appendInvoke(int opcode, RiMethod target, Value[] args, int cpi, RiConstantPool constantPool) { |
942 CiKind resultType = returnKind(target); | 939 CiKind resultType = returnKind(target); |
943 Value result = append(new Invoke(opcode, resultType.stackKind(), args, isStatic, target, target.signature().returnType(compilation.method.holder()), null)); | 940 Value result = append(new Invoke(opcode, resultType.stackKind(), args, target, target.signature().returnType(compilation.method.holder()), null)); |
944 pushReturn(resultType, result); | 941 pushReturn(resultType, result); |
945 } | 942 } |
946 | 943 |
947 private RiType getExactType(RiType staticType, Value receiver) { | 944 private RiType getExactType(RiType staticType, Value receiver) { |
948 RiType exact = staticType.exactType(); | 945 RiType exact = staticType.exactType(); |