| OLD | NEW |
| 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_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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 645 |
| 646 | 646 |
| 647 // Copied from CodeGenerator::CopyParameters (CodeGenerator will be deprecated). | 647 // Copied from CodeGenerator::CopyParameters (CodeGenerator will be deprecated). |
| 648 void FlowGraphCompiler::CopyParameters() { | 648 void FlowGraphCompiler::CopyParameters() { |
| 649 const Function& function = parsed_function().function(); | 649 const Function& function = parsed_function().function(); |
| 650 const bool is_native_instance_closure = | 650 const bool is_native_instance_closure = |
| 651 function.is_native() && function.IsImplicitInstanceClosureFunction(); | 651 function.is_native() && function.IsImplicitInstanceClosureFunction(); |
| 652 LocalScope* scope = parsed_function().node_sequence()->scope(); | 652 LocalScope* scope = parsed_function().node_sequence()->scope(); |
| 653 const int num_fixed_params = function.num_fixed_parameters(); | 653 const int num_fixed_params = function.num_fixed_parameters(); |
| 654 const int num_opt_params = function.num_optional_parameters(); | 654 const int num_opt_params = function.num_optional_parameters(); |
| 655 int implicit_this_param_pos = is_native_instance_closure ? -1 : 0; |
| 655 ASSERT(parsed_function().first_parameter_index() == | 656 ASSERT(parsed_function().first_parameter_index() == |
| 656 ParsedFunction::kFirstLocalSlotIndex); | 657 ParsedFunction::kFirstLocalSlotIndex + implicit_this_param_pos); |
| 657 // Copy positional arguments. | 658 // Copy positional arguments. |
| 658 // Check that no fewer than num_fixed_params positional arguments are passed | 659 // Check that no fewer than num_fixed_params positional arguments are passed |
| 659 // in and that no more than num_params arguments are passed in. | 660 // in and that no more than num_params arguments are passed in. |
| 660 // Passed argument i at fp[1 + argc - i] | 661 // Passed argument i at fp[1 + argc - i] |
| 661 // copied to fp[ParsedFunction::kFirstLocalSlotIndex - i]. | 662 // copied to fp[ParsedFunction::kFirstLocalSlotIndex - i]. |
| 662 const int num_params = num_fixed_params + num_opt_params; | 663 const int num_params = num_fixed_params + num_opt_params; |
| 663 | 664 |
| 664 // Total number of args is the first Smi in args descriptor array (R10). | 665 // Total number of args is the first Smi in args descriptor array (R10). |
| 665 __ movq(RBX, FieldAddress(R10, Array::data_offset())); | 666 __ movq(RBX, FieldAddress(R10, Array::data_offset())); |
| 666 // Check that num_args <= num_params. | 667 // Check that num_args <= num_params. |
| 667 Label wrong_num_arguments; | 668 Label wrong_num_arguments; |
| 668 __ cmpq(RBX, Immediate(Smi::RawValue(num_params))); | 669 __ cmpq(RBX, Immediate(Smi::RawValue(num_params))); |
| 669 __ j(GREATER, &wrong_num_arguments); | 670 __ j(GREATER, &wrong_num_arguments); |
| 670 // Number of positional args is the second Smi in descriptor array (R10). | 671 // Number of positional args is the second Smi in descriptor array (R10). |
| 671 __ movq(RCX, FieldAddress(R10, Array::data_offset() + (1 * kWordSize))); | 672 __ movq(RCX, FieldAddress(R10, Array::data_offset() + (1 * kWordSize))); |
| 672 // Check that num_pos_args >= num_fixed_params. | 673 // Check that num_pos_args >= num_fixed_params. |
| 673 __ cmpq(RCX, Immediate(Smi::RawValue(num_fixed_params))); | 674 __ cmpq(RCX, Immediate(Smi::RawValue(num_fixed_params))); |
| 674 __ j(LESS, &wrong_num_arguments); | 675 __ j(LESS, &wrong_num_arguments); |
| 675 | 676 |
| 676 // Since RBX and RCX are Smi, use TIMES_4 instead of TIMES_8. | 677 // Since RBX and RCX are Smi, use TIMES_4 instead of TIMES_8. |
| 677 // Let RBX point to the last passed positional argument, i.e. to | 678 // Let RBX point to the last passed positional argument, i.e. to |
| 678 // fp[1 + num_args - (num_pos_args - 1)]. | 679 // fp[1 + num_args - (num_pos_args - 1)]. |
| 679 __ subq(RBX, RCX); | 680 __ subq(RBX, RCX); |
| 680 __ leaq(RBX, Address(RBP, RBX, TIMES_4, 2 * kWordSize)); | 681 __ leaq(RBX, Address(RBP, RBX, TIMES_4, 2 * kWordSize)); |
| 681 // Let RDI point to the last copied positional argument, i.e. to | 682 // Let RDI point to the last copied positional argument, i.e. to |
| 682 // fp[ParsedFunction::kFirstLocalSlotIndex - (num_pos_args - 1)]. | 683 // fp[ParsedFunction::kFirstLocalSlotIndex - (num_pos_args - 1)]. |
| 683 int implicit_this_param_pos = is_native_instance_closure ? -1 : 0; | |
| 684 const int index = | 684 const int index = |
| 685 ParsedFunction::kFirstLocalSlotIndex + 1 + implicit_this_param_pos; | 685 ParsedFunction::kFirstLocalSlotIndex + 1 + implicit_this_param_pos; |
| 686 // First copy captured receiver if function is an implicit native closure. | 686 // First copy captured receiver if function is an implicit native closure. |
| 687 if (is_native_instance_closure) { | 687 if (is_native_instance_closure) { |
| 688 __ movq(RAX, FieldAddress(CTX, Context::variable_offset(0))); | 688 __ movq(RAX, FieldAddress(CTX, Context::variable_offset(0))); |
| 689 __ movq(Address(RBP, (index * kWordSize)), RAX); | 689 __ movq(Address(RBP, (index * kWordSize)), RAX); |
| 690 } | 690 } |
| 691 __ SmiUntag(RCX); | 691 __ SmiUntag(RCX); |
| 692 __ movq(RAX, RCX); | 692 __ movq(RAX, RCX); |
| 693 __ negq(RAX); | 693 __ negq(RAX); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 __ cvtsi2sd(result, temp); | 1067 __ cvtsi2sd(result, temp); |
| 1068 __ Bind(&done); | 1068 __ Bind(&done); |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 | 1071 |
| 1072 #undef __ | 1072 #undef __ |
| 1073 | 1073 |
| 1074 } // namespace dart | 1074 } // namespace dart |
| 1075 | 1075 |
| 1076 #endif // defined TARGET_ARCH_X64 | 1076 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |