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" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 __ sw(A2, Address(SP, 2 * kWordSize)); | 160 __ sw(A2, Address(SP, 2 * kWordSize)); |
161 __ sw(A1, Address(SP, 1 * kWordSize)); | 161 __ sw(A1, Address(SP, 1 * kWordSize)); |
162 __ sw(A0, Address(SP, 0 * kWordSize)); | 162 __ sw(A0, Address(SP, 0 * kWordSize)); |
163 | 163 |
164 __ mov(A0, SP); // Pass the pointer to the NativeArguments. | 164 __ mov(A0, SP); // Pass the pointer to the NativeArguments. |
165 | 165 |
166 // Call native function or redirection via simulator. | 166 // Call native function or redirection via simulator. |
167 __ jalr(T5); | 167 __ jalr(T5); |
168 | 168 |
169 // Reset exit frame information in Isolate structure. | 169 // Reset exit frame information in Isolate structure. |
170 __ LoadImmediate(A2, 0); | 170 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); |
171 __ sw(A2, Address(CTX, Isolate::top_exit_frame_info_offset())); | |
172 | 171 |
173 // Load Context pointer from Isolate structure into R2. | 172 // Load Context pointer from Isolate structure into R2. |
174 __ lw(A2, Address(CTX, Isolate::top_context_offset())); | 173 __ lw(A2, Address(CTX, Isolate::top_context_offset())); |
175 | 174 |
176 // Reset Context pointer in Isolate structure. | 175 // Reset Context pointer in Isolate structure. |
177 __ LoadImmediate(A3, reinterpret_cast<intptr_t>(Object::null())); | 176 __ LoadImmediate(A3, reinterpret_cast<intptr_t>(Object::null())); |
178 __ sw(A3, Address(CTX, Isolate::top_context_offset())); | 177 __ sw(A3, Address(CTX, Isolate::top_context_offset())); |
179 | 178 |
180 // Cache Context pointer into CTX while executing Dart code. | 179 // Cache Context pointer into CTX while executing Dart code. |
181 __ mov(CTX, A2); | 180 __ mov(CTX, A2); |
182 | 181 |
183 __ mov(SP, FP); | 182 __ mov(SP, FP); |
184 __ lw(RA, Address(SP, 1 * kWordSize)); | 183 __ lw(RA, Address(SP, 1 * kWordSize)); |
185 __ lw(FP, Address(SP, 0 * kWordSize)); | 184 __ lw(FP, Address(SP, 0 * kWordSize)); |
186 __ addiu(SP, SP, Immediate(2 * kWordSize)); | 185 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
187 __ Ret(); | 186 __ Ret(); |
188 } | 187 } |
189 | 188 |
190 | 189 |
191 // Input parameters: | 190 // Input parameters: |
192 // S4: arguments descriptor array. | 191 // S4: arguments descriptor array. |
193 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { | 192 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { |
194 __ EnterStubFrame(); | 193 __ EnterStubFrame(); |
195 // Setup space on stack for return value and preserve arguments descriptor. | 194 // Setup space on stack for return value and preserve arguments descriptor. |
196 __ LoadImmediate(V0, reinterpret_cast<intptr_t>(Object::null())); | 195 __ LoadImmediate(T0, reinterpret_cast<intptr_t>(Object::null())); |
197 | 196 |
198 __ addiu(SP, SP, Immediate(-2 * kWordSize)); | 197 __ addiu(SP, SP, Immediate(-2 * kWordSize)); |
199 __ sw(S4, Address(SP, 1 * kWordSize)); | 198 __ sw(S4, Address(SP, 1 * kWordSize)); |
200 __ sw(V0, Address(SP, 0 * kWordSize)); | 199 __ sw(T0, Address(SP, 0 * kWordSize)); |
201 | 200 |
202 __ CallRuntime(kPatchStaticCallRuntimeEntry); | 201 __ CallRuntime(kPatchStaticCallRuntimeEntry); |
203 | 202 |
204 // Get Code object result and restore arguments descriptor array. | 203 // Get Code object result and restore arguments descriptor array. |
205 __ lw(V0, Address(SP, 0 * kWordSize)); | 204 __ lw(T0, Address(SP, 0 * kWordSize)); |
206 __ lw(S4, Address(SP, 1 * kWordSize)); | 205 __ lw(S4, Address(SP, 1 * kWordSize)); |
207 __ addiu(SP, SP, Immediate(2 * kWordSize)); | 206 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
208 | 207 |
209 // Remove the stub frame as we are about to jump to the dart function. | 208 // Remove the stub frame as we are about to jump to the dart function. |
210 __ LeaveStubFrame(); | 209 __ LeaveStubFrame(); |
211 | 210 |
212 __ lw(V0, FieldAddress(V0, Code::instructions_offset())); | 211 __ lw(T0, FieldAddress(T0, Code::instructions_offset())); |
213 __ addiu(V0, V0, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 212 __ addiu(T0, T0, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
214 __ jr(V0); | 213 __ jr(T0); |
215 } | 214 } |
216 | 215 |
217 | 216 |
218 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { | 217 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { |
219 __ Unimplemented("FixCallersTarget stub"); | 218 __ Unimplemented("FixCallersTarget stub"); |
220 } | 219 } |
221 | 220 |
222 | 221 |
223 void StubCode::GenerateInstanceFunctionLookupStub(Assembler* assembler) { | 222 void StubCode::GenerateInstanceFunctionLookupStub(Assembler* assembler) { |
224 __ Unimplemented("InstanceFunctionLookup stub"); | 223 __ Unimplemented("InstanceFunctionLookup stub"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // available in generated code and calls to Isolate::Current() need not be | 276 // available in generated code and calls to Isolate::Current() need not be |
278 // done. The assumption is that this register will never be clobbered by | 277 // done. The assumption is that this register will never be clobbered by |
279 // compiled or runtime stub code. | 278 // compiled or runtime stub code. |
280 | 279 |
281 // Cache the new Context pointer into CTX while executing Dart code. | 280 // Cache the new Context pointer into CTX while executing Dart code. |
282 __ lw(CTX, Address(A3, VMHandles::kOffsetOfRawPtrInHandle)); | 281 __ lw(CTX, Address(A3, VMHandles::kOffsetOfRawPtrInHandle)); |
283 | 282 |
284 // Load Isolate pointer from Context structure into temporary register R8. | 283 // Load Isolate pointer from Context structure into temporary register R8. |
285 __ lw(T2, FieldAddress(CTX, Context::isolate_offset())); | 284 __ lw(T2, FieldAddress(CTX, Context::isolate_offset())); |
286 | 285 |
287 // Save the top exit frame info. Use R5 as a temporary register. | 286 // Save the top exit frame info. Use T0 as a temporary register. |
288 // StackFrameIterator reads the top exit frame info saved in this frame. | 287 // StackFrameIterator reads the top exit frame info saved in this frame. |
289 __ lw(S5, Address(T2, Isolate::top_exit_frame_info_offset())); | 288 __ lw(T0, Address(T2, Isolate::top_exit_frame_info_offset())); |
290 __ LoadImmediate(T0, 0); | 289 __ sw(ZR, Address(T2, Isolate::top_exit_frame_info_offset())); |
291 __ sw(T0, Address(T2, Isolate::top_exit_frame_info_offset())); | |
292 | 290 |
293 // Save the old Context pointer. Use S4 as a temporary register. | 291 // Save the old Context pointer. Use T1 as a temporary register. |
294 // Note that VisitObjectPointers will find this saved Context pointer during | 292 // Note that VisitObjectPointers will find this saved Context pointer during |
295 // GC marking, since it traverses any information between SP and | 293 // GC marking, since it traverses any information between SP and |
296 // FP - kExitLinkOffsetInEntryFrame. | 294 // FP - kExitLinkOffsetInEntryFrame. |
297 // EntryFrame::SavedContext reads the context saved in this frame. | 295 // EntryFrame::SavedContext reads the context saved in this frame. |
298 __ lw(S4, Address(T2, Isolate::top_context_offset())); | 296 __ lw(T1, Address(T2, Isolate::top_context_offset())); |
299 | 297 |
300 // The constants kSavedContextOffsetInEntryFrame and | 298 // The constants kSavedContextOffsetInEntryFrame and |
301 // kExitLinkOffsetInEntryFrame must be kept in sync with the code below. | 299 // kExitLinkOffsetInEntryFrame must be kept in sync with the code below. |
302 __ sw(S5, Address(SP, 1 * kWordSize)); | 300 __ sw(T0, Address(SP, 1 * kWordSize)); |
303 __ sw(S4, Address(SP, 0 * kWordSize)); | 301 __ sw(T1, Address(SP, 0 * kWordSize)); |
304 | 302 |
305 // after the call, The stack pointer is restored to this location. | 303 // after the call, The stack pointer is restored to this location. |
306 // Pushed A3, S0-7, S4, S5 = 11. | 304 // Pushed A3, S0-7, S4, S5 = 11. |
307 const intptr_t kSavedContextOffsetInEntryFrame = -11 * kWordSize; | 305 const intptr_t kSavedContextOffsetInEntryFrame = -11 * kWordSize; |
308 | 306 |
309 // Load arguments descriptor array into S4, which is passed to Dart code. | 307 // Load arguments descriptor array into S4, which is passed to Dart code. |
310 __ lw(S4, Address(A1, VMHandles::kOffsetOfRawPtrInHandle)); | 308 __ lw(S4, Address(A1, VMHandles::kOffsetOfRawPtrInHandle)); |
311 | 309 |
312 // Load number of arguments into S5. | 310 // Load number of arguments into S5. |
313 __ lw(S5, FieldAddress(S4, ArgumentsDescriptor::count_offset())); | 311 __ lw(T1, FieldAddress(S4, ArgumentsDescriptor::count_offset())); |
314 __ SmiUntag(S5); | 312 __ SmiUntag(T1); |
315 | |
316 // Compute address of 'arguments array' data area into A2. | |
317 __ lw(A2, Address(A2, VMHandles::kOffsetOfRawPtrInHandle)); | |
318 __ addiu(A2, A2, Immediate(Array::data_offset() - kHeapObjectTag)); | |
319 | 313 |
320 // Set up arguments for the Dart call. | 314 // Set up arguments for the Dart call. |
321 Label push_arguments; | 315 Label push_arguments; |
322 Label done_push_arguments; | 316 Label done_push_arguments; |
323 | 317 |
324 __ beq(S5, ZR, &done_push_arguments); // check if there are arguments. | 318 // Compute address of 'arguments array' data area into A2. |
325 __ LoadImmediate(A1, 0); | 319 // See also the addiu in the delay slot of the upcoming beq. |
| 320 __ lw(A2, Address(A2, VMHandles::kOffsetOfRawPtrInHandle)); |
| 321 |
| 322 __ beq(T1, ZR, &done_push_arguments); // check if there are arguments. |
| 323 __ delay_slot()->addiu(A2, A2, |
| 324 Immediate(Array::data_offset() - kHeapObjectTag)); |
| 325 |
| 326 __ mov(A1, ZR); |
326 __ Bind(&push_arguments); | 327 __ Bind(&push_arguments); |
327 __ lw(A3, Address(A2)); | 328 __ lw(A3, Address(A2)); |
328 __ Push(A3); | 329 __ Push(A3); |
329 __ addiu(A2, A2, Immediate(kWordSize)); | 330 __ addiu(A2, A2, Immediate(kWordSize)); |
330 __ addiu(A1, A1, Immediate(1)); | 331 __ addiu(A1, A1, Immediate(1)); |
331 __ subu(T0, A1, S5); | 332 __ BranchLess(A1, T1, &push_arguments); |
332 __ bltz(T0, &push_arguments); | |
333 | 333 |
334 __ Bind(&done_push_arguments); | 334 __ Bind(&done_push_arguments); |
335 | 335 |
336 // Call the Dart code entrypoint. | 336 // Call the Dart code entrypoint. |
337 __ jalr(A0); // S4 is the arguments descriptor array. | 337 __ jalr(A0); // S4 is the arguments descriptor array. |
338 | 338 |
339 // Read the saved new Context pointer. | 339 // Read the saved new Context pointer. |
340 __ lw(CTX, Address(FP, kNewContextOffset)); | 340 __ lw(CTX, Address(FP, kNewContextOffset)); |
341 __ lw(CTX, Address(CTX, VMHandles::kOffsetOfRawPtrInHandle)); | 341 __ lw(CTX, Address(CTX, VMHandles::kOffsetOfRawPtrInHandle)); |
342 | 342 |
343 // Get rid of arguments pushed on the stack. | 343 // Get rid of arguments pushed on the stack. |
344 __ addiu(SP, FP, Immediate(kSavedContextOffsetInEntryFrame)); | 344 __ addiu(SP, FP, Immediate(kSavedContextOffsetInEntryFrame)); |
345 | 345 |
346 // Load Isolate pointer from Context structure into CTX. Drop Context. | 346 // Load Isolate pointer from Context structure into CTX. Drop Context. |
347 __ lw(CTX, FieldAddress(CTX, Context::isolate_offset())); | 347 __ lw(CTX, FieldAddress(CTX, Context::isolate_offset())); |
348 | 348 |
349 // Restore the saved Context pointer into the Isolate structure. | 349 // Restore the saved Context pointer into the Isolate structure. |
350 // Uses S4 as a temporary register for this. | 350 // Uses T1 as a temporary register for this. |
351 // Restore the saved top exit frame info back into the Isolate structure. | 351 // Restore the saved top exit frame info back into the Isolate structure. |
352 // Uses S5 as a temporary register for this. | 352 // Uses T0 as a temporary register for this. |
353 __ lw(S4, Address(SP, 0 * kWordSize)); | 353 __ lw(T1, Address(SP, 0 * kWordSize)); |
354 __ lw(S5, Address(SP, 1 * kWordSize)); | 354 __ lw(T0, Address(SP, 1 * kWordSize)); |
355 __ sw(S4, Address(CTX, Isolate::top_context_offset())); | 355 __ sw(T1, Address(CTX, Isolate::top_context_offset())); |
356 __ sw(S5, Address(CTX, Isolate::top_exit_frame_info_offset())); | 356 __ sw(T0, Address(CTX, Isolate::top_exit_frame_info_offset())); |
357 | 357 |
358 // Restore C++ ABI callee-saved registers. | 358 // Restore C++ ABI callee-saved registers. |
359 for (int i = S0; i <= S7; i++) { | 359 for (int i = S0; i <= S7; i++) { |
360 Register r = static_cast<Register>(i); | 360 Register r = static_cast<Register>(i); |
361 __ lw(r, Address(SP, (i - S0 + 3) * kWordSize)); | 361 __ lw(r, Address(SP, (i - S0 + 3) * kWordSize)); |
362 } | 362 } |
363 __ lw(A3, Address(SP)); | 363 __ lw(A3, Address(SP)); |
364 __ addiu(SP, SP, Immediate((3 + kAbiPreservedCpuRegCount) * kWordSize)); | 364 __ addiu(SP, SP, Immediate((3 + kAbiPreservedCpuRegCount) * kWordSize)); |
365 | 365 |
366 // Restore the frame pointer and return. | 366 // Restore the frame pointer and return. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 } | 520 } |
521 | 521 |
522 | 522 |
523 void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) { | 523 void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) { |
524 __ Unimplemented("IdenticalWithNumberCheck stub"); | 524 __ Unimplemented("IdenticalWithNumberCheck stub"); |
525 } | 525 } |
526 | 526 |
527 } // namespace dart | 527 } // namespace dart |
528 | 528 |
529 #endif // defined TARGET_ARCH_MIPS | 529 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |