src/share/vm/oops/cpCacheKlass.cpp

Sun, 13 Apr 2008 17:43:42 -0400

author
coleenp
date
Sun, 13 Apr 2008 17:43:42 -0400
changeset 548
ba764ed4b6f2
parent 435
a61af66fc99e
child 631
d1605aabd0a1
permissions
-rw-r--r--

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold

duke@435 1 /*
duke@435 2 * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_cpCacheKlass.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 int constantPoolCacheKlass::oop_size(oop obj) const {
duke@435 30 assert(obj->is_constantPoolCache(), "must be constantPool");
duke@435 31 return constantPoolCacheOop(obj)->object_size();
duke@435 32 }
duke@435 33
duke@435 34
duke@435 35 constantPoolCacheOop constantPoolCacheKlass::allocate(int length, TRAPS) {
duke@435 36 // allocate memory
duke@435 37 int size = constantPoolCacheOopDesc::object_size(length);
duke@435 38 KlassHandle klass (THREAD, as_klassOop());
duke@435 39 constantPoolCacheOop cache = (constantPoolCacheOop)
coleenp@548 40 CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
coleenp@548 41 cache->set_length(length);
duke@435 42 cache->set_constant_pool(NULL);
duke@435 43 return cache;
duke@435 44 }
duke@435 45
duke@435 46 klassOop constantPoolCacheKlass::create_klass(TRAPS) {
duke@435 47 constantPoolCacheKlass o;
coleenp@548 48 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
coleenp@548 49 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
coleenp@548 50 // Make sure size calculation is right
coleenp@548 51 assert(k()->size() == align_object_size(header_size()), "wrong size for object");
coleenp@548 52 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
duke@435 53 return k();
duke@435 54 }
duke@435 55
duke@435 56
duke@435 57 void constantPoolCacheKlass::oop_follow_contents(oop obj) {
duke@435 58 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 59 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 60 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 61 // know that Universe::constantPoolCacheKlassObj never moves.
duke@435 62 // gc of constant pool cache instance variables
duke@435 63 MarkSweep::mark_and_push((oop*)cache->constant_pool_addr());
duke@435 64 // gc of constant pool cache entries
duke@435 65 int i = cache->length();
duke@435 66 while (i-- > 0) cache->entry_at(i)->follow_contents();
duke@435 67 }
duke@435 68
duke@435 69 #ifndef SERIALGC
duke@435 70 void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm,
duke@435 71 oop obj) {
duke@435 72 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 73 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 74 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 75 // know that Universe::constantPoolCacheKlassObj never moves.
duke@435 76 // gc of constant pool cache instance variables
duke@435 77 PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr());
duke@435 78 // gc of constant pool cache entries
duke@435 79 int i = cache->length();
duke@435 80 while (i-- > 0) cache->entry_at(i)->follow_contents(cm);
duke@435 81 }
duke@435 82 #endif // SERIALGC
duke@435 83
duke@435 84
duke@435 85 int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
duke@435 86 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 87 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 88 // Get size before changing pointers.
duke@435 89 // Don't call size() or oop_size() since that is a virtual call.
duke@435 90 int size = cache->object_size();
duke@435 91 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 92 // know that Universe::constantPoolCacheKlassObj never moves.
duke@435 93 // iteration over constant pool cache instance variables
duke@435 94 blk->do_oop((oop*)cache->constant_pool_addr());
duke@435 95 // iteration over constant pool cache entries
duke@435 96 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk);
duke@435 97 return size;
duke@435 98 }
duke@435 99
duke@435 100
duke@435 101 int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
duke@435 102 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 103 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 104 // Get size before changing pointers.
duke@435 105 // Don't call size() or oop_size() since that is a virtual call.
duke@435 106 int size = cache->object_size();
duke@435 107 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 108 // know that Universe::constantPoolCacheKlassObj never moves.
duke@435 109 // iteration over constant pool cache instance variables
duke@435 110 oop* addr = (oop*)cache->constant_pool_addr();
duke@435 111 if (mr.contains(addr)) blk->do_oop(addr);
duke@435 112 // iteration over constant pool cache entries
duke@435 113 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr);
duke@435 114 return size;
duke@435 115 }
duke@435 116
duke@435 117
duke@435 118 int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
duke@435 119 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 120 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 121 // Get size before changing pointers.
duke@435 122 // Don't call size() or oop_size() since that is a virtual call.
duke@435 123 int size = cache->object_size();
duke@435 124 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 125 // know that Universe::constantPoolCacheKlassObj never moves.
duke@435 126 // Iteration over constant pool cache instance variables
duke@435 127 MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr());
duke@435 128 // iteration over constant pool cache entries
duke@435 129 for (int i = 0; i < cache->length(); i++)
duke@435 130 cache->entry_at(i)->adjust_pointers();
duke@435 131 return size;
duke@435 132 }
duke@435 133
duke@435 134 #ifndef SERIALGC
duke@435 135 void constantPoolCacheKlass::oop_copy_contents(PSPromotionManager* pm,
duke@435 136 oop obj) {
duke@435 137 assert(obj->is_constantPoolCache(), "should be constant pool");
duke@435 138 }
duke@435 139
duke@435 140 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
duke@435 141 oop obj) {
duke@435 142 assert(obj->is_constantPoolCache(), "should be constant pool");
duke@435 143 }
duke@435 144
duke@435 145 int
duke@435 146 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
duke@435 147 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 148 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 149
duke@435 150 // Iteration over constant pool cache instance variables
duke@435 151 PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr());
duke@435 152
duke@435 153 // iteration over constant pool cache entries
duke@435 154 for (int i = 0; i < cache->length(); ++i) {
duke@435 155 cache->entry_at(i)->update_pointers();
duke@435 156 }
duke@435 157
duke@435 158 return cache->object_size();
duke@435 159 }
duke@435 160
duke@435 161 int
duke@435 162 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
duke@435 163 HeapWord* beg_addr,
duke@435 164 HeapWord* end_addr) {
duke@435 165 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 166 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 167
duke@435 168 // Iteration over constant pool cache instance variables
duke@435 169 oop* p;
duke@435 170 p = (oop*)cache->constant_pool_addr();
duke@435 171 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
duke@435 172
duke@435 173 // Iteration over constant pool cache entries
duke@435 174 for (int i = 0; i < cache->length(); ++i) {
duke@435 175 cache->entry_at(i)->update_pointers(beg_addr, end_addr);
duke@435 176 }
duke@435 177 return cache->object_size();
duke@435 178 }
duke@435 179 #endif // SERIALGC
duke@435 180
duke@435 181 #ifndef PRODUCT
duke@435 182
duke@435 183 void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
duke@435 184 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 185 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 186 // super print
coleenp@548 187 Klass::oop_print_on(obj, st);
duke@435 188 // print constant pool cache entries
duke@435 189 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i);
duke@435 190 }
duke@435 191
duke@435 192 #endif
duke@435 193
duke@435 194 void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) {
duke@435 195 guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache");
duke@435 196 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
duke@435 197 // super verify
coleenp@548 198 Klass::oop_verify_on(obj, st);
duke@435 199 // print constant pool cache entries
duke@435 200 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st);
duke@435 201 }
duke@435 202
duke@435 203
duke@435 204 const char* constantPoolCacheKlass::internal_name() const {
duke@435 205 return "{constant pool cache}";
duke@435 206 }

mercurial