OLD | NEW |
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/dart_entry.h" | 10 #include "vm/dart_entry.h" |
11 #include "vm/instructions.h" | 11 #include "vm/instructions.h" |
12 #include "vm/stack_frame.h" | 12 #include "vm/stack_frame.h" |
13 #include "vm/stub_code.h" | 13 #include "vm/stub_code.h" |
14 | 14 |
15 #define __ assembler-> | 15 #define __ assembler-> |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
| 19 // Input parameters: |
| 20 // RA : return address. |
| 21 // SP : address of last argument in argument array. |
| 22 // SP + 4*S4 - 4 : address of first argument in argument array. |
| 23 // SP + 4*S4 : address of return value. |
| 24 // S5 : address of the runtime function to call. |
| 25 // S4 : number of arguments to the call. |
19 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 26 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
20 __ Unimplemented("CallToRuntime stub"); | 27 const intptr_t isolate_offset = NativeArguments::isolate_offset(); |
| 28 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); |
| 29 const intptr_t argv_offset = NativeArguments::argv_offset(); |
| 30 const intptr_t retval_offset = NativeArguments::retval_offset(); |
| 31 |
| 32 __ addiu(SP, SP, Immediate(-2 * kWordSize)); |
| 33 __ sw(RA, Address(SP, 1 * kWordSize)); |
| 34 __ sw(FP, Address(SP, 0 * kWordSize)); |
| 35 __ mov(FP, SP); |
| 36 |
| 37 // Load current Isolate pointer from Context structure into R0. |
| 38 __ lw(A0, FieldAddress(CTX, Context::isolate_offset())); |
| 39 |
| 40 // Save exit frame information to enable stack walking as we are about |
| 41 // to transition to Dart VM C++ code. |
| 42 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset())); |
| 43 |
| 44 // Save current Context pointer into Isolate structure. |
| 45 __ sw(CTX, Address(A0, Isolate::top_context_offset())); |
| 46 |
| 47 // Cache Isolate pointer into CTX while executing runtime code. |
| 48 __ mov(CTX, A0); |
| 49 |
| 50 // Reserve space for arguments and align frame before entering C++ world. |
| 51 // NativeArguments are passed in registers. |
| 52 ASSERT(sizeof(NativeArguments) == 4 * kWordSize); |
| 53 __ ReserveAlignedFrameSpace(0); |
| 54 |
| 55 // Pass NativeArguments structure by value and call runtime. |
| 56 // Registers A0, A1, A2, and A3 are used. |
| 57 |
| 58 ASSERT(isolate_offset == 0 * kWordSize); |
| 59 // Set isolate in NativeArgs: A0 already contains CTX. |
| 60 |
| 61 // There are no runtime calls to closures, so we do not need to set the tag |
| 62 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. |
| 63 ASSERT(argc_tag_offset == 1 * kWordSize); |
| 64 __ mov(A1, S4); // Set argc in NativeArguments. |
| 65 |
| 66 ASSERT(argv_offset == 2 * kWordSize); |
| 67 __ sll(A2, S4, 2); |
| 68 __ addu(A2, FP, A2); // Compute argv. |
| 69 __ addiu(A2, A2, Immediate(kWordSize)); // Set argv in NativeArguments. |
| 70 |
| 71 ASSERT(retval_offset == 3 * kWordSize); |
| 72 __ addiu(A3, A2, Immediate(kWordSize)); // Retval is next to 1st argument. |
| 73 |
| 74 // Call runtime or redirection via simulator. |
| 75 __ jalr(S5); |
| 76 |
| 77 // Reset exit frame information in Isolate structure. |
| 78 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); |
| 79 |
| 80 // Load Context pointer from Isolate structure into A2. |
| 81 __ lw(A2, Address(CTX, Isolate::top_context_offset())); |
| 82 |
| 83 // Reset Context pointer in Isolate structure. |
| 84 __ LoadImmediate(A3, reinterpret_cast<intptr_t>(Object::null())); |
| 85 __ sw(A3, Address(CTX, Isolate::top_context_offset())); |
| 86 |
| 87 // Cache Context pointer into CTX while executing Dart code. |
| 88 __ mov(CTX, A2); |
| 89 |
| 90 __ mov(SP, FP); |
| 91 __ lw(RA, Address(SP, 1 * kWordSize)); |
| 92 __ lw(FP, Address(SP, 0 * kWordSize)); |
| 93 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
| 94 __ Ret(); |
21 } | 95 } |
22 | 96 |
23 | 97 |
24 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { | 98 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { |
25 __ Unimplemented("PrintStopMessage stub"); | 99 __ Unimplemented("PrintStopMessage stub"); |
26 } | 100 } |
27 | 101 |
28 | 102 |
29 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { | 103 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { |
30 __ Unimplemented("CallNativeCFunction stub"); | 104 __ Unimplemented("CallNativeCFunction stub"); |
31 } | 105 } |
32 | 106 |
33 | 107 |
| 108 // Input parameters: |
| 109 // S4: arguments descriptor array. |
34 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { | 110 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { |
35 __ Unimplemented("CallStaticFunction stub"); | 111 __ EnterStubFrame(); |
| 112 // Setup space on stack for return value and preserve arguments descriptor. |
| 113 __ LoadImmediate(V0, reinterpret_cast<intptr_t>(Object::null())); |
| 114 |
| 115 __ addiu(SP, SP, Immediate(-2 * kWordSize)); |
| 116 __ sw(S4, Address(SP, 1 * kWordSize)); |
| 117 __ sw(V0, Address(SP, 0 * kWordSize)); |
| 118 |
| 119 __ CallRuntime(kPatchStaticCallRuntimeEntry); |
| 120 |
| 121 // Get Code object result and restore arguments descriptor array. |
| 122 __ lw(V0, Address(SP, 0 * kWordSize)); |
| 123 __ lw(S4, Address(SP, 1 * kWordSize)); |
| 124 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
| 125 |
| 126 // Remove the stub frame as we are about to jump to the dart function. |
| 127 __ LeaveStubFrame(); |
| 128 |
| 129 __ lw(V0, FieldAddress(V0, Code::instructions_offset())); |
| 130 __ addiu(V0, V0, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 131 __ jr(V0); |
36 } | 132 } |
37 | 133 |
38 | 134 |
39 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { | 135 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { |
40 __ Unimplemented("FixCallersTarget stub"); | 136 __ Unimplemented("FixCallersTarget stub"); |
41 } | 137 } |
42 | 138 |
43 | 139 |
44 void StubCode::GenerateInstanceFunctionLookupStub(Assembler* assembler) { | 140 void StubCode::GenerateInstanceFunctionLookupStub(Assembler* assembler) { |
45 __ Unimplemented("InstanceFunctionLookup stub"); | 141 __ Unimplemented("InstanceFunctionLookup stub"); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 __ Bind(&push_arguments); | 243 __ Bind(&push_arguments); |
148 __ lw(A3, Address(A2)); | 244 __ lw(A3, Address(A2)); |
149 __ Push(A3); | 245 __ Push(A3); |
150 __ addiu(A2, A2, Immediate(kWordSize)); | 246 __ addiu(A2, A2, Immediate(kWordSize)); |
151 __ addiu(A1, A1, Immediate(1)); | 247 __ addiu(A1, A1, Immediate(1)); |
152 __ subu(T0, A1, S5); | 248 __ subu(T0, A1, S5); |
153 __ bltz(T0, &push_arguments); | 249 __ bltz(T0, &push_arguments); |
154 | 250 |
155 __ Bind(&done_push_arguments); | 251 __ Bind(&done_push_arguments); |
156 | 252 |
157 | |
158 // Call the Dart code entrypoint. | 253 // Call the Dart code entrypoint. |
159 __ jalr(A0); // S4 is the arguments descriptor array. | 254 __ jalr(A0); // S4 is the arguments descriptor array. |
160 | 255 |
161 // Read the saved new Context pointer. | 256 // Read the saved new Context pointer. |
162 __ lw(CTX, Address(FP, kNewContextOffset)); | 257 __ lw(CTX, Address(FP, kNewContextOffset)); |
163 __ lw(CTX, Address(CTX, VMHandles::kOffsetOfRawPtrInHandle)); | 258 __ lw(CTX, Address(CTX, VMHandles::kOffsetOfRawPtrInHandle)); |
164 | 259 |
165 // Get rid of arguments pushed on the stack. | 260 // Get rid of arguments pushed on the stack. |
166 __ addiu(SP, FP, Immediate(kSavedContextOffsetInEntryFrame)); | 261 __ addiu(SP, FP, Immediate(kSavedContextOffsetInEntryFrame)); |
167 | 262 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 437 } |
343 | 438 |
344 | 439 |
345 void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) { | 440 void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) { |
346 __ Unimplemented("IdenticalWithNumberCheck stub"); | 441 __ Unimplemented("IdenticalWithNumberCheck stub"); |
347 } | 442 } |
348 | 443 |
349 } // namespace dart | 444 } // namespace dart |
350 | 445 |
351 #endif // defined TARGET_ARCH_MIPS | 446 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |