647 // of these values back to constant pool indices.
648
649 // There are also "uncached" versions which do not adjust the operand index; see below.
650
651 // FIXME: Consider renaming these with a prefix "cached_" to make the distinction clear.
652 // In a few cases (the verifier) there are uses before a cpcache has been built,
653 // which are handled by a dynamic check in remap_instruction_operand_from_cache.
654 // FIXME: Remove the dynamic check, and adjust all callers to specify the correct mode.
655
656 // Lookup for entries consisting of (klass_index, name_and_type index)
657 Klass* klass_ref_at(int which, TRAPS);
658 Symbol* klass_ref_at_noresolve(int which);
659 Symbol* name_ref_at(int which) { return impl_name_ref_at(which, false); }
660 Symbol* signature_ref_at(int which) { return impl_signature_ref_at(which, false); }
661
662 int klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, false); }
663 int name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, false); }
664
665 int remap_instruction_operand_from_cache(int operand); // operand must be biased by CPCACHE_INDEX_TAG
666
667 // Lookup for entries consisting of (name_index, signature_index)
668 int name_ref_index_at(int which_nt); // == low-order jshort of name_and_type_at(which_nt)
669 int signature_ref_index_at(int which_nt); // == high-order jshort of name_and_type_at(which_nt)
670
671 BasicType basic_type_for_signature_at(int which) const;
672
673 // Resolve string constants (to prevent allocation during compilation)
674 void resolve_string_constants(TRAPS) {
675 constantPoolHandle h_this(THREAD, this);
676 resolve_string_constants_impl(h_this, CHECK);
677 }
678
679 // CDS support
680 void remove_unshareable_info();
681 void restore_unshareable_info(TRAPS);
682 bool resolve_class_constants(TRAPS);
683 // The ConstantPool vtable is restored by this call when the ConstantPool is
684 // in the shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
685 // all the gory details. SA, dtrace and pstack helpers distinguish metadata
686 // by their vtable.
767 static int decode_cpcache_index(int raw_index, bool invokedynamic_ok = false) {
768 if (invokedynamic_ok && is_invokedynamic_index(raw_index))
769 return decode_invokedynamic_index(raw_index);
770 else
771 return raw_index - CPCACHE_INDEX_TAG;
772 }
773
774 private:
775
776 void set_resolved_references(jobject s) { _resolved_references = s; }
777 Array<u2>* reference_map() const { return _reference_map; }
778 void set_reference_map(Array<u2>* o) { _reference_map = o; }
779
780 // patch JSR 292 resolved references after the class is linked.
781 void patch_resolved_references(GrowableArray<Handle>* cp_patches);
782
783 Symbol* impl_name_ref_at(int which, bool uncached);
784 Symbol* impl_signature_ref_at(int which, bool uncached);
785 int impl_klass_ref_index_at(int which, bool uncached);
786 int impl_name_and_type_ref_index_at(int which, bool uncached);
787
788 // Used while constructing constant pool (only by ClassFileParser)
789 jint klass_index_at(int which) {
790 assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
791 return *int_at_addr(which);
792 }
793
794 jint string_index_at(int which) {
795 assert(tag_at(which).is_string_index(), "Corrupted constant pool");
796 return *int_at_addr(which);
797 }
798
799 // Performs the LinkResolver checks
800 static void verify_constant_pool_resolve(const constantPoolHandle& this_cp, KlassHandle klass, TRAPS);
801
802 // Implementation of methods that needs an exposed 'this' pointer, in order to
803 // handle GC while executing the method
804 static Klass* klass_at_impl(const constantPoolHandle& this_cp, int which,
805 bool save_resolution_error, TRAPS);
806 static oop string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, TRAPS);
|
647 // of these values back to constant pool indices.
648
649 // There are also "uncached" versions which do not adjust the operand index; see below.
650
651 // FIXME: Consider renaming these with a prefix "cached_" to make the distinction clear.
652 // In a few cases (the verifier) there are uses before a cpcache has been built,
653 // which are handled by a dynamic check in remap_instruction_operand_from_cache.
654 // FIXME: Remove the dynamic check, and adjust all callers to specify the correct mode.
655
656 // Lookup for entries consisting of (klass_index, name_and_type index)
657 Klass* klass_ref_at(int which, TRAPS);
658 Symbol* klass_ref_at_noresolve(int which);
659 Symbol* name_ref_at(int which) { return impl_name_ref_at(which, false); }
660 Symbol* signature_ref_at(int which) { return impl_signature_ref_at(which, false); }
661
662 int klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, false); }
663 int name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, false); }
664
665 int remap_instruction_operand_from_cache(int operand); // operand must be biased by CPCACHE_INDEX_TAG
666
667 constantTag tag_ref_at(int cp_cache_index) { return impl_tag_ref_at(cp_cache_index, false); }
668
669 // Lookup for entries consisting of (name_index, signature_index)
670 int name_ref_index_at(int which_nt); // == low-order jshort of name_and_type_at(which_nt)
671 int signature_ref_index_at(int which_nt); // == high-order jshort of name_and_type_at(which_nt)
672
673 BasicType basic_type_for_signature_at(int which) const;
674
675 // Resolve string constants (to prevent allocation during compilation)
676 void resolve_string_constants(TRAPS) {
677 constantPoolHandle h_this(THREAD, this);
678 resolve_string_constants_impl(h_this, CHECK);
679 }
680
681 // CDS support
682 void remove_unshareable_info();
683 void restore_unshareable_info(TRAPS);
684 bool resolve_class_constants(TRAPS);
685 // The ConstantPool vtable is restored by this call when the ConstantPool is
686 // in the shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
687 // all the gory details. SA, dtrace and pstack helpers distinguish metadata
688 // by their vtable.
769 static int decode_cpcache_index(int raw_index, bool invokedynamic_ok = false) {
770 if (invokedynamic_ok && is_invokedynamic_index(raw_index))
771 return decode_invokedynamic_index(raw_index);
772 else
773 return raw_index - CPCACHE_INDEX_TAG;
774 }
775
776 private:
777
778 void set_resolved_references(jobject s) { _resolved_references = s; }
779 Array<u2>* reference_map() const { return _reference_map; }
780 void set_reference_map(Array<u2>* o) { _reference_map = o; }
781
782 // patch JSR 292 resolved references after the class is linked.
783 void patch_resolved_references(GrowableArray<Handle>* cp_patches);
784
785 Symbol* impl_name_ref_at(int which, bool uncached);
786 Symbol* impl_signature_ref_at(int which, bool uncached);
787 int impl_klass_ref_index_at(int which, bool uncached);
788 int impl_name_and_type_ref_index_at(int which, bool uncached);
789 constantTag impl_tag_ref_at(int which, bool uncached);
790
791 // Used while constructing constant pool (only by ClassFileParser)
792 jint klass_index_at(int which) {
793 assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
794 return *int_at_addr(which);
795 }
796
797 jint string_index_at(int which) {
798 assert(tag_at(which).is_string_index(), "Corrupted constant pool");
799 return *int_at_addr(which);
800 }
801
802 // Performs the LinkResolver checks
803 static void verify_constant_pool_resolve(const constantPoolHandle& this_cp, KlassHandle klass, TRAPS);
804
805 // Implementation of methods that needs an exposed 'this' pointer, in order to
806 // handle GC while executing the method
807 static Klass* klass_at_impl(const constantPoolHandle& this_cp, int which,
808 bool save_resolution_error, TRAPS);
809 static oop string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, TRAPS);
|