| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/mips/codegen-mips.h" | 5 #include "src/mips/codegen-mips.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 724 } |
| 725 #endif | 725 #endif |
| 726 | 726 |
| 727 | 727 |
| 728 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { | 728 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { |
| 729 bool result = isolate->code_aging_helper()->IsYoung(sequence); | 729 bool result = isolate->code_aging_helper()->IsYoung(sequence); |
| 730 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); | 730 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); |
| 731 return result; | 731 return result; |
| 732 } | 732 } |
| 733 | 733 |
| 734 Code::Age Code::GetCodeAge(Isolate* isolate, byte* sequence) { |
| 735 if (IsYoungSequence(isolate, sequence)) return kNoAgeCodeAge; |
| 734 | 736 |
| 735 void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age, | 737 Address target_address = |
| 736 MarkingParity* parity) { | 738 Assembler::target_address_at(sequence + Assembler::kInstrSize); |
| 737 if (IsYoungSequence(isolate, sequence)) { | 739 Code* stub = GetCodeFromTargetAddress(target_address); |
| 738 *age = kNoAgeCodeAge; | 740 return GetAgeOfCodeAgeStub(stub); |
| 739 *parity = NO_MARKING_PARITY; | |
| 740 } else { | |
| 741 Address target_address = Assembler::target_address_at( | |
| 742 sequence + Assembler::kInstrSize); | |
| 743 Code* stub = GetCodeFromTargetAddress(target_address); | |
| 744 GetCodeAgeAndParity(stub, age, parity); | |
| 745 } | |
| 746 } | 741 } |
| 747 | 742 |
| 748 | 743 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, |
| 749 void Code::PatchPlatformCodeAge(Isolate* isolate, | 744 Code::Age age) { |
| 750 byte* sequence, | |
| 751 Code::Age age, | |
| 752 MarkingParity parity) { | |
| 753 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 745 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
| 754 if (age == kNoAgeCodeAge) { | 746 if (age == kNoAgeCodeAge) { |
| 755 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 747 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
| 756 Assembler::FlushICache(isolate, sequence, young_length); | 748 Assembler::FlushICache(isolate, sequence, young_length); |
| 757 } else { | 749 } else { |
| 758 Code* stub = GetCodeAgeStub(isolate, age, parity); | 750 Code* stub = GetCodeAgeStub(isolate, age); |
| 759 CodePatcher patcher(isolate, sequence, | 751 CodePatcher patcher(isolate, sequence, |
| 760 young_length / Assembler::kInstrSize); | 752 young_length / Assembler::kInstrSize); |
| 761 // Mark this code sequence for FindPlatformCodeAgeSequence(). | 753 // Mark this code sequence for FindPlatformCodeAgeSequence(). |
| 762 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); | 754 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); |
| 763 // Load the stub address to t9 and call it, | 755 // Load the stub address to t9 and call it, |
| 764 // GetCodeAgeAndParity() extracts the stub address from this instruction. | 756 // GetCodeAge() extracts the stub address from this instruction. |
| 765 patcher.masm()->li( | 757 patcher.masm()->li( |
| 766 t9, | 758 t9, |
| 767 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), | 759 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), |
| 768 CONSTANT_SIZE); | 760 CONSTANT_SIZE); |
| 769 patcher.masm()->nop(); // Prevent jalr to jal optimization. | 761 patcher.masm()->nop(); // Prevent jalr to jal optimization. |
| 770 patcher.masm()->jalr(t9, a0); | 762 patcher.masm()->jalr(t9, a0); |
| 771 patcher.masm()->nop(); // Branch delay slot nop. | 763 patcher.masm()->nop(); // Branch delay slot nop. |
| 772 patcher.masm()->nop(); // Pad the empty space. | 764 patcher.masm()->nop(); // Pad the empty space. |
| 773 } | 765 } |
| 774 } | 766 } |
| 775 | 767 |
| 776 | 768 |
| 777 #undef __ | 769 #undef __ |
| 778 | 770 |
| 779 } // namespace internal | 771 } // namespace internal |
| 780 } // namespace v8 | 772 } // namespace v8 |
| 781 | 773 |
| 782 #endif // V8_TARGET_ARCH_MIPS | 774 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |