OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 __ CompareImmediate(R6, Smi::RawValue(min_num_pos_args)); | 762 __ CompareImmediate(R6, Smi::RawValue(min_num_pos_args)); |
763 __ b(&wrong_num_arguments, LT); | 763 __ b(&wrong_num_arguments, LT); |
764 // Check that num_pos_args <= max_num_pos_args. | 764 // Check that num_pos_args <= max_num_pos_args. |
765 __ CompareImmediate(R6, Smi::RawValue(max_num_pos_args)); | 765 __ CompareImmediate(R6, Smi::RawValue(max_num_pos_args)); |
766 __ b(&wrong_num_arguments, GT); | 766 __ b(&wrong_num_arguments, GT); |
767 | 767 |
768 // Copy positional arguments. | 768 // Copy positional arguments. |
769 // Argument i passed at fp[kParamEndSlotFromFp + num_args - i] is copied | 769 // Argument i passed at fp[kParamEndSlotFromFp + num_args - i] is copied |
770 // to fp[kFirstLocalSlotFromFp - i]. | 770 // to fp[kFirstLocalSlotFromFp - i]. |
771 | 771 |
772 __ ldr(R7, FieldAddress(R4, ArgumentsDescriptor::count_offset())); | 772 __ ldr(NOTFP, FieldAddress(R4, ArgumentsDescriptor::count_offset())); |
773 // Since R7 and R6 are Smi, use LSL 1 instead of LSL 2. | 773 // Since NOTFP and R6 are Smi, use LSL 1 instead of LSL 2. |
774 // Let R7 point to the last passed positional argument, i.e. to | 774 // Let NOTFP point to the last passed positional argument, i.e. to |
775 // fp[kParamEndSlotFromFp + num_args - (num_pos_args - 1)]. | 775 // fp[kParamEndSlotFromFp + num_args - (num_pos_args - 1)]. |
776 __ sub(R7, R7, Operand(R6)); | 776 __ sub(NOTFP, NOTFP, Operand(R6)); |
777 __ add(R7, FP, Operand(R7, LSL, 1)); | 777 __ add(NOTFP, FP, Operand(NOTFP, LSL, 1)); |
778 __ add(R7, R7, Operand((kParamEndSlotFromFp + 1) * kWordSize)); | 778 __ add(NOTFP, NOTFP, Operand((kParamEndSlotFromFp + 1) * kWordSize)); |
779 | 779 |
780 // Let R8 point to the last copied positional argument, i.e. to | 780 // Let R8 point to the last copied positional argument, i.e. to |
781 // fp[kFirstLocalSlotFromFp - (num_pos_args - 1)]. | 781 // fp[kFirstLocalSlotFromFp - (num_pos_args - 1)]. |
782 __ AddImmediate(R8, FP, (kFirstLocalSlotFromFp + 1) * kWordSize); | 782 __ AddImmediate(R8, FP, (kFirstLocalSlotFromFp + 1) * kWordSize); |
783 __ sub(R8, R8, Operand(R6, LSL, 1)); // R6 is a Smi. | 783 __ sub(R8, R8, Operand(R6, LSL, 1)); // R6 is a Smi. |
784 __ SmiUntag(R6); | 784 __ SmiUntag(R6); |
785 Label loop, loop_condition; | 785 Label loop, loop_condition; |
786 __ b(&loop_condition); | 786 __ b(&loop_condition); |
787 // We do not use the final allocation index of the variable here, i.e. | 787 // We do not use the final allocation index of the variable here, i.e. |
788 // scope->VariableAt(i)->index(), because captured variables still need | 788 // scope->VariableAt(i)->index(), because captured variables still need |
789 // to be copied to the context that is not yet allocated. | 789 // to be copied to the context that is not yet allocated. |
790 const Address argument_addr(R7, R6, LSL, 2); | 790 const Address argument_addr(NOTFP, R6, LSL, 2); |
791 const Address copy_addr(R8, R6, LSL, 2); | 791 const Address copy_addr(R8, R6, LSL, 2); |
792 __ Bind(&loop); | 792 __ Bind(&loop); |
793 __ ldr(IP, argument_addr); | 793 __ ldr(IP, argument_addr); |
794 __ str(IP, copy_addr); | 794 __ str(IP, copy_addr); |
795 __ Bind(&loop_condition); | 795 __ Bind(&loop_condition); |
796 __ subs(R6, R6, Operand(1)); | 796 __ subs(R6, R6, Operand(1)); |
797 __ b(&loop, PL); | 797 __ b(&loop, PL); |
798 | 798 |
799 // Copy or initialize optional named arguments. | 799 // Copy or initialize optional named arguments. |
800 Label all_arguments_processed; | 800 Label all_arguments_processed; |
(...skipping 15 matching lines...) Expand all Loading... |
816 const intptr_t result = opt_param_name.CompareTo(param_i->name()); | 816 const intptr_t result = opt_param_name.CompareTo(param_i->name()); |
817 ASSERT(result != 0); | 817 ASSERT(result != 0); |
818 if (result > 0) break; | 818 if (result > 0) break; |
819 opt_param[i + 1] = opt_param[i]; | 819 opt_param[i + 1] = opt_param[i]; |
820 opt_param_position[i + 1] = opt_param_position[i]; | 820 opt_param_position[i + 1] = opt_param_position[i]; |
821 } | 821 } |
822 opt_param[i + 1] = parameter; | 822 opt_param[i + 1] = parameter; |
823 opt_param_position[i + 1] = pos; | 823 opt_param_position[i + 1] = pos; |
824 } | 824 } |
825 // Generate code handling each optional parameter in alphabetical order. | 825 // Generate code handling each optional parameter in alphabetical order. |
826 __ ldr(R7, FieldAddress(R4, ArgumentsDescriptor::count_offset())); | 826 __ ldr(NOTFP, FieldAddress(R4, ArgumentsDescriptor::count_offset())); |
827 __ ldr(R6, | 827 __ ldr(R6, |
828 FieldAddress(R4, ArgumentsDescriptor::positional_count_offset())); | 828 FieldAddress(R4, ArgumentsDescriptor::positional_count_offset())); |
829 __ SmiUntag(R6); | 829 __ SmiUntag(R6); |
830 // Let R7 point to the first passed argument, i.e. to | 830 // Let NOTFP point to the first passed argument, i.e. to |
831 // fp[kParamEndSlotFromFp + num_args - 0]; num_args (R7) is Smi. | 831 // fp[kParamEndSlotFromFp + num_args - 0]; num_args (NOTFP) is Smi. |
832 __ add(R7, FP, Operand(R7, LSL, 1)); | 832 __ add(NOTFP, FP, Operand(NOTFP, LSL, 1)); |
833 __ AddImmediate(R7, R7, kParamEndSlotFromFp * kWordSize); | 833 __ AddImmediate(NOTFP, NOTFP, kParamEndSlotFromFp * kWordSize); |
834 // Let R8 point to the entry of the first named argument. | 834 // Let R8 point to the entry of the first named argument. |
835 __ add(R8, R4, Operand( | 835 __ add(R8, R4, Operand( |
836 ArgumentsDescriptor::first_named_entry_offset() - kHeapObjectTag)); | 836 ArgumentsDescriptor::first_named_entry_offset() - kHeapObjectTag)); |
837 for (int i = 0; i < num_opt_named_params; i++) { | 837 for (int i = 0; i < num_opt_named_params; i++) { |
838 Label load_default_value, assign_optional_parameter; | 838 Label load_default_value, assign_optional_parameter; |
839 const int param_pos = opt_param_position[i]; | 839 const int param_pos = opt_param_position[i]; |
840 // Check if this named parameter was passed in. | 840 // Check if this named parameter was passed in. |
841 // Load R9 with the name of the argument. | 841 // Load R9 with the name of the argument. |
842 __ ldr(R9, Address(R8, ArgumentsDescriptor::name_offset())); | 842 __ ldr(R9, Address(R8, ArgumentsDescriptor::name_offset())); |
843 ASSERT(opt_param[i]->name().IsSymbol()); | 843 ASSERT(opt_param[i]->name().IsSymbol()); |
844 __ CompareObject(R9, opt_param[i]->name()); | 844 __ CompareObject(R9, opt_param[i]->name()); |
845 __ b(&load_default_value, NE); | 845 __ b(&load_default_value, NE); |
846 // Load R9 with passed-in argument at provided arg_pos, i.e. at | 846 // Load R9 with passed-in argument at provided arg_pos, i.e. at |
847 // fp[kParamEndSlotFromFp + num_args - arg_pos]. | 847 // fp[kParamEndSlotFromFp + num_args - arg_pos]. |
848 __ ldr(R9, Address(R8, ArgumentsDescriptor::position_offset())); | 848 __ ldr(R9, Address(R8, ArgumentsDescriptor::position_offset())); |
849 // R9 is arg_pos as Smi. | 849 // R9 is arg_pos as Smi. |
850 // Point to next named entry. | 850 // Point to next named entry. |
851 __ add(R8, R8, Operand(ArgumentsDescriptor::named_entry_size())); | 851 __ add(R8, R8, Operand(ArgumentsDescriptor::named_entry_size())); |
852 __ rsb(R9, R9, Operand(0)); | 852 __ rsb(R9, R9, Operand(0)); |
853 Address argument_addr(R7, R9, LSL, 1); // R9 is a negative Smi. | 853 Address argument_addr(NOTFP, R9, LSL, 1); // R9 is a negative Smi. |
854 __ ldr(R9, argument_addr); | 854 __ ldr(R9, argument_addr); |
855 __ b(&assign_optional_parameter); | 855 __ b(&assign_optional_parameter); |
856 __ Bind(&load_default_value); | 856 __ Bind(&load_default_value); |
857 // Load R9 with default argument. | 857 // Load R9 with default argument. |
858 const Instance& value = parsed_function().DefaultParameterValueAt( | 858 const Instance& value = parsed_function().DefaultParameterValueAt( |
859 param_pos - num_fixed_params); | 859 param_pos - num_fixed_params); |
860 __ LoadObject(R9, value); | 860 __ LoadObject(R9, value); |
861 __ Bind(&assign_optional_parameter); | 861 __ Bind(&assign_optional_parameter); |
862 // Assign R9 to fp[kFirstLocalSlotFromFp - param_pos]. | 862 // Assign R9 to fp[kFirstLocalSlotFromFp - param_pos]. |
863 // We do not use the final allocation index of the variable here, i.e. | 863 // We do not use the final allocation index of the variable here, i.e. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 // Assign R9 to fp[kFirstLocalSlotFromFp - param_pos]. | 895 // Assign R9 to fp[kFirstLocalSlotFromFp - param_pos]. |
896 // We do not use the final allocation index of the variable here, i.e. | 896 // We do not use the final allocation index of the variable here, i.e. |
897 // scope->VariableAt(i)->index(), because captured variables still need | 897 // scope->VariableAt(i)->index(), because captured variables still need |
898 // to be copied to the context that is not yet allocated. | 898 // to be copied to the context that is not yet allocated. |
899 const intptr_t computed_param_pos = kFirstLocalSlotFromFp - param_pos; | 899 const intptr_t computed_param_pos = kFirstLocalSlotFromFp - param_pos; |
900 const Address param_addr(FP, computed_param_pos * kWordSize); | 900 const Address param_addr(FP, computed_param_pos * kWordSize); |
901 __ str(R9, param_addr); | 901 __ str(R9, param_addr); |
902 __ Bind(&next_parameter); | 902 __ Bind(&next_parameter); |
903 } | 903 } |
904 if (check_correct_named_args) { | 904 if (check_correct_named_args) { |
905 __ ldr(R7, FieldAddress(R4, ArgumentsDescriptor::count_offset())); | 905 __ ldr(NOTFP, FieldAddress(R4, ArgumentsDescriptor::count_offset())); |
906 __ SmiUntag(R7); | 906 __ SmiUntag(NOTFP); |
907 // Check that R6 equals R7, i.e. no named arguments passed. | 907 // Check that R6 equals NOTFP, i.e. no named arguments passed. |
908 __ cmp(R6, Operand(R7)); | 908 __ cmp(R6, Operand(NOTFP)); |
909 __ b(&all_arguments_processed, EQ); | 909 __ b(&all_arguments_processed, EQ); |
910 } | 910 } |
911 } | 911 } |
912 | 912 |
913 __ Bind(&wrong_num_arguments); | 913 __ Bind(&wrong_num_arguments); |
914 if (function.IsClosureFunction()) { | 914 if (function.IsClosureFunction()) { |
915 __ LeaveDartFrame(kKeepCalleePP); // The arguments are still on the stack. | 915 __ LeaveDartFrame(kKeepCalleePP); // The arguments are still on the stack. |
916 __ Branch(*StubCode::CallClosureNoSuchMethod_entry()); | 916 __ Branch(*StubCode::CallClosureNoSuchMethod_entry()); |
917 // The noSuchMethod call may return to the caller, but not here. | 917 // The noSuchMethod call may return to the caller, but not here. |
918 } else if (check_correct_named_args) { | 918 } else if (check_correct_named_args) { |
919 __ Stop("Wrong arguments"); | 919 __ Stop("Wrong arguments"); |
920 } | 920 } |
921 | 921 |
922 __ Bind(&all_arguments_processed); | 922 __ Bind(&all_arguments_processed); |
923 // Nullify originally passed arguments only after they have been copied and | 923 // Nullify originally passed arguments only after they have been copied and |
924 // checked, otherwise noSuchMethod would not see their original values. | 924 // checked, otherwise noSuchMethod would not see their original values. |
925 // This step can be skipped in case we decide that formal parameters are | 925 // This step can be skipped in case we decide that formal parameters are |
926 // implicitly final, since garbage collecting the unmodified value is not | 926 // implicitly final, since garbage collecting the unmodified value is not |
927 // an issue anymore. | 927 // an issue anymore. |
928 | 928 |
929 // R4 : arguments descriptor array. | 929 // R4 : arguments descriptor array. |
930 __ ldr(R6, FieldAddress(R4, ArgumentsDescriptor::count_offset())); | 930 __ ldr(R6, FieldAddress(R4, ArgumentsDescriptor::count_offset())); |
931 __ SmiUntag(R6); | 931 __ SmiUntag(R6); |
932 __ add(R7, FP, Operand((kParamEndSlotFromFp + 1) * kWordSize)); | 932 __ add(NOTFP, FP, Operand((kParamEndSlotFromFp + 1) * kWordSize)); |
933 const Address original_argument_addr(R7, R6, LSL, 2); | 933 const Address original_argument_addr(NOTFP, R6, LSL, 2); |
934 __ LoadObject(IP, Object::null_object()); | 934 __ LoadObject(IP, Object::null_object()); |
935 Label null_args_loop, null_args_loop_condition; | 935 Label null_args_loop, null_args_loop_condition; |
936 __ b(&null_args_loop_condition); | 936 __ b(&null_args_loop_condition); |
937 __ Bind(&null_args_loop); | 937 __ Bind(&null_args_loop); |
938 __ str(IP, original_argument_addr); | 938 __ str(IP, original_argument_addr); |
939 __ Bind(&null_args_loop_condition); | 939 __ Bind(&null_args_loop_condition); |
940 __ subs(R6, R6, Operand(1)); | 940 __ subs(R6, R6, Operand(1)); |
941 __ b(&null_args_loop, PL); | 941 __ b(&null_args_loop, PL); |
942 } | 942 } |
943 | 943 |
(...skipping 16 matching lines...) Expand all Loading... |
960 // Sequence node has one store node and one return NULL node. | 960 // Sequence node has one store node and one return NULL node. |
961 __ Comment("Inlined Setter"); | 961 __ Comment("Inlined Setter"); |
962 __ ldr(R0, Address(SP, 1 * kWordSize)); // Receiver. | 962 __ ldr(R0, Address(SP, 1 * kWordSize)); // Receiver. |
963 __ ldr(R1, Address(SP, 0 * kWordSize)); // Value. | 963 __ ldr(R1, Address(SP, 0 * kWordSize)); // Value. |
964 __ StoreIntoObjectOffset(R0, offset, R1); | 964 __ StoreIntoObjectOffset(R0, offset, R1); |
965 __ LoadObject(R0, Object::null_object()); | 965 __ LoadObject(R0, Object::null_object()); |
966 __ Ret(); | 966 __ Ret(); |
967 } | 967 } |
968 | 968 |
969 | 969 |
970 static const Register new_pp = R7; | 970 static const Register new_pp = NOTFP; |
971 | 971 |
972 | 972 |
973 void FlowGraphCompiler::EmitFrameEntry() { | 973 void FlowGraphCompiler::EmitFrameEntry() { |
974 const Function& function = parsed_function().function(); | 974 const Function& function = parsed_function().function(); |
975 if (CanOptimizeFunction() && | 975 if (CanOptimizeFunction() && |
976 function.IsOptimizable() && | 976 function.IsOptimizable() && |
977 (!is_optimizing() || may_reoptimize())) { | 977 (!is_optimizing() || may_reoptimize())) { |
978 const Register function_reg = R8; | 978 const Register function_reg = R8; |
979 | 979 |
980 // The pool pointer is not setup before entering the Dart frame. | 980 // The pool pointer is not setup before entering the Dart frame. |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 DRegister dreg = EvenDRegisterOf(reg); | 1873 DRegister dreg = EvenDRegisterOf(reg); |
1874 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); | 1874 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); |
1875 } | 1875 } |
1876 | 1876 |
1877 | 1877 |
1878 #undef __ | 1878 #undef __ |
1879 | 1879 |
1880 } // namespace dart | 1880 } // namespace dart |
1881 | 1881 |
1882 #endif // defined TARGET_ARCH_ARM | 1882 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |