| 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" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 __ LeaveFrame(); | 696 __ LeaveFrame(); |
| 697 __ ret(); | 697 __ ret(); |
| 698 } | 698 } |
| 699 | 699 |
| 700 | 700 |
| 701 // Called when invoking Dart code from C++ (VM code). | 701 // Called when invoking Dart code from C++ (VM code). |
| 702 // Input parameters: | 702 // Input parameters: |
| 703 // RSP : points to return address. | 703 // RSP : points to return address. |
| 704 // RDI : entrypoint of the Dart function to call. | 704 // RDI : entrypoint of the Dart function to call. |
| 705 // RSI : arguments descriptor array. | 705 // RSI : arguments descriptor array. |
| 706 // RDX : pointer to the argument array. | 706 // RDX : arguments array. |
| 707 // RCX : new context containing the current isolate pointer. | 707 // RCX : new context containing the current isolate pointer. |
| 708 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { | 708 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { |
| 709 // Save frame pointer coming in. | 709 // Save frame pointer coming in. |
| 710 __ EnterFrame(0); | 710 __ EnterFrame(0); |
| 711 | 711 |
| 712 // Save arguments descriptor array and new context. | 712 // Save arguments descriptor array and new context. |
| 713 const intptr_t kArgumentsDescOffset = -1 * kWordSize; | 713 const intptr_t kArgumentsDescOffset = -1 * kWordSize; |
| 714 __ pushq(RSI); | 714 __ pushq(RSI); |
| 715 const intptr_t kNewContextOffset = -2 * kWordSize; | 715 const intptr_t kNewContextOffset = -2 * kWordSize; |
| 716 __ pushq(RCX); | 716 __ pushq(RCX); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 __ movq(RAX, Address(R8, Isolate::top_context_offset())); | 750 __ movq(RAX, Address(R8, Isolate::top_context_offset())); |
| 751 __ pushq(RAX); | 751 __ pushq(RAX); |
| 752 | 752 |
| 753 // Load arguments descriptor array into R10, which is passed to Dart code. | 753 // Load arguments descriptor array into R10, which is passed to Dart code. |
| 754 __ movq(R10, Address(RSI, VMHandles::kOffsetOfRawPtrInHandle)); | 754 __ movq(R10, Address(RSI, VMHandles::kOffsetOfRawPtrInHandle)); |
| 755 | 755 |
| 756 // Load number of arguments into RBX. | 756 // Load number of arguments into RBX. |
| 757 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 757 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 758 __ SmiUntag(RBX); | 758 __ SmiUntag(RBX); |
| 759 | 759 |
| 760 // Compute address of 'arguments array' data area into RDX. |
| 761 __ movq(RDX, Address(RDX, VMHandles::kOffsetOfRawPtrInHandle)); |
| 762 __ leaq(RDX, FieldAddress(RDX, Array::data_offset())); |
| 763 |
| 760 // Set up arguments for the Dart call. | 764 // Set up arguments for the Dart call. |
| 761 Label push_arguments; | 765 Label push_arguments; |
| 762 Label done_push_arguments; | 766 Label done_push_arguments; |
| 763 __ testq(RBX, RBX); // check if there are arguments. | 767 __ testq(RBX, RBX); // check if there are arguments. |
| 764 __ j(ZERO, &done_push_arguments, Assembler::kNearJump); | 768 __ j(ZERO, &done_push_arguments, Assembler::kNearJump); |
| 765 __ movq(RAX, Immediate(0)); | 769 __ movq(RAX, Immediate(0)); |
| 766 __ Bind(&push_arguments); | 770 __ Bind(&push_arguments); |
| 767 __ movq(RCX, Address(RDX, RAX, TIMES_8, 0)); // RDX is start of arguments. | 771 __ movq(RCX, Address(RDX, RAX, TIMES_8, 0)); // RDX is start of arguments. |
| 768 __ movq(RCX, Address(RCX, VMHandles::kOffsetOfRawPtrInHandle)); | |
| 769 __ pushq(RCX); | 772 __ pushq(RCX); |
| 770 __ incq(RAX); | 773 __ incq(RAX); |
| 771 __ cmpq(RAX, RBX); | 774 __ cmpq(RAX, RBX); |
| 772 __ j(LESS, &push_arguments, Assembler::kNearJump); | 775 __ j(LESS, &push_arguments, Assembler::kNearJump); |
| 773 __ Bind(&done_push_arguments); | 776 __ Bind(&done_push_arguments); |
| 774 | 777 |
| 775 // Call the Dart code entrypoint. | 778 // Call the Dart code entrypoint. |
| 776 __ call(RDI); // R10 is the arguments descriptor array. | 779 __ call(RDI); // R10 is the arguments descriptor array. |
| 777 | 780 |
| 778 // Read the saved new Context pointer. | 781 // Read the saved new Context pointer. |
| (...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 __ cmpq(left, right); | 2069 __ cmpq(left, right); |
| 2067 __ Bind(&done); | 2070 __ Bind(&done); |
| 2068 __ popq(right); | 2071 __ popq(right); |
| 2069 __ popq(left); | 2072 __ popq(left); |
| 2070 __ ret(); | 2073 __ ret(); |
| 2071 } | 2074 } |
| 2072 | 2075 |
| 2073 } // namespace dart | 2076 } // namespace dart |
| 2074 | 2077 |
| 2075 #endif // defined TARGET_ARCH_X64 | 2078 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |