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

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

Issue 3000333002: Fix several bugs in closure conversion. (Closed)
Patch Set: Fix bugs. 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
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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 if (check_correct_named_args) { 877 if (check_correct_named_args) {
878 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); 878 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
879 __ SmiUntag(EBX); 879 __ SmiUntag(EBX);
880 // Check that ECX equals EBX, i.e. no named arguments passed. 880 // Check that ECX equals EBX, i.e. no named arguments passed.
881 __ cmpl(ECX, EBX); 881 __ cmpl(ECX, EBX);
882 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); 882 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump);
883 } 883 }
884 } 884 }
885 885
886 __ Bind(&wrong_num_arguments); 886 __ Bind(&wrong_num_arguments);
887 if (function.IsClosureFunction()) { 887 if (function.IsClosureFunction() || function.IsConvertedClosureFunction()) {
888 __ LeaveFrame(); // The arguments are still on the stack. 888 __ LeaveFrame(); // The arguments are still on the stack.
889 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry()); 889 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry());
890 // The noSuchMethod call may return to the caller, but not here. 890 // The noSuchMethod call may return to the caller, but not here.
891 } else if (check_correct_named_args) { 891 } else if (check_correct_named_args) {
892 __ Stop("Wrong arguments"); 892 __ Stop("Wrong arguments");
893 } 893 }
894 894
895 __ Bind(&all_arguments_processed); 895 __ Bind(&all_arguments_processed);
896 // Nullify originally passed arguments only after they have been copied and 896 // Nullify originally passed arguments only after they have been copied and
897 // checked, otherwise noSuchMethod would not see their original values. 897 // checked, otherwise noSuchMethod would not see their original values.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 984
985 const int num_fixed_params = function.num_fixed_parameters(); 985 const int num_fixed_params = function.num_fixed_parameters();
986 const int num_copied_params = parsed_function().num_copied_params(); 986 const int num_copied_params = parsed_function().num_copied_params();
987 const int num_locals = parsed_function().num_stack_locals(); 987 const int num_locals = parsed_function().num_stack_locals();
988 988
989 // We check the number of passed arguments when we have to copy them due to 989 // We check the number of passed arguments when we have to copy them due to
990 // the presence of optional parameters. 990 // the presence of optional parameters.
991 // No such checking code is generated if only fixed parameters are declared, 991 // 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. 992 // unless we are in debug mode or unless we are compiling a closure.
993 if (num_copied_params == 0) { 993 if (num_copied_params == 0) {
994 const bool check_arguments = 994 const bool check_arguments = (function.IsClosureFunction() ||
995 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); 995 function.IsConvertedClosureFunction()) &&
996 !flow_graph().IsCompiledForOsr();
996 if (check_arguments) { 997 if (check_arguments) {
997 __ Comment("Check argument count"); 998 __ Comment("Check argument count");
998 // Check that exactly num_fixed arguments are passed in. 999 // Check that exactly num_fixed arguments are passed in.
999 Label correct_num_arguments, wrong_num_arguments; 1000 Label correct_num_arguments, wrong_num_arguments;
1000 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); 1001 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
1001 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params))); 1002 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params)));
1002 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); 1003 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump);
1003 __ cmpl(EAX, FieldAddress( 1004 __ cmpl(EAX, FieldAddress(
1004 EDX, ArgumentsDescriptor::positional_count_offset())); 1005 EDX, ArgumentsDescriptor::positional_count_offset()));
1005 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); 1006 __ 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) { 1700 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
1700 __ movups(reg, Address(ESP, 0)); 1701 __ movups(reg, Address(ESP, 0));
1701 __ addl(ESP, Immediate(kFpuRegisterSize)); 1702 __ addl(ESP, Immediate(kFpuRegisterSize));
1702 } 1703 }
1703 1704
1704 #undef __ 1705 #undef __
1705 1706
1706 } // namespace dart 1707 } // namespace dart
1707 1708
1708 #endif // defined TARGET_ARCH_IA32 1709 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698