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

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

Issue 23480098: Setup the pool pointer when entering Dart from C++ so the intrinsic functions may rely on it being … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
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" 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/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 758
759 // Called when invoking Dart code from C++ (VM code). 759 // Called when invoking Dart code from C++ (VM code).
760 // Input parameters: 760 // Input parameters:
761 // RSP : points to return address. 761 // RSP : points to return address.
762 // RDI : entrypoint of the Dart function to call. 762 // RDI : entrypoint of the Dart function to call.
763 // RSI : arguments descriptor array. 763 // RSI : arguments descriptor array.
764 // RDX : arguments array. 764 // RDX : arguments array.
765 // RCX : new context containing the current isolate pointer. 765 // RCX : new context containing the current isolate pointer.
766 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { 766 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
767 // Save frame pointer coming in. 767 // Save frame pointer coming in.
768 __ EnterStubFrame(); 768 __ EnterStubFrameWithPP();
769
770 // The old frame pointer, the return address, the old R15 (for PP).
771 const intptr_t kInitiallyPushedSlots = 3;
siva 2013/09/19 00:45:37 Not sure if kInitiallyPushedSlots is a good name,
zra 2013/09/19 00:55:22 +1
rmacnak 2013/09/19 16:57:36 This stack looks upside down to me. __ EnterStu
769 772
770 // Save arguments descriptor array and new context. 773 // Save arguments descriptor array and new context.
771 const intptr_t kArgumentsDescOffset = -2 * kWordSize; 774 const intptr_t kArgumentsDescOffset = -(kInitiallyPushedSlots) * kWordSize;
772 __ pushq(RSI); 775 __ pushq(RSI);
773 const intptr_t kNewContextOffset = -3 * kWordSize; 776 const intptr_t kNewContextOffset = -(kInitiallyPushedSlots + 1) * kWordSize;
774 __ pushq(RCX); 777 __ pushq(RCX);
775 778
776 // Save C++ ABI callee-saved registers. 779 // Save C++ ABI callee-saved registers.
777 __ pushq(RBX); 780 __ pushq(RBX);
778 __ pushq(R12); 781 __ pushq(R12);
779 __ pushq(R13); 782 __ pushq(R13);
780 __ pushq(R14); 783 __ pushq(R14);
781 __ pushq(R15); 784 // R15 is already saved above by EnterStubFrameWithPP.
rmacnak 2013/09/18 21:04:24 Actually, we MUST not save R15 again, because it c
siva 2013/09/19 00:45:37 True, the comment is to make sure we document that
785
782 786
783 // The new Context structure contains a pointer to the current Isolate 787 // The new Context structure contains a pointer to the current Isolate
784 // structure. Cache the Context pointer in the CTX register so that it is 788 // structure. Cache the Context pointer in the CTX register so that it is
785 // available in generated code and calls to Isolate::Current() need not be 789 // available in generated code and calls to Isolate::Current() need not be
786 // done. The assumption is that this register will never be clobbered by 790 // done. The assumption is that this register will never be clobbered by
787 // compiled or runtime stub code. 791 // compiled or runtime stub code.
788 792
789 // Cache the new Context pointer into CTX while executing Dart code. 793 // Cache the new Context pointer into CTX while executing Dart code.
790 __ movq(CTX, Address(RCX, VMHandles::kOffsetOfRawPtrInHandle)); 794 __ movq(CTX, Address(RCX, VMHandles::kOffsetOfRawPtrInHandle));
791 795
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 // Uses RCX as a temporary register for this. 863 // Uses RCX as a temporary register for this.
860 __ popq(RCX); 864 __ popq(RCX);
861 __ movq(Address(CTX, Isolate::top_context_offset()), RCX); 865 __ movq(Address(CTX, Isolate::top_context_offset()), RCX);
862 866
863 // Restore the saved top exit frame info back into the Isolate structure. 867 // Restore the saved top exit frame info back into the Isolate structure.
864 // Uses RDX as a temporary register for this. 868 // Uses RDX as a temporary register for this.
865 __ popq(RDX); 869 __ popq(RDX);
866 __ movq(Address(CTX, Isolate::top_exit_frame_info_offset()), RDX); 870 __ movq(Address(CTX, Isolate::top_exit_frame_info_offset()), RDX);
867 871
868 // Restore C++ ABI callee-saved registers. 872 // Restore C++ ABI callee-saved registers.
869 __ popq(R15); 873 // R15 will be restored below by LeaveFrameWithPP.
870 __ popq(R14); 874 __ popq(R14);
871 __ popq(R13); 875 __ popq(R13);
872 __ popq(R12); 876 __ popq(R12);
873 __ popq(RBX); 877 __ popq(RBX);
874 878
875 // Restore the frame pointer. 879 // Restore the frame pointer.
876 __ LeaveFrame(); 880 __ LeaveFrameWithPP();
877 881
878 __ ret(); 882 __ ret();
879 } 883 }
880 884
881 885
882 // Called for inline allocation of contexts. 886 // Called for inline allocation of contexts.
883 // Input: 887 // Input:
884 // R10: number of context variables. 888 // R10: number of context variables.
885 // Output: 889 // Output:
886 // RAX: new allocated RawContext object. 890 // RAX: new allocated RawContext object.
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 __ movq(right, Address(RSP, 3 * kWordSize)); 2224 __ movq(right, Address(RSP, 3 * kWordSize));
2221 GenerateIdenticalWithNumberCheckStub(assembler, left, right); 2225 GenerateIdenticalWithNumberCheckStub(assembler, left, right);
2222 __ popq(right); 2226 __ popq(right);
2223 __ popq(left); 2227 __ popq(left);
2224 __ ret(); 2228 __ ret();
2225 } 2229 }
2226 2230
2227 } // namespace dart 2231 } // namespace dart
2228 2232
2229 #endif // defined TARGET_ARCH_X64 2233 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intrinsifier_x64.cc ('K') | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698