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