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

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

Issue 3000333002: Fix several bugs in closure conversion. (Closed)
Patch Set: Comments. Created 3 years, 3 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_ia32.cc ('k') | runtime/vm/kernel_binary_flowgraph.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) 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_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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 __ movq(copy_addr, RAX); 763 __ movq(copy_addr, RAX);
764 __ Bind(&loop_condition); 764 __ Bind(&loop_condition);
765 __ decq(RCX); 765 __ decq(RCX);
766 __ j(POSITIVE, &loop, Assembler::kNearJump); 766 __ j(POSITIVE, &loop, Assembler::kNearJump);
767 767
768 // Copy or initialize optional named arguments. 768 // Copy or initialize optional named arguments.
769 Label all_arguments_processed; 769 Label all_arguments_processed;
770 #ifdef DEBUG 770 #ifdef DEBUG
771 const bool check_correct_named_args = true; 771 const bool check_correct_named_args = true;
772 #else 772 #else
773 const bool check_correct_named_args = function.IsClosureFunction(); 773 const bool check_correct_named_args =
774 function.IsClosureFunction() || function.IsConvertedClosureFunction();
774 #endif 775 #endif
775 if (num_opt_named_params > 0) { 776 if (num_opt_named_params > 0) {
776 // Start by alphabetically sorting the names of the optional parameters. 777 // Start by alphabetically sorting the names of the optional parameters.
777 LocalVariable** opt_param = new LocalVariable*[num_opt_named_params]; 778 LocalVariable** opt_param = new LocalVariable*[num_opt_named_params];
778 int* opt_param_position = new int[num_opt_named_params]; 779 int* opt_param_position = new int[num_opt_named_params];
779 for (int pos = num_fixed_params; pos < num_params; pos++) { 780 for (int pos = num_fixed_params; pos < num_params; pos++) {
780 LocalVariable* parameter = scope->VariableAt(pos); 781 LocalVariable* parameter = scope->VariableAt(pos);
781 const String& opt_param_name = parameter->name(); 782 const String& opt_param_name = parameter->name();
782 int i = pos - num_fixed_params; 783 int i = pos - num_fixed_params;
783 while (--i >= 0) { 784 while (--i >= 0) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 if (check_correct_named_args) { 870 if (check_correct_named_args) {
870 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); 871 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset()));
871 __ SmiUntag(RBX); 872 __ SmiUntag(RBX);
872 // Check that RCX equals RBX, i.e. no named arguments passed. 873 // Check that RCX equals RBX, i.e. no named arguments passed.
873 __ cmpq(RCX, RBX); 874 __ cmpq(RCX, RBX);
874 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); 875 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump);
875 } 876 }
876 } 877 }
877 878
878 __ Bind(&wrong_num_arguments); 879 __ Bind(&wrong_num_arguments);
879 if (function.IsClosureFunction()) { 880 if (function.IsClosureFunction() || function.IsConvertedClosureFunction()) {
880 __ LeaveDartFrame(kKeepCalleePP); // The arguments are still on the stack. 881 __ LeaveDartFrame(kKeepCalleePP); // The arguments are still on the stack.
881 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry()); 882 __ Jmp(*StubCode::CallClosureNoSuchMethod_entry());
882 // The noSuchMethod call may return to the caller, but not here. 883 // The noSuchMethod call may return to the caller, but not here.
883 } else if (check_correct_named_args) { 884 } else if (check_correct_named_args) {
884 __ Stop("Wrong arguments"); 885 __ Stop("Wrong arguments");
885 } 886 }
886 887
887 __ Bind(&all_arguments_processed); 888 __ Bind(&all_arguments_processed);
888 // Nullify originally passed arguments only after they have been copied and 889 // Nullify originally passed arguments only after they have been copied and
889 // checked, otherwise noSuchMethod would not see their original values. 890 // checked, otherwise noSuchMethod would not see their original values.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 986
986 const int num_fixed_params = function.num_fixed_parameters(); 987 const int num_fixed_params = function.num_fixed_parameters();
987 const int num_copied_params = parsed_function().num_copied_params(); 988 const int num_copied_params = parsed_function().num_copied_params();
988 const int num_locals = parsed_function().num_stack_locals(); 989 const int num_locals = parsed_function().num_stack_locals();
989 990
990 // We check the number of passed arguments when we have to copy them due to 991 // We check the number of passed arguments when we have to copy them due to
991 // the presence of optional parameters. 992 // the presence of optional parameters.
992 // No such checking code is generated if only fixed parameters are declared, 993 // No such checking code is generated if only fixed parameters are declared,
993 // unless we are in debug mode or unless we are compiling a closure. 994 // unless we are in debug mode or unless we are compiling a closure.
994 if (num_copied_params == 0) { 995 if (num_copied_params == 0) {
995 const bool check_arguments = 996 const bool check_arguments = (function.IsClosureFunction() ||
996 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); 997 function.IsConvertedClosureFunction()) &&
998 !flow_graph().IsCompiledForOsr();
997 if (check_arguments) { 999 if (check_arguments) {
998 __ Comment("Check argument count"); 1000 __ Comment("Check argument count");
999 // Check that exactly num_fixed arguments are passed in. 1001 // Check that exactly num_fixed arguments are passed in.
1000 Label correct_num_arguments, wrong_num_arguments; 1002 Label correct_num_arguments, wrong_num_arguments;
1001 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); 1003 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset()));
1002 __ CompareImmediate(RAX, Immediate(Smi::RawValue(num_fixed_params))); 1004 __ CompareImmediate(RAX, Immediate(Smi::RawValue(num_fixed_params)));
1003 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); 1005 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump);
1004 __ cmpq(RAX, FieldAddress( 1006 __ cmpq(RAX, FieldAddress(
1005 R10, ArgumentsDescriptor::positional_count_offset())); 1007 R10, ArgumentsDescriptor::positional_count_offset()));
1006 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); 1008 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump);
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { 1679 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
1678 __ movups(reg, Address(RSP, 0)); 1680 __ movups(reg, Address(RSP, 0));
1679 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1681 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1680 } 1682 }
1681 1683
1682 #undef __ 1684 #undef __
1683 1685
1684 } // namespace dart 1686 } // namespace dart
1685 1687
1686 #endif // defined TARGET_ARCH_X64 1688 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/kernel_binary_flowgraph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698