OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 bool result = !memcmp(sequence, young_sequence, young_length); | 631 bool result = !memcmp(sequence, young_sequence, young_length); |
632 ASSERT(result || | 632 ASSERT(result || |
633 Memory::uint32_at(sequence) == kCodeAgePatchFirstInstruction); | 633 Memory::uint32_at(sequence) == kCodeAgePatchFirstInstruction); |
634 return result; | 634 return result; |
635 } | 635 } |
636 | 636 |
637 | 637 |
638 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, | 638 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, |
639 MarkingParity* parity) { | 639 MarkingParity* parity) { |
640 if (IsYoungSequence(sequence)) { | 640 if (IsYoungSequence(sequence)) { |
641 *age = kNoAge; | 641 *age = kNoAgeCodeAge; |
642 *parity = NO_MARKING_PARITY; | 642 *parity = NO_MARKING_PARITY; |
643 } else { | 643 } else { |
644 Address target_address = Memory::Address_at( | 644 Address target_address = Memory::Address_at( |
645 sequence + Assembler::kInstrSize * (kNoCodeAgeSequenceLength - 1)); | 645 sequence + Assembler::kInstrSize * (kNoCodeAgeSequenceLength - 1)); |
646 Code* stub = GetCodeFromTargetAddress(target_address); | 646 Code* stub = GetCodeFromTargetAddress(target_address); |
647 GetCodeAgeAndParity(stub, age, parity); | 647 GetCodeAgeAndParity(stub, age, parity); |
648 } | 648 } |
649 } | 649 } |
650 | 650 |
651 | 651 |
652 void Code::PatchPlatformCodeAge(Isolate* isolate, | 652 void Code::PatchPlatformCodeAge(Isolate* isolate, |
653 byte* sequence, | 653 byte* sequence, |
654 Code::Age age, | 654 Code::Age age, |
655 MarkingParity parity) { | 655 MarkingParity parity) { |
656 uint32_t young_length; | 656 uint32_t young_length; |
657 byte* young_sequence = GetNoCodeAgeSequence(&young_length); | 657 byte* young_sequence = GetNoCodeAgeSequence(&young_length); |
658 if (age == kNoAge) { | 658 if (age == kNoAgeCodeAge) { |
659 CopyBytes(sequence, young_sequence, young_length); | 659 CopyBytes(sequence, young_sequence, young_length); |
660 CPU::FlushICache(sequence, young_length); | 660 CPU::FlushICache(sequence, young_length); |
661 } else { | 661 } else { |
662 Code* stub = GetCodeAgeStub(isolate, age, parity); | 662 Code* stub = GetCodeAgeStub(isolate, age, parity); |
663 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); | 663 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); |
664 // Mark this code sequence for FindPlatformCodeAgeSequence() | 664 // Mark this code sequence for FindPlatformCodeAgeSequence() |
665 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); | 665 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); |
666 // Save the function's original return address | 666 // Save the function's original return address |
667 // (it will be clobbered by Call(t9)) | 667 // (it will be clobbered by Call(t9)) |
668 patcher.masm()->mov(at, ra); | 668 patcher.masm()->mov(at, ra); |
669 // Load the stub address to t9 and call it | 669 // Load the stub address to t9 and call it |
670 patcher.masm()->li(t9, | 670 patcher.masm()->li(t9, |
671 Operand(reinterpret_cast<uint32_t>(stub->instruction_start()))); | 671 Operand(reinterpret_cast<uint32_t>(stub->instruction_start()))); |
672 patcher.masm()->Call(t9); | 672 patcher.masm()->Call(t9); |
673 // Record the stub address in the empty space for GetCodeAgeAndParity() | 673 // Record the stub address in the empty space for GetCodeAgeAndParity() |
674 patcher.masm()->dd(reinterpret_cast<uint32_t>(stub->instruction_start())); | 674 patcher.masm()->dd(reinterpret_cast<uint32_t>(stub->instruction_start())); |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 | 678 |
679 #undef __ | 679 #undef __ |
680 | 680 |
681 } } // namespace v8::internal | 681 } } // namespace v8::internal |
682 | 682 |
683 #endif // V8_TARGET_ARCH_MIPS | 683 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |