626 if (!metadata_is_immediate()) {
627 // get the metadata from the pool, and re-insert it into the instruction:
628 verify_value(value());
629 }
630 }
631
632 address virtual_call_Relocation::cached_value() {
633 assert(_cached_value != NULL && _cached_value < addr(), "must precede ic_call");
634 return _cached_value;
635 }
636
637 Method* virtual_call_Relocation::method_value() {
638 CompiledMethod* cm = code();
639 if (cm == NULL) return (Method*)NULL;
640 Metadata* m = cm->metadata_at(_method_index);
641 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
642 assert(m == NULL || m->is_method(), "not a method");
643 return (Method*)m;
644 }
645
646 void virtual_call_Relocation::clear_inline_cache() {
647 // No stubs for ICs
648 // Clean IC
649 ResourceMark rm;
650 CompiledIC* icache = CompiledIC_at(this);
651 icache->set_to_clean();
652 }
653
654
655 void opt_virtual_call_Relocation::pack_data_to(CodeSection* dest) {
656 short* p = (short*) dest->locs_end();
657 p = pack_1_int_to(p, _method_index);
658 dest->set_locs_end((relocInfo*) p);
659 }
660
661 void opt_virtual_call_Relocation::unpack_data() {
662 _method_index = unpack_1_int();
663 }
664
665 Method* opt_virtual_call_Relocation::method_value() {
666 CompiledMethod* cm = code();
667 if (cm == NULL) return (Method*)NULL;
668 Metadata* m = cm->metadata_at(_method_index);
669 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
670 assert(m == NULL || m->is_method(), "not a method");
671 return (Method*)m;
672 }
673
674 void opt_virtual_call_Relocation::clear_inline_cache() {
675 // No stubs for ICs
676 // Clean IC
677 ResourceMark rm;
678 CompiledIC* icache = CompiledIC_at(this);
679 icache->set_to_clean();
680 }
681
682
683 address opt_virtual_call_Relocation::static_stub(bool is_aot) {
684 // search for the static stub who points back to this static call
685 address static_call_addr = addr();
686 RelocIterator iter(code());
687 while (iter.next()) {
688 if (iter.type() == relocInfo::static_stub_type) {
689 static_stub_Relocation* stub_reloc = iter.static_stub_reloc();
690 if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) {
691 return iter.addr();
692 }
693 }
694 }
695 return NULL;
696 }
697
698 Method* static_call_Relocation::method_value() {
699 CompiledMethod* cm = code();
700 if (cm == NULL) return (Method*)NULL;
701 Metadata* m = cm->metadata_at(_method_index);
702 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
703 assert(m == NULL || m->is_method(), "not a method");
704 return (Method*)m;
705 }
706
707 void static_call_Relocation::pack_data_to(CodeSection* dest) {
708 short* p = (short*) dest->locs_end();
709 p = pack_1_int_to(p, _method_index);
710 dest->set_locs_end((relocInfo*) p);
711 }
712
713 void static_call_Relocation::unpack_data() {
714 _method_index = unpack_1_int();
715 }
716
717 void static_call_Relocation::clear_inline_cache() {
718 // Safe call site info
719 CompiledStaticCall* handler = this->code()->compiledStaticCall_at(this);
720 handler->set_to_clean();
721 }
722
723
724 address static_call_Relocation::static_stub(bool is_aot) {
725 // search for the static stub who points back to this static call
726 address static_call_addr = addr();
727 RelocIterator iter(code());
728 while (iter.next()) {
729 if (iter.type() == relocInfo::static_stub_type) {
730 static_stub_Relocation* stub_reloc = iter.static_stub_reloc();
731 if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) {
732 return iter.addr();
733 }
734 }
735 }
736 return NULL;
737 }
738
739 // Finds the trampoline address for a call. If no trampoline stub is
740 // found NULL is returned which can be handled by the caller.
741 address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) {
742 // There are no relocations available when the code gets relocated
743 // because of CodeBuffer expansion.
744 if (code->relocation_size() == 0)
745 return NULL;
746
747 RelocIterator iter(code, call);
748 while (iter.next()) {
749 if (iter.type() == relocInfo::trampoline_stub_type) {
750 if (iter.trampoline_stub_reloc()->owner() == call) {
751 return iter.addr();
752 }
753 }
754 }
755
756 return NULL;
757 }
758
759 void static_stub_Relocation::clear_inline_cache() {
760 // Call stub is only used when calling the interpreted code.
761 // It does not really need to be cleared, except that we want to clean out the methodoop.
762 CompiledDirectStaticCall::set_stub_to_clean(this);
763 }
764
765
766 void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
767 address target = _target;
768 if (target == NULL) {
769 // An absolute embedded reference to an external location,
770 // which means there is nothing to fix here.
771 return;
772 }
773 // Probably this reference is absolute, not relative, so the
774 // following is probably a no-op.
775 assert(src->section_index_of(target) == CodeBuffer::SECT_NONE, "sanity");
776 set_value(target);
777 }
778
779
780 address external_word_Relocation::target() {
781 address target = _target;
|
626 if (!metadata_is_immediate()) {
627 // get the metadata from the pool, and re-insert it into the instruction:
628 verify_value(value());
629 }
630 }
631
632 address virtual_call_Relocation::cached_value() {
633 assert(_cached_value != NULL && _cached_value < addr(), "must precede ic_call");
634 return _cached_value;
635 }
636
637 Method* virtual_call_Relocation::method_value() {
638 CompiledMethod* cm = code();
639 if (cm == NULL) return (Method*)NULL;
640 Metadata* m = cm->metadata_at(_method_index);
641 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
642 assert(m == NULL || m->is_method(), "not a method");
643 return (Method*)m;
644 }
645
646 bool virtual_call_Relocation::clear_inline_cache() {
647 // No stubs for ICs
648 // Clean IC
649 ResourceMark rm;
650 CompiledIC* icache = CompiledIC_at(this);
651 return icache->set_to_clean();
652 }
653
654
655 void opt_virtual_call_Relocation::pack_data_to(CodeSection* dest) {
656 short* p = (short*) dest->locs_end();
657 p = pack_1_int_to(p, _method_index);
658 dest->set_locs_end((relocInfo*) p);
659 }
660
661 void opt_virtual_call_Relocation::unpack_data() {
662 _method_index = unpack_1_int();
663 }
664
665 Method* opt_virtual_call_Relocation::method_value() {
666 CompiledMethod* cm = code();
667 if (cm == NULL) return (Method*)NULL;
668 Metadata* m = cm->metadata_at(_method_index);
669 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
670 assert(m == NULL || m->is_method(), "not a method");
671 return (Method*)m;
672 }
673
674 bool opt_virtual_call_Relocation::clear_inline_cache() {
675 // No stubs for ICs
676 // Clean IC
677 ResourceMark rm;
678 CompiledIC* icache = CompiledIC_at(this);
679 guarantee(icache->set_to_clean(), "opt_virtual_call cleaning should never fail");
680 return true;
681 }
682
683
684 address opt_virtual_call_Relocation::static_stub(bool is_aot) {
685 // search for the static stub who points back to this static call
686 address static_call_addr = addr();
687 RelocIterator iter(code());
688 while (iter.next()) {
689 if (iter.type() == relocInfo::static_stub_type) {
690 static_stub_Relocation* stub_reloc = iter.static_stub_reloc();
691 if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) {
692 return iter.addr();
693 }
694 }
695 }
696 return NULL;
697 }
698
699 Method* static_call_Relocation::method_value() {
700 CompiledMethod* cm = code();
701 if (cm == NULL) return (Method*)NULL;
702 Metadata* m = cm->metadata_at(_method_index);
703 assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
704 assert(m == NULL || m->is_method(), "not a method");
705 return (Method*)m;
706 }
707
708 void static_call_Relocation::pack_data_to(CodeSection* dest) {
709 short* p = (short*) dest->locs_end();
710 p = pack_1_int_to(p, _method_index);
711 dest->set_locs_end((relocInfo*) p);
712 }
713
714 void static_call_Relocation::unpack_data() {
715 _method_index = unpack_1_int();
716 }
717
718 bool static_call_Relocation::clear_inline_cache() {
719 // Safe call site info
720 CompiledStaticCall* handler = this->code()->compiledStaticCall_at(this);
721 guarantee(handler->set_to_clean(), "CompiledStaticCall cleaning should not fail");
722 return true;
723 }
724
725
726 address static_call_Relocation::static_stub(bool is_aot) {
727 // search for the static stub who points back to this static call
728 address static_call_addr = addr();
729 RelocIterator iter(code());
730 while (iter.next()) {
731 if (iter.type() == relocInfo::static_stub_type) {
732 static_stub_Relocation* stub_reloc = iter.static_stub_reloc();
733 if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) {
734 return iter.addr();
735 }
736 }
737 }
738 return NULL;
739 }
740
741 // Finds the trampoline address for a call. If no trampoline stub is
742 // found NULL is returned which can be handled by the caller.
743 address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) {
744 // There are no relocations available when the code gets relocated
745 // because of CodeBuffer expansion.
746 if (code->relocation_size() == 0)
747 return NULL;
748
749 RelocIterator iter(code, call);
750 while (iter.next()) {
751 if (iter.type() == relocInfo::trampoline_stub_type) {
752 if (iter.trampoline_stub_reloc()->owner() == call) {
753 return iter.addr();
754 }
755 }
756 }
757
758 return NULL;
759 }
760
761 bool static_stub_Relocation::clear_inline_cache() {
762 // Call stub is only used when calling the interpreted code.
763 // It does not really need to be cleared, except that we want to clean out the methodoop.
764 CompiledDirectStaticCall::set_stub_to_clean(this);
765 return true;
766 }
767
768
769 void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
770 address target = _target;
771 if (target == NULL) {
772 // An absolute embedded reference to an external location,
773 // which means there is nothing to fix here.
774 return;
775 }
776 // Probably this reference is absolute, not relative, so the
777 // following is probably a no-op.
778 assert(src->section_index_of(target) == CodeBuffer::SECT_NONE, "sanity");
779 set_value(target);
780 }
781
782
783 address external_word_Relocation::target() {
784 address target = _target;
|