duke@435: /* duke@435: * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: #include "incls/_precompiled.incl" duke@435: #include "incls/_cpCacheKlass.cpp.incl" duke@435: duke@435: duke@435: int constantPoolCacheKlass::oop_size(oop obj) const { duke@435: assert(obj->is_constantPoolCache(), "must be constantPool"); duke@435: return constantPoolCacheOop(obj)->object_size(); duke@435: } duke@435: duke@435: duke@435: constantPoolCacheOop constantPoolCacheKlass::allocate(int length, TRAPS) { duke@435: // allocate memory duke@435: int size = constantPoolCacheOopDesc::object_size(length); duke@435: KlassHandle klass (THREAD, as_klassOop()); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop) coleenp@548: CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); coleenp@548: cache->set_length(length); duke@435: cache->set_constant_pool(NULL); duke@435: return cache; duke@435: } duke@435: duke@435: klassOop constantPoolCacheKlass::create_klass(TRAPS) { duke@435: constantPoolCacheKlass o; coleenp@548: KlassHandle h_this_klass(THREAD, Universe::klassKlassObj()); coleenp@548: KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); coleenp@548: // Make sure size calculation is right coleenp@548: assert(k()->size() == align_object_size(header_size()), "wrong size for object"); coleenp@548: java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror duke@435: return k(); duke@435: } duke@435: duke@435: duke@435: void constantPoolCacheKlass::oop_follow_contents(oop obj) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: // Performance tweak: We skip iterating over the klass pointer since we duke@435: // know that Universe::constantPoolCacheKlassObj never moves. duke@435: // gc of constant pool cache instance variables duke@435: MarkSweep::mark_and_push((oop*)cache->constant_pool_addr()); duke@435: // gc of constant pool cache entries duke@435: int i = cache->length(); duke@435: while (i-- > 0) cache->entry_at(i)->follow_contents(); duke@435: } duke@435: duke@435: #ifndef SERIALGC duke@435: void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm, duke@435: oop obj) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: // Performance tweak: We skip iterating over the klass pointer since we duke@435: // know that Universe::constantPoolCacheKlassObj never moves. duke@435: // gc of constant pool cache instance variables duke@435: PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr()); duke@435: // gc of constant pool cache entries duke@435: int i = cache->length(); duke@435: while (i-- > 0) cache->entry_at(i)->follow_contents(cm); duke@435: } duke@435: #endif // SERIALGC duke@435: duke@435: duke@435: int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: // Get size before changing pointers. duke@435: // Don't call size() or oop_size() since that is a virtual call. duke@435: int size = cache->object_size(); duke@435: // Performance tweak: We skip iterating over the klass pointer since we duke@435: // know that Universe::constantPoolCacheKlassObj never moves. duke@435: // iteration over constant pool cache instance variables duke@435: blk->do_oop((oop*)cache->constant_pool_addr()); duke@435: // iteration over constant pool cache entries duke@435: for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk); duke@435: return size; duke@435: } duke@435: duke@435: duke@435: int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: // Get size before changing pointers. duke@435: // Don't call size() or oop_size() since that is a virtual call. duke@435: int size = cache->object_size(); duke@435: // Performance tweak: We skip iterating over the klass pointer since we duke@435: // know that Universe::constantPoolCacheKlassObj never moves. duke@435: // iteration over constant pool cache instance variables duke@435: oop* addr = (oop*)cache->constant_pool_addr(); duke@435: if (mr.contains(addr)) blk->do_oop(addr); duke@435: // iteration over constant pool cache entries duke@435: for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr); duke@435: return size; duke@435: } duke@435: duke@435: duke@435: int constantPoolCacheKlass::oop_adjust_pointers(oop obj) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: // Get size before changing pointers. duke@435: // Don't call size() or oop_size() since that is a virtual call. duke@435: int size = cache->object_size(); duke@435: // Performance tweak: We skip iterating over the klass pointer since we duke@435: // know that Universe::constantPoolCacheKlassObj never moves. duke@435: // Iteration over constant pool cache instance variables duke@435: MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr()); duke@435: // iteration over constant pool cache entries duke@435: for (int i = 0; i < cache->length(); i++) duke@435: cache->entry_at(i)->adjust_pointers(); duke@435: return size; duke@435: } duke@435: duke@435: #ifndef SERIALGC duke@435: void constantPoolCacheKlass::oop_copy_contents(PSPromotionManager* pm, duke@435: oop obj) { duke@435: assert(obj->is_constantPoolCache(), "should be constant pool"); duke@435: } duke@435: duke@435: void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm, duke@435: oop obj) { duke@435: assert(obj->is_constantPoolCache(), "should be constant pool"); duke@435: } duke@435: duke@435: int duke@435: constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: duke@435: // Iteration over constant pool cache instance variables duke@435: PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr()); duke@435: duke@435: // iteration over constant pool cache entries duke@435: for (int i = 0; i < cache->length(); ++i) { duke@435: cache->entry_at(i)->update_pointers(); duke@435: } duke@435: duke@435: return cache->object_size(); duke@435: } duke@435: duke@435: int duke@435: constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, duke@435: HeapWord* beg_addr, duke@435: HeapWord* end_addr) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: duke@435: // Iteration over constant pool cache instance variables duke@435: oop* p; duke@435: p = (oop*)cache->constant_pool_addr(); duke@435: PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); duke@435: duke@435: // Iteration over constant pool cache entries duke@435: for (int i = 0; i < cache->length(); ++i) { duke@435: cache->entry_at(i)->update_pointers(beg_addr, end_addr); duke@435: } duke@435: return cache->object_size(); duke@435: } duke@435: #endif // SERIALGC duke@435: duke@435: #ifndef PRODUCT duke@435: duke@435: void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) { duke@435: assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: // super print coleenp@548: Klass::oop_print_on(obj, st); duke@435: // print constant pool cache entries duke@435: for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i); duke@435: } duke@435: duke@435: #endif duke@435: duke@435: void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) { duke@435: guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache"); duke@435: constantPoolCacheOop cache = (constantPoolCacheOop)obj; duke@435: // super verify coleenp@548: Klass::oop_verify_on(obj, st); duke@435: // print constant pool cache entries duke@435: for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st); duke@435: } duke@435: duke@435: duke@435: const char* constantPoolCacheKlass::internal_name() const { duke@435: return "{constant pool cache}"; duke@435: }