548 void virtual_call_Relocation::unpack_data() { 549 jint x0 = 0; 550 unpack_2_ints(x0, _method_index); 551 address point = addr(); 552 _cached_value = x0==0? NULL: address_from_scaled_offset(x0, point); 553 } 554 555 void runtime_call_w_cp_Relocation::pack_data_to(CodeSection * dest) { 556 short* p = pack_1_int_to((short *)dest->locs_end(), (jint)(_offset >> 2)); 557 dest->set_locs_end((relocInfo*) p); 558 } 559 560 void runtime_call_w_cp_Relocation::unpack_data() { 561 _offset = unpack_1_int() << 2; 562 } 563 564 void static_stub_Relocation::pack_data_to(CodeSection* dest) { 565 short* p = (short*) dest->locs_end(); 566 CodeSection* insts = dest->outer()->insts(); 567 normalize_address(_static_call, insts); 568 p = pack_1_int_to(p, scaled_offset(_static_call, insts->start())); 569 dest->set_locs_end((relocInfo*) p); 570 } 571 572 void static_stub_Relocation::unpack_data() { 573 address base = binding()->section_start(CodeBuffer::SECT_INSTS); 574 jint offset = unpack_1_int(); 575 _static_call = address_from_scaled_offset(offset, base); 576 } 577 578 void trampoline_stub_Relocation::pack_data_to(CodeSection* dest ) { 579 short* p = (short*) dest->locs_end(); 580 CodeSection* insts = dest->outer()->insts(); 581 normalize_address(_owner, insts); 582 p = pack_1_int_to(p, scaled_offset(_owner, insts->start())); 583 dest->set_locs_end((relocInfo*) p); 584 } 585 586 void trampoline_stub_Relocation::unpack_data() { 587 address base = binding()->section_start(CodeBuffer::SECT_INSTS); 588 _owner = address_from_scaled_offset(unpack_1_int(), base); 589 } 590 591 void external_word_Relocation::pack_data_to(CodeSection* dest) { 592 short* p = (short*) dest->locs_end(); 593 #ifndef _LP64 594 p = pack_1_int_to(p, (int32_t) (intptr_t)_target); 595 #else 779 } 780 781 Method* opt_virtual_call_Relocation::method_value() { 782 CompiledMethod* cm = code(); 783 if (cm == NULL) return (Method*)NULL; 784 Metadata* m = cm->metadata_at(_method_index); 785 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); 786 assert(m == NULL || m->is_method(), "not a method"); 787 return (Method*)m; 788 } 789 790 void opt_virtual_call_Relocation::clear_inline_cache() { 791 // No stubs for ICs 792 // Clean IC 793 ResourceMark rm; 794 CompiledIC* icache = CompiledIC_at(this); 795 icache->set_to_clean(); 796 } 797 798 799 address opt_virtual_call_Relocation::static_stub() { 800 // search for the static stub who points back to this static call 801 address static_call_addr = addr(); 802 RelocIterator iter(code()); 803 while (iter.next()) { 804 if (iter.type() == relocInfo::static_stub_type) { 805 static_stub_Relocation* stub_reloc = iter.static_stub_reloc(); 806 if (stub_reloc->static_call() == static_call_addr) { 807 return iter.addr(); 808 } 809 } 810 } 811 return NULL; 812 } 813 814 Method* static_call_Relocation::method_value() { 815 CompiledMethod* cm = code(); 816 if (cm == NULL) return (Method*)NULL; 817 Metadata* m = cm->metadata_at(_method_index); 818 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); 819 assert(m == NULL || m->is_method(), "not a method"); 820 return (Method*)m; 821 } 822 823 void static_call_Relocation::pack_data_to(CodeSection* dest) { 824 short* p = (short*) dest->locs_end(); 825 p = pack_1_int_to(p, _method_index); 826 dest->set_locs_end((relocInfo*) p); 827 } 828 829 void static_call_Relocation::unpack_data() { 830 _method_index = unpack_1_int(); 831 } 832 833 void static_call_Relocation::clear_inline_cache() { 834 // Safe call site info 835 CompiledStaticCall* handler = compiledStaticCall_at(this); 836 handler->set_to_clean(); 837 } 838 839 840 address static_call_Relocation::static_stub() { 841 // search for the static stub who points back to this static call 842 address static_call_addr = addr(); 843 RelocIterator iter(code()); 844 while (iter.next()) { 845 if (iter.type() == relocInfo::static_stub_type) { 846 static_stub_Relocation* stub_reloc = iter.static_stub_reloc(); 847 if (stub_reloc->static_call() == static_call_addr) { 848 return iter.addr(); 849 } 850 } 851 } 852 return NULL; 853 } 854 855 // Finds the trampoline address for a call. If no trampoline stub is 856 // found NULL is returned which can be handled by the caller. 857 address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) { 858 // There are no relocations available when the code gets relocated 859 // because of CodeBuffer expansion. 860 if (code->relocation_size() == 0) 861 return NULL; 862 863 RelocIterator iter(code, call); 864 while (iter.next()) { 865 if (iter.type() == relocInfo::trampoline_stub_type) { 866 if (iter.trampoline_stub_reloc()->owner() == call) { 867 return iter.addr(); 868 } 869 } 870 } 871 872 return NULL; 873 } 874 875 void static_stub_Relocation::clear_inline_cache() { 876 // Call stub is only used when calling the interpreted code. 877 // It does not really need to be cleared, except that we want to clean out the methodoop. 878 CompiledStaticCall::set_stub_to_clean(this); 879 } 880 881 882 void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { 883 address target = _target; 884 if (target == NULL) { 885 // An absolute embedded reference to an external location, 886 // which means there is nothing to fix here. 887 return; 888 } 889 // Probably this reference is absolute, not relative, so the 890 // following is probably a no-op. 891 assert(src->section_index_of(target) == CodeBuffer::SECT_NONE, "sanity"); 892 set_value(target); 893 } 894 895 896 address external_word_Relocation::target() { 897 address target = _target; 898 if (target == NULL) { | 548 void virtual_call_Relocation::unpack_data() { 549 jint x0 = 0; 550 unpack_2_ints(x0, _method_index); 551 address point = addr(); 552 _cached_value = x0==0? NULL: address_from_scaled_offset(x0, point); 553 } 554 555 void runtime_call_w_cp_Relocation::pack_data_to(CodeSection * dest) { 556 short* p = pack_1_int_to((short *)dest->locs_end(), (jint)(_offset >> 2)); 557 dest->set_locs_end((relocInfo*) p); 558 } 559 560 void runtime_call_w_cp_Relocation::unpack_data() { 561 _offset = unpack_1_int() << 2; 562 } 563 564 void static_stub_Relocation::pack_data_to(CodeSection* dest) { 565 short* p = (short*) dest->locs_end(); 566 CodeSection* insts = dest->outer()->insts(); 567 normalize_address(_static_call, insts); 568 jint is_aot = _is_aot ? 1 : 0; 569 p = pack_2_ints_to(p, scaled_offset(_static_call, insts->start()), is_aot); 570 dest->set_locs_end((relocInfo*) p); 571 } 572 573 void static_stub_Relocation::unpack_data() { 574 address base = binding()->section_start(CodeBuffer::SECT_INSTS); 575 jint offset; 576 jint is_aot; 577 unpack_2_ints(offset, is_aot); 578 _static_call = address_from_scaled_offset(offset, base); 579 _is_aot = (is_aot == 1); 580 } 581 582 void trampoline_stub_Relocation::pack_data_to(CodeSection* dest ) { 583 short* p = (short*) dest->locs_end(); 584 CodeSection* insts = dest->outer()->insts(); 585 normalize_address(_owner, insts); 586 p = pack_1_int_to(p, scaled_offset(_owner, insts->start())); 587 dest->set_locs_end((relocInfo*) p); 588 } 589 590 void trampoline_stub_Relocation::unpack_data() { 591 address base = binding()->section_start(CodeBuffer::SECT_INSTS); 592 _owner = address_from_scaled_offset(unpack_1_int(), base); 593 } 594 595 void external_word_Relocation::pack_data_to(CodeSection* dest) { 596 short* p = (short*) dest->locs_end(); 597 #ifndef _LP64 598 p = pack_1_int_to(p, (int32_t) (intptr_t)_target); 599 #else 783 } 784 785 Method* opt_virtual_call_Relocation::method_value() { 786 CompiledMethod* cm = code(); 787 if (cm == NULL) return (Method*)NULL; 788 Metadata* m = cm->metadata_at(_method_index); 789 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); 790 assert(m == NULL || m->is_method(), "not a method"); 791 return (Method*)m; 792 } 793 794 void opt_virtual_call_Relocation::clear_inline_cache() { 795 // No stubs for ICs 796 // Clean IC 797 ResourceMark rm; 798 CompiledIC* icache = CompiledIC_at(this); 799 icache->set_to_clean(); 800 } 801 802 803 address opt_virtual_call_Relocation::static_stub(bool is_aot) { 804 // search for the static stub who points back to this static call 805 address static_call_addr = addr(); 806 RelocIterator iter(code()); 807 while (iter.next()) { 808 if (iter.type() == relocInfo::static_stub_type) { 809 static_stub_Relocation* stub_reloc = iter.static_stub_reloc(); 810 if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) { 811 return iter.addr(); 812 } 813 } 814 } 815 return NULL; 816 } 817 818 Method* static_call_Relocation::method_value() { 819 CompiledMethod* cm = code(); 820 if (cm == NULL) return (Method*)NULL; 821 Metadata* m = cm->metadata_at(_method_index); 822 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); 823 assert(m == NULL || m->is_method(), "not a method"); 824 return (Method*)m; 825 } 826 827 void static_call_Relocation::pack_data_to(CodeSection* dest) { 828 short* p = (short*) dest->locs_end(); 829 p = pack_1_int_to(p, _method_index); 830 dest->set_locs_end((relocInfo*) p); 831 } 832 833 void static_call_Relocation::unpack_data() { 834 _method_index = unpack_1_int(); 835 } 836 837 void static_call_Relocation::clear_inline_cache() { 838 // Safe call site info 839 CompiledStaticCall* handler = this->code()->compiledStaticCall_at(this); 840 handler->set_to_clean(); 841 } 842 843 844 address static_call_Relocation::static_stub(bool is_aot) { 845 // search for the static stub who points back to this static call 846 address static_call_addr = addr(); 847 RelocIterator iter(code()); 848 while (iter.next()) { 849 if (iter.type() == relocInfo::static_stub_type) { 850 static_stub_Relocation* stub_reloc = iter.static_stub_reloc(); 851 if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) { 852 return iter.addr(); 853 } 854 } 855 } 856 return NULL; 857 } 858 859 // Finds the trampoline address for a call. If no trampoline stub is 860 // found NULL is returned which can be handled by the caller. 861 address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) { 862 // There are no relocations available when the code gets relocated 863 // because of CodeBuffer expansion. 864 if (code->relocation_size() == 0) 865 return NULL; 866 867 RelocIterator iter(code, call); 868 while (iter.next()) { 869 if (iter.type() == relocInfo::trampoline_stub_type) { 870 if (iter.trampoline_stub_reloc()->owner() == call) { 871 return iter.addr(); 872 } 873 } 874 } 875 876 return NULL; 877 } 878 879 void static_stub_Relocation::clear_inline_cache() { 880 // Call stub is only used when calling the interpreted code. 881 // It does not really need to be cleared, except that we want to clean out the methodoop. 882 CompiledDirectStaticCall::set_stub_to_clean(this); 883 } 884 885 886 void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { 887 address target = _target; 888 if (target == NULL) { 889 // An absolute embedded reference to an external location, 890 // which means there is nothing to fix here. 891 return; 892 } 893 // Probably this reference is absolute, not relative, so the 894 // following is probably a no-op. 895 assert(src->section_index_of(target) == CodeBuffer::SECT_NONE, "sanity"); 896 set_value(target); 897 } 898 899 900 address external_word_Relocation::target() { 901 address target = _target; 902 if (target == NULL) { |