Changeset 44341 in webkit for trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h
- Timestamp:
- Jun 1, 2009, 6:20:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h
r44076 r44341 35 35 #if ENABLE(ASSEMBLER) 36 36 37 // FIXME: keep transitioning this out into MacroAssemblerX86_64. 38 #if PLATFORM(X86_64) 39 #define REPTACH_OFFSET_CALL_R11 3 40 #endif 41 37 42 namespace JSC { 38 43 … … 48 53 class CodeLocationJump; 49 54 class CodeLocationCall; 55 class CodeLocationNearCall; 50 56 class CodeLocationDataLabel32; 51 57 class CodeLocationDataLabelPtr; … … 422 428 CodeLocationJump jumpAtOffset(int offset); 423 429 CodeLocationCall callAtOffset(int offset); 430 CodeLocationNearCall nearCallAtOffset(int offset); 424 431 CodeLocationDataLabelPtr dataLabelPtrAtOffset(int offset); 425 432 CodeLocationDataLabel32 dataLabel32AtOffset(int offset); … … 447 454 } 448 455 449 void patchLoadToLEA() { 450 AssemblerType::patchLoadToLEA(reinterpret_cast<intptr_t>(this->m_location)); 456 void repatchLoadToLEA() 457 { 458 AssemblerType::repatchLoadToLEA(this->m_location); 451 459 } 452 460 … … 464 472 friend class CodeLocationCommon; 465 473 friend class CodeLocationJump; 474 friend class CodeLocationCall; 475 friend class CodeLocationNearCall; 466 476 friend class PatchBuffer; 467 477 friend class ProcessorReturnAddress; … … 476 486 void* addressForJSR() { return this->m_location; } 477 487 488 template<typename FunctionSig> 489 static CodeLocationLabel fromFunctionPointer(FunctionSig* function) 490 { 491 return CodeLocationLabel(reinterpret_cast<void*>(function)); 492 } 493 478 494 private: 479 495 explicit CodeLocationLabel(void* location) … … 498 514 void relink(CodeLocationLabel destination) 499 515 { 500 AssemblerType:: patchJump(reinterpret_cast<intptr_t>(this->m_location), destination.m_location);516 AssemblerType::relinkJump(this->m_location, destination.m_location); 501 517 } 502 518 … … 519 535 } 520 536 537 CodeLocationCall(ProcessorReturnAddress*); 538 539 void relink(CodeLocationLabel destination) 540 { 541 #if PLATFORM(X86_64) 542 CodeLocationCommon::dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).repatch(destination.m_location); 543 #else 544 AssemblerType::relinkCall(this->m_location, destination.m_location); 545 #endif 546 } 547 521 548 template<typename FunctionSig> 522 549 void relink(FunctionSig* function) 523 550 { 524 AssemblerType::patchMacroAssemblerCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(function));551 relink(CodeLocationLabel::fromFunctionPointer(function)); 525 552 } 526 553 … … 550 577 } 551 578 579 CodeLocationNearCall(ProcessorReturnAddress*); 580 581 void relink(CodeLocationLabel destination) 582 { 583 AssemblerType::relinkCall(this->m_location, destination.m_location); 584 } 585 552 586 template<typename FunctionSig> 553 587 void relink(FunctionSig* function) 554 588 { 555 AssemblerType::patchCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(function));589 relink(CodeLocationLabel::fromFunctionPointer(function)); 556 590 } 557 591 … … 583 617 void repatch(int32_t value) 584 618 { 585 AssemblerType:: patchImmediate(reinterpret_cast<intptr_t>(this->m_location), value);619 AssemblerType::repatchInt32(this->m_location, value); 586 620 } 587 621 … … 606 640 void repatch(void* value) 607 641 { 608 AssemblerType:: patchPointer(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<intptr_t>(value));642 AssemblerType::repatchPointer(this->m_location, value); 609 643 } 610 644 … … 620 654 // This class can be used to relink a call identified by its return address. 621 655 class ProcessorReturnAddress { 656 friend class CodeLocationCall; 657 friend class CodeLocationNearCall; 622 658 public: 623 659 ProcessorReturnAddress(void* location) … … 628 664 void relinkCallerToTrampoline(CodeLocationLabel label) 629 665 { 630 AssemblerType::patchMacroAssemblerCall(reinterpret_cast<intptr_t>(this->m_location), label.getJumpDestination());666 CodeLocationCall(this).relink(label); 631 667 } 632 668 … … 634 670 void relinkCallerToFunction(FunctionSig* newCalleeFunction) 635 671 { 636 AssemblerType::patchMacroAssemblerCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(newCalleeFunction)); 672 relinkCallerToTrampoline(CodeLocationLabel::fromFunctionPointer(newCalleeFunction)); 673 } 674 675 void relinkNearCallerToTrampoline(CodeLocationLabel label) 676 { 677 CodeLocationNearCall(this).relink(label); 637 678 } 638 679 … … 640 681 void relinkNearCallerToFunction(FunctionSig* newCalleeFunction) 641 682 { 642 AssemblerType::patchCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(newCalleeFunction));683 relinkNearCallerToTrampoline(CodeLocationLabel::fromFunctionPointer(newCalleeFunction)); 643 684 } 644 685 … … 681 722 PatchBuffer(AbstractMacroAssembler<AssemblerType>* masm, PassRefPtr<ExecutablePool> executablePool) 682 723 : m_ref(0, executablePool, masm->m_assembler.size()) 724 , m_size(masm->m_assembler.size()) 683 725 #ifndef NDEBUG 684 726 , m_completed(false) … … 688 730 } 689 731 690 #ifndef NDEBUG691 732 ~PatchBuffer() 692 733 { 693 734 ASSERT(m_completed); 694 735 } 695 #endif696 736 697 737 // These methods are used to link or set values at code generation time. … … 702 742 ASSERT(call.isFlagSet(Call::Linkable)); 703 743 #if PLATFORM(X86_64) 704 if (call.isFlagSet(Call::Near)) 705 AssemblerType::linkCall(code(), call.m_jmp, reinterpret_cast<void*>(function)); 706 else { 707 intptr_t callLocation = reinterpret_cast<intptr_t>(AssemblerType::getRelocatedAddress(code(), call.m_jmp)); 708 AssemblerType::patchMacroAssemblerCall(callLocation, reinterpret_cast<void*>(function)); 709 } 710 #else 744 if (!call.isFlagSet(Call::Near)) { 745 intptr_t callLocation = reinterpret_cast<intptr_t>(AssemblerType::getRelocatedAddress(code(), call.m_jmp)) - REPTACH_OFFSET_CALL_R11; 746 AssemblerType::patchPointer(reinterpret_cast<void*>(callLocation), reinterpret_cast<void*>(function)); 747 } else 748 #endif 711 749 AssemblerType::linkCall(code(), call.m_jmp, reinterpret_cast<void*>(function)); 712 #endif713 750 } 714 751 … … 739 776 void patch(DataLabelPtr label, void* value) 740 777 { 741 AssemblerType::patch Address(code(), label.m_label, value);778 AssemblerType::patchPointer(code(), label.m_label, value); 742 779 } 743 780 744 781 void patch(DataLabelPtr label, CodeLocationLabel value) 745 782 { 746 AssemblerType::patch Address(code(), label.m_label, value.getJumpDestination());783 AssemblerType::patchPointer(code(), label.m_label, value.getJumpDestination()); 747 784 } 748 785 … … 816 853 m_completed = true; 817 854 #endif 855 856 ExecutableAllocator::makeExecutable(m_ref.m_code, m_size); 818 857 } 819 858 820 859 CodeRef m_ref; 860 size_t m_size; 821 861 #ifndef NDEBUG 822 862 bool m_completed; … … 913 953 914 954 template <class AssemblerType> 955 typename AbstractMacroAssembler<AssemblerType>::CodeLocationNearCall AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::nearCallAtOffset(int offset) 956 { 957 return typename AbstractMacroAssembler::CodeLocationNearCall(reinterpret_cast<char*>(m_location) + offset); 958 } 959 960 template <class AssemblerType> 915 961 typename AbstractMacroAssembler<AssemblerType>::CodeLocationDataLabelPtr AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::dataLabelPtrAtOffset(int offset) 916 962 { … … 924 970 } 925 971 972 template <class AssemblerType> 973 AbstractMacroAssembler<AssemblerType>::CodeLocationCall::CodeLocationCall(AbstractMacroAssembler<AssemblerType>::ProcessorReturnAddress* ra) 974 : CodeLocationCommon(ra->m_location) 975 { 976 } 977 978 template <class AssemblerType> 979 AbstractMacroAssembler<AssemblerType>::CodeLocationNearCall::CodeLocationNearCall(AbstractMacroAssembler<AssemblerType>::ProcessorReturnAddress* ra) 980 : CodeLocationCommon(ra->m_location) 981 { 982 } 926 983 927 984 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.