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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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/dart_entry.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('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_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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 LocationSummary* prologue_locs = NULL; 892 LocationSummary* prologue_locs = NULL;
893 if (is_optimizing()) { 893 if (is_optimizing()) {
894 // Spill slots are allocated but not initialized. 894 // Spill slots are allocated but not initialized.
895 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall); 895 prologue_locs = new LocationSummary(0, 0, LocationSummary::kCall);
896 prologue_locs->stack_bitmap()->SetLength(StackSize()); 896 prologue_locs->stack_bitmap()->SetLength(StackSize());
897 } 897 }
898 898
899 // We check the number of passed arguments when we have to copy them due to 899 // We check the number of passed arguments when we have to copy them due to
900 // the presence of optional parameters. 900 // the presence of optional parameters.
901 // No such checking code is generated if only fixed parameters are declared, 901 // No such checking code is generated if only fixed parameters are declared,
902 // unless we are debug mode or unless we are compiling a closure. 902 // unless we are in debug mode or unless we are compiling a closure.
903 LocalVariable* saved_args_desc_var = 903 LocalVariable* saved_args_desc_var =
904 parsed_function().GetSavedArgumentsDescriptorVar(); 904 parsed_function().GetSavedArgumentsDescriptorVar();
905 if (num_copied_params == 0) { 905 if (num_copied_params == 0) {
906 #ifdef DEBUG 906 #ifdef DEBUG
907 ASSERT(!parsed_function().function().HasOptionalParameters()); 907 ASSERT(!parsed_function().function().HasOptionalParameters());
908 const bool check_arguments = true; 908 const bool check_arguments = true;
909 #else 909 #else
910 const bool check_arguments = function.IsClosureFunction(); 910 const bool check_arguments = function.IsClosureFunction();
911 #endif 911 #endif
912 if (check_arguments) { 912 if (check_arguments) {
913 __ Comment("Check argument count"); 913 __ Comment("Check argument count");
914 // Check that num_fixed <= argc <= num_params. 914 // Check that exactly num_fixed arguments are passed in.
915 Label argc_in_range; 915 Label correct_num_arguments, wrong_num_arguments;
916 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); 916 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
917 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params))); 917 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params)));
918 __ j(EQUAL, &argc_in_range, Assembler::kNearJump); 918 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump);
919 __ cmpl(EAX,
920 FieldAddress(EDX,
921 ArgumentsDescriptor::positional_count_offset()));
922 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump);
923
924 __ Bind(&wrong_num_arguments);
919 if (function.IsClosureFunction()) { 925 if (function.IsClosureFunction()) {
920 if (StackSize() != 0) { 926 if (StackSize() != 0) {
921 // We need to unwind the space we reserved for locals and copied 927 // We need to unwind the space we reserved for locals and copied
922 // parameters. The NoSuchMethodFunction stub does not expect to see 928 // parameters. The NoSuchMethodFunction stub does not expect to see
923 // that area on the stack. 929 // that area on the stack.
924 __ addl(ESP, Immediate(StackSize() * kWordSize)); 930 __ addl(ESP, Immediate(StackSize() * kWordSize));
925 } 931 }
926 // The call below has an empty stackmap because we have just 932 // The call below has an empty stackmap because we have just
927 // dropped the spill slots. 933 // dropped the spill slots.
928 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); 934 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder();
(...skipping 16 matching lines...) Expand all
945 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), 951 stackmap_table_builder_->AddEntry(assembler()->CodeSize(),
946 empty_stack_bitmap, 952 empty_stack_bitmap,
947 0); // No registers. 953 0); // No registers.
948 } 954 }
949 // The noSuchMethod call may return. 955 // The noSuchMethod call may return.
950 __ LeaveFrame(); 956 __ LeaveFrame();
951 __ ret(); 957 __ ret();
952 } else { 958 } else {
953 __ Stop("Wrong number of arguments"); 959 __ Stop("Wrong number of arguments");
954 } 960 }
955 __ Bind(&argc_in_range); 961 __ Bind(&correct_num_arguments);
956 } 962 }
957 // The arguments descriptor is never saved in the absence of optional 963 // The arguments descriptor is never saved in the absence of optional
958 // parameters, since any argument definition test would always yield true. 964 // parameters, since any argument definition test would always yield true.
959 ASSERT(saved_args_desc_var == NULL); 965 ASSERT(saved_args_desc_var == NULL);
960 } else { 966 } else {
961 if (saved_args_desc_var != NULL) { 967 if (saved_args_desc_var != NULL) {
962 __ Comment("Save arguments descriptor"); 968 __ Comment("Save arguments descriptor");
963 const Register kArgumentsDescriptorReg = EDX; 969 const Register kArgumentsDescriptorReg = EDX;
964 // The saved_args_desc_var is allocated one slot before the first local. 970 // The saved_args_desc_var is allocated one slot before the first local.
965 const intptr_t slot = parsed_function().first_stack_local_index() + 1; 971 const intptr_t slot = parsed_function().first_stack_local_index() + 1;
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 __ popl(ECX); 1504 __ popl(ECX);
1499 __ popl(EAX); 1505 __ popl(EAX);
1500 } 1506 }
1501 1507
1502 1508
1503 #undef __ 1509 #undef __
1504 1510
1505 } // namespace dart 1511 } // namespace dart
1506 1512
1507 #endif // defined TARGET_ARCH_IA32 1513 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698