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

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

Issue 1156593002: Cache current thread in a reserved register and use it in LoadIsolate (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Added more comments. Created 5 years, 7 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
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_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 __ BranchPatchable(&stub_code->FixAllocateArrayStubTargetLabel()); 808 __ BranchPatchable(&stub_code->FixAllocateArrayStubTargetLabel());
809 } 809 }
810 810
811 811
812 // Called when invoking Dart code from C++ (VM code). 812 // Called when invoking Dart code from C++ (VM code).
813 // Input parameters: 813 // Input parameters:
814 // RA : points to return address. 814 // RA : points to return address.
815 // A0 : entrypoint of the Dart function to call. 815 // A0 : entrypoint of the Dart function to call.
816 // A1 : arguments descriptor array. 816 // A1 : arguments descriptor array.
817 // A2 : arguments array. 817 // A2 : arguments array.
818 // A3 : current thread.
818 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { 819 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
819 // Save frame pointer coming in. 820 // Save frame pointer coming in.
820 __ Comment("InvokeDartCodeStub"); 821 __ Comment("InvokeDartCodeStub");
821 __ EnterFrame(); 822 __ EnterFrame();
822 823
823 // Save new context and C++ ABI callee-saved registers. 824 // Save new context and C++ ABI callee-saved registers.
824 825
825 // The saved vm tag, top resource, and top exit frame info. 826 // The saved vm tag, top resource, and top exit frame info.
826 const intptr_t kPreservedSlots = 3; 827 const intptr_t kPreservedSlots = 3;
827 const intptr_t kPreservedRegSpace = 828 const intptr_t kPreservedRegSpace =
(...skipping 14 matching lines...) Expand all
842 kAbiPreservedCpuRegCount + kPreservedSlots + i - 843 kAbiPreservedCpuRegCount + kPreservedSlots + i -
843 kAbiFirstPreservedFpuReg; 844 kAbiFirstPreservedFpuReg;
844 __ swc1(r, Address(SP, slot * kWordSize)); 845 __ swc1(r, Address(SP, slot * kWordSize));
845 } 846 }
846 847
847 // We now load the pool pointer(PP) as we are about to invoke dart code and we 848 // We now load the pool pointer(PP) as we are about to invoke dart code and we
848 // could potentially invoke some intrinsic functions which need the PP to be 849 // could potentially invoke some intrinsic functions which need the PP to be
849 // set up. 850 // set up.
850 __ LoadPoolPointer(); 851 __ LoadPoolPointer();
851 852
853 // Set up THR, which caches the current thread in Dart code.
854 if (THR != A3) {
855 __ mov(THR, A3);
856 }
852 __ LoadIsolate(T2); 857 __ LoadIsolate(T2);
853 858
854 // Save the current VMTag on the stack. 859 // Save the current VMTag on the stack.
855 __ lw(T1, Address(T2, Isolate::vm_tag_offset())); 860 __ lw(T1, Address(T2, Isolate::vm_tag_offset()));
856 __ sw(T1, Address(SP, 2 * kWordSize)); 861 __ sw(T1, Address(SP, 2 * kWordSize));
857 862
858 // Mark that the isolate is executing Dart code. 863 // Mark that the isolate is executing Dart code.
859 __ LoadImmediate(T0, VMTag::kDartTagId); 864 __ LoadImmediate(T0, VMTag::kDartTagId);
860 __ sw(T0, Address(T2, Isolate::vm_tag_offset())); 865 __ sw(T0, Address(T2, Isolate::vm_tag_offset()));
861 866
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 // Does not return. 2096 // Does not return.
2092 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { 2097 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) {
2093 ASSERT(kExceptionObjectReg == V0); 2098 ASSERT(kExceptionObjectReg == V0);
2094 ASSERT(kStackTraceObjectReg == V1); 2099 ASSERT(kStackTraceObjectReg == V1);
2095 __ mov(V0, A3); // Exception object. 2100 __ mov(V0, A3); // Exception object.
2096 // MIPS ABI reserves stack space for all arguments. The StackTrace object is 2101 // MIPS ABI reserves stack space for all arguments. The StackTrace object is
2097 // the last of five arguments, so it is first pushed on the stack. 2102 // the last of five arguments, so it is first pushed on the stack.
2098 __ lw(V1, Address(SP, 4 * kWordSize)); // StackTrace object. 2103 __ lw(V1, Address(SP, 4 * kWordSize)); // StackTrace object.
2099 __ mov(FP, A2); // Frame_pointer. 2104 __ mov(FP, A2); // Frame_pointer.
2100 __ lw(A3, Address(SP, 5 * kWordSize)); // Isolate. 2105 __ lw(A3, Address(SP, 5 * kWordSize)); // Isolate.
2106 // TODO(koda): Pass thread instead of isolate.
2107 __ lw(THR, Address(A3, Isolate::mutator_thread_offset()));
2101 // Set tag. 2108 // Set tag.
2102 __ LoadImmediate(A2, VMTag::kDartTagId); 2109 __ LoadImmediate(A2, VMTag::kDartTagId);
2103 __ sw(A2, Address(A3, Isolate::vm_tag_offset())); 2110 __ sw(A2, Address(A3, Isolate::vm_tag_offset()));
2104 // Clear top exit frame. 2111 // Clear top exit frame.
2105 __ sw(ZR, Address(A3, Isolate::top_exit_frame_info_offset())); 2112 __ sw(ZR, Address(A3, Isolate::top_exit_frame_info_offset()));
2106 2113
2107 __ jr(A0); // Jump to the exception handler code. 2114 __ jr(A0); // Jump to the exception handler code.
2108 __ delay_slot()->mov(SP, A1); // Stack pointer. 2115 __ delay_slot()->mov(SP, A1); // Stack pointer.
2109 } 2116 }
2110 2117
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 // Result: 2335 // Result:
2329 // T1: entry point. 2336 // T1: entry point.
2330 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2337 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2331 EmitMegamorphicLookup(assembler, T0, T1, T1); 2338 EmitMegamorphicLookup(assembler, T0, T1, T1);
2332 __ Ret(); 2339 __ Ret();
2333 } 2340 }
2334 2341
2335 } // namespace dart 2342 } // namespace dart
2336 2343
2337 #endif // defined TARGET_ARCH_MIPS 2344 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698