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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 __ addiu(SP, SP, Immediate(2 * kWordSize)); | 93 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
94 __ Ret(); | 94 __ Ret(); |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { | 98 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { |
99 __ Unimplemented("PrintStopMessage stub"); | 99 __ Unimplemented("PrintStopMessage stub"); |
100 } | 100 } |
101 | 101 |
102 | 102 |
| 103 // Input parameters: |
| 104 // RA : return address. |
| 105 // SP : address of return value. |
| 106 // T5 : address of the native function to call. |
| 107 // A2 : address of first argument in argument array. |
| 108 // A1 : argc_tag including number of arguments and function kind. |
103 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { | 109 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { |
104 __ Unimplemented("CallNativeCFunction stub"); | 110 const intptr_t isolate_offset = NativeArguments::isolate_offset(); |
| 111 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); |
| 112 const intptr_t argv_offset = NativeArguments::argv_offset(); |
| 113 const intptr_t retval_offset = NativeArguments::retval_offset(); |
| 114 |
| 115 __ addiu(SP, SP, Immediate(-2 * kWordSize)); |
| 116 __ sw(RA, Address(SP, 1 * kWordSize)); |
| 117 __ sw(FP, Address(SP, 0 * kWordSize)); |
| 118 __ mov(FP, SP); |
| 119 |
| 120 // Load current Isolate pointer from Context structure into A0. |
| 121 __ lw(A0, FieldAddress(CTX, Context::isolate_offset())); |
| 122 |
| 123 // Save exit frame information to enable stack walking as we are about |
| 124 // to transition to native code. |
| 125 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset())); |
| 126 |
| 127 // Save current Context pointer into Isolate structure. |
| 128 __ sw(CTX, Address(A0, Isolate::top_context_offset())); |
| 129 |
| 130 // Cache Isolate pointer into CTX while executing native code. |
| 131 __ mov(CTX, A0); |
| 132 |
| 133 // Reserve space for the native arguments structure passed on the stack (the |
| 134 // outgoing pointer parameter to the native arguments structure is passed in |
| 135 // R0) and align frame before entering the C++ world. |
| 136 __ ReserveAlignedFrameSpace(sizeof(NativeArguments)); |
| 137 |
| 138 // Initialize NativeArguments structure and call native function. |
| 139 // Registers A0, A1, A2, and A3 are used. |
| 140 |
| 141 ASSERT(isolate_offset == 0 * kWordSize); |
| 142 // Set isolate in NativeArgs: A0 already contains CTX. |
| 143 |
| 144 // There are no native calls to closures, so we do not need to set the tag |
| 145 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. |
| 146 ASSERT(argc_tag_offset == 1 * kWordSize); |
| 147 // Set argc in NativeArguments: T1 already contains argc. |
| 148 |
| 149 ASSERT(argv_offset == 2 * kWordSize); |
| 150 // Set argv in NativeArguments: T2 already contains argv. |
| 151 |
| 152 ASSERT(retval_offset == 3 * kWordSize); |
| 153 __ addiu(A3, FP, Immediate(2 * kWordSize)); // Set retval in NativeArgs. |
| 154 |
| 155 // TODO(regis): Should we pass the structure by value as in runtime calls? |
| 156 // It would require changing Dart API for native functions. |
| 157 // For now, space is reserved on the stack and we pass a pointer to it. |
| 158 __ addiu(SP, SP, Immediate(-4 * kWordSize)); |
| 159 __ sw(A3, Address(SP, 3 * kWordSize)); |
| 160 __ sw(A2, Address(SP, 2 * kWordSize)); |
| 161 __ sw(A1, Address(SP, 1 * kWordSize)); |
| 162 __ sw(A0, Address(SP, 0 * kWordSize)); |
| 163 |
| 164 __ mov(A0, SP); // Pass the pointer to the NativeArguments. |
| 165 |
| 166 // Call native function or redirection via simulator. |
| 167 __ jalr(T5); |
| 168 |
| 169 // Reset exit frame information in Isolate structure. |
| 170 __ LoadImmediate(A2, 0); |
| 171 __ sw(A2, Address(CTX, Isolate::top_exit_frame_info_offset())); |
| 172 |
| 173 // Load Context pointer from Isolate structure into R2. |
| 174 __ lw(A2, Address(CTX, Isolate::top_context_offset())); |
| 175 |
| 176 // Reset Context pointer in Isolate structure. |
| 177 __ LoadImmediate(A3, reinterpret_cast<intptr_t>(Object::null())); |
| 178 __ sw(A3, Address(CTX, Isolate::top_context_offset())); |
| 179 |
| 180 // Cache Context pointer into CTX while executing Dart code. |
| 181 __ mov(CTX, A2); |
| 182 |
| 183 __ mov(SP, FP); |
| 184 __ lw(RA, Address(SP, 1 * kWordSize)); |
| 185 __ lw(FP, Address(SP, 0 * kWordSize)); |
| 186 __ addiu(SP, SP, Immediate(2 * kWordSize)); |
| 187 __ Ret(); |
105 } | 188 } |
106 | 189 |
107 | 190 |
108 // Input parameters: | 191 // Input parameters: |
109 // S4: arguments descriptor array. | 192 // S4: arguments descriptor array. |
110 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { | 193 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { |
111 __ EnterStubFrame(); | 194 __ EnterStubFrame(); |
112 // Setup space on stack for return value and preserve arguments descriptor. | 195 // Setup space on stack for return value and preserve arguments descriptor. |
113 __ LoadImmediate(V0, reinterpret_cast<intptr_t>(Object::null())); | 196 __ LoadImmediate(V0, reinterpret_cast<intptr_t>(Object::null())); |
114 | 197 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 520 } |
438 | 521 |
439 | 522 |
440 void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) { | 523 void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) { |
441 __ Unimplemented("IdenticalWithNumberCheck stub"); | 524 __ Unimplemented("IdenticalWithNumberCheck stub"); |
442 } | 525 } |
443 | 526 |
444 } // namespace dart | 527 } // namespace dart |
445 | 528 |
446 #endif // defined TARGET_ARCH_MIPS | 529 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |