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

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

Issue 3000333002: Fix several bugs in closure conversion. (Closed)
Patch Set: Comments. Created 3 years, 4 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm64.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 __ decl(ECX); 772 __ decl(ECX);
773 __ j(POSITIVE, &loop, Assembler::kNearJump); 773 __ j(POSITIVE, &loop, Assembler::kNearJump);
774 774
775 // Copy or initialize optional named arguments. 775 // Copy or initialize optional named arguments.
776 const Immediate& raw_null = 776 const Immediate& raw_null =
777 Immediate(reinterpret_cast<intptr_t>(Object::null())); 777 Immediate(reinterpret_cast<intptr_t>(Object::null()));
778 Label all_arguments_processed; 778 Label all_arguments_processed;
779 #ifdef DEBUG 779 #ifdef DEBUG
780 const bool check_correct_named_args = true; 780 const bool check_correct_named_args = true;
781 #else 781 #else
782 const bool check_correct_named_args = function.IsClosureFunction(); 782 const bool check_correct_named_args =
783 function.IsClosureFunction() || function.IsConvertedClosureFunction();
783 #endif 784 #endif
784 if (num_opt_named_params > 0) { 785 if (num_opt_named_params > 0) {
785 // Start by alphabetically sorting the names of the optional parameters. 786 // Start by alphabetically sorting the names of the optional parameters.
786 LocalVariable** opt_param = new LocalVariable*[num_opt_named_params]; 787 LocalVariable** opt_param = new LocalVariable*[num_opt_named_params];
787 int* opt_param_position = new int[num_opt_named_params]; 788 int* opt_param_position = new int[num_opt_named_params];
788 for (int pos = num_fixed_params; pos < num_params; pos++) { 789 for (int pos = num_fixed_params; pos < num_params; pos++) {
789 LocalVariable* parameter = scope->VariableAt(pos); 790 LocalVariable* parameter = scope->VariableAt(pos);
790 const String& opt_param_name = parameter->name(); 791 const String& opt_param_name = parameter->name();
791 int i = pos - num_fixed_params; 792 int i = pos - num_fixed_params;
792 while (--i >= 0) { 793 while (--i >= 0) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 if (check_correct_named_args) { 878 if (check_correct_named_args) {
878 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); 879 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
879 __ SmiUntag(EBX); 880 __ SmiUntag(EBX);
880 // Check that ECX equals EBX, i.e. no named arguments passed. 881 // Check that ECX equals EBX, i.e. no named arguments passed.
881 __ cmpl(ECX, EBX); 882 __ cmpl(ECX, EBX);
882 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); 883 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump);
883 } 884 }
884 } 885 }
885 886
886 __ Bind(&wrong_num_arguments); 887 __ Bind(&wrong_num_arguments);
887 if (function.IsClosureFunction()) { 888 if (function.IsClosureFunction() || function.IsConvertedClosureFunction()) {
888 __ LeaveFrame(); // The arguments are still on the stack. 889 __ LeaveFrame(); // The arguments are still on the stack.
889 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry()); 890 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry());
890 // The noSuchMethod call may return to the caller, but not here. 891 // The noSuchMethod call may return to the caller, but not here.
891 } else if (check_correct_named_args) { 892 } else if (check_correct_named_args) {
892 __ Stop("Wrong arguments"); 893 __ Stop("Wrong arguments");
893 } 894 }
894 895
895 __ Bind(&all_arguments_processed); 896 __ Bind(&all_arguments_processed);
896 // Nullify originally passed arguments only after they have been copied and 897 // Nullify originally passed arguments only after they have been copied and
897 // checked, otherwise noSuchMethod would not see their original values. 898 // checked, otherwise noSuchMethod would not see their original values.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 985
985 const int num_fixed_params = function.num_fixed_parameters(); 986 const int num_fixed_params = function.num_fixed_parameters();
986 const int num_copied_params = parsed_function().num_copied_params(); 987 const int num_copied_params = parsed_function().num_copied_params();
987 const int num_locals = parsed_function().num_stack_locals(); 988 const int num_locals = parsed_function().num_stack_locals();
988 989
989 // We check the number of passed arguments when we have to copy them due to 990 // We check the number of passed arguments when we have to copy them due to
990 // the presence of optional parameters. 991 // the presence of optional parameters.
991 // No such checking code is generated if only fixed parameters are declared, 992 // No such checking code is generated if only fixed parameters are declared,
992 // unless we are in debug mode or unless we are compiling a closure. 993 // unless we are in debug mode or unless we are compiling a closure.
993 if (num_copied_params == 0) { 994 if (num_copied_params == 0) {
994 const bool check_arguments = 995 const bool check_arguments = (function.IsClosureFunction() ||
995 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); 996 function.IsConvertedClosureFunction()) &&
997 !flow_graph().IsCompiledForOsr();
996 if (check_arguments) { 998 if (check_arguments) {
997 __ Comment("Check argument count"); 999 __ Comment("Check argument count");
998 // Check that exactly num_fixed arguments are passed in. 1000 // Check that exactly num_fixed arguments are passed in.
999 Label correct_num_arguments, wrong_num_arguments; 1001 Label correct_num_arguments, wrong_num_arguments;
1000 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); 1002 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
1001 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params))); 1003 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params)));
1002 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); 1004 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump);
1003 __ cmpl(EAX, FieldAddress( 1005 __ cmpl(EAX, FieldAddress(
1004 EDX, ArgumentsDescriptor::positional_count_offset())); 1006 EDX, ArgumentsDescriptor::positional_count_offset()));
1005 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); 1007 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump);
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { 1701 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
1700 __ movups(reg, Address(ESP, 0)); 1702 __ movups(reg, Address(ESP, 0));
1701 __ addl(ESP, Immediate(kFpuRegisterSize)); 1703 __ addl(ESP, Immediate(kFpuRegisterSize));
1702 } 1704 }
1703 1705
1704 #undef __ 1706 #undef __
1705 1707
1706 } // namespace dart 1708 } // namespace dart
1707 1709
1708 #endif // defined TARGET_ARCH_IA32 1710 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm64.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698