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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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 // A constantPool is an array containing class constants as described in the 26 // class file. 27 // 28 // Most of the constant pool entries are written during class parsing, which 29 // is safe. For klass and string types, the constant pool entry is 30 // modified when the entry is resolved. If a klass or string constant pool 31 // entry is read without a lock, only the resolved state guarantees that 32 // the entry in the constant pool is a klass or String object and 33 // not a symbolOop. 34 35 class SymbolHashMap; 36 37 class constantPoolOopDesc : public oopDesc { 38 friend class VMStructs; 39 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast 40 private: 41 typeArrayOop _tags; // the tag array describing the constant pool's contents 42 constantPoolCacheOop _cache; // the cache holding interpreter runtime information 43 klassOop _pool_holder; // the corresponding class 44 int _flags; // a few header bits to describe contents for GC 649 650 void add_entry(symbolOop sym, u2 value); 651 SymbolHashMapEntry* find_entry(symbolOop sym); 652 653 u2 symbol_to_value(symbolOop sym) { 654 SymbolHashMapEntry *entry = find_entry(sym); 655 return (entry == NULL) ? 0 : entry->value(); 656 } 657 658 ~SymbolHashMap() { 659 SymbolHashMapEntry* next; 660 for (int i = 0; i < _table_size; i++) { 661 for (SymbolHashMapEntry* cur = bucket(i); cur != NULL; cur = next) { 662 next = cur->next(); 663 delete(cur); 664 } 665 } 666 delete _buckets; 667 } 668 }; // End SymbolHashMap class | 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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/cpCacheOop.hpp" 30 #include "oops/typeArrayOop.hpp" 31 #include "utilities/constantTag.hpp" 32 #ifdef TARGET_ARCH_x86 33 # include "bytes_x86.hpp" 34 #endif 35 #ifdef TARGET_ARCH_sparc 36 # include "bytes_sparc.hpp" 37 #endif 38 #ifdef TARGET_ARCH_zero 39 # include "bytes_zero.hpp" 40 #endif 41 42 // A constantPool is an array containing class constants as described in the 43 // class file. 44 // 45 // Most of the constant pool entries are written during class parsing, which 46 // is safe. For klass and string types, the constant pool entry is 47 // modified when the entry is resolved. If a klass or string constant pool 48 // entry is read without a lock, only the resolved state guarantees that 49 // the entry in the constant pool is a klass or String object and 50 // not a symbolOop. 51 52 class SymbolHashMap; 53 54 class constantPoolOopDesc : public oopDesc { 55 friend class VMStructs; 56 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast 57 private: 58 typeArrayOop _tags; // the tag array describing the constant pool's contents 59 constantPoolCacheOop _cache; // the cache holding interpreter runtime information 60 klassOop _pool_holder; // the corresponding class 61 int _flags; // a few header bits to describe contents for GC 666 667 void add_entry(symbolOop sym, u2 value); 668 SymbolHashMapEntry* find_entry(symbolOop sym); 669 670 u2 symbol_to_value(symbolOop sym) { 671 SymbolHashMapEntry *entry = find_entry(sym); 672 return (entry == NULL) ? 0 : entry->value(); 673 } 674 675 ~SymbolHashMap() { 676 SymbolHashMapEntry* next; 677 for (int i = 0; i < _table_size; i++) { 678 for (SymbolHashMapEntry* cur = bucket(i); cur != NULL; cur = next) { 679 next = cur->next(); 680 delete(cur); 681 } 682 } 683 delete _buckets; 684 } 685 }; // End SymbolHashMap class 686 687 #endif // SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP |