| 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" |
| 11 #include "vm/stack_frame.h" |
| 11 #include "vm/stub_code.h" | 12 #include "vm/stub_code.h" |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 15 #if defined(USING_SIMULATOR) | 16 #if defined(USING_SIMULATOR) |
| 16 DECLARE_FLAG(bool, trace_sim); | 17 DECLARE_FLAG(bool, trace_sim); |
| 17 #endif | 18 #endif |
| 18 DEFINE_FLAG(bool, print_stop_message, false, "Print stop message."); | 19 DEFINE_FLAG(bool, print_stop_message, false, "Print stop message."); |
| 19 DECLARE_FLAG(bool, inline_alloc); | 20 DECLARE_FLAG(bool, inline_alloc); |
| 20 | 21 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 // Branch and link to the instruction after the delay slot to get the PC. | 469 // Branch and link to the instruction after the delay slot to get the PC. |
| 469 bal(&next); | 470 bal(&next); |
| 470 // RA is the address of the sw instruction below. Save it in T0. | 471 // RA is the address of the sw instruction below. Save it in T0. |
| 471 delay_slot()->mov(TMP1, RA); | 472 delay_slot()->mov(TMP1, RA); |
| 472 | 473 |
| 473 // Calculate the offset of the pool pointer from the PC. | 474 // Calculate the offset of the pool pointer from the PC. |
| 474 const intptr_t object_pool_pc_dist = | 475 const intptr_t object_pool_pc_dist = |
| 475 Instructions::HeaderSize() - Instructions::object_pool_offset() + | 476 Instructions::HeaderSize() - Instructions::object_pool_offset() + |
| 476 CodeSize(); | 477 CodeSize(); |
| 477 | 478 |
| 478 // This sw instruction is the return address for the bal, so T0 holds | 479 // TMP1 has the address of the next instruction. |
| 479 // the PC at this sw instruction. | |
| 480 Bind(&next); | 480 Bind(&next); |
| 481 | 481 |
| 482 // Save PC in frame for fast identification of corresponding code. | 482 // Save PC in frame for fast identification of corresponding code. |
| 483 if (offset == 0) { | 483 AddImmediate(TMP1, -offset); |
| 484 sw(TMP1, Address(SP, 3 * kWordSize)); | 484 sw(TMP1, Address(SP, 3 * kWordSize)); |
| 485 } else { | |
| 486 // Adjust saved PC for any intrinsic code that could have been generated | |
| 487 // before a frame is created. | |
| 488 addiu(TMP1, TMP1, Immediate(-offset)); | |
| 489 sw(TMP1, Address(SP, 3 * kWordSize)); | |
| 490 } | |
| 491 | 485 |
| 492 // Set FP to the saved previous FP. | 486 // Set FP to the saved previous FP. |
| 493 addiu(FP, SP, Immediate(kWordSize)); | 487 addiu(FP, SP, Immediate(kWordSize)); |
| 494 | 488 |
| 495 // Load the pool pointer. offset has already been subtracted from TMP1. | 489 // Load the pool pointer. offset has already been subtracted from TMP1. |
| 496 lw(PP, Address(TMP1, -object_pool_pc_dist + offset)); | 490 lw(PP, Address(TMP1, -object_pool_pc_dist + offset)); |
| 497 | 491 |
| 498 // Reserve space for locals. | 492 // Reserve space for locals. |
| 499 AddImmediate(SP, -frame_size); | 493 AddImmediate(SP, -frame_size); |
| 500 } | 494 } |
| 501 | 495 |
| 502 | 496 |
| 497 // On entry to a function compiled for OSR, the caller's frame pointer, the |
| 498 // stack locals, and any copied parameters are already in place. The frame |
| 499 // pointer is already set up. The PC marker is not correct for the |
| 500 // optimized function and there may be extra space for spill slots to |
| 501 // allocate. We must also set up the pool pointer for the function. |
| 502 void Assembler::EnterOsrFrame(intptr_t extra_size) { |
| 503 Comment("EnterOsrFrame"); |
| 504 Label next; |
| 505 // Branch and link to the instruction after the delay slot to get the PC. |
| 506 bal(&next); |
| 507 // RA is the address of the sw instruction below. Save it in T0. |
| 508 delay_slot()->mov(TMP, RA); |
| 509 |
| 510 // The runtime system assumes that the code marker address is |
| 511 // kEntryPointToPcMarkerOffset bytes from the entry. Since there is no |
| 512 // code to set up the frame pointer, etc., the address needs to be adjusted. |
| 513 const intptr_t offset = kEntryPointToPcMarkerOffset - CodeSize(); |
| 514 // Calculate the offset of the pool pointer from the PC. |
| 515 const intptr_t object_pool_pc_dist = |
| 516 Instructions::HeaderSize() - Instructions::object_pool_offset() + |
| 517 CodeSize(); |
| 518 |
| 519 // temp has the address of the next instruction. |
| 520 Bind(&next); |
| 521 |
| 522 // Adjust PC by the offset, and store it in the stack frame. |
| 523 AddImmediate(TMP, TMP, offset); |
| 524 sw(TMP, Address(FP, kPcMarkerSlotFromFp * kWordSize)); |
| 525 |
| 526 // Restore return address. |
| 527 lw(RA, Address(FP, 1 * kWordSize)); |
| 528 |
| 529 // Load the pool pointer. offset has already been subtracted from temp. |
| 530 lw(PP, Address(TMP, -object_pool_pc_dist - offset)); |
| 531 |
| 532 // Reserve space for locals. |
| 533 AddImmediate(SP, -extra_size); |
| 534 } |
| 535 |
| 536 |
| 503 void Assembler::LeaveDartFrame() { | 537 void Assembler::LeaveDartFrame() { |
| 504 addiu(SP, FP, Immediate(-kWordSize)); | 538 addiu(SP, FP, Immediate(-kWordSize)); |
| 505 | 539 |
| 506 lw(RA, Address(SP, 2 * kWordSize)); | 540 lw(RA, Address(SP, 2 * kWordSize)); |
| 507 lw(FP, Address(SP, 1 * kWordSize)); | 541 lw(FP, Address(SP, 1 * kWordSize)); |
| 508 lw(PP, Address(SP, 0 * kWordSize)); | 542 lw(PP, Address(SP, 0 * kWordSize)); |
| 509 | 543 |
| 510 // Adjust SP for PC, RA, FP, PP pushed in EnterDartFrame. | 544 // Adjust SP for PC, RA, FP, PP pushed in EnterDartFrame. |
| 511 addiu(SP, SP, Immediate(4 * kWordSize)); | 545 addiu(SP, SP, Immediate(4 * kWordSize)); |
| 512 } | 546 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 Bind(&msg); | 711 Bind(&msg); |
| 678 break_(Instr::kMsgMessageCode); | 712 break_(Instr::kMsgMessageCode); |
| 679 } | 713 } |
| 680 #endif | 714 #endif |
| 681 } | 715 } |
| 682 | 716 |
| 683 } // namespace dart | 717 } // namespace dart |
| 684 | 718 |
| 685 #endif // defined TARGET_ARCH_MIPS | 719 #endif // defined TARGET_ARCH_MIPS |
| 686 | 720 |
| OLD | NEW |