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/mips64/codegen-mips64.h" | 5 #include "src/mips64/codegen-mips64.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 } | 728 } |
729 #endif | 729 #endif |
730 | 730 |
731 | 731 |
732 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { | 732 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { |
733 bool result = isolate->code_aging_helper()->IsYoung(sequence); | 733 bool result = isolate->code_aging_helper()->IsYoung(sequence); |
734 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); | 734 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); |
735 return result; | 735 return result; |
736 } | 736 } |
737 | 737 |
| 738 Code::Age Code::GetCodeAge(Isolate* isolate, byte* sequence) { |
| 739 if (IsYoungSequence(isolate, sequence)) return kNoAgeCodeAge; |
738 | 740 |
739 void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age, | 741 Address target_address = |
740 MarkingParity* parity) { | 742 Assembler::target_address_at(sequence + Assembler::kInstrSize); |
741 if (IsYoungSequence(isolate, sequence)) { | 743 Code* stub = GetCodeFromTargetAddress(target_address); |
742 *age = kNoAgeCodeAge; | 744 return GetAgeOfCodeAgeStub(stub); |
743 *parity = NO_MARKING_PARITY; | |
744 } else { | |
745 Address target_address = Assembler::target_address_at( | |
746 sequence + Assembler::kInstrSize); | |
747 Code* stub = GetCodeFromTargetAddress(target_address); | |
748 GetCodeAgeAndParity(stub, age, parity); | |
749 } | |
750 } | 745 } |
751 | 746 |
752 | 747 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, |
753 void Code::PatchPlatformCodeAge(Isolate* isolate, | 748 Code::Age age) { |
754 byte* sequence, | |
755 Code::Age age, | |
756 MarkingParity parity) { | |
757 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 749 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
758 if (age == kNoAgeCodeAge) { | 750 if (age == kNoAgeCodeAge) { |
759 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 751 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
760 Assembler::FlushICache(isolate, sequence, young_length); | 752 Assembler::FlushICache(isolate, sequence, young_length); |
761 } else { | 753 } else { |
762 Code* stub = GetCodeAgeStub(isolate, age, parity); | 754 Code* stub = GetCodeAgeStub(isolate, age); |
763 CodePatcher patcher(isolate, sequence, | 755 CodePatcher patcher(isolate, sequence, |
764 young_length / Assembler::kInstrSize); | 756 young_length / Assembler::kInstrSize); |
765 // Mark this code sequence for FindPlatformCodeAgeSequence(). | 757 // Mark this code sequence for FindPlatformCodeAgeSequence(). |
766 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); | 758 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); |
767 // Load the stub address to t9 and call it, | 759 // Load the stub address to t9 and call it, |
768 // GetCodeAgeAndParity() extracts the stub address from this instruction. | 760 // GetCodeAge() extracts the stub address from this instruction. |
769 patcher.masm()->li( | 761 patcher.masm()->li( |
770 t9, | 762 t9, |
771 Operand(reinterpret_cast<uint64_t>(stub->instruction_start())), | 763 Operand(reinterpret_cast<uint64_t>(stub->instruction_start())), |
772 ADDRESS_LOAD); | 764 ADDRESS_LOAD); |
773 patcher.masm()->nop(); // Prevent jalr to jal optimization. | 765 patcher.masm()->nop(); // Prevent jalr to jal optimization. |
774 patcher.masm()->jalr(t9, a0); | 766 patcher.masm()->jalr(t9, a0); |
775 patcher.masm()->nop(); // Branch delay slot nop. | 767 patcher.masm()->nop(); // Branch delay slot nop. |
776 patcher.masm()->nop(); // Pad the empty space. | 768 patcher.masm()->nop(); // Pad the empty space. |
777 } | 769 } |
778 } | 770 } |
779 | 771 |
780 | 772 |
781 #undef __ | 773 #undef __ |
782 | 774 |
783 } // namespace internal | 775 } // namespace internal |
784 } // namespace v8 | 776 } // namespace v8 |
785 | 777 |
786 #endif // V8_TARGET_ARCH_MIPS64 | 778 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |