1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
46 #endif |
46 #endif |
47 #ifdef TARGET_ARCH_ppc |
47 #ifdef TARGET_ARCH_ppc |
48 # include "bytes_ppc.hpp" |
48 # include "bytes_ppc.hpp" |
49 #endif |
49 #endif |
50 |
50 |
51 // A constantPool is an array containing class constants as described in the |
51 // A ConstantPool is an array containing class constants as described in the |
52 // class file. |
52 // class file. |
53 // |
53 // |
54 // Most of the constant pool entries are written during class parsing, which |
54 // Most of the constant pool entries are written during class parsing, which |
55 // is safe. For klass types, the constant pool entry is |
55 // is safe. For klass types, the constant pool entry is |
56 // modified when the entry is resolved. If a klass constant pool |
56 // modified when the entry is resolved. If a klass constant pool |
79 return (Klass*)_ptr; |
79 return (Klass*)_ptr; |
80 } |
80 } |
81 }; |
81 }; |
82 |
82 |
83 class KlassSizeStats; |
83 class KlassSizeStats; |
|
84 |
84 class ConstantPool : public Metadata { |
85 class ConstantPool : public Metadata { |
85 friend class VMStructs; |
86 friend class VMStructs; |
86 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast |
87 friend class BytecodeInterpreter; // Directly extracts a klass in the pool for fast instanceof/checkcast |
87 friend class Universe; // For null constructor |
88 friend class Universe; // For null constructor |
88 private: |
89 private: |
89 Array<u1>* _tags; // the tag array describing the constant pool's contents |
90 Array<u1>* _tags; // the tag array describing the constant pool's contents |
90 ConstantPoolCache* _cache; // the cache holding interpreter runtime information |
91 ConstantPoolCache* _cache; // the cache holding interpreter runtime information |
91 InstanceKlass* _pool_holder; // the corresponding class |
92 InstanceKlass* _pool_holder; // the corresponding class |
745 |
746 |
746 friend class ClassFileParser; |
747 friend class ClassFileParser; |
747 friend class SystemDictionary; |
748 friend class SystemDictionary; |
748 |
749 |
749 // Used by compiler to prevent classloading. |
750 // Used by compiler to prevent classloading. |
750 static Method* method_at_if_loaded (constantPoolHandle this_oop, int which); |
751 static Method* method_at_if_loaded (constantPoolHandle this_cp, int which); |
751 static bool has_appendix_at_if_loaded (constantPoolHandle this_oop, int which); |
752 static bool has_appendix_at_if_loaded (constantPoolHandle this_cp, int which); |
752 static oop appendix_at_if_loaded (constantPoolHandle this_oop, int which); |
753 static oop appendix_at_if_loaded (constantPoolHandle this_cp, int which); |
753 static bool has_method_type_at_if_loaded (constantPoolHandle this_oop, int which); |
754 static bool has_method_type_at_if_loaded (constantPoolHandle this_cp, int which); |
754 static oop method_type_at_if_loaded (constantPoolHandle this_oop, int which); |
755 static oop method_type_at_if_loaded (constantPoolHandle this_cp, int which); |
755 static Klass* klass_at_if_loaded (constantPoolHandle this_oop, int which); |
756 static Klass* klass_at_if_loaded (constantPoolHandle this_cp, int which); |
756 static Klass* klass_ref_at_if_loaded (constantPoolHandle this_oop, int which); |
757 static Klass* klass_ref_at_if_loaded (constantPoolHandle this_cp, int which); |
757 |
758 |
758 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the |
759 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the |
759 // future by other Java code. These take constant pool indices rather than |
760 // future by other Java code. These take constant pool indices rather than |
760 // constant pool cache indices as do the peer methods above. |
761 // constant pool cache indices as do the peer methods above. |
761 Symbol* uncached_klass_ref_at_noresolve(int which); |
762 Symbol* uncached_klass_ref_at_noresolve(int which); |
809 assert(tag_at(which).is_string_index(), "Corrupted constant pool"); |
810 assert(tag_at(which).is_string_index(), "Corrupted constant pool"); |
810 return *int_at_addr(which); |
811 return *int_at_addr(which); |
811 } |
812 } |
812 |
813 |
813 // Performs the LinkResolver checks |
814 // Performs the LinkResolver checks |
814 static void verify_constant_pool_resolve(constantPoolHandle this_oop, KlassHandle klass, TRAPS); |
815 static void verify_constant_pool_resolve(constantPoolHandle this_cp, KlassHandle klass, TRAPS); |
815 |
816 |
816 // Implementation of methods that needs an exposed 'this' pointer, in order to |
817 // Implementation of methods that needs an exposed 'this' pointer, in order to |
817 // handle GC while executing the method |
818 // handle GC while executing the method |
818 static Klass* klass_at_impl(constantPoolHandle this_oop, int which, TRAPS); |
819 static Klass* klass_at_impl(constantPoolHandle this_cp, int which, TRAPS); |
819 static oop string_at_impl(constantPoolHandle this_oop, int which, int obj_index, TRAPS); |
820 static oop string_at_impl(constantPoolHandle this_cp, int which, int obj_index, TRAPS); |
820 |
821 |
821 // Resolve string constants (to prevent allocation during compilation) |
822 // Resolve string constants (to prevent allocation during compilation) |
822 static void resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS); |
823 static void resolve_string_constants_impl(constantPoolHandle this_cp, TRAPS); |
823 |
824 |
824 static oop resolve_constant_at_impl(constantPoolHandle this_oop, int index, int cache_index, TRAPS); |
825 static oop resolve_constant_at_impl(constantPoolHandle this_cp, int index, int cache_index, TRAPS); |
825 static void save_and_throw_exception(constantPoolHandle this_oop, int which, int tag_value, TRAPS); |
826 static void save_and_throw_exception(constantPoolHandle this_cp, int which, int tag_value, TRAPS); |
826 static oop resolve_bootstrap_specifier_at_impl(constantPoolHandle this_oop, int index, TRAPS); |
827 static oop resolve_bootstrap_specifier_at_impl(constantPoolHandle this_cp, int index, TRAPS); |
827 |
828 |
828 public: |
829 public: |
829 // Merging ConstantPool* support: |
830 // Merging ConstantPool* support: |
830 bool compare_entry_to(int index1, constantPoolHandle cp2, int index2, TRAPS); |
831 bool compare_entry_to(int index1, constantPoolHandle cp2, int index2, TRAPS); |
831 void copy_cp_to(int start_i, int end_i, constantPoolHandle to_cp, int to_i, TRAPS) { |
832 void copy_cp_to(int start_i, int end_i, constantPoolHandle to_cp, int to_i, TRAPS) { |