comparison src/share/vm/services/classLoadingService.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 436b4a3231bf
children fb19af007ffc
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2012, 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.
132 PerfDataManager::create_variable(SUN_CLS, "methodBytes", 132 PerfDataManager::create_variable(SUN_CLS, "methodBytes",
133 PerfData::U_Bytes, CHECK); 133 PerfData::U_Bytes, CHECK);
134 } 134 }
135 } 135 }
136 136
137 void ClassLoadingService::notify_class_unloaded(instanceKlass* k) { 137 void ClassLoadingService::notify_class_unloaded(InstanceKlass* k) {
138 DTRACE_CLASSLOAD_PROBE(unloaded, k, false); 138 DTRACE_CLASSLOAD_PROBE(unloaded, k, false);
139 // Classes that can be unloaded must be non-shared 139 // Classes that can be unloaded must be non-shared
140 _classes_unloaded_count->inc(); 140 _classes_unloaded_count->inc();
141 141
142 if (UsePerfData) { 142 if (UsePerfData) {
144 size_t size = compute_class_size(k); 144 size_t size = compute_class_size(k);
145 _classbytes_unloaded->inc(size); 145 _classbytes_unloaded->inc(size);
146 146
147 // Compute method size & subtract from running total. 147 // Compute method size & subtract from running total.
148 // We are called during phase 1 of mark sweep, so it's 148 // We are called during phase 1 of mark sweep, so it's
149 // still ok to iterate through methodOops here. 149 // still ok to iterate through Method*s here.
150 objArrayOop methods = k->methods(); 150 Array<Method*>* methods = k->methods();
151 for (int i = 0; i < methods->length(); i++) { 151 for (int i = 0; i < methods->length(); i++) {
152 _class_methods_size->inc(-methods->obj_at(i)->size()); 152 _class_methods_size->inc(-methods->at(i)->size());
153 } 153 }
154 } 154 }
155 155
156 if (TraceClassUnloading) { 156 if (TraceClassUnloading) {
157 ResourceMark rm; 157 ResourceMark rm;
158 tty->print_cr("[Unloading class %s]", k->external_name()); 158 tty->print_cr("[Unloading class %s " INTPTR_FORMAT "]", k->external_name(), k);
159 } 159 }
160 } 160 }
161 161
162 void ClassLoadingService::notify_class_loaded(instanceKlass* k, bool shared_class) { 162 void ClassLoadingService::notify_class_loaded(InstanceKlass* k, bool shared_class) {
163 DTRACE_CLASSLOAD_PROBE(loaded, k, shared_class); 163 DTRACE_CLASSLOAD_PROBE(loaded, k, shared_class);
164 PerfCounter* classes_counter = (shared_class ? _shared_classes_loaded_count 164 PerfCounter* classes_counter = (shared_class ? _shared_classes_loaded_count
165 : _classes_loaded_count); 165 : _classes_loaded_count);
166 // increment the count 166 // increment the count
167 classes_counter->inc(); 167 classes_counter->inc();
173 size_t size = compute_class_size(k); 173 size_t size = compute_class_size(k);
174 classbytes_counter->inc(size); 174 classbytes_counter->inc(size);
175 } 175 }
176 } 176 }
177 177
178 size_t ClassLoadingService::compute_class_size(instanceKlass* k) { 178 size_t ClassLoadingService::compute_class_size(InstanceKlass* k) {
179 // lifted from ClassStatistics.do_class(klassOop k) 179 // lifted from ClassStatistics.do_class(Klass* k)
180 180
181 size_t class_size = 0; 181 size_t class_size = 0;
182 182
183 class_size += k->as_klassOop()->size(); 183 class_size += k->size();
184 184
185 if (k->oop_is_instance()) { 185 if (k->oop_is_instance()) {
186 class_size += k->methods()->size(); 186 class_size += k->methods()->size();
187 // FIXME: Need to count the contents of methods
187 class_size += k->constants()->size(); 188 class_size += k->constants()->size();
188 class_size += k->local_interfaces()->size(); 189 class_size += k->local_interfaces()->size();
189 class_size += k->transitive_interfaces()->size(); 190 class_size += k->transitive_interfaces()->size();
190 // We do not have to count implementors, since we only store one! 191 // We do not have to count implementors, since we only store one!
191 class_size += k->fields()->size(); 192 // FIXME: How should these be accounted for, now when they have moved.
193 //class_size += k->fields()->size();
192 } 194 }
193 return class_size * oopSize; 195 return class_size * oopSize;
194 } 196 }
195 197
196 198