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

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

Issue 11341014: Remove --reject_named_argument_as_positional flag from the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « no previous file | 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"
11 #include "vm/ast_printer.h" 11 #include "vm/ast_printer.h"
12 #include "vm/il_printer.h" 12 #include "vm/il_printer.h"
13 #include "vm/locations.h" 13 #include "vm/locations.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/parser.h" 15 #include "vm/parser.h"
16 #include "vm/stub_code.h" 16 #include "vm/stub_code.h"
17 #include "vm/symbols.h" 17 #include "vm/symbols.h"
18 18
19 namespace dart { 19 namespace dart {
20 20
21 DECLARE_FLAG(bool, print_ast); 21 DECLARE_FLAG(bool, print_ast);
22 DECLARE_FLAG(bool, print_scopes); 22 DECLARE_FLAG(bool, print_scopes);
23 DECLARE_FLAG(bool, reject_named_argument_as_positional);
24 DECLARE_FLAG(bool, trace_functions); 23 DECLARE_FLAG(bool, trace_functions);
25 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); 24 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization.");
26 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); 25 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic.");
27 26
28 27
29 FieldAddress FlowGraphCompiler::ElementAddressForRegIndex(intptr_t cid, 28 FieldAddress FlowGraphCompiler::ElementAddressForRegIndex(intptr_t cid,
30 Register array, 29 Register array,
31 Register index) { 30 Register index) {
32 // Note that index is Smi, i.e, times 2. 31 // Note that index is Smi, i.e, times 2.
33 ASSERT(kSmiTagShift == 1); 32 ASSERT(kSmiTagShift == 1);
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 const Address argument_addr(EBX, ECX, TIMES_4, 0); 687 const Address argument_addr(EBX, ECX, TIMES_4, 0);
689 const Address copy_addr(EDI, ECX, TIMES_4, 0); 688 const Address copy_addr(EDI, ECX, TIMES_4, 0);
690 __ Bind(&loop); 689 __ Bind(&loop);
691 __ movl(EAX, argument_addr); 690 __ movl(EAX, argument_addr);
692 __ movl(copy_addr, EAX); 691 __ movl(copy_addr, EAX);
693 __ Bind(&loop_condition); 692 __ Bind(&loop_condition);
694 __ decl(ECX); 693 __ decl(ECX);
695 __ j(POSITIVE, &loop, Assembler::kNearJump); 694 __ j(POSITIVE, &loop, Assembler::kNearJump);
696 695
697 // Copy or initialize optional named arguments. 696 // Copy or initialize optional named arguments.
698
699 if (!FLAG_reject_named_argument_as_positional) {
700 // Treat optional positional parameters as optional named parameters.
701 num_opt_named_params += num_opt_pos_params;
702 }
703 const Immediate raw_null = 697 const Immediate raw_null =
704 Immediate(reinterpret_cast<intptr_t>(Object::null())); 698 Immediate(reinterpret_cast<intptr_t>(Object::null()));
705 Label all_arguments_processed; 699 Label all_arguments_processed;
706 if (num_opt_named_params > 0) { 700 if (num_opt_named_params > 0) {
707 // Start by alphabetically sorting the names of the optional parameters. 701 // Start by alphabetically sorting the names of the optional parameters.
708 LocalVariable** opt_param = new LocalVariable*[num_opt_named_params]; 702 LocalVariable** opt_param = new LocalVariable*[num_opt_named_params];
709 int* opt_param_position = new int[num_opt_named_params]; 703 int* opt_param_position = new int[num_opt_named_params];
710 for (int pos = num_fixed_params; pos < num_params; pos++) { 704 for (int pos = num_fixed_params; pos < num_params; pos++) {
711 LocalVariable* parameter = scope->VariableAt(pos); 705 LocalVariable* parameter = scope->VariableAt(pos);
712 const String& opt_param_name = parameter->name(); 706 const String& opt_param_name = parameter->name();
(...skipping 15 matching lines...) Expand all
728 // Number of positional args is the second Smi in descriptor array (EDX). 722 // Number of positional args is the second Smi in descriptor array (EDX).
729 __ movl(ECX, FieldAddress(EDX, Array::data_offset() + (1 * kWordSize))); 723 __ movl(ECX, FieldAddress(EDX, Array::data_offset() + (1 * kWordSize)));
730 __ SmiUntag(ECX); 724 __ SmiUntag(ECX);
731 // Let EBX point to the first passed argument, i.e. to fp[1 + argc - 0]. 725 // Let EBX point to the first passed argument, i.e. to fp[1 + argc - 0].
732 __ leal(EBX, Address(EBP, EBX, TIMES_2, kWordSize)); // EBX is Smi. 726 __ leal(EBX, Address(EBP, EBX, TIMES_2, kWordSize)); // EBX is Smi.
733 // Let EDI point to the name/pos pair of the first named argument. 727 // Let EDI point to the name/pos pair of the first named argument.
734 __ leal(EDI, FieldAddress(EDX, Array::data_offset() + (2 * kWordSize))); 728 __ leal(EDI, FieldAddress(EDX, Array::data_offset() + (2 * kWordSize)));
735 for (int i = 0; i < num_opt_named_params; i++) { 729 for (int i = 0; i < num_opt_named_params; i++) {
736 Label load_default_value, assign_optional_parameter, next_parameter; 730 Label load_default_value, assign_optional_parameter, next_parameter;
737 const int param_pos = opt_param_position[i]; 731 const int param_pos = opt_param_position[i];
738 if (!FLAG_reject_named_argument_as_positional) {
739 // Handle this optional parameter only if k or fewer positional
740 // arguments have been passed, where k is the position of this optional
741 // parameter in the formal parameter list.
742 __ cmpl(ECX, Immediate(param_pos));
743 __ j(GREATER, &next_parameter, Assembler::kNearJump);
744 }
745 // Check if this named parameter was passed in. 732 // Check if this named parameter was passed in.
746 __ movl(EAX, Address(EDI, 0)); // Load EAX with the name of the argument. 733 __ movl(EAX, Address(EDI, 0)); // Load EAX with the name of the argument.
747 ASSERT(opt_param[i]->name().IsSymbol()); 734 ASSERT(opt_param[i]->name().IsSymbol());
748 __ CompareObject(EAX, opt_param[i]->name()); 735 __ CompareObject(EAX, opt_param[i]->name());
749 __ j(NOT_EQUAL, &load_default_value, Assembler::kNearJump); 736 __ j(NOT_EQUAL, &load_default_value, Assembler::kNearJump);
750 // Load EAX with passed-in argument at provided arg_pos, i.e. at 737 // Load EAX with passed-in argument at provided arg_pos, i.e. at
751 // fp[1 + argc - arg_pos]. 738 // fp[1 + argc - arg_pos].
752 __ movl(EAX, Address(EDI, kWordSize)); // EAX is arg_pos as Smi. 739 __ movl(EAX, Address(EDI, kWordSize)); // EAX is arg_pos as Smi.
753 __ addl(EDI, Immediate(2 * kWordSize)); // Point to next name/pos pair. 740 __ addl(EDI, Immediate(2 * kWordSize)); // Point to next name/pos pair.
754 __ negl(EAX); 741 __ negl(EAX);
(...skipping 16 matching lines...) Expand all
771 const Address param_addr(EBP, (computed_param_pos * kWordSize)); 758 const Address param_addr(EBP, (computed_param_pos * kWordSize));
772 __ movl(param_addr, EAX); 759 __ movl(param_addr, EAX);
773 __ Bind(&next_parameter); 760 __ Bind(&next_parameter);
774 } 761 }
775 delete[] opt_param; 762 delete[] opt_param;
776 delete[] opt_param_position; 763 delete[] opt_param_position;
777 // Check that EDI now points to the null terminator in the array descriptor. 764 // Check that EDI now points to the null terminator in the array descriptor.
778 __ cmpl(Address(EDI, 0), raw_null); 765 __ cmpl(Address(EDI, 0), raw_null);
779 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); 766 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump);
780 } else if (num_opt_pos_params > 0) { 767 } else if (num_opt_pos_params > 0) {
781 ASSERT(FLAG_reject_named_argument_as_positional);
782 // Number of positional args is the second Smi in descriptor array (EDX). 768 // Number of positional args is the second Smi in descriptor array (EDX).
783 __ movl(ECX, FieldAddress(EDX, Array::data_offset() + (1 * kWordSize))); 769 __ movl(ECX, FieldAddress(EDX, Array::data_offset() + (1 * kWordSize)));
784 __ SmiUntag(ECX); 770 __ SmiUntag(ECX);
785 for (int i = 0; i < num_opt_pos_params; i++) { 771 for (int i = 0; i < num_opt_pos_params; i++) {
786 Label next_parameter; 772 Label next_parameter;
787 // Handle this optional positonal parameter only if k or fewer positional 773 // Handle this optional positonal parameter only if k or fewer positional
788 // arguments have been passed, where k is param_pos, the position of this 774 // arguments have been passed, where k is param_pos, the position of this
789 // optional parameter in the formal parameter list. 775 // optional parameter in the formal parameter list.
790 const int param_pos = num_fixed_params + i; 776 const int param_pos = num_fixed_params + i;
791 __ cmpl(ECX, Immediate(param_pos)); 777 __ cmpl(ECX, Immediate(param_pos));
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 __ popl(ECX); 1384 __ popl(ECX);
1399 __ popl(EAX); 1385 __ popl(EAX);
1400 } 1386 }
1401 1387
1402 1388
1403 #undef __ 1389 #undef __
1404 1390
1405 } // namespace dart 1391 } // namespace dart
1406 1392
1407 #endif // defined TARGET_ARCH_IA32 1393 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698