Changeset 44700 in webkit for trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h
- Timestamp:
- Jun 15, 2009, 5:26:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h
r44514 r44700 50 50 class Jump; 51 51 class PatchBuffer; 52 class RepatchBuffer; 52 53 class CodeLocationInstruction; 53 54 class CodeLocationLabel; … … 429 430 // instruction stream, without any semantic information. 430 431 class CodeLocationCommon { 432 friend class RepatchBuffer; 433 431 434 public: 432 435 CodeLocationCommon() … … 469 472 // An arbitrary instruction in the JIT code. 470 473 class CodeLocationInstruction : public CodeLocationCommon { 471 friend class CodeLocationCommon;472 474 public: 473 475 CodeLocationInstruction() … … 475 477 } 476 478 477 void repatchLoadPtrToLEA()478 {479 AssemblerType::repatchLoadPtrToLEA(this->dataLocation());480 }481 482 private:483 479 explicit CodeLocationInstruction(void* location) 484 480 : CodeLocationCommon(CodePtr(location)) … … 496 492 friend class CodeLocationNearCall; 497 493 friend class PatchBuffer; 494 friend class RepatchBuffer; 498 495 friend class ProcessorReturnAddress; 499 496 … … 542 539 } 543 540 544 void relink(CodeLocationLabel destination)545 {546 AssemblerType::relinkJump(this->dataLocation(), destination.dataLocation());547 }548 549 private:550 541 explicit CodeLocationJump(void* location) 551 542 : CodeLocationCommon(CodePtr(location)) … … 558 549 // A point in the JIT code at which there is a call instruction. 559 550 class CodeLocationCall : public CodeLocationCommon { 560 friend class CodeLocationCommon;561 friend class PatchBuffer;562 friend class ProcessorReturnAddress;563 551 public: 564 552 CodeLocationCall() … … 566 554 } 567 555 568 void relink(CodeLocationLabel destination) 569 { 570 #if PLATFORM(X86_64) 571 CodeLocationCommon::dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).repatch(destination.executableAddress()); 572 #else 573 AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress()); 574 #endif 575 } 576 577 void relink(FunctionPtr destination) 578 { 579 #if PLATFORM(X86_64) 580 CodeLocationCommon::dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11).repatch(destination.executableAddress()); 581 #else 582 AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress()); 583 #endif 556 explicit CodeLocationCall(CodePtr location) 557 : CodeLocationCommon(location) 558 { 559 } 560 561 explicit CodeLocationCall(void* location) 562 : CodeLocationCommon(CodePtr(location)) 563 { 584 564 } 585 565 … … 591 571 } 592 572 593 private:594 explicit CodeLocationCall(CodePtr location)595 : CodeLocationCommon(location)596 {597 }598 599 explicit CodeLocationCall(void* location)600 : CodeLocationCommon(CodePtr(location))601 {602 }603 573 }; 604 574 … … 607 577 // A point in the JIT code at which there is a call instruction with near linkage. 608 578 class CodeLocationNearCall : public CodeLocationCommon { 609 friend class CodeLocationCommon;610 friend class PatchBuffer;611 friend class ProcessorReturnAddress;612 579 public: 613 580 CodeLocationNearCall() … … 615 582 } 616 583 617 void relink(CodePtr destination) 618 { 619 AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress()); 620 } 621 622 void relink(CodeLocationLabel destination) 623 { 624 AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress()); 625 } 626 627 void relink(FunctionPtr destination) 628 { 629 AssemblerType::relinkCall(this->dataLocation(), destination.executableAddress()); 584 explicit CodeLocationNearCall(CodePtr location) 585 : CodeLocationCommon(location) 586 { 587 } 588 589 explicit CodeLocationNearCall(void* location) 590 : CodeLocationCommon(CodePtr(location)) 591 { 630 592 } 631 593 … … 636 598 return this->executableAddress(); 637 599 } 638 639 private:640 explicit CodeLocationNearCall(CodePtr location)641 : CodeLocationCommon(location)642 {643 }644 645 explicit CodeLocationNearCall(void* location)646 : CodeLocationCommon(CodePtr(location))647 {648 }649 600 }; 650 601 … … 653 604 // A point in the JIT code at which there is an int32_t immediate that may be repatched. 654 605 class CodeLocationDataLabel32 : public CodeLocationCommon { 655 friend class CodeLocationCommon;656 friend class PatchBuffer;657 606 public: 658 607 CodeLocationDataLabel32() … … 660 609 } 661 610 662 void repatch(int32_t value)663 {664 AssemblerType::repatchInt32(this->dataLocation(), value);665 }666 667 private:668 611 explicit CodeLocationDataLabel32(void* location) 669 612 : CodeLocationCommon(CodePtr(location)) … … 676 619 // A point in the JIT code at which there is a void* immediate that may be repatched. 677 620 class CodeLocationDataLabelPtr : public CodeLocationCommon { 678 friend class CodeLocationCommon;679 friend class PatchBuffer;680 621 public: 681 622 CodeLocationDataLabelPtr() … … 683 624 } 684 625 685 void repatch(void* value)686 {687 AssemblerType::repatchPointer(this->dataLocation(), value);688 }689 690 private:691 626 explicit CodeLocationDataLabelPtr(void* location) 692 627 : CodeLocationCommon(CodePtr(location)) … … 699 634 // This class can be used to relink a call identified by its return address. 700 635 class ProcessorReturnAddress { 701 friend class CodeLocationCall;702 friend class CodeLocationNearCall;703 636 public: 704 637 ProcessorReturnAddress(void* location) … … 707 640 } 708 641 709 void relinkCallerToTrampoline(CodeLocationLabel label)710 {711 CodeLocationCall(CodePtr(m_location)).relink(label);712 }713 714 void relinkCallerToTrampoline(CodePtr newCalleeFunction)715 {716 relinkCallerToTrampoline(CodeLocationLabel(newCalleeFunction));717 }718 719 void relinkCallerToFunction(FunctionPtr function)720 {721 CodeLocationCall(CodePtr(m_location)).relink(function);722 }723 724 void relinkNearCallerToTrampoline(CodeLocationLabel label)725 {726 CodeLocationNearCall(CodePtr(m_location)).relink(label);727 }728 729 void relinkNearCallerToTrampoline(CodePtr newCalleeFunction)730 {731 relinkNearCallerToTrampoline(CodeLocationLabel(newCalleeFunction));732 }733 734 642 void* addressForLookup() 735 643 { … … 737 645 } 738 646 739 private:740 647 ReturnAddressPtr m_location; 741 648 }; … … 902 809 }; 903 810 811 class RepatchBuffer { 812 public: 813 RepatchBuffer() 814 { 815 } 816 817 void relink(CodeLocationJump jump, CodeLocationLabel destination) 818 { 819 AssemblerType::relinkJump(jump.dataLocation(), destination.dataLocation()); 820 } 821 822 void relink(CodeLocationCall call, CodeLocationLabel destination) 823 { 824 #if PLATFORM(X86_64) 825 repatch(call.dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11), destination.executableAddress()); 826 #else 827 AssemblerType::relinkCall(call.dataLocation(), destination.executableAddress()); 828 #endif 829 } 830 831 void relink(CodeLocationCall call, FunctionPtr destination) 832 { 833 #if PLATFORM(X86_64) 834 repatch(call.dataLabelPtrAtOffset(-REPTACH_OFFSET_CALL_R11), destination.executableAddress()); 835 #else 836 AssemblerType::relinkCall(call.dataLocation(), destination.executableAddress()); 837 #endif 838 } 839 840 void relink(CodeLocationNearCall nearCall, CodePtr destination) 841 { 842 AssemblerType::relinkCall(nearCall.dataLocation(), destination.executableAddress()); 843 } 844 845 void relink(CodeLocationNearCall nearCall, CodeLocationLabel destination) 846 { 847 AssemblerType::relinkCall(nearCall.dataLocation(), destination.executableAddress()); 848 } 849 850 void relink(CodeLocationNearCall nearCall, FunctionPtr destination) 851 { 852 AssemblerType::relinkCall(nearCall.dataLocation(), destination.executableAddress()); 853 } 854 855 void repatch(CodeLocationDataLabel32 dataLabel32, int32_t value) 856 { 857 AssemblerType::repatchInt32(dataLabel32.dataLocation(), value); 858 } 859 860 void repatch(CodeLocationDataLabelPtr dataLabelPtr, void* value) 861 { 862 AssemblerType::repatchPointer(dataLabelPtr.dataLocation(), value); 863 } 864 865 void relinkCallerToTrampoline(ProcessorReturnAddress returnAddress, CodeLocationLabel label) 866 { 867 relink(CodeLocationCall(CodePtr(returnAddress.m_location)), label); 868 } 869 870 void relinkCallerToTrampoline(ProcessorReturnAddress returnAddress, CodePtr newCalleeFunction) 871 { 872 relinkCallerToTrampoline(returnAddress, CodeLocationLabel(newCalleeFunction)); 873 } 874 875 void relinkCallerToFunction(ProcessorReturnAddress returnAddress, FunctionPtr function) 876 { 877 relink(CodeLocationCall(CodePtr(returnAddress.m_location)), function); 878 } 879 880 void relinkNearCallerToTrampoline(ProcessorReturnAddress returnAddress, CodeLocationLabel label) 881 { 882 relink(CodeLocationNearCall(CodePtr(returnAddress.m_location)), label); 883 } 884 885 void relinkNearCallerToTrampoline(ProcessorReturnAddress returnAddress, CodePtr newCalleeFunction) 886 { 887 relinkNearCallerToTrampoline(returnAddress, CodeLocationLabel(newCalleeFunction)); 888 } 889 890 void repatchLoadPtrToLEA(CodeLocationInstruction instruction) 891 { 892 AssemblerType::repatchLoadPtrToLEA(instruction.dataLocation()); 893 } 894 }; 895 904 896 905 897 // Section 5: Misc admin methods
Note:
See TracChangeset
for help on using the changeset viewer.