Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10915022: Implement argument definition test in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 if (is_optimizing()) { 925 if (is_optimizing()) {
926 // Spill slots are allocated but not initialized. 926 // Spill slots are allocated but not initialized.
927 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall); 927 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall);
928 prologue_locs->stack_bitmap()->SetLength(StackSize()); 928 prologue_locs->stack_bitmap()->SetLength(StackSize());
929 } 929 }
930 930
931 // We check the number of passed arguments when we have to copy them due to 931 // We check the number of passed arguments when we have to copy them due to
932 // the presence of optional named parameters. 932 // the presence of optional named parameters.
933 // No such checking code is generated if only fixed parameters are declared, 933 // No such checking code is generated if only fixed parameters are declared,
934 // unless we are debug mode or unless we are compiling a closure. 934 // unless we are debug mode or unless we are compiling a closure.
935 LocalVariable* saved_args_desc_var =
936 parsed_function().GetSavedArgumentsDescriptorVar();
935 if (copied_parameter_count == 0) { 937 if (copied_parameter_count == 0) {
936 #ifdef DEBUG 938 #ifdef DEBUG
937 const bool check_arguments = true; 939 const bool check_arguments = true;
938 #else 940 #else
939 const bool check_arguments = function.IsClosureFunction(); 941 const bool check_arguments = function.IsClosureFunction();
940 #endif 942 #endif
941 if (check_arguments) { 943 if (check_arguments) {
942 __ Comment("Check argument count"); 944 __ Comment("Check argument count");
943 // Check that num_fixed <= argc <= num_params. 945 // Check that num_fixed <= argc <= num_params.
944 Label argc_in_range; 946 Label argc_in_range;
945 // Total number of args is the first Smi in args descriptor array (R10). 947 // Total number of args is the first Smi in args descriptor array (R10).
946 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 948 __ movq(RAX, FieldAddress(R10, Array::data_offset()));
947 __ cmpq(RAX, Immediate(Smi::RawValue(parameter_count))); 949 __ cmpq(RAX, Immediate(Smi::RawValue(parameter_count)));
948 __ j(EQUAL, &argc_in_range, Assembler::kNearJump); 950 __ j(EQUAL, &argc_in_range, Assembler::kNearJump);
949 if (function.IsClosureFunction()) { 951 if (function.IsClosureFunction()) {
950 GenerateCallRuntime(Isolate::kNoDeoptId, 952 GenerateCallRuntime(Isolate::kNoDeoptId,
951 function.token_pos(), 953 function.token_pos(),
952 kClosureArgumentMismatchRuntimeEntry, 954 kClosureArgumentMismatchRuntimeEntry,
953 prologue_locs); 955 prologue_locs);
954 } else { 956 } else {
955 __ Stop("Wrong number of arguments"); 957 __ Stop("Wrong number of arguments");
956 } 958 }
957 __ Bind(&argc_in_range); 959 __ Bind(&argc_in_range);
958 } 960 }
961 // The arguments descriptor is never saved in the absence of optional
962 // parameters, since any argument definition test would always yield true.
963 ASSERT(saved_args_desc_var == NULL);
959 } else { 964 } else {
965 if (saved_args_desc_var != NULL) {
966 __ Comment("Save arguments descriptor");
967 const Register kArgumentsDescriptorReg = R10;
968 // The saved_args_desc_var is allocated one slot before the first local.
969 const intptr_t slot = parsed_function().first_stack_local_index() + 1;
970 // If the saved_args_desc_var is captured, it is first moved to the stack
971 // and later to the context, once the context is allocated.
972 ASSERT(saved_args_desc_var->is_captured() ||
973 (saved_args_desc_var->index() == slot));
974 __ movq(Address(RBP, slot * kWordSize), kArgumentsDescriptorReg);
975 }
960 CopyParameters(); 976 CopyParameters();
961 } 977 }
962 978
963 // In unoptimized code, initialize (non-argument) stack allocated slots to 979 // In unoptimized code, initialize (non-argument) stack allocated slots to
964 // null. 980 // null. This does not cover the saved_args_desc_var slot.
965 if (!is_optimizing() && (local_count > 0)) { 981 if (!is_optimizing() && (local_count > 0)) {
966 __ Comment("Initialize spill slots"); 982 __ Comment("Initialize spill slots");
967 const intptr_t slot_base = parsed_function().first_stack_local_index(); 983 const intptr_t slot_base = parsed_function().first_stack_local_index();
968 const Immediate raw_null = 984 const Immediate raw_null =
969 Immediate(reinterpret_cast<intptr_t>(Object::null())); 985 Immediate(reinterpret_cast<intptr_t>(Object::null()));
970 __ movq(RAX, raw_null); 986 __ movq(RAX, raw_null);
971 for (intptr_t i = 0; i < local_count; ++i) { 987 for (intptr_t i = 0; i < local_count; ++i) {
972 // Subtract index i (locals lie at lower addresses than RBP). 988 // Subtract index i (locals lie at lower addresses than RBP).
973 __ movq(Address(RBP, (slot_base - i) * kWordSize), RAX); 989 __ movq(Address(RBP, (slot_base - i) * kWordSize), RAX);
974 } 990 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { 1309 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) {
1294 __ Exchange(mem1, mem2); 1310 __ Exchange(mem1, mem2);
1295 } 1311 }
1296 1312
1297 1313
1298 #undef __ 1314 #undef __
1299 1315
1300 } // namespace dart 1316 } // namespace dart
1301 1317
1302 #endif // defined TARGET_ARCH_X64 1318 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698