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