< prev index next >

src/share/vm/oops/constantPool.hpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP
  26 #define SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP
  27 
  28 #include "oops/arrayOop.hpp"
  29 #include "oops/cpCache.hpp"
  30 #include "oops/objArrayOop.hpp"

  31 #include "oops/symbol.hpp"
  32 #include "oops/typeArrayOop.hpp"
  33 #include "runtime/handles.hpp"
  34 #include "utilities/align.hpp"
  35 #include "utilities/bytes.hpp"
  36 #include "utilities/constantTag.hpp"
  37 
  38 // A ConstantPool is an array containing class constants as described in the
  39 // class file.
  40 //
  41 // Most of the constant pool entries are written during class parsing, which
  42 // is safe.  For klass types, the constant pool entry is
  43 // modified when the entry is resolved.  If a klass constant pool
  44 // entry is read without a lock, only the resolved state guarantees that
  45 // the entry in the constant pool is a klass object and not a Symbol*.
  46 
  47 class SymbolHashMap;
  48 
  49 class CPSlot VALUE_OBJ_CLASS_SPEC {
  50  friend class ConstantPool;


 803   int pre_resolve_shared_klasses(TRAPS);
 804 
 805   // Debugging
 806   const char* printable_name_at(int which) PRODUCT_RETURN0;
 807 
 808 #ifdef ASSERT
 809   enum { CPCACHE_INDEX_TAG = 0x10000 };  // helps keep CP cache indices distinct from CP indices
 810 #else
 811   enum { CPCACHE_INDEX_TAG = 0 };        // in product mode, this zero value is a no-op
 812 #endif //ASSERT
 813 
 814   static int decode_cpcache_index(int raw_index, bool invokedynamic_ok = false) {
 815     if (invokedynamic_ok && is_invokedynamic_index(raw_index))
 816       return decode_invokedynamic_index(raw_index);
 817     else
 818       return raw_index - CPCACHE_INDEX_TAG;
 819   }
 820 
 821  private:
 822 
 823   void set_resolved_references(jobject s) { _cache->set_resolved_references(s); }
 824   Array<u2>* reference_map() const        {  return (_cache == NULL) ? NULL :  _cache->reference_map(); }
 825   void set_reference_map(Array<u2>* o)    { _cache->set_reference_map(o); }
 826 
 827   // patch JSR 292 resolved references after the class is linked.
 828   void patch_resolved_references(GrowableArray<Handle>* cp_patches);
 829 
 830   Symbol* impl_name_ref_at(int which, bool uncached);
 831   Symbol* impl_signature_ref_at(int which, bool uncached);
 832   int       impl_klass_ref_index_at(int which, bool uncached);
 833   int       impl_name_and_type_ref_index_at(int which, bool uncached);
 834   constantTag impl_tag_ref_at(int which, bool uncached);
 835 
 836   // Used while constructing constant pool (only by ClassFileParser)
 837   jint klass_index_at(int which) {
 838     assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
 839     return *int_at_addr(which);
 840   }
 841 
 842   jint string_index_at(int which) {
 843     assert(tag_at(which).is_string_index(), "Corrupted constant pool");




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP
  26 #define SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP
  27 
  28 #include "oops/arrayOop.hpp"
  29 #include "oops/cpCache.hpp"
  30 #include "oops/objArrayOop.hpp"
  31 #include "oops/oopHandle.hpp"
  32 #include "oops/symbol.hpp"
  33 #include "oops/typeArrayOop.hpp"
  34 #include "runtime/handles.hpp"
  35 #include "utilities/align.hpp"
  36 #include "utilities/bytes.hpp"
  37 #include "utilities/constantTag.hpp"
  38 
  39 // A ConstantPool is an array containing class constants as described in the
  40 // class file.
  41 //
  42 // Most of the constant pool entries are written during class parsing, which
  43 // is safe.  For klass types, the constant pool entry is
  44 // modified when the entry is resolved.  If a klass constant pool
  45 // entry is read without a lock, only the resolved state guarantees that
  46 // the entry in the constant pool is a klass object and not a Symbol*.
  47 
  48 class SymbolHashMap;
  49 
  50 class CPSlot VALUE_OBJ_CLASS_SPEC {
  51  friend class ConstantPool;


 804   int pre_resolve_shared_klasses(TRAPS);
 805 
 806   // Debugging
 807   const char* printable_name_at(int which) PRODUCT_RETURN0;
 808 
 809 #ifdef ASSERT
 810   enum { CPCACHE_INDEX_TAG = 0x10000 };  // helps keep CP cache indices distinct from CP indices
 811 #else
 812   enum { CPCACHE_INDEX_TAG = 0 };        // in product mode, this zero value is a no-op
 813 #endif //ASSERT
 814 
 815   static int decode_cpcache_index(int raw_index, bool invokedynamic_ok = false) {
 816     if (invokedynamic_ok && is_invokedynamic_index(raw_index))
 817       return decode_invokedynamic_index(raw_index);
 818     else
 819       return raw_index - CPCACHE_INDEX_TAG;
 820   }
 821 
 822  private:
 823 
 824   void set_resolved_references(OopHandle s) { _cache->set_resolved_references(s); }
 825   Array<u2>* reference_map() const        {  return (_cache == NULL) ? NULL :  _cache->reference_map(); }
 826   void set_reference_map(Array<u2>* o)    { _cache->set_reference_map(o); }
 827 
 828   // patch JSR 292 resolved references after the class is linked.
 829   void patch_resolved_references(GrowableArray<Handle>* cp_patches);
 830 
 831   Symbol* impl_name_ref_at(int which, bool uncached);
 832   Symbol* impl_signature_ref_at(int which, bool uncached);
 833   int       impl_klass_ref_index_at(int which, bool uncached);
 834   int       impl_name_and_type_ref_index_at(int which, bool uncached);
 835   constantTag impl_tag_ref_at(int which, bool uncached);
 836 
 837   // Used while constructing constant pool (only by ClassFileParser)
 838   jint klass_index_at(int which) {
 839     assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
 840     return *int_at_addr(which);
 841   }
 842 
 843   jint string_index_at(int which) {
 844     assert(tag_at(which).is_string_index(), "Corrupted constant pool");


< prev index next >