| 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/runtime_entry.h" | 9 #include "vm/runtime_entry.h" |
| 10 #include "vm/simulator.h" | 10 #include "vm/simulator.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 lw(result, FieldAddress(CTX, Context::isolate_offset())); | 197 lw(result, FieldAddress(CTX, Context::isolate_offset())); |
| 198 const intptr_t table_offset_in_isolate = | 198 const intptr_t table_offset_in_isolate = |
| 199 Isolate::class_table_offset() + ClassTable::table_offset(); | 199 Isolate::class_table_offset() + ClassTable::table_offset(); |
| 200 lw(result, Address(result, table_offset_in_isolate)); | 200 lw(result, Address(result, table_offset_in_isolate)); |
| 201 sll(TMP1, TMP1, 2); | 201 sll(TMP1, TMP1, 2); |
| 202 addu(result, result, TMP1); | 202 addu(result, result, TMP1); |
| 203 lw(result, Address(result)); | 203 lw(result, Address(result)); |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 void Assembler::EnterStubFrame() { | 207 void Assembler::EnterStubFrame(bool uses_pp) { |
| 208 addiu(SP, SP, Immediate(-3 * kWordSize)); | 208 if (uses_pp) { |
| 209 sw(ZR, Address(SP, 2 * kWordSize)); // PC marker is 0 in stubs. | 209 addiu(SP, SP, Immediate(-4 * kWordSize)); |
| 210 sw(RA, Address(SP, 1 * kWordSize)); | 210 sw(ZR, Address(SP, 3 * kWordSize)); // PC marker is 0 in stubs. |
| 211 sw(FP, Address(SP, 0 * kWordSize)); | 211 sw(RA, Address(SP, 2 * kWordSize)); |
| 212 mov(FP, SP); | 212 sw(PP, Address(SP, 1 * kWordSize)); |
| 213 sw(FP, Address(SP, 0 * kWordSize)); |
| 214 mov(FP, SP); |
| 215 // Setup pool pointer for this stub. |
| 216 Label next; |
| 217 bal(&next); |
| 218 delay_slot()->mov(T0, RA); |
| 219 |
| 220 const intptr_t object_pool_pc_dist = |
| 221 Instructions::HeaderSize() - Instructions::object_pool_offset() + |
| 222 CodeSize(); |
| 223 |
| 224 Bind(&next); |
| 225 lw(PP, Address(T0, -object_pool_pc_dist)); |
| 226 } else { |
| 227 addiu(SP, SP, Immediate(-3 * kWordSize)); |
| 228 sw(ZR, Address(SP, 2 * kWordSize)); // PC marker is 0 in stubs. |
| 229 sw(RA, Address(SP, 1 * kWordSize)); |
| 230 sw(FP, Address(SP, 0 * kWordSize)); |
| 231 mov(FP, SP); |
| 232 } |
| 213 } | 233 } |
| 214 | 234 |
| 215 | 235 |
| 216 void Assembler::LeaveStubFrame() { | 236 void Assembler::LeaveStubFrame(bool uses_pp) { |
| 217 mov(SP, FP); | 237 mov(SP, FP); |
| 218 lw(RA, Address(SP, 1 * kWordSize)); | 238 if (uses_pp) { |
| 219 lw(FP, Address(SP, 0 * kWordSize)); | 239 lw(RA, Address(SP, 2 * kWordSize)); |
| 220 addiu(SP, SP, Immediate(3 * kWordSize)); | 240 lw(PP, Address(SP, 1 * kWordSize)); |
| 241 lw(FP, Address(SP, 0 * kWordSize)); |
| 242 addiu(SP, SP, Immediate(4 * kWordSize)); |
| 243 } else { |
| 244 lw(RA, Address(SP, 1 * kWordSize)); |
| 245 lw(FP, Address(SP, 0 * kWordSize)); |
| 246 addiu(SP, SP, Immediate(3 * kWordSize)); |
| 247 } |
| 221 } | 248 } |
| 222 | 249 |
| 223 | 250 |
| 224 void Assembler::CallRuntime(const RuntimeEntry& entry) { | 251 void Assembler::CallRuntime(const RuntimeEntry& entry) { |
| 225 entry.Call(this); | 252 entry.Call(this); |
| 226 } | 253 } |
| 227 | 254 |
| 228 | 255 |
| 229 void Assembler::EnterDartFrame(intptr_t frame_size) { | 256 void Assembler::EnterDartFrame(intptr_t frame_size) { |
| 230 const intptr_t offset = CodeSize(); | 257 const intptr_t offset = CodeSize(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 243 | 270 |
| 244 // Calculate the offset of the pool pointer from the PC. | 271 // Calculate the offset of the pool pointer from the PC. |
| 245 const intptr_t object_pool_pc_dist = | 272 const intptr_t object_pool_pc_dist = |
| 246 Instructions::HeaderSize() - Instructions::object_pool_offset() + | 273 Instructions::HeaderSize() - Instructions::object_pool_offset() + |
| 247 CodeSize(); | 274 CodeSize(); |
| 248 | 275 |
| 249 // This sw instruction is the return address for the bal, so T0 holds | 276 // This sw instruction is the return address for the bal, so T0 holds |
| 250 // the PC at this sw instruction. | 277 // the PC at this sw instruction. |
| 251 Bind(&next); | 278 Bind(&next); |
| 252 | 279 |
| 253 if (offset != 0) { | 280 // Save PC in frame for fast identification of corresponding code. |
| 254 // Adjust PC for any intrinsic code that could have been generated | 281 if (offset == 0) { |
| 282 sw(T0, Address(SP, 3 * kWordSize)); |
| 283 } else { |
| 284 // Adjust saved PC for any intrinsic code that could have been generated |
| 255 // before a frame is created. | 285 // before a frame is created. |
| 256 addiu(T0, T0, Immediate(-offset)); | 286 AddImmediate(T1, T0, -offset); |
| 287 sw(T1, Address(SP, 3 * kWordSize)); |
| 257 } | 288 } |
| 258 | 289 |
| 259 // Save PC in frame for fast identification of corresponding code. | |
| 260 sw(T0, Address(SP, 3 * kWordSize)); | |
| 261 | |
| 262 // Set FP to the saved previous FP. | 290 // Set FP to the saved previous FP. |
| 263 addiu(FP, SP, Immediate(kWordSize)); | 291 addiu(FP, SP, Immediate(kWordSize)); |
| 264 | 292 |
| 265 // Load the pool pointer. | 293 // Load the pool pointer. |
| 266 lw(PP, Address(T0, -object_pool_pc_dist)); | 294 lw(PP, Address(T0, -object_pool_pc_dist)); |
| 267 | 295 |
| 268 // Reserve space for locals. | 296 // Reserve space for locals. |
| 269 addiu(SP, SP, Immediate(-frame_size)); | 297 AddImmediate(SP, -frame_size); |
| 270 } | 298 } |
| 271 | 299 |
| 272 | 300 |
| 273 void Assembler::LeaveDartFrame() { | 301 void Assembler::LeaveDartFrame() { |
| 274 addiu(SP, FP, Immediate(-kWordSize)); | 302 addiu(SP, FP, Immediate(-kWordSize)); |
| 275 | 303 |
| 276 lw(RA, Address(SP, 2 * kWordSize)); | 304 lw(RA, Address(SP, 2 * kWordSize)); |
| 277 lw(FP, Address(SP, 1 * kWordSize)); | 305 lw(FP, Address(SP, 1 * kWordSize)); |
| 278 lw(PP, Address(SP, 0 * kWordSize)); | 306 lw(PP, Address(SP, 0 * kWordSize)); |
| 279 | 307 |
| 280 // Adjust SP for PC pushed in EnterDartFrame. | 308 // Adjust SP for PC pushed in EnterDartFrame. |
| 281 addiu(SP, SP, Immediate(4 * kWordSize)); | 309 addiu(SP, SP, Immediate(4 * kWordSize)); |
| 282 } | 310 } |
| 283 | 311 |
| 284 | 312 |
| 285 void Assembler::ReserveAlignedFrameSpace(intptr_t frame_space) { | 313 void Assembler::ReserveAlignedFrameSpace(intptr_t frame_space) { |
| 286 // Reserve space for arguments and align frame before entering | 314 // Reserve space for arguments and align frame before entering |
| 287 // the C++ world. | 315 // the C++ world. |
| 288 addiu(SP, SP, Immediate(-frame_space)); | 316 AddImmediate(SP, -frame_space); |
| 289 if (OS::ActivationFrameAlignment() > 0) { | 317 if (OS::ActivationFrameAlignment() > 0) { |
| 290 LoadImmediate(TMP1, ~(OS::ActivationFrameAlignment() - 1)); | 318 LoadImmediate(TMP1, ~(OS::ActivationFrameAlignment() - 1)); |
| 291 and_(SP, SP, TMP1); | 319 and_(SP, SP, TMP1); |
| 292 } | 320 } |
| 293 } | 321 } |
| 294 | 322 |
| 295 | 323 |
| 296 int32_t Assembler::AddExternalLabel(const ExternalLabel* label) { | 324 int32_t Assembler::AddExternalLabel(const ExternalLabel* label) { |
| 297 if (object_pool_.IsNull()) { | 325 if (object_pool_.IsNull()) { |
| 298 // The object pool cannot be used in the vm isolate. | 326 // The object pool cannot be used in the vm isolate. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 318 b(&stop); | 346 b(&stop); |
| 319 Emit(reinterpret_cast<int32_t>(message)); | 347 Emit(reinterpret_cast<int32_t>(message)); |
| 320 Bind(&stop); | 348 Bind(&stop); |
| 321 break_(Instr::kStopMessageCode); | 349 break_(Instr::kStopMessageCode); |
| 322 } | 350 } |
| 323 | 351 |
| 324 } // namespace dart | 352 } // namespace dart |
| 325 | 353 |
| 326 #endif // defined TARGET_ARCH_MIPS | 354 #endif // defined TARGET_ARCH_MIPS |
| 327 | 355 |
| OLD | NEW |