OLD | NEW |
1 | 1 |
2 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 2 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
3 // All Rights Reserved. | 3 // All Rights Reserved. |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // - Redistributions of source code must retain the above copyright notice, | 9 // - Redistributions of source code must retain the above copyright notice, |
10 // this list of conditions and the following disclaimer. | 10 // this list of conditions and the following disclaimer. |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } | 431 } |
432 | 432 |
433 | 433 |
434 void Assembler::CheckTrampolinePoolQuick(int extra_instructions) { | 434 void Assembler::CheckTrampolinePoolQuick(int extra_instructions) { |
435 if (pc_offset() >= next_buffer_check_ - extra_instructions * kInstrSize) { | 435 if (pc_offset() >= next_buffer_check_ - extra_instructions * kInstrSize) { |
436 CheckTrampolinePool(); | 436 CheckTrampolinePool(); |
437 } | 437 } |
438 } | 438 } |
439 | 439 |
440 | 440 |
441 void Assembler::emit(Instr x, CompactBranchType is_compact_branch) { | 441 void Assembler::CheckForEmitInForbiddenSlot() { |
442 if (!is_buffer_growth_blocked()) { | 442 if (!is_buffer_growth_blocked()) { |
443 CheckBuffer(); | 443 CheckBuffer(); |
444 } | 444 } |
445 if (IsPrevInstrCompactBranch()) { | 445 if (IsPrevInstrCompactBranch()) { |
| 446 // Nop instruction to preceed a CTI in forbidden slot: |
| 447 Instr nop = SPECIAL | SLL; |
| 448 *reinterpret_cast<Instr*>(pc_) = nop; |
| 449 pc_ += kInstrSize; |
| 450 |
| 451 ClearCompactBranchState(); |
| 452 } |
| 453 } |
| 454 |
| 455 |
| 456 void Assembler::EmitHelper(Instr x, CompactBranchType is_compact_branch) { |
| 457 if (IsPrevInstrCompactBranch()) { |
446 if (Instruction::IsForbiddenAfterBranchInstr(x)) { | 458 if (Instruction::IsForbiddenAfterBranchInstr(x)) { |
447 // Nop instruction to preceed a CTI in forbidden slot: | 459 // Nop instruction to preceed a CTI in forbidden slot: |
448 Instr nop = SPECIAL | SLL; | 460 Instr nop = SPECIAL | SLL; |
449 *reinterpret_cast<Instr*>(pc_) = nop; | 461 *reinterpret_cast<Instr*>(pc_) = nop; |
450 pc_ += kInstrSize; | 462 pc_ += kInstrSize; |
451 } | 463 } |
452 ClearCompactBranchState(); | 464 ClearCompactBranchState(); |
453 } | 465 } |
454 *reinterpret_cast<Instr*>(pc_) = x; | 466 *reinterpret_cast<Instr*>(pc_) = x; |
455 pc_ += kInstrSize; | 467 pc_ += kInstrSize; |
456 if (is_compact_branch == CompactBranchType::COMPACT_BRANCH) { | 468 if (is_compact_branch == CompactBranchType::COMPACT_BRANCH) { |
457 EmittedCompactBranchInstruction(); | 469 EmittedCompactBranchInstruction(); |
458 } | 470 } |
459 CheckTrampolinePoolQuick(); | 471 CheckTrampolinePoolQuick(); |
460 } | 472 } |
461 | 473 |
462 | 474 |
463 void Assembler::emit(uint64_t x) { | 475 template <typename T> |
464 if (!is_buffer_growth_blocked()) { | 476 void Assembler::EmitHelper(T x) { |
465 CheckBuffer(); | 477 *reinterpret_cast<T*>(pc_) = x; |
466 } | 478 pc_ += sizeof(x); |
467 if (IsPrevInstrCompactBranch()) { | |
468 // Nop instruction to preceed a CTI in forbidden slot: | |
469 Instr nop = SPECIAL | SLL; | |
470 *reinterpret_cast<Instr*>(pc_) = nop; | |
471 pc_ += kInstrSize; | |
472 | |
473 ClearCompactBranchState(); | |
474 } | |
475 *reinterpret_cast<uint64_t*>(pc_) = x; | |
476 pc_ += kInstrSize * 2; | |
477 CheckTrampolinePoolQuick(); | 479 CheckTrampolinePoolQuick(); |
478 } | 480 } |
479 | 481 |
480 | 482 |
| 483 void Assembler::emit(Instr x, CompactBranchType is_compact_branch) { |
| 484 if (!is_buffer_growth_blocked()) { |
| 485 CheckBuffer(); |
| 486 } |
| 487 EmitHelper(x, is_compact_branch); |
| 488 } |
| 489 |
| 490 |
| 491 void Assembler::emit(uint64_t data) { |
| 492 CheckForEmitInForbiddenSlot(); |
| 493 EmitHelper(data); |
| 494 } |
| 495 |
| 496 |
481 } // namespace internal | 497 } // namespace internal |
482 } // namespace v8 | 498 } // namespace v8 |
483 | 499 |
484 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ | 500 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
OLD | NEW |