< prev index next >

src/share/vm/oops/constantPool.hpp

Print this page




 528 
 529   // Derived queries:
 530   Symbol* method_handle_name_ref_at(int which) {
 531     int member = method_handle_index_at(which);
 532     return impl_name_ref_at(member, true);
 533   }
 534   Symbol* method_handle_signature_ref_at(int which) {
 535     int member = method_handle_index_at(which);
 536     return impl_signature_ref_at(member, true);
 537   }
 538   int method_handle_klass_index_at(int which) {
 539     int member = method_handle_index_at(which);
 540     return impl_klass_ref_index_at(member, true);
 541   }
 542   Symbol* method_type_signature_at(int which) {
 543     int sym = method_type_index_at(which);
 544     return symbol_at(sym);
 545   }
 546 
 547   int invoke_dynamic_name_and_type_ref_index_at(int which) {
 548     assert(tag_at(which).is_invoke_dynamic(), "Corrupted constant pool");

 549     return extract_high_short_from_int(*int_at_addr(which));
 550   }
 551   int invoke_dynamic_bootstrap_specifier_index(int which) {
 552     assert(tag_at(which).value() == JVM_CONSTANT_InvokeDynamic, "Corrupted constant pool");

 553     return extract_low_short_from_int(*int_at_addr(which));
 554   }
 555   int invoke_dynamic_operand_base(int which) {
 556     int bootstrap_specifier_index = invoke_dynamic_bootstrap_specifier_index(which);
 557     return operand_offset_at(operands(), bootstrap_specifier_index);
 558   }
 559   // The first part of the operands array consists of an index into the second part.
 560   // Extract a 32-bit index value from the first part.
 561   static int operand_offset_at(Array<u2>* operands, int bootstrap_specifier_index) {
 562     int n = (bootstrap_specifier_index * 2);
 563     assert(n >= 0 && n+2 <= operands->length(), "oob");
 564     // The first 32-bit index points to the beginning of the second part
 565     // of the operands array.  Make sure this index is in the first part.
 566     DEBUG_ONLY(int second_part = build_int_from_shorts(operands->at(0),
 567                                                        operands->at(1)));
 568     assert(second_part == 0 || n+2 <= second_part, "oob (2)");
 569     int offset = build_int_from_shorts(operands->at(n+0),
 570                                        operands->at(n+1));
 571     // The offset itself must point into the second part of the array.
 572     assert(offset == 0 || offset >= second_part && offset <= operands->length(), "oob (3)");


 630   int operand_next_offset_at(int bootstrap_specifier_index) {
 631     int offset = operand_offset_at(bootstrap_specifier_index) + _indy_argv_offset
 632                    + operand_argument_count_at(bootstrap_specifier_index);
 633     return offset;
 634   }
 635   // Compare a bootsrap specifier in the operands arrays
 636   bool compare_operand_to(int bootstrap_specifier_index1, const constantPoolHandle& cp2,
 637                           int bootstrap_specifier_index2, TRAPS);
 638   // Find a bootsrap specifier in the operands array
 639   int find_matching_operand(int bootstrap_specifier_index, const constantPoolHandle& search_cp,
 640                             int operands_cur_len, TRAPS);
 641   // Resize the operands array with delta_len and delta_size
 642   void resize_operands(int delta_len, int delta_size, TRAPS);
 643   // Extend the operands array with the length and size of the ext_cp operands
 644   void extend_operands(const constantPoolHandle& ext_cp, TRAPS);
 645   // Shrink the operands array to a smaller array with new_len length
 646   void shrink_operands(int new_len, TRAPS);
 647 
 648 
 649   int invoke_dynamic_bootstrap_method_ref_index_at(int which) {
 650     assert(tag_at(which).is_invoke_dynamic(), "Corrupted constant pool");

 651     int op_base = invoke_dynamic_operand_base(which);
 652     return operands()->at(op_base + _indy_bsm_offset);
 653   }
 654   int invoke_dynamic_argument_count_at(int which) {
 655     assert(tag_at(which).is_invoke_dynamic(), "Corrupted constant pool");

 656     int op_base = invoke_dynamic_operand_base(which);
 657     int argc = operands()->at(op_base + _indy_argc_offset);
 658     DEBUG_ONLY(int end_offset = op_base + _indy_argv_offset + argc;
 659                int next_offset = invoke_dynamic_operand_limit(which));
 660     assert(end_offset == next_offset, "matched ending");
 661     return argc;
 662   }
 663   int invoke_dynamic_argument_index_at(int which, int j) {
 664     int op_base = invoke_dynamic_operand_base(which);
 665     DEBUG_ONLY(int argc = operands()->at(op_base + _indy_argc_offset));
 666     assert((uint)j < (uint)argc, "oob");
 667     return operands()->at(op_base + _indy_argv_offset + j);
 668   }
 669 
 670   // The following methods (name/signature/klass_ref_at, klass_ref_at_noresolve,
 671   // name_and_type_ref_index_at) all expect to be passed indices obtained
 672   // directly from the bytecode.
 673   // If the indices are meant to refer to fields or methods, they are
 674   // actually rewritten constant pool cache indices.
 675   // The routine remap_instruction_operand_from_cache manages the adjustment


 836   }
 837 
 838   // Performs the LinkResolver checks
 839   static void verify_constant_pool_resolve(const constantPoolHandle& this_cp, Klass* klass, TRAPS);
 840 
 841   // Implementation of methods that needs an exposed 'this' pointer, in order to
 842   // handle GC while executing the method
 843   static Klass* klass_at_impl(const constantPoolHandle& this_cp, int which,
 844                               bool save_resolution_error, TRAPS);
 845   static oop string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, TRAPS);
 846 
 847   static void trace_class_resolution(const constantPoolHandle& this_cp, Klass* k);
 848 
 849   // Resolve string constants (to prevent allocation during compilation)
 850   static void resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS);
 851 
 852   static oop resolve_constant_at_impl(const constantPoolHandle& this_cp, int index, int cache_index, TRAPS);
 853   static oop resolve_bootstrap_specifier_at_impl(const constantPoolHandle& this_cp, int index, TRAPS);
 854 
 855   // Exception handling
 856   static void throw_resolution_error(const constantPoolHandle& this_cp, int which, TRAPS);
 857   static Symbol* exception_message(const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception);
 858   static void save_and_throw_exception(const constantPoolHandle& this_cp, int which, constantTag tag, TRAPS);
 859 
 860  public:




 861   // Merging ConstantPool* support:
 862   bool compare_entry_to(int index1, const constantPoolHandle& cp2, int index2, TRAPS);
 863   void copy_cp_to(int start_i, int end_i, const constantPoolHandle& to_cp, int to_i, TRAPS) {
 864     constantPoolHandle h_this(THREAD, this);
 865     copy_cp_to_impl(h_this, start_i, end_i, to_cp, to_i, THREAD);
 866   }
 867   static void copy_cp_to_impl(const constantPoolHandle& from_cp, int start_i, int end_i, const constantPoolHandle& to_cp, int to_i, TRAPS);
 868   static void copy_entry_to(const constantPoolHandle& from_cp, int from_i, const constantPoolHandle& to_cp, int to_i, TRAPS);
 869   static void copy_operands(const constantPoolHandle& from_cp, const constantPoolHandle& to_cp, TRAPS);
 870   int  find_matching_entry(int pattern_i, const constantPoolHandle& search_cp, TRAPS);
 871   int  version() const                    { return _saved._version; }
 872   void set_version(int version)           { _saved._version = version; }
 873   void increment_and_save_version(int version) {
 874     _saved._version = version >= 0 ? (version + 1) : version;  // keep overflow
 875   }
 876 
 877   void set_resolved_reference_length(int length) { _saved._resolved_reference_length = length; }
 878   int  resolved_reference_length() const  { return _saved._resolved_reference_length; }
 879 
 880   // Decrease ref counts of symbols that are in the constant pool




 528 
 529   // Derived queries:
 530   Symbol* method_handle_name_ref_at(int which) {
 531     int member = method_handle_index_at(which);
 532     return impl_name_ref_at(member, true);
 533   }
 534   Symbol* method_handle_signature_ref_at(int which) {
 535     int member = method_handle_index_at(which);
 536     return impl_signature_ref_at(member, true);
 537   }
 538   int method_handle_klass_index_at(int which) {
 539     int member = method_handle_index_at(which);
 540     return impl_klass_ref_index_at(member, true);
 541   }
 542   Symbol* method_type_signature_at(int which) {
 543     int sym = method_type_index_at(which);
 544     return symbol_at(sym);
 545   }
 546 
 547   int invoke_dynamic_name_and_type_ref_index_at(int which) {
 548     assert(tag_at(which).is_invoke_dynamic() ||
 549            tag_at(which).is_invoke_dynamic_in_error(), "Corrupted constant pool");
 550     return extract_high_short_from_int(*int_at_addr(which));
 551   }
 552   int invoke_dynamic_bootstrap_specifier_index(int which) {
 553     assert(tag_at(which).is_invoke_dynamic() ||
 554            tag_at(which).is_invoke_dynamic_in_error(), "Corrupted constant pool");
 555     return extract_low_short_from_int(*int_at_addr(which));
 556   }
 557   int invoke_dynamic_operand_base(int which) {
 558     int bootstrap_specifier_index = invoke_dynamic_bootstrap_specifier_index(which);
 559     return operand_offset_at(operands(), bootstrap_specifier_index);
 560   }
 561   // The first part of the operands array consists of an index into the second part.
 562   // Extract a 32-bit index value from the first part.
 563   static int operand_offset_at(Array<u2>* operands, int bootstrap_specifier_index) {
 564     int n = (bootstrap_specifier_index * 2);
 565     assert(n >= 0 && n+2 <= operands->length(), "oob");
 566     // The first 32-bit index points to the beginning of the second part
 567     // of the operands array.  Make sure this index is in the first part.
 568     DEBUG_ONLY(int second_part = build_int_from_shorts(operands->at(0),
 569                                                        operands->at(1)));
 570     assert(second_part == 0 || n+2 <= second_part, "oob (2)");
 571     int offset = build_int_from_shorts(operands->at(n+0),
 572                                        operands->at(n+1));
 573     // The offset itself must point into the second part of the array.
 574     assert(offset == 0 || offset >= second_part && offset <= operands->length(), "oob (3)");


 632   int operand_next_offset_at(int bootstrap_specifier_index) {
 633     int offset = operand_offset_at(bootstrap_specifier_index) + _indy_argv_offset
 634                    + operand_argument_count_at(bootstrap_specifier_index);
 635     return offset;
 636   }
 637   // Compare a bootsrap specifier in the operands arrays
 638   bool compare_operand_to(int bootstrap_specifier_index1, const constantPoolHandle& cp2,
 639                           int bootstrap_specifier_index2, TRAPS);
 640   // Find a bootsrap specifier in the operands array
 641   int find_matching_operand(int bootstrap_specifier_index, const constantPoolHandle& search_cp,
 642                             int operands_cur_len, TRAPS);
 643   // Resize the operands array with delta_len and delta_size
 644   void resize_operands(int delta_len, int delta_size, TRAPS);
 645   // Extend the operands array with the length and size of the ext_cp operands
 646   void extend_operands(const constantPoolHandle& ext_cp, TRAPS);
 647   // Shrink the operands array to a smaller array with new_len length
 648   void shrink_operands(int new_len, TRAPS);
 649 
 650 
 651   int invoke_dynamic_bootstrap_method_ref_index_at(int which) {
 652     assert(tag_at(which).is_invoke_dynamic() ||
 653            tag_at(which).is_invoke_dynamic_in_error(), "Corrupted constant pool");
 654     int op_base = invoke_dynamic_operand_base(which);
 655     return operands()->at(op_base + _indy_bsm_offset);
 656   }
 657   int invoke_dynamic_argument_count_at(int which) {
 658     assert(tag_at(which).is_invoke_dynamic() ||
 659            tag_at(which).is_invoke_dynamic_in_error(), "Corrupted constant pool");
 660     int op_base = invoke_dynamic_operand_base(which);
 661     int argc = operands()->at(op_base + _indy_argc_offset);
 662     DEBUG_ONLY(int end_offset = op_base + _indy_argv_offset + argc;
 663                int next_offset = invoke_dynamic_operand_limit(which));
 664     assert(end_offset == next_offset, "matched ending");
 665     return argc;
 666   }
 667   int invoke_dynamic_argument_index_at(int which, int j) {
 668     int op_base = invoke_dynamic_operand_base(which);
 669     DEBUG_ONLY(int argc = operands()->at(op_base + _indy_argc_offset));
 670     assert((uint)j < (uint)argc, "oob");
 671     return operands()->at(op_base + _indy_argv_offset + j);
 672   }
 673 
 674   // The following methods (name/signature/klass_ref_at, klass_ref_at_noresolve,
 675   // name_and_type_ref_index_at) all expect to be passed indices obtained
 676   // directly from the bytecode.
 677   // If the indices are meant to refer to fields or methods, they are
 678   // actually rewritten constant pool cache indices.
 679   // The routine remap_instruction_operand_from_cache manages the adjustment


 840   }
 841 
 842   // Performs the LinkResolver checks
 843   static void verify_constant_pool_resolve(const constantPoolHandle& this_cp, Klass* klass, TRAPS);
 844 
 845   // Implementation of methods that needs an exposed 'this' pointer, in order to
 846   // handle GC while executing the method
 847   static Klass* klass_at_impl(const constantPoolHandle& this_cp, int which,
 848                               bool save_resolution_error, TRAPS);
 849   static oop string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, TRAPS);
 850 
 851   static void trace_class_resolution(const constantPoolHandle& this_cp, Klass* k);
 852 
 853   // Resolve string constants (to prevent allocation during compilation)
 854   static void resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS);
 855 
 856   static oop resolve_constant_at_impl(const constantPoolHandle& this_cp, int index, int cache_index, TRAPS);
 857   static oop resolve_bootstrap_specifier_at_impl(const constantPoolHandle& this_cp, int index, TRAPS);
 858 
 859   // Exception handling

 860   static Symbol* exception_message(const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception);

 861 
 862  public:
 863   // Exception handling
 864   static void throw_resolution_error(const constantPoolHandle& this_cp, int which, TRAPS);
 865   static void save_and_throw_exception(const constantPoolHandle& this_cp, int which, constantTag tag, TRAPS);
 866 
 867   // Merging ConstantPool* support:
 868   bool compare_entry_to(int index1, const constantPoolHandle& cp2, int index2, TRAPS);
 869   void copy_cp_to(int start_i, int end_i, const constantPoolHandle& to_cp, int to_i, TRAPS) {
 870     constantPoolHandle h_this(THREAD, this);
 871     copy_cp_to_impl(h_this, start_i, end_i, to_cp, to_i, THREAD);
 872   }
 873   static void copy_cp_to_impl(const constantPoolHandle& from_cp, int start_i, int end_i, const constantPoolHandle& to_cp, int to_i, TRAPS);
 874   static void copy_entry_to(const constantPoolHandle& from_cp, int from_i, const constantPoolHandle& to_cp, int to_i, TRAPS);
 875   static void copy_operands(const constantPoolHandle& from_cp, const constantPoolHandle& to_cp, TRAPS);
 876   int  find_matching_entry(int pattern_i, const constantPoolHandle& search_cp, TRAPS);
 877   int  version() const                    { return _saved._version; }
 878   void set_version(int version)           { _saved._version = version; }
 879   void increment_and_save_version(int version) {
 880     _saved._version = version >= 0 ? (version + 1) : version;  // keep overflow
 881   }
 882 
 883   void set_resolved_reference_length(int length) { _saved._resolved_reference_length = length; }
 884   int  resolved_reference_length() const  { return _saved._resolved_reference_length; }
 885 
 886   // Decrease ref counts of symbols that are in the constant pool


< prev index next >