Chromium Code Reviews| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 ASSERT(argc_tag_offset == 1 * kWordSize); | 76 ASSERT(argc_tag_offset == 1 * kWordSize); |
| 77 __ mov(A1, S4); // Set argc in NativeArguments. | 77 __ mov(A1, S4); // Set argc in NativeArguments. |
| 78 | 78 |
| 79 ASSERT(argv_offset == 2 * kWordSize); | 79 ASSERT(argv_offset == 2 * kWordSize); |
| 80 __ sll(A2, S4, 2); | 80 __ sll(A2, S4, 2); |
| 81 __ addu(A2, FP, A2); // Compute argv. | 81 __ addu(A2, FP, A2); // Compute argv. |
| 82 __ addiu(A2, A2, Immediate(kWordSize)); // Set argv in NativeArguments. | 82 __ addiu(A2, A2, Immediate(kWordSize)); // Set argv in NativeArguments. |
| 83 | 83 |
| 84 ASSERT(retval_offset == 3 * kWordSize); | 84 ASSERT(retval_offset == 3 * kWordSize); |
| 85 | 85 |
| 86 // Call runtime or redirection via simulator. | 86 // Call native wrapper or redirection via simulator. |
|
regis
2013/08/06 17:01:22
Did you update this comment by mistake?
siva
2013/08/06 19:04:26
Yes that was a mistake, restored comment.
On 2013
| |
| 87 __ jalr(S5); | 87 __ jalr(S5); |
| 88 // Retval is next to 1st argument. | 88 // Retval is next to 1st argument. |
| 89 __ delay_slot()->addiu(A3, A2, Immediate(kWordSize)); | 89 __ delay_slot()->addiu(A3, A2, Immediate(kWordSize)); |
| 90 __ TraceSimMsg("CallToRuntimeStub return"); | 90 __ TraceSimMsg("CallToRuntimeStub return"); |
| 91 | 91 |
| 92 // Reset exit frame information in Isolate structure. | 92 // Reset exit frame information in Isolate structure. |
| 93 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); | 93 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); |
| 94 | 94 |
| 95 // Load Context pointer from Isolate structure into A2. | 95 // Load Context pointer from Isolate structure into A2. |
| 96 __ lw(A2, Address(CTX, Isolate::top_context_offset())); | 96 __ lw(A2, Address(CTX, Isolate::top_context_offset())); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 | 182 |
| 183 // TODO(regis): Should we pass the structure by value as in runtime calls? | 183 // TODO(regis): Should we pass the structure by value as in runtime calls? |
| 184 // It would require changing Dart API for native functions. | 184 // It would require changing Dart API for native functions. |
| 185 // For now, space is reserved on the stack and we pass a pointer to it. | 185 // For now, space is reserved on the stack and we pass a pointer to it. |
| 186 __ addiu(SP, SP, Immediate(-4 * kWordSize)); | 186 __ addiu(SP, SP, Immediate(-4 * kWordSize)); |
| 187 __ sw(A3, Address(SP, 3 * kWordSize)); | 187 __ sw(A3, Address(SP, 3 * kWordSize)); |
| 188 __ sw(A2, Address(SP, 2 * kWordSize)); | 188 __ sw(A2, Address(SP, 2 * kWordSize)); |
| 189 __ sw(A1, Address(SP, 1 * kWordSize)); | 189 __ sw(A1, Address(SP, 1 * kWordSize)); |
| 190 __ sw(A0, Address(SP, 0 * kWordSize)); | 190 __ sw(A0, Address(SP, 0 * kWordSize)); |
| 191 __ mov(A0, SP); // Pass the pointer to the NativeArguments. | 191 __ mov(A0, SP); // Pass the pointer to the NativeArguments. |
| 192 __ mov(A1, T5); // Pass the function entrypoint. | |
| 193 | |
| 194 __ ReserveAlignedFrameSpace(2 * kWordSize); // Just passing A0, A1. | |
| 195 | |
| 196 // Call native function or redirection via simulator. | |
| 197 #if defined(USING_SIMULATOR) | |
| 198 uword entry = reinterpret_cast<uword>(NativeEntry::NativeCallWrapper); | |
| 199 entry = Simulator::RedirectExternalReference( | |
| 200 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments); | |
| 201 __ LoadImmediate(T5, entry); | |
| 202 __ jalr(T5); | |
| 203 #else | |
| 204 __ BranchLink(&NativeEntry::NativeCallWrapperLabel()); | |
| 205 #endif | |
| 206 __ TraceSimMsg("CallNativeCFunctionStub return"); | |
| 207 | |
| 208 // Reset exit frame information in Isolate structure. | |
| 209 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); | |
| 210 | |
| 211 // Load Context pointer from Isolate structure into A2. | |
| 212 __ lw(A2, Address(CTX, Isolate::top_context_offset())); | |
| 213 | |
| 214 // Load null. | |
| 215 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); | |
| 216 | |
| 217 // Reset Context pointer in Isolate structure. | |
| 218 __ sw(TMP, Address(CTX, Isolate::top_context_offset())); | |
| 219 | |
| 220 // Cache Context pointer into CTX while executing Dart code. | |
| 221 __ mov(CTX, A2); | |
| 222 | |
| 223 __ mov(SP, FP); | |
| 224 __ lw(RA, Address(SP, 1 * kWordSize)); | |
| 225 __ lw(FP, Address(SP, 0 * kWordSize)); | |
| 226 __ Ret(); | |
| 227 __ delay_slot()->addiu(SP, SP, Immediate(2 * kWordSize)); | |
| 228 } | |
| 229 | |
| 230 | |
| 231 // Input parameters: | |
| 232 // RA : return address. | |
| 233 // SP : address of return value. | |
| 234 // T5 : address of the native function to call. | |
| 235 // A2 : address of first argument in argument array. | |
| 236 // A1 : argc_tag including number of arguments and function kind. | |
| 237 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) { | |
| 238 const intptr_t isolate_offset = NativeArguments::isolate_offset(); | |
| 239 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); | |
| 240 const intptr_t argv_offset = NativeArguments::argv_offset(); | |
| 241 const intptr_t retval_offset = NativeArguments::retval_offset(); | |
| 242 | |
| 243 __ SetPrologueOffset(); | |
| 244 __ TraceSimMsg("CallNativeCFunctionStub"); | |
| 245 __ addiu(SP, SP, Immediate(-2 * kWordSize)); | |
| 246 __ sw(RA, Address(SP, 1 * kWordSize)); | |
| 247 __ sw(FP, Address(SP, 0 * kWordSize)); | |
| 248 __ mov(FP, SP); | |
| 249 | |
| 250 // Load current Isolate pointer from Context structure into A0. | |
| 251 __ lw(A0, FieldAddress(CTX, Context::isolate_offset())); | |
| 252 | |
| 253 // Save exit frame information to enable stack walking as we are about | |
| 254 // to transition to native code. | |
| 255 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset())); | |
| 256 | |
| 257 // Save current Context pointer into Isolate structure. | |
| 258 __ sw(CTX, Address(A0, Isolate::top_context_offset())); | |
| 259 | |
| 260 // Cache Isolate pointer into CTX while executing native code. | |
| 261 __ mov(CTX, A0); | |
| 262 | |
| 263 // Initialize NativeArguments structure and call native function. | |
| 264 // Registers A0, A1, A2, and A3 are used. | |
| 265 | |
| 266 ASSERT(isolate_offset == 0 * kWordSize); | |
| 267 // Set isolate in NativeArgs: A0 already contains CTX. | |
| 268 | |
| 269 // There are no native calls to closures, so we do not need to set the tag | |
| 270 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. | |
| 271 ASSERT(argc_tag_offset == 1 * kWordSize); | |
| 272 // Set argc in NativeArguments: A1 already contains argc. | |
| 273 | |
| 274 ASSERT(argv_offset == 2 * kWordSize); | |
| 275 // Set argv in NativeArguments: A2 already contains argv. | |
| 276 | |
| 277 ASSERT(retval_offset == 3 * kWordSize); | |
| 278 __ addiu(A3, FP, Immediate(2 * kWordSize)); // Set retval in NativeArgs. | |
| 279 | |
| 280 // TODO(regis): Should we pass the structure by value as in runtime calls? | |
| 281 // It would require changing Dart API for native functions. | |
| 282 // For now, space is reserved on the stack and we pass a pointer to it. | |
| 283 __ addiu(SP, SP, Immediate(-4 * kWordSize)); | |
| 284 __ sw(A3, Address(SP, 3 * kWordSize)); | |
| 285 __ sw(A2, Address(SP, 2 * kWordSize)); | |
| 286 __ sw(A1, Address(SP, 1 * kWordSize)); | |
| 287 __ sw(A0, Address(SP, 0 * kWordSize)); | |
| 288 __ mov(A0, SP); // Pass the pointer to the NativeArguments. | |
| 192 | 289 |
| 193 __ ReserveAlignedFrameSpace(kWordSize); // Just passing A0. | 290 __ ReserveAlignedFrameSpace(kWordSize); // Just passing A0. |
| 194 | 291 |
| 195 // Call native function or redirection via simulator. | 292 // Call native function or redirection via simulator. |
| 196 __ jalr(T5); | 293 __ jalr(T5); |
| 197 __ TraceSimMsg("CallNativeCFunctionStub return"); | 294 __ TraceSimMsg("CallNativeCFunctionStub return"); |
| 198 | 295 |
| 199 // Reset exit frame information in Isolate structure. | 296 // Reset exit frame information in Isolate structure. |
| 200 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); | 297 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); |
| 201 | 298 |
| (...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2364 __ lw(left, Address(SP, 1 * kWordSize)); | 2461 __ lw(left, Address(SP, 1 * kWordSize)); |
| 2365 __ lw(temp2, Address(SP, 2 * kWordSize)); | 2462 __ lw(temp2, Address(SP, 2 * kWordSize)); |
| 2366 __ lw(temp1, Address(SP, 3 * kWordSize)); | 2463 __ lw(temp1, Address(SP, 3 * kWordSize)); |
| 2367 __ Ret(); | 2464 __ Ret(); |
| 2368 __ delay_slot()->addiu(SP, SP, Immediate(4 * kWordSize)); | 2465 __ delay_slot()->addiu(SP, SP, Immediate(4 * kWordSize)); |
| 2369 } | 2466 } |
| 2370 | 2467 |
| 2371 } // namespace dart | 2468 } // namespace dart |
| 2372 | 2469 |
| 2373 #endif // defined TARGET_ARCH_MIPS | 2470 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |