| 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 return result; | 635 return result; |
| 636 } | 636 } |
| 637 | 637 |
| 638 | 638 |
| 639 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, | 639 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, |
| 640 MarkingParity* parity) { | 640 MarkingParity* parity) { |
| 641 if (IsYoungSequence(sequence)) { | 641 if (IsYoungSequence(sequence)) { |
| 642 *age = kNoAgeCodeAge; | 642 *age = kNoAgeCodeAge; |
| 643 *parity = NO_MARKING_PARITY; | 643 *parity = NO_MARKING_PARITY; |
| 644 } else { | 644 } else { |
| 645 Address target_address = Memory::Address_at( | 645 Address target_address = Assembler::target_address_at( |
| 646 sequence + Assembler::kInstrSize * (kNoCodeAgeSequenceLength - 1)); | 646 sequence + Assembler::kInstrSize); |
| 647 Code* stub = GetCodeFromTargetAddress(target_address); | 647 Code* stub = GetCodeFromTargetAddress(target_address); |
| 648 GetCodeAgeAndParity(stub, age, parity); | 648 GetCodeAgeAndParity(stub, age, parity); |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 | 651 |
| 652 | 652 |
| 653 void Code::PatchPlatformCodeAge(Isolate* isolate, | 653 void Code::PatchPlatformCodeAge(Isolate* isolate, |
| 654 byte* sequence, | 654 byte* sequence, |
| 655 Code::Age age, | 655 Code::Age age, |
| 656 MarkingParity parity) { | 656 MarkingParity parity) { |
| 657 uint32_t young_length; | 657 uint32_t young_length; |
| 658 byte* young_sequence = GetNoCodeAgeSequence(&young_length); | 658 byte* young_sequence = GetNoCodeAgeSequence(&young_length); |
| 659 if (age == kNoAgeCodeAge) { | 659 if (age == kNoAgeCodeAge) { |
| 660 CopyBytes(sequence, young_sequence, young_length); | 660 CopyBytes(sequence, young_sequence, young_length); |
| 661 CPU::FlushICache(sequence, young_length); | 661 CPU::FlushICache(sequence, young_length); |
| 662 } else { | 662 } else { |
| 663 Code* stub = GetCodeAgeStub(isolate, age, parity); | 663 Code* stub = GetCodeAgeStub(isolate, age, parity); |
| 664 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); | 664 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); |
| 665 // Mark this code sequence for FindPlatformCodeAgeSequence() | 665 // Mark this code sequence for FindPlatformCodeAgeSequence(). |
| 666 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); | 666 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); |
| 667 // Save the function's original return address | 667 // Load the stub address to t9 and call it, |
| 668 // (it will be clobbered by Call(t9)) | 668 // GetCodeAgeAndParity() extracts the stub address from this instruction. |
| 669 patcher.masm()->mov(at, ra); | 669 patcher.masm()->li( |
| 670 // Load the stub address to t9 and call it | 670 t9, |
| 671 patcher.masm()->li(t9, | 671 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), |
| 672 Operand(reinterpret_cast<uint32_t>(stub->instruction_start()))); | 672 CONSTANT_SIZE); |
| 673 patcher.masm()->Call(t9); | 673 patcher.masm()->nop(); // Prevent jalr to jal optimization. |
| 674 // Record the stub address in the empty space for GetCodeAgeAndParity() | 674 patcher.masm()->jalr(t9, a0); |
| 675 patcher.masm()->emit_code_stub_address(stub); | 675 patcher.masm()->nop(); // Branch delay slot nop. |
| 676 patcher.masm()->nop(); // Pad the empty space. |
| 676 } | 677 } |
| 677 } | 678 } |
| 678 | 679 |
| 679 | 680 |
| 680 #undef __ | 681 #undef __ |
| 681 | 682 |
| 682 } } // namespace v8::internal | 683 } } // namespace v8::internal |
| 683 | 684 |
| 684 #endif // V8_TARGET_ARCH_MIPS | 685 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |