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

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

Issue 11564029: Implement Function.apply in vm (issue 5670). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 LocationSummary* prologue_locs = NULL; 895 LocationSummary* prologue_locs = NULL;
896 if (is_optimizing()) { 896 if (is_optimizing()) {
897 // Spill slots are allocated but not initialized. 897 // Spill slots are allocated but not initialized.
898 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall); 898 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall);
899 prologue_locs->stack_bitmap()->SetLength(StackSize()); 899 prologue_locs->stack_bitmap()->SetLength(StackSize());
900 } 900 }
901 901
902 // We check the number of passed arguments when we have to copy them due to 902 // We check the number of passed arguments when we have to copy them due to
903 // the presence of optional parameters. 903 // the presence of optional parameters.
904 // No such checking code is generated if only fixed parameters are declared, 904 // No such checking code is generated if only fixed parameters are declared,
905 // unless we are debug mode or unless we are compiling a closure. 905 // unless we are in debug mode or unless we are compiling a closure.
906 LocalVariable* saved_args_desc_var = 906 LocalVariable* saved_args_desc_var =
907 parsed_function().GetSavedArgumentsDescriptorVar(); 907 parsed_function().GetSavedArgumentsDescriptorVar();
908 if (num_copied_params == 0) { 908 if (num_copied_params == 0) {
909 #ifdef DEBUG 909 #ifdef DEBUG
910 ASSERT(!parsed_function().function().HasOptionalParameters()); 910 ASSERT(!parsed_function().function().HasOptionalParameters());
911 const bool check_arguments = true; 911 const bool check_arguments = true;
912 #else 912 #else
913 const bool check_arguments = function.IsClosureFunction(); 913 const bool check_arguments = function.IsClosureFunction();
914 #endif 914 #endif
915 if (check_arguments) { 915 if (check_arguments) {
916 __ Comment("Check argument count"); 916 __ Comment("Check argument count");
917 // Check that num_fixed <= argc <= num_params. 917 // Check that exactly num_fixed arguments are passed in.
918 Label argc_in_range; 918 Label correct_num_arguments, wrong_num_arguments;
919 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); 919 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset()));
920 __ cmpq(RAX, Immediate(Smi::RawValue(num_fixed_params))); 920 __ cmpq(RAX, Immediate(Smi::RawValue(num_fixed_params)));
921 __ j(EQUAL, &argc_in_range, Assembler::kNearJump); 921 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump);
922 __ cmpq(RAX,
923 FieldAddress(R10,
924 ArgumentsDescriptor::positional_count_offset()));
925 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump);
926
927 __ Bind(&wrong_num_arguments);
922 if (function.IsClosureFunction()) { 928 if (function.IsClosureFunction()) {
923 if (StackSize() != 0) { 929 if (StackSize() != 0) {
924 // We need to unwind the space we reserved for locals and copied 930 // We need to unwind the space we reserved for locals and copied
925 // parameters. The NoSuchMethodFunction stub does not expect to see 931 // parameters. The NoSuchMethodFunction stub does not expect to see
926 // that area on the stack. 932 // that area on the stack.
927 __ addq(RSP, Immediate(StackSize() * kWordSize)); 933 __ addq(RSP, Immediate(StackSize() * kWordSize));
928 } 934 }
929 // The call below has an empty stackmap because we have just 935 // The call below has an empty stackmap because we have just
930 // dropped the spill slots. 936 // dropped the spill slots.
931 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); 937 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder();
(...skipping 16 matching lines...) Expand all
948 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), 954 stackmap_table_builder_->AddEntry(assembler()->CodeSize(),
949 empty_stack_bitmap, 955 empty_stack_bitmap,
950 0); // No registers. 956 0); // No registers.
951 } 957 }
952 // The noSuchMethod call may return. 958 // The noSuchMethod call may return.
953 __ LeaveFrame(); 959 __ LeaveFrame();
954 __ ret(); 960 __ ret();
955 } else { 961 } else {
956 __ Stop("Wrong number of arguments"); 962 __ Stop("Wrong number of arguments");
957 } 963 }
958 __ Bind(&argc_in_range); 964 __ Bind(&correct_num_arguments);
959 } 965 }
960 // The arguments descriptor is never saved in the absence of optional 966 // The arguments descriptor is never saved in the absence of optional
961 // parameters, since any argument definition test would always yield true. 967 // parameters, since any argument definition test would always yield true.
962 ASSERT(saved_args_desc_var == NULL); 968 ASSERT(saved_args_desc_var == NULL);
963 } else { 969 } else {
964 if (saved_args_desc_var != NULL) { 970 if (saved_args_desc_var != NULL) {
965 __ Comment("Save arguments descriptor"); 971 __ Comment("Save arguments descriptor");
966 const Register kArgumentsDescriptorReg = R10; 972 const Register kArgumentsDescriptorReg = R10;
967 // The saved_args_desc_var is allocated one slot before the first local. 973 // The saved_args_desc_var is allocated one slot before the first local.
968 const intptr_t slot = parsed_function().first_stack_local_index() + 1; 974 const intptr_t slot = parsed_function().first_stack_local_index() + 1;
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { 1482 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) {
1477 __ Exchange(mem1, mem2); 1483 __ Exchange(mem1, mem2);
1478 } 1484 }
1479 1485
1480 1486
1481 #undef __ 1487 #undef __
1482 1488
1483 } // namespace dart 1489 } // namespace dart
1484 1490
1485 #endif // defined TARGET_ARCH_X64 1491 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698