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/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 // TODO(regis): Should we pass the structure by value as in runtime calls? | 186 // TODO(regis): Should we pass the structure by value as in runtime calls? |
187 // It would require changing Dart API for native functions. | 187 // It would require changing Dart API for native functions. |
188 // For now, space is reserved on the stack and we pass a pointer to it. | 188 // For now, space is reserved on the stack and we pass a pointer to it. |
189 __ addiu(SP, SP, Immediate(-4 * kWordSize)); | 189 __ addiu(SP, SP, Immediate(-4 * kWordSize)); |
190 __ sw(A3, Address(SP, 3 * kWordSize)); | 190 __ sw(A3, Address(SP, 3 * kWordSize)); |
191 __ sw(A2, Address(SP, 2 * kWordSize)); | 191 __ sw(A2, Address(SP, 2 * kWordSize)); |
192 __ sw(A1, Address(SP, 1 * kWordSize)); | 192 __ sw(A1, Address(SP, 1 * kWordSize)); |
193 __ sw(A0, Address(SP, 0 * kWordSize)); | 193 __ sw(A0, Address(SP, 0 * kWordSize)); |
194 __ mov(A0, SP); // Pass the pointer to the NativeArguments. | 194 __ mov(A0, SP); // Pass the pointer to the NativeArguments. |
| 195 |
| 196 // Call native function (setup scope if not leaf function). |
| 197 Label leaf_call; |
| 198 Label done; |
| 199 __ AndImmediate(CMPRES1, A1, NativeArguments::AutoSetupScopeMask()); |
| 200 __ beq(CMPRES1, ZR, &leaf_call); |
| 201 |
195 __ mov(A1, T5); // Pass the function entrypoint. | 202 __ mov(A1, T5); // Pass the function entrypoint. |
196 | |
197 __ ReserveAlignedFrameSpace(2 * kWordSize); // Just passing A0, A1. | 203 __ ReserveAlignedFrameSpace(2 * kWordSize); // Just passing A0, A1. |
198 | |
199 // Call native wrapper function or redirection via simulator. | 204 // Call native wrapper function or redirection via simulator. |
200 #if defined(USING_SIMULATOR) | 205 #if defined(USING_SIMULATOR) |
201 uword entry = reinterpret_cast<uword>(NativeEntry::NativeCallWrapper); | 206 uword entry = reinterpret_cast<uword>(NativeEntry::NativeCallWrapper); |
202 entry = Simulator::RedirectExternalReference( | 207 entry = Simulator::RedirectExternalReference( |
203 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments); | 208 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments); |
204 __ LoadImmediate(T5, entry); | 209 __ LoadImmediate(T5, entry); |
205 __ jalr(T5); | 210 __ jalr(T5); |
206 #else | 211 #else |
207 __ BranchLink(&NativeEntry::NativeCallWrapperLabel()); | 212 __ BranchLink(&NativeEntry::NativeCallWrapperLabel()); |
208 #endif | 213 #endif |
209 __ TraceSimMsg("CallNativeCFunctionStub return"); | 214 __ TraceSimMsg("CallNativeCFunctionStub return"); |
| 215 __ b(&done); |
| 216 |
| 217 __ Bind(&leaf_call); |
| 218 // Call native function or redirection via simulator. |
| 219 __ ReserveAlignedFrameSpace(kWordSize); // Just passing A0. |
| 220 __ jalr(T5); |
| 221 |
| 222 __ Bind(&done); |
210 | 223 |
211 // Reset exit frame information in Isolate structure. | 224 // Reset exit frame information in Isolate structure. |
212 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); | 225 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); |
213 | 226 |
214 // Load Context pointer from Isolate structure into A2. | 227 // Load Context pointer from Isolate structure into A2. |
215 __ lw(A2, Address(CTX, Isolate::top_context_offset())); | 228 __ lw(A2, Address(CTX, Isolate::top_context_offset())); |
216 | 229 |
217 // Load null. | 230 // Load null. |
218 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); | 231 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); |
219 | 232 |
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2434 const Register right = T0; | 2447 const Register right = T0; |
2435 __ lw(left, Address(SP, 1 * kWordSize)); | 2448 __ lw(left, Address(SP, 1 * kWordSize)); |
2436 __ lw(right, Address(SP, 0 * kWordSize)); | 2449 __ lw(right, Address(SP, 0 * kWordSize)); |
2437 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2); | 2450 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2); |
2438 __ Ret(); | 2451 __ Ret(); |
2439 } | 2452 } |
2440 | 2453 |
2441 } // namespace dart | 2454 } // namespace dart |
2442 | 2455 |
2443 #endif // defined TARGET_ARCH_MIPS | 2456 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |