| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 if (is_optimizing()) { | 916 if (is_optimizing()) { |
| 917 // Spill slots are allocated but not initialized. | 917 // Spill slots are allocated but not initialized. |
| 918 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall); | 918 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall); |
| 919 prologue_locs->stack_bitmap()->SetLength(StackSize()); | 919 prologue_locs->stack_bitmap()->SetLength(StackSize()); |
| 920 } | 920 } |
| 921 | 921 |
| 922 // We check the number of passed arguments when we have to copy them due to | 922 // We check the number of passed arguments when we have to copy them due to |
| 923 // the presence of optional named parameters. | 923 // the presence of optional named parameters. |
| 924 // No such checking code is generated if only fixed parameters are declared, | 924 // No such checking code is generated if only fixed parameters are declared, |
| 925 // unless we are debug mode or unless we are compiling a closure. | 925 // unless we are debug mode or unless we are compiling a closure. |
| 926 LocalVariable* saved_args_desc_var = |
| 927 parsed_function().GetSavedArgumentsDescriptorVar(); |
| 926 if (copied_parameter_count == 0) { | 928 if (copied_parameter_count == 0) { |
| 927 #ifdef DEBUG | 929 #ifdef DEBUG |
| 928 const bool check_arguments = true; | 930 const bool check_arguments = true; |
| 929 #else | 931 #else |
| 930 const bool check_arguments = function.IsClosureFunction(); | 932 const bool check_arguments = function.IsClosureFunction(); |
| 931 #endif | 933 #endif |
| 932 if (check_arguments) { | 934 if (check_arguments) { |
| 933 __ Comment("Check argument count"); | 935 __ Comment("Check argument count"); |
| 934 // Check that num_fixed <= argc <= num_params. | 936 // Check that num_fixed <= argc <= num_params. |
| 935 Label argc_in_range; | 937 Label argc_in_range; |
| 936 // Total number of args is the first Smi in args descriptor array (EDX). | 938 // Total number of args is the first Smi in args descriptor array (EDX). |
| 937 __ movl(EAX, FieldAddress(EDX, Array::data_offset())); | 939 __ movl(EAX, FieldAddress(EDX, Array::data_offset())); |
| 938 __ cmpl(EAX, Immediate(Smi::RawValue(parameter_count))); | 940 __ cmpl(EAX, Immediate(Smi::RawValue(parameter_count))); |
| 939 __ j(EQUAL, &argc_in_range, Assembler::kNearJump); | 941 __ j(EQUAL, &argc_in_range, Assembler::kNearJump); |
| 940 if (function.IsClosureFunction()) { | 942 if (function.IsClosureFunction()) { |
| 941 GenerateCallRuntime(Isolate::kNoDeoptId, | 943 GenerateCallRuntime(Isolate::kNoDeoptId, |
| 942 function.token_pos(), | 944 function.token_pos(), |
| 943 kClosureArgumentMismatchRuntimeEntry, | 945 kClosureArgumentMismatchRuntimeEntry, |
| 944 prologue_locs); | 946 prologue_locs); |
| 945 } else { | 947 } else { |
| 946 __ Stop("Wrong number of arguments"); | 948 __ Stop("Wrong number of arguments"); |
| 947 } | 949 } |
| 948 __ Bind(&argc_in_range); | 950 __ Bind(&argc_in_range); |
| 949 } | 951 } |
| 952 // The arguments descriptor is never saved in the absence of optional |
| 953 // parameters, since any argument definition test would always yield true. |
| 954 ASSERT(saved_args_desc_var == NULL); |
| 950 } else { | 955 } else { |
| 956 if (saved_args_desc_var != NULL) { |
| 957 __ Comment("Save arguments descriptor"); |
| 958 const Register kArgumentsDescriptorReg = EDX; |
| 959 // The saved_args_desc_var is allocated one slot before the first local. |
| 960 const intptr_t slot = parsed_function().first_stack_local_index() + 1; |
| 961 // If the saved_args_desc_var is captured, it is first moved to the stack |
| 962 // and later to the context, once the context is allocated. |
| 963 ASSERT(saved_args_desc_var->is_captured() || |
| 964 (saved_args_desc_var->index() == slot)); |
| 965 __ movl(Address(EBP, slot * kWordSize), kArgumentsDescriptorReg); |
| 966 } |
| 951 CopyParameters(); | 967 CopyParameters(); |
| 952 } | 968 } |
| 953 | 969 |
| 954 // In unoptimized code, initialize (non-argument) stack allocated slots to | 970 // In unoptimized code, initialize (non-argument) stack allocated slots to |
| 955 // null. | 971 // null. This does not cover the saved_args_desc_var slot. |
| 956 if (!is_optimizing() && (local_count > 0)) { | 972 if (!is_optimizing() && (local_count > 0)) { |
| 957 __ Comment("Initialize spill slots"); | 973 __ Comment("Initialize spill slots"); |
| 958 const intptr_t slot_base = parsed_function().first_stack_local_index(); | 974 const intptr_t slot_base = parsed_function().first_stack_local_index(); |
| 959 const Immediate raw_null = | 975 const Immediate raw_null = |
| 960 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 976 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 961 __ movl(EAX, raw_null); | 977 __ movl(EAX, raw_null); |
| 962 for (intptr_t i = 0; i < local_count; ++i) { | 978 for (intptr_t i = 0; i < local_count; ++i) { |
| 963 // Subtract index i (locals lie at lower addresses than EBP). | 979 // Subtract index i (locals lie at lower addresses than EBP). |
| 964 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); | 980 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); |
| 965 } | 981 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 __ popl(ECX); | 1319 __ popl(ECX); |
| 1304 __ popl(EAX); | 1320 __ popl(EAX); |
| 1305 } | 1321 } |
| 1306 | 1322 |
| 1307 | 1323 |
| 1308 #undef __ | 1324 #undef __ |
| 1309 | 1325 |
| 1310 } // namespace dart | 1326 } // namespace dart |
| 1311 | 1327 |
| 1312 #endif // defined TARGET_ARCH_IA32 | 1328 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |