Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2647:0bf54306c139
Removed accessor workaround.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 11 May 2011 14:39:56 +0200 |
parents | b2c1e959be46 |
children | 62306ff0ccc2 |
comparison
equal
deleted
inserted
replaced
2646:ce054e34fbaf | 2647:0bf54306c139 |
---|---|
715 Value[] args = frameState.popArguments(target.signature().argumentSlots(true)); | 715 Value[] args = frameState.popArguments(target.signature().argumentSlots(true)); |
716 invokeDirect(target, args, knownHolder, cpi, constantPool); | 716 invokeDirect(target, args, knownHolder, cpi, constantPool); |
717 | 717 |
718 } | 718 } |
719 | 719 |
720 /** | |
721 * Temporary work-around to support the @ACCESSOR Maxine annotation. | |
722 */ | |
723 private static final Class<?> Accessor; | |
724 static { | |
725 Class<?> c = null; | |
726 try { | |
727 c = Class.forName("com.sun.max.unsafe.Accessor"); | |
728 } catch (ClassNotFoundException e) { | |
729 } | |
730 Accessor = c; | |
731 } | |
732 | |
733 /** | |
734 * Temporary work-around to support the @ACCESSOR Maxine annotation. | |
735 */ | |
736 private static ThreadLocal<RiType> boundAccessor = new ThreadLocal<RiType>(); | |
737 | |
738 /** | |
739 * Temporary work-around to support the @ACCESSOR Maxine annotation. | |
740 */ | |
741 private static RiMethod bindAccessorMethod(RiMethod target) { | |
742 if (Accessor != null && target.isResolved() && target.holder().javaClass() == Accessor) { | |
743 RiType accessor = boundAccessor.get(); | |
744 assert accessor != null : "Cannot compile call to method in " + target.holder() + " without enclosing @ACCESSOR annotated method"; | |
745 RiMethod newTarget = accessor.resolveMethodImpl(target); | |
746 assert target != newTarget : "Could not bind " + target + " to a method in " + accessor; | |
747 target = newTarget; | |
748 } | |
749 return target; | |
750 } | |
751 | |
752 private void genInvokeIndirect(int opcode, RiMethod target, Value[] args, int cpi, RiConstantPool constantPool) { | 720 private void genInvokeIndirect(int opcode, RiMethod target, Value[] args, int cpi, RiConstantPool constantPool) { |
753 Value receiver = args[0]; | 721 Value receiver = args[0]; |
754 // attempt to devirtualize the call | 722 // attempt to devirtualize the call |
755 if (target.isResolved()) { | 723 if (target.isResolved()) { |
756 RiType klass = target.holder(); | 724 RiType klass = target.holder(); |
819 } | 787 } |
820 } | 788 } |
821 return assumed; | 789 return assumed; |
822 } | 790 } |
823 | 791 |
824 void callRegisterFinalizer() { | 792 private void callRegisterFinalizer() { |
825 Value receiver = frameState.loadLocal(0); | 793 Value receiver = frameState.loadLocal(0); |
826 RiType declaredType = receiver.declaredType(); | 794 RiType declaredType = receiver.declaredType(); |
827 RiType receiverType = declaredType; | 795 RiType receiverType = declaredType; |
828 RiType exactType = receiver.exactType(); | 796 RiType exactType = receiver.exactType(); |
829 if (exactType == null && declaredType != null) { | 797 if (exactType == null && declaredType != null) { |
858 append(new RegisterFinalizer(frameState.loadLocal(0), graph)); | 826 append(new RegisterFinalizer(frameState.loadLocal(0), graph)); |
859 C1XMetrics.InlinedFinalizerChecks++; | 827 C1XMetrics.InlinedFinalizerChecks++; |
860 } | 828 } |
861 } | 829 } |
862 | 830 |
863 void genReturn(Value x) { | 831 private void genReturn(Value x) { |
864 if (method().isConstructor() && method().holder().superType() == null) { | 832 if (method().isConstructor() && method().holder().superType() == null) { |
865 callRegisterFinalizer(); | 833 callRegisterFinalizer(); |
866 } | 834 } |
867 | 835 |
868 frameState.clearStack(); | 836 frameState.clearStack(); |
878 frameState.unlock(); | 846 frameState.unlock(); |
879 } | 847 } |
880 append(new Return(x, !noSafepoints(), graph)); | 848 append(new Return(x, !noSafepoints(), graph)); |
881 } | 849 } |
882 | 850 |
883 void genMonitorEnter(Value x, int bci) { | 851 private void genMonitorEnter(Value x, int bci) { |
884 int lockNumber = frameState.locksSize(); | 852 int lockNumber = frameState.locksSize(); |
885 MonitorAddress lockAddress = null; | 853 MonitorAddress lockAddress = null; |
886 if (compilation.runtime.sizeOfBasicObjectLock() != 0) { | 854 if (compilation.runtime.sizeOfBasicObjectLock() != 0) { |
887 lockAddress = new MonitorAddress(lockNumber, graph); | 855 lockAddress = new MonitorAddress(lockNumber, graph); |
888 append(lockAddress); | 856 append(lockAddress); |
893 if (bci == Instruction.SYNCHRONIZATION_ENTRY_BCI) { | 861 if (bci == Instruction.SYNCHRONIZATION_ENTRY_BCI) { |
894 monitorEnter.setStateAfter(frameState.create(0)); | 862 monitorEnter.setStateAfter(frameState.create(0)); |
895 } | 863 } |
896 } | 864 } |
897 | 865 |
898 void genMonitorExit(Value x, int bci) { | 866 private void genMonitorExit(Value x, int bci) { |
899 int lockNumber = frameState.locksSize() - 1; | 867 int lockNumber = frameState.locksSize() - 1; |
900 if (lockNumber < 0) { | 868 if (lockNumber < 0) { |
901 throw new CiBailout("monitor stack underflow"); | 869 throw new CiBailout("monitor stack underflow"); |
902 } | 870 } |
903 MonitorAddress lockAddress = null; | 871 MonitorAddress lockAddress = null; |
907 } | 875 } |
908 appendWithoutOptimization(new MonitorExit(x, lockAddress, lockNumber, graph), bci); | 876 appendWithoutOptimization(new MonitorExit(x, lockAddress, lockNumber, graph), bci); |
909 frameState.unlock(); | 877 frameState.unlock(); |
910 } | 878 } |
911 | 879 |
912 void genJsr(int dest) { | 880 private void genJsr(int dest) { |
913 throw new CiBailout("jsr/ret not supported"); | 881 throw new CiBailout("jsr/ret not supported"); |
914 } | 882 } |
915 | 883 |
916 void genRet(int localIndex) { | 884 private void genRet(int localIndex) { |
917 throw new CiBailout("jsr/ret not supported"); | 885 throw new CiBailout("jsr/ret not supported"); |
918 } | 886 } |
919 | 887 |
920 void genTableswitch() { | 888 private void genTableswitch() { |
921 int bci = bci(); | 889 int bci = bci(); |
922 BytecodeTableSwitch ts = new BytecodeTableSwitch(stream(), bci); | 890 BytecodeTableSwitch ts = new BytecodeTableSwitch(stream(), bci); |
923 int max = ts.numberOfCases(); | 891 int max = ts.numberOfCases(); |
924 List<BlockBegin> list = new ArrayList<BlockBegin>(max + 1); | 892 List<BlockBegin> list = new ArrayList<BlockBegin>(max + 1); |
925 boolean isBackwards = false; | 893 boolean isBackwards = false; |
935 boolean isSafepoint = isBackwards && !noSafepoints(); | 903 boolean isSafepoint = isBackwards && !noSafepoints(); |
936 FrameState stateBefore = isSafepoint ? frameState.create(bci()) : null; | 904 FrameState stateBefore = isSafepoint ? frameState.create(bci()) : null; |
937 append(new TableSwitch(frameState.ipop(), list, ts.lowKey(), stateBefore, isSafepoint, graph)); | 905 append(new TableSwitch(frameState.ipop(), list, ts.lowKey(), stateBefore, isSafepoint, graph)); |
938 } | 906 } |
939 | 907 |
940 void genLookupswitch() { | 908 private void genLookupswitch() { |
941 int bci = bci(); | 909 int bci = bci(); |
942 BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci); | 910 BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci); |
943 int max = ls.numberOfCases(); | 911 int max = ls.numberOfCases(); |
944 List<BlockBegin> list = new ArrayList<BlockBegin>(max + 1); | 912 List<BlockBegin> list = new ArrayList<BlockBegin>(max + 1); |
945 int[] keys = new int[max]; | 913 int[] keys = new int[max]; |