| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 __ cmpq(RAX, raw_null); | 558 __ cmpq(RAX, raw_null); |
| 559 __ j(EQUAL, &lookup, Assembler::kNearJump); | 559 __ j(EQUAL, &lookup, Assembler::kNearJump); |
| 560 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 560 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 561 __ jmp(RAX); | 561 __ jmp(RAX); |
| 562 | 562 |
| 563 __ Bind(&lookup); | 563 __ Bind(&lookup); |
| 564 __ jmp(&StubCode::InstanceFunctionLookupLabel()); | 564 __ jmp(&StubCode::InstanceFunctionLookupLabel()); |
| 565 } | 565 } |
| 566 | 566 |
| 567 | 567 |
| 568 | |
| 569 // Called for inline allocation of arrays. | 568 // Called for inline allocation of arrays. |
| 570 // Input parameters: | 569 // Input parameters: |
| 571 // R10 : Array length as Smi. | 570 // R10 : Array length as Smi. |
| 572 // RBX : array element type (either NULL or an instantiated type). | 571 // RBX : array element type (either NULL or an instantiated type). |
| 573 // NOTE: R10 cannot be clobbered here as the caller relies on it being saved. | 572 // NOTE: R10 cannot be clobbered here as the caller relies on it being saved. |
| 574 // The newly allocated object is returned in RAX. | 573 // The newly allocated object is returned in RAX. |
| 575 void StubCode::GenerateAllocateArrayStub(Assembler* assembler) { | 574 void StubCode::GenerateAllocateArrayStub(Assembler* assembler) { |
| 576 Label slow_case; | 575 Label slow_case; |
| 577 const Immediate raw_null = | 576 const Immediate raw_null = |
| 578 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 577 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 __ Bind(&done); | 652 __ Bind(&done); |
| 654 | 653 |
| 655 // Get the class index and insert it into the tags. | 654 // Get the class index and insert it into the tags. |
| 656 __ orq(RBX, Immediate(RawObject::ClassIdTag::encode(kArrayCid))); | 655 __ orq(RBX, Immediate(RawObject::ClassIdTag::encode(kArrayCid))); |
| 657 __ movq(FieldAddress(RAX, Array::tags_offset()), RBX); | 656 __ movq(FieldAddress(RAX, Array::tags_offset()), RBX); |
| 658 } | 657 } |
| 659 | 658 |
| 660 // Initialize all array elements to raw_null. | 659 // Initialize all array elements to raw_null. |
| 661 // RAX: new object start as a tagged pointer. | 660 // RAX: new object start as a tagged pointer. |
| 662 // R12: new object end address. | 661 // R12: new object end address. |
| 662 // R10: Array length as Smi. |
| 663 __ leaq(RBX, FieldAddress(RAX, Array::data_offset())); | 663 __ leaq(RBX, FieldAddress(RAX, Array::data_offset())); |
| 664 // RBX: iterator which initially points to the start of the variable | 664 // RBX: iterator which initially points to the start of the variable |
| 665 // data area to be initialized. | 665 // data area to be initialized. |
| 666 Label done; | 666 Label done; |
| 667 Label init_loop; | 667 Label init_loop; |
| 668 __ Bind(&init_loop); | 668 __ Bind(&init_loop); |
| 669 __ cmpq(RBX, R12); | 669 __ cmpq(RBX, R12); |
| 670 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); | 670 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); |
| 671 // TODO(cshapiro): StoreIntoObjectNoBarrier |
| 671 __ movq(Address(RBX, 0), raw_null); | 672 __ movq(Address(RBX, 0), raw_null); |
| 672 __ addq(RBX, Immediate(kWordSize)); | 673 __ addq(RBX, Immediate(kWordSize)); |
| 673 __ jmp(&init_loop, Assembler::kNearJump); | 674 __ jmp(&init_loop, Assembler::kNearJump); |
| 674 __ Bind(&done); | 675 __ Bind(&done); |
| 675 | 676 |
| 676 // Done allocating and initializing the array. | 677 // Done allocating and initializing the array. |
| 677 // RAX: new object. | 678 // RAX: new object. |
| 678 // R10: Array length as Smi (preserved for the caller.) | 679 // R10: Array length as Smi (preserved for the caller.) |
| 679 __ ret(); | 680 __ ret(); |
| 680 } | 681 } |
| 681 | 682 |
| 682 // Unable to allocate the array using the fast inline code, just call | 683 // Unable to allocate the array using the fast inline code, just call |
| 683 // into the runtime. | 684 // into the runtime. |
| 684 __ Bind(&slow_case); | 685 __ Bind(&slow_case); |
| 686 // Create a stub frame as we are pushing some objects on the stack before |
| 687 // calling into the runtime. |
| 685 AssemblerMacros::EnterStubFrame(assembler); | 688 AssemblerMacros::EnterStubFrame(assembler); |
| 686 __ pushq(raw_null); // Setup space on stack for return value. | 689 __ pushq(raw_null); // Setup space on stack for return value. |
| 687 __ pushq(R10); // Array length as Smi. | 690 __ pushq(R10); // Array length as Smi. |
| 688 __ pushq(RBX); // Element type. | 691 __ pushq(RBX); // Element type. |
| 689 __ CallRuntime(kAllocateArrayRuntimeEntry); | 692 __ CallRuntime(kAllocateArrayRuntimeEntry); |
| 690 __ popq(RAX); // Pop element type argument. | 693 __ popq(RAX); // Pop element type argument. |
| 691 __ popq(R10); // Pop array length argument. | 694 __ popq(R10); // Pop array length argument. |
| 692 __ popq(RAX); // Pop return value from return slot. | 695 __ popq(RAX); // Pop return value from return slot. |
| 693 __ LeaveFrame(); | 696 __ LeaveFrame(); |
| 694 __ ret(); | 697 __ ret(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 __ Bind(&function_compiled); | 757 __ Bind(&function_compiled); |
| 755 // RAX: Code. | 758 // RAX: Code. |
| 756 // RBX: Function. | 759 // RBX: Function. |
| 757 // R10: Arguments descriptor array. | 760 // R10: Arguments descriptor array. |
| 758 | 761 |
| 759 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); | 762 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); |
| 760 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 763 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 761 __ jmp(RBX); | 764 __ jmp(RBX); |
| 762 | 765 |
| 763 __ Bind(¬_closure); | 766 __ Bind(¬_closure); |
| 764 // Call runtime to report that a closure call was attempted on a non-closure | 767 // Call runtime to attempt to resolve and invoke a call method on a |
| 765 // object, passing the non-closure object and its arguments array. | 768 // non-closure object, passing the non-closure object and its arguments array, |
| 769 // returning here. |
| 770 // If no call method exists, throw a NoSuchMethodError. |
| 766 // R13: non-closure object. | 771 // R13: non-closure object. |
| 767 // R10: arguments descriptor array. | 772 // R10: arguments descriptor array. |
| 768 | 773 |
| 769 // Create a stub frame as we are pushing some objects on the stack before | 774 // Create a stub frame as we are pushing some objects on the stack before |
| 770 // calling into the runtime. | 775 // calling into the runtime. |
| 771 AssemblerMacros::EnterStubFrame(assembler); | 776 AssemblerMacros::EnterStubFrame(assembler); |
| 772 | 777 |
| 773 __ pushq(raw_null); // Setup space on stack for result from error reporting. | 778 __ pushq(raw_null); // Setup space on stack for result from call. |
| 774 __ pushq(R13); // Non-closure object. | 779 __ pushq(R13); // Non-closure object. |
| 780 __ pushq(R10); // Arguments descriptor. |
| 775 // Load num_args. | 781 // Load num_args. |
| 776 __ movq(R13, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 782 __ movq(R13, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 777 __ SmiUntag(R13); // Arguments array length, including the non-closure. | 783 __ SmiUntag(R13); // Arguments array length, including the non-closure. |
| 778 // See stack layout below explaining "wordSize * 5" offset. | 784 // See stack layout below explaining "wordSize * 6" offset. |
| 779 PushArgumentsArray(assembler, (kWordSize * 5)); | 785 PushArgumentsArray(assembler, (kWordSize * 6)); |
| 780 | 786 |
| 781 // Stack: | 787 // Stack: |
| 782 // TOS + 0: Argument array. | 788 // TOS + 0: Argument array. |
| 783 // TOS + 1: Non-closure object. | 789 // TOS + 1: Arguments descriptor array. |
| 784 // TOS + 2: Place for result from reporting the error. | 790 // TOS + 2: Non-closure object. |
| 785 // TOS + 3: PC marker => RawInstruction object. | 791 // TOS + 3: Place for result from the call. |
| 786 // TOS + 4: Saved RBP of previous frame. <== RBP | 792 // TOS + 4: PC marker => RawInstruction object. |
| 787 // TOS + 5: Dart code return address | 793 // TOS + 5: Saved RBP of previous frame. <== RBP |
| 788 // TOS + 6: Last argument of caller. | 794 // TOS + 6: Dart code return address |
| 795 // TOS + 7: Last argument of caller. |
| 789 // .... | 796 // .... |
| 790 __ CallRuntime(kReportObjectNotClosureRuntimeEntry); | 797 __ CallRuntime(kInvokeNonClosureRuntimeEntry); |
| 791 __ Stop("runtime call throws an exception"); | 798 // Remove arguments. |
| 799 __ popq(RAX); |
| 800 __ popq(RAX); |
| 801 __ popq(RAX); |
| 802 __ popq(RAX); // Get result into RAX. |
| 803 |
| 804 // Remove the stub frame as we are about to return. |
| 805 __ LeaveFrame(); |
| 806 __ ret(); |
| 792 } | 807 } |
| 793 | 808 |
| 794 | 809 |
| 795 // Called when invoking Dart code from C++ (VM code). | 810 // Called when invoking Dart code from C++ (VM code). |
| 796 // Input parameters: | 811 // Input parameters: |
| 797 // RSP : points to return address. | 812 // RSP : points to return address. |
| 798 // RDI : entrypoint of the Dart function to call. | 813 // RDI : entrypoint of the Dart function to call. |
| 799 // RSI : arguments descriptor array. | 814 // RSI : arguments descriptor array. |
| 800 // RDX : pointer to the argument array. | 815 // RDX : pointer to the argument array. |
| 801 // RCX : new context containing the current isolate pointer. | 816 // RCX : new context containing the current isolate pointer. |
| (...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 __ cmpq(left, right); | 2175 __ cmpq(left, right); |
| 2161 __ Bind(&done); | 2176 __ Bind(&done); |
| 2162 __ popq(right); | 2177 __ popq(right); |
| 2163 __ popq(left); | 2178 __ popq(left); |
| 2164 __ ret(); | 2179 __ ret(); |
| 2165 } | 2180 } |
| 2166 | 2181 |
| 2167 } // namespace dart | 2182 } // namespace dart |
| 2168 | 2183 |
| 2169 #endif // defined TARGET_ARCH_X64 | 2184 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |