src/share/vm/code/codeCache.cpp

Mon, 15 Apr 2019 16:27:50 +0000

author
cvarming
date
Mon, 15 Apr 2019 16:27:50 +0000
changeset 9661
379a59bf685d
parent 9191
a0373be7fe1b
child 9703
2fdf635bcf28
child 9858
b985cbb00e68
permissions
-rw-r--r--

8150013: ParNew: Prune nmethods scavengable list.
Summary: Speed up ParNew collections by pruning the list of scavengable nmethods.
Reviewed-by: jmasa, tonyp, twisti

duke@435 1 /*
stuefe@9191 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "code/codeBlob.hpp"
stefank@2314 27 #include "code/codeCache.hpp"
coleenp@4037 28 #include "code/compiledIC.hpp"
stefank@2314 29 #include "code/dependencies.hpp"
coleenp@4037 30 #include "code/icBuffer.hpp"
stefank@2314 31 #include "code/nmethod.hpp"
stefank@2314 32 #include "code/pcDesc.hpp"
vladidan@4438 33 #include "compiler/compileBroker.hpp"
stefank@2314 34 #include "gc_implementation/shared/markSweep.hpp"
stefank@2314 35 #include "memory/allocation.inline.hpp"
stefank@2314 36 #include "memory/gcLocker.hpp"
stefank@2314 37 #include "memory/iterator.hpp"
stefank@2314 38 #include "memory/resourceArea.hpp"
coleenp@4037 39 #include "oops/method.hpp"
stefank@2314 40 #include "oops/objArrayOop.hpp"
stefank@2314 41 #include "oops/oop.inline.hpp"
stefank@2314 42 #include "runtime/handles.inline.hpp"
vladidan@4438 43 #include "runtime/arguments.hpp"
stuefe@9191 44 #include "runtime/deoptimization.hpp"
stefank@2314 45 #include "runtime/icache.hpp"
stefank@2314 46 #include "runtime/java.hpp"
stefank@2314 47 #include "runtime/mutexLocker.hpp"
stefank@2314 48 #include "services/memoryService.hpp"
sla@5237 49 #include "trace/tracing.hpp"
stefank@2314 50 #include "utilities/xmlstream.hpp"
duke@435 51
duke@435 52 // Helper class for printing in CodeCache
duke@435 53
duke@435 54 class CodeBlob_sizes {
duke@435 55 private:
duke@435 56 int count;
duke@435 57 int total_size;
duke@435 58 int header_size;
duke@435 59 int code_size;
duke@435 60 int stub_size;
duke@435 61 int relocation_size;
duke@435 62 int scopes_oop_size;
coleenp@4037 63 int scopes_metadata_size;
duke@435 64 int scopes_data_size;
duke@435 65 int scopes_pcs_size;
duke@435 66
duke@435 67 public:
duke@435 68 CodeBlob_sizes() {
duke@435 69 count = 0;
duke@435 70 total_size = 0;
duke@435 71 header_size = 0;
duke@435 72 code_size = 0;
duke@435 73 stub_size = 0;
duke@435 74 relocation_size = 0;
duke@435 75 scopes_oop_size = 0;
coleenp@4037 76 scopes_metadata_size = 0;
duke@435 77 scopes_data_size = 0;
duke@435 78 scopes_pcs_size = 0;
duke@435 79 }
duke@435 80
duke@435 81 int total() { return total_size; }
duke@435 82 bool is_empty() { return count == 0; }
duke@435 83
duke@435 84 void print(const char* title) {
drchase@6680 85 tty->print_cr(" #%d %s = %dK (hdr %d%%, loc %d%%, code %d%%, stub %d%%, [oops %d%%, metadata %d%%, data %d%%, pcs %d%%])",
duke@435 86 count,
duke@435 87 title,
drchase@6680 88 (int)(total() / K),
duke@435 89 header_size * 100 / total_size,
duke@435 90 relocation_size * 100 / total_size,
duke@435 91 code_size * 100 / total_size,
duke@435 92 stub_size * 100 / total_size,
duke@435 93 scopes_oop_size * 100 / total_size,
coleenp@4037 94 scopes_metadata_size * 100 / total_size,
duke@435 95 scopes_data_size * 100 / total_size,
duke@435 96 scopes_pcs_size * 100 / total_size);
duke@435 97 }
duke@435 98
duke@435 99 void add(CodeBlob* cb) {
duke@435 100 count++;
duke@435 101 total_size += cb->size();
duke@435 102 header_size += cb->header_size();
duke@435 103 relocation_size += cb->relocation_size();
duke@435 104 if (cb->is_nmethod()) {
twisti@1918 105 nmethod* nm = cb->as_nmethod_or_null();
twisti@2103 106 code_size += nm->insts_size();
duke@435 107 stub_size += nm->stub_size();
duke@435 108
twisti@1918 109 scopes_oop_size += nm->oops_size();
coleenp@4037 110 scopes_metadata_size += nm->metadata_size();
duke@435 111 scopes_data_size += nm->scopes_data_size();
duke@435 112 scopes_pcs_size += nm->scopes_pcs_size();
duke@435 113 } else {
twisti@2103 114 code_size += cb->code_size();
duke@435 115 }
duke@435 116 }
duke@435 117 };
duke@435 118
duke@435 119 // CodeCache implementation
duke@435 120
duke@435 121 CodeHeap * CodeCache::_heap = new CodeHeap();
duke@435 122 int CodeCache::_number_of_blobs = 0;
never@1999 123 int CodeCache::_number_of_adapters = 0;
never@1999 124 int CodeCache::_number_of_nmethods = 0;
duke@435 125 int CodeCache::_number_of_nmethods_with_dependencies = 0;
duke@435 126 bool CodeCache::_needs_cache_clean = false;
jrose@1424 127 nmethod* CodeCache::_scavenge_root_nmethods = NULL;
duke@435 128
sla@5237 129 int CodeCache::_codemem_full_count = 0;
duke@435 130
duke@435 131 CodeBlob* CodeCache::first() {
duke@435 132 assert_locked_or_safepoint(CodeCache_lock);
duke@435 133 return (CodeBlob*)_heap->first();
duke@435 134 }
duke@435 135
duke@435 136
duke@435 137 CodeBlob* CodeCache::next(CodeBlob* cb) {
duke@435 138 assert_locked_or_safepoint(CodeCache_lock);
duke@435 139 return (CodeBlob*)_heap->next(cb);
duke@435 140 }
duke@435 141
duke@435 142
duke@435 143 CodeBlob* CodeCache::alive(CodeBlob *cb) {
duke@435 144 assert_locked_or_safepoint(CodeCache_lock);
duke@435 145 while (cb != NULL && !cb->is_alive()) cb = next(cb);
duke@435 146 return cb;
duke@435 147 }
duke@435 148
duke@435 149
duke@435 150 nmethod* CodeCache::alive_nmethod(CodeBlob* cb) {
duke@435 151 assert_locked_or_safepoint(CodeCache_lock);
duke@435 152 while (cb != NULL && (!cb->is_alive() || !cb->is_nmethod())) cb = next(cb);
duke@435 153 return (nmethod*)cb;
duke@435 154 }
duke@435 155
never@1893 156 nmethod* CodeCache::first_nmethod() {
never@1893 157 assert_locked_or_safepoint(CodeCache_lock);
never@1893 158 CodeBlob* cb = first();
never@1893 159 while (cb != NULL && !cb->is_nmethod()) {
never@1893 160 cb = next(cb);
never@1893 161 }
never@1893 162 return (nmethod*)cb;
never@1893 163 }
never@1893 164
never@1893 165 nmethod* CodeCache::next_nmethod (CodeBlob* cb) {
never@1893 166 assert_locked_or_safepoint(CodeCache_lock);
never@1893 167 cb = next(cb);
never@1893 168 while (cb != NULL && !cb->is_nmethod()) {
never@1893 169 cb = next(cb);
never@1893 170 }
never@1893 171 return (nmethod*)cb;
never@1893 172 }
duke@435 173
vladidan@4438 174 static size_t maxCodeCacheUsed = 0;
vladidan@4438 175
neliasso@4952 176 CodeBlob* CodeCache::allocate(int size, bool is_critical) {
duke@435 177 // Do not seize the CodeCache lock here--if the caller has not
duke@435 178 // already done so, we are going to lose bigtime, since the code
duke@435 179 // cache will contain a garbage CodeBlob until the caller can
duke@435 180 // run the constructor for the CodeBlob subclass he is busy
duke@435 181 // instantiating.
duke@435 182 guarantee(size >= 0, "allocation request must be reasonable");
duke@435 183 assert_locked_or_safepoint(CodeCache_lock);
duke@435 184 CodeBlob* cb = NULL;
duke@435 185 _number_of_blobs++;
duke@435 186 while (true) {
neliasso@4952 187 cb = (CodeBlob*)_heap->allocate(size, is_critical);
duke@435 188 if (cb != NULL) break;
duke@435 189 if (!_heap->expand_by(CodeCacheExpansionSize)) {
duke@435 190 // Expansion failed
duke@435 191 return NULL;
duke@435 192 }
duke@435 193 if (PrintCodeCacheExtension) {
duke@435 194 ResourceMark rm;
drchase@6680 195 tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)",
neliasso@4952 196 (intptr_t)_heap->low_boundary(), (intptr_t)_heap->high(),
neliasso@4952 197 (address)_heap->high() - (address)_heap->low_boundary());
duke@435 198 }
duke@435 199 }
vladidan@4438 200 maxCodeCacheUsed = MAX2(maxCodeCacheUsed, ((address)_heap->high_boundary() -
vladidan@4438 201 (address)_heap->low_boundary()) - unallocated_capacity());
duke@435 202 verify_if_often();
jrose@1424 203 print_trace("allocation", cb, size);
duke@435 204 return cb;
duke@435 205 }
duke@435 206
duke@435 207 void CodeCache::free(CodeBlob* cb) {
duke@435 208 assert_locked_or_safepoint(CodeCache_lock);
duke@435 209 verify_if_often();
duke@435 210
jrose@1424 211 print_trace("free", cb);
never@1999 212 if (cb->is_nmethod()) {
never@1999 213 _number_of_nmethods--;
never@1999 214 if (((nmethod *)cb)->has_dependencies()) {
never@1999 215 _number_of_nmethods_with_dependencies--;
never@1999 216 }
never@1999 217 }
never@1999 218 if (cb->is_adapter_blob()) {
never@1999 219 _number_of_adapters--;
duke@435 220 }
duke@435 221 _number_of_blobs--;
duke@435 222
duke@435 223 _heap->deallocate(cb);
duke@435 224
duke@435 225 verify_if_often();
duke@435 226 assert(_number_of_blobs >= 0, "sanity check");
duke@435 227 }
duke@435 228
duke@435 229
duke@435 230 void CodeCache::commit(CodeBlob* cb) {
duke@435 231 // this is called by nmethod::nmethod, which must already own CodeCache_lock
duke@435 232 assert_locked_or_safepoint(CodeCache_lock);
never@1999 233 if (cb->is_nmethod()) {
never@1999 234 _number_of_nmethods++;
never@1999 235 if (((nmethod *)cb)->has_dependencies()) {
never@1999 236 _number_of_nmethods_with_dependencies++;
never@1999 237 }
duke@435 238 }
never@1999 239 if (cb->is_adapter_blob()) {
never@1999 240 _number_of_adapters++;
never@1999 241 }
never@1999 242
duke@435 243 // flush the hardware I-cache
twisti@2103 244 ICache::invalidate_range(cb->content_begin(), cb->content_size());
duke@435 245 }
duke@435 246
duke@435 247
duke@435 248 void CodeCache::flush() {
duke@435 249 assert_locked_or_safepoint(CodeCache_lock);
duke@435 250 Unimplemented();
duke@435 251 }
duke@435 252
duke@435 253
duke@435 254 // Iteration over CodeBlobs
duke@435 255
duke@435 256 #define FOR_ALL_BLOBS(var) for (CodeBlob *var = first() ; var != NULL; var = next(var) )
duke@435 257 #define FOR_ALL_ALIVE_BLOBS(var) for (CodeBlob *var = alive(first()); var != NULL; var = alive(next(var)))
duke@435 258 #define FOR_ALL_ALIVE_NMETHODS(var) for (nmethod *var = alive_nmethod(first()); var != NULL; var = alive_nmethod(next(var)))
duke@435 259
duke@435 260
duke@435 261 bool CodeCache::contains(void *p) {
duke@435 262 // It should be ok to call contains without holding a lock
duke@435 263 return _heap->contains(p);
duke@435 264 }
duke@435 265
duke@435 266
duke@435 267 // This method is safe to call without holding the CodeCache_lock, as long as a dead codeblob is not
duke@435 268 // looked up (i.e., one that has been marked for deletion). It only dependes on the _segmap to contain
duke@435 269 // valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled.
duke@435 270 CodeBlob* CodeCache::find_blob(void* start) {
duke@435 271 CodeBlob* result = find_blob_unsafe(start);
duke@435 272 if (result == NULL) return NULL;
duke@435 273 // We could potientially look up non_entrant methods
duke@435 274 guarantee(!result->is_zombie() || result->is_locked_by_vm() || is_error_reported(), "unsafe access to zombie method");
duke@435 275 return result;
duke@435 276 }
duke@435 277
duke@435 278 nmethod* CodeCache::find_nmethod(void* start) {
duke@435 279 CodeBlob *cb = find_blob(start);
duke@435 280 assert(cb == NULL || cb->is_nmethod(), "did not find an nmethod");
duke@435 281 return (nmethod*)cb;
duke@435 282 }
duke@435 283
duke@435 284
duke@435 285 void CodeCache::blobs_do(void f(CodeBlob* nm)) {
duke@435 286 assert_locked_or_safepoint(CodeCache_lock);
duke@435 287 FOR_ALL_BLOBS(p) {
duke@435 288 f(p);
duke@435 289 }
duke@435 290 }
duke@435 291
duke@435 292
duke@435 293 void CodeCache::nmethods_do(void f(nmethod* nm)) {
duke@435 294 assert_locked_or_safepoint(CodeCache_lock);
duke@435 295 FOR_ALL_BLOBS(nm) {
duke@435 296 if (nm->is_nmethod()) f((nmethod*)nm);
duke@435 297 }
duke@435 298 }
duke@435 299
coleenp@4037 300 void CodeCache::alive_nmethods_do(void f(nmethod* nm)) {
coleenp@4037 301 assert_locked_or_safepoint(CodeCache_lock);
coleenp@4037 302 FOR_ALL_ALIVE_NMETHODS(nm) {
coleenp@4037 303 f(nm);
coleenp@4037 304 }
coleenp@4037 305 }
duke@435 306
duke@435 307 int CodeCache::alignment_unit() {
duke@435 308 return (int)_heap->alignment_unit();
duke@435 309 }
duke@435 310
duke@435 311
duke@435 312 int CodeCache::alignment_offset() {
duke@435 313 return (int)_heap->alignment_offset();
duke@435 314 }
duke@435 315
duke@435 316
twisti@1918 317 // Mark nmethods for unloading if they contain otherwise unreachable
twisti@1918 318 // oops.
brutisso@4098 319 void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
duke@435 320 assert_locked_or_safepoint(CodeCache_lock);
twisti@1918 321 FOR_ALL_ALIVE_NMETHODS(nm) {
brutisso@4098 322 nm->do_unloading(is_alive, unloading_occurred);
duke@435 323 }
duke@435 324 }
duke@435 325
jrose@1424 326 void CodeCache::blobs_do(CodeBlobClosure* f) {
duke@435 327 assert_locked_or_safepoint(CodeCache_lock);
duke@435 328 FOR_ALL_ALIVE_BLOBS(cb) {
jrose@1424 329 f->do_code_blob(cb);
jrose@1424 330
jrose@1424 331 #ifdef ASSERT
jrose@1424 332 if (cb->is_nmethod())
jrose@1424 333 ((nmethod*)cb)->verify_scavenge_root_oops();
jrose@1424 334 #endif //ASSERT
duke@435 335 }
duke@435 336 }
duke@435 337
jrose@1424 338 // Walk the list of methods which might contain non-perm oops.
cvarming@9661 339 void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) {
jrose@1424 340 assert_locked_or_safepoint(CodeCache_lock);
stefank@6992 341
stefank@6992 342 if (UseG1GC) {
stefank@6992 343 return;
stefank@6992 344 }
stefank@6992 345
cvarming@9661 346 const bool fix_relocations = f->fix_relocations();
jrose@1424 347 debug_only(mark_scavenge_root_nmethods());
jrose@1424 348
cvarming@9661 349 nmethod* prev = NULL;
cvarming@9661 350 nmethod* cur = scavenge_root_nmethods();
cvarming@9661 351 while (cur != NULL) {
jrose@1424 352 debug_only(cur->clear_scavenge_root_marked());
jrose@1424 353 assert(cur->scavenge_root_not_marked(), "");
jrose@1424 354 assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
jrose@1424 355
jrose@1424 356 bool is_live = (!cur->is_zombie() && !cur->is_unloaded());
jrose@1424 357 #ifndef PRODUCT
jrose@1424 358 if (TraceScavenge) {
jrose@1424 359 cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr();
jrose@1424 360 }
jrose@1424 361 #endif //PRODUCT
twisti@1798 362 if (is_live) {
jrose@1424 363 // Perform cur->oops_do(f), maybe just once per nmethod.
jrose@1424 364 f->do_code_blob(cur);
twisti@1798 365 }
cvarming@9661 366 nmethod* const next = cur->scavenge_root_link();
cvarming@9661 367 // The scavengable nmethod list must contain all methods with scavengable
cvarming@9661 368 // oops. It is safe to include more nmethod on the list, but we do not
cvarming@9661 369 // expect any live non-scavengable nmethods on the list.
cvarming@9661 370 if (fix_relocations) {
cvarming@9661 371 if (!is_live || !cur->detect_scavenge_root_oops()) {
cvarming@9661 372 unlink_scavenge_root_nmethod(cur, prev);
cvarming@9661 373 } else {
cvarming@9661 374 prev = cur;
cvarming@9661 375 }
cvarming@9661 376 }
cvarming@9661 377 cur = next;
jrose@1424 378 }
jrose@1424 379
jrose@1424 380 // Check for stray marks.
jrose@1424 381 debug_only(verify_perm_nmethods(NULL));
jrose@1424 382 }
jrose@1424 383
jrose@1424 384 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
jrose@1424 385 assert_locked_or_safepoint(CodeCache_lock);
stefank@6992 386
stefank@6992 387 if (UseG1GC) {
stefank@6992 388 return;
stefank@6992 389 }
stefank@6992 390
jrose@1424 391 nm->set_on_scavenge_root_list();
jrose@1424 392 nm->set_scavenge_root_link(_scavenge_root_nmethods);
jrose@1424 393 set_scavenge_root_nmethods(nm);
jrose@1424 394 print_trace("add_scavenge_root", nm);
jrose@1424 395 }
jrose@1424 396
cvarming@9661 397 void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) {
cvarming@9661 398 assert_locked_or_safepoint(CodeCache_lock);
cvarming@9661 399
cvarming@9661 400 assert((prev == NULL && scavenge_root_nmethods() == nm) ||
cvarming@9661 401 (prev != NULL && prev->scavenge_root_link() == nm), "precondition");
cvarming@9661 402
cvarming@9661 403 assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list");
cvarming@9661 404
cvarming@9661 405 print_trace("unlink_scavenge_root", nm);
cvarming@9661 406 if (prev == NULL) {
cvarming@9661 407 set_scavenge_root_nmethods(nm->scavenge_root_link());
cvarming@9661 408 } else {
cvarming@9661 409 prev->set_scavenge_root_link(nm->scavenge_root_link());
cvarming@9661 410 }
cvarming@9661 411 nm->set_scavenge_root_link(NULL);
cvarming@9661 412 nm->clear_on_scavenge_root_list();
cvarming@9661 413 }
cvarming@9661 414
jrose@1424 415 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
jrose@1424 416 assert_locked_or_safepoint(CodeCache_lock);
stefank@6992 417
stefank@6992 418 if (UseG1GC) {
stefank@6992 419 return;
stefank@6992 420 }
stefank@6992 421
jrose@1424 422 print_trace("drop_scavenge_root", nm);
cvarming@9661 423 nmethod* prev = NULL;
cvarming@9661 424 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
jrose@1424 425 if (cur == nm) {
cvarming@9661 426 unlink_scavenge_root_nmethod(cur, prev);
jrose@1424 427 return;
jrose@1424 428 }
cvarming@9661 429 prev = cur;
jrose@1424 430 }
jrose@1424 431 assert(false, "should have been on list");
jrose@1424 432 }
jrose@1424 433
jrose@1424 434 void CodeCache::prune_scavenge_root_nmethods() {
jrose@1424 435 assert_locked_or_safepoint(CodeCache_lock);
stefank@6992 436
stefank@6992 437 if (UseG1GC) {
stefank@6992 438 return;
stefank@6992 439 }
stefank@6992 440
jrose@1424 441 debug_only(mark_scavenge_root_nmethods());
jrose@1424 442
jrose@1424 443 nmethod* last = NULL;
jrose@1424 444 nmethod* cur = scavenge_root_nmethods();
jrose@1424 445 while (cur != NULL) {
jrose@1424 446 nmethod* next = cur->scavenge_root_link();
jrose@1424 447 debug_only(cur->clear_scavenge_root_marked());
jrose@1424 448 assert(cur->scavenge_root_not_marked(), "");
jrose@1424 449 assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
jrose@1424 450
jrose@1424 451 if (!cur->is_zombie() && !cur->is_unloaded()
jrose@1424 452 && cur->detect_scavenge_root_oops()) {
jrose@1424 453 // Keep it. Advance 'last' to prevent deletion.
jrose@1424 454 last = cur;
jrose@1424 455 } else {
jrose@1424 456 // Prune it from the list, so we don't have to look at it any more.
jrose@1424 457 print_trace("prune_scavenge_root", cur);
cvarming@9661 458 unlink_scavenge_root_nmethod(cur, last);
jrose@1424 459 }
jrose@1424 460 cur = next;
jrose@1424 461 }
jrose@1424 462
jrose@1424 463 // Check for stray marks.
jrose@1424 464 debug_only(verify_perm_nmethods(NULL));
jrose@1424 465 }
jrose@1424 466
jrose@1424 467 #ifndef PRODUCT
jrose@1424 468 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
stefank@6992 469 if (UseG1GC) {
stefank@6992 470 return;
stefank@6992 471 }
stefank@6992 472
jrose@1424 473 // While we are here, verify the integrity of the list.
jrose@1424 474 mark_scavenge_root_nmethods();
jrose@1424 475 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
jrose@1424 476 assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
jrose@1424 477 cur->clear_scavenge_root_marked();
jrose@1424 478 }
jrose@1424 479 verify_perm_nmethods(f);
jrose@1424 480 }
jrose@1424 481
jrose@1424 482 // Temporarily mark nmethods that are claimed to be on the non-perm list.
jrose@1424 483 void CodeCache::mark_scavenge_root_nmethods() {
jrose@1424 484 FOR_ALL_ALIVE_BLOBS(cb) {
jrose@1424 485 if (cb->is_nmethod()) {
jrose@1424 486 nmethod *nm = (nmethod*)cb;
jrose@1424 487 assert(nm->scavenge_root_not_marked(), "clean state");
jrose@1424 488 if (nm->on_scavenge_root_list())
jrose@1424 489 nm->set_scavenge_root_marked();
jrose@1424 490 }
jrose@1424 491 }
jrose@1424 492 }
jrose@1424 493
jrose@1424 494 // If the closure is given, run it on the unlisted nmethods.
jrose@1424 495 // Also make sure that the effects of mark_scavenge_root_nmethods is gone.
jrose@1424 496 void CodeCache::verify_perm_nmethods(CodeBlobClosure* f_or_null) {
jrose@1424 497 FOR_ALL_ALIVE_BLOBS(cb) {
jrose@1424 498 bool call_f = (f_or_null != NULL);
jrose@1424 499 if (cb->is_nmethod()) {
jrose@1424 500 nmethod *nm = (nmethod*)cb;
jrose@1424 501 assert(nm->scavenge_root_not_marked(), "must be already processed");
jrose@1424 502 if (nm->on_scavenge_root_list())
jrose@1424 503 call_f = false; // don't show this one to the client
jrose@1424 504 nm->verify_scavenge_root_oops();
jrose@1424 505 } else {
jrose@1424 506 call_f = false; // not an nmethod
jrose@1424 507 }
jrose@1424 508 if (call_f) f_or_null->do_code_blob(cb);
jrose@1424 509 }
jrose@1424 510 }
jrose@1424 511 #endif //PRODUCT
jrose@1424 512
stefank@6992 513 void CodeCache::verify_clean_inline_caches() {
stefank@6992 514 #ifdef ASSERT
stefank@6992 515 FOR_ALL_ALIVE_BLOBS(cb) {
stefank@6992 516 if (cb->is_nmethod()) {
stefank@6992 517 nmethod* nm = (nmethod*)cb;
stefank@6992 518 assert(!nm->is_unloaded(), "Tautology");
stefank@6992 519 nm->verify_clean_inline_caches();
stefank@6992 520 nm->verify();
stefank@6992 521 }
stefank@6992 522 }
stefank@6992 523 #endif
stefank@6992 524 }
stefank@6992 525
stefank@6992 526 void CodeCache::verify_icholder_relocations() {
stefank@6992 527 #ifdef ASSERT
stefank@6992 528 // make sure that we aren't leaking icholders
stefank@6992 529 int count = 0;
stefank@6992 530 FOR_ALL_BLOBS(cb) {
stefank@6992 531 if (cb->is_nmethod()) {
stefank@6992 532 nmethod* nm = (nmethod*)cb;
stefank@6992 533 count += nm->verify_icholder_relocations();
stefank@6992 534 }
stefank@6992 535 }
stefank@6992 536
stefank@6992 537 assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() ==
stefank@6992 538 CompiledICHolder::live_count(), "must agree");
stefank@6992 539 #endif
stefank@6992 540 }
kvn@1637 541
duke@435 542 void CodeCache::gc_prologue() {
duke@435 543 }
duke@435 544
duke@435 545 void CodeCache::gc_epilogue() {
duke@435 546 assert_locked_or_safepoint(CodeCache_lock);
thartmann@8075 547 NOT_DEBUG(if (needs_cache_clean())) {
thartmann@8075 548 FOR_ALL_ALIVE_BLOBS(cb) {
thartmann@8075 549 if (cb->is_nmethod()) {
thartmann@8075 550 nmethod *nm = (nmethod*)cb;
thartmann@8075 551 assert(!nm->is_unloaded(), "Tautology");
thartmann@8075 552 DEBUG_ONLY(if (needs_cache_clean())) {
thartmann@8074 553 nm->cleanup_inline_caches();
thartmann@8074 554 }
thartmann@8074 555 DEBUG_ONLY(nm->verify());
thartmann@8074 556 DEBUG_ONLY(nm->verify_oop_relocations());
duke@435 557 }
duke@435 558 }
duke@435 559 }
duke@435 560 set_needs_cache_clean(false);
jrose@1424 561 prune_scavenge_root_nmethods();
coleenp@4037 562
stefank@6992 563 verify_icholder_relocations();
duke@435 564 }
duke@435 565
never@2657 566 void CodeCache::verify_oops() {
never@2657 567 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
never@2657 568 VerifyOopClosure voc;
never@2657 569 FOR_ALL_ALIVE_BLOBS(cb) {
never@2657 570 if (cb->is_nmethod()) {
never@2657 571 nmethod *nm = (nmethod*)cb;
never@2657 572 nm->oops_do(&voc);
never@2657 573 nm->verify_oop_relocations();
never@2657 574 }
never@2657 575 }
never@2657 576 }
never@2657 577
never@2657 578
duke@435 579 address CodeCache::first_address() {
duke@435 580 assert_locked_or_safepoint(CodeCache_lock);
neliasso@4952 581 return (address)_heap->low_boundary();
duke@435 582 }
duke@435 583
duke@435 584
duke@435 585 address CodeCache::last_address() {
duke@435 586 assert_locked_or_safepoint(CodeCache_lock);
neliasso@4952 587 return (address)_heap->high();
duke@435 588 }
duke@435 589
anoll@5151 590 /**
anoll@5151 591 * Returns the reverse free ratio. E.g., if 25% (1/4) of the code cache
anoll@5151 592 * is free, reverse_free_ratio() returns 4.
anoll@5151 593 */
anoll@5151 594 double CodeCache::reverse_free_ratio() {
anoll@5151 595 double unallocated_capacity = (double)(CodeCache::unallocated_capacity() - CodeCacheMinimumFreeSpace);
anoll@5151 596 double max_capacity = (double)CodeCache::max_capacity();
anoll@5151 597 return max_capacity / unallocated_capacity;
anoll@5151 598 }
duke@435 599
duke@435 600 void icache_init();
duke@435 601
duke@435 602 void CodeCache::initialize() {
duke@435 603 assert(CodeCacheSegmentSize >= (uintx)CodeEntryAlignment, "CodeCacheSegmentSize must be large enough to align entry points");
duke@435 604 #ifdef COMPILER2
duke@435 605 assert(CodeCacheSegmentSize >= (uintx)OptoLoopAlignment, "CodeCacheSegmentSize must be large enough to align inner loops");
duke@435 606 #endif
duke@435 607 assert(CodeCacheSegmentSize >= sizeof(jdouble), "CodeCacheSegmentSize must be large enough to align constants");
duke@435 608 // This was originally just a check of the alignment, causing failure, instead, round
duke@435 609 // the code cache to the page size. In particular, Solaris is moving to a larger
duke@435 610 // default page size.
duke@435 611 CodeCacheExpansionSize = round_to(CodeCacheExpansionSize, os::vm_page_size());
duke@435 612 InitialCodeCacheSize = round_to(InitialCodeCacheSize, os::vm_page_size());
duke@435 613 ReservedCodeCacheSize = round_to(ReservedCodeCacheSize, os::vm_page_size());
duke@435 614 if (!_heap->reserve(ReservedCodeCacheSize, InitialCodeCacheSize, CodeCacheSegmentSize)) {
duke@435 615 vm_exit_during_initialization("Could not reserve enough space for code cache");
duke@435 616 }
duke@435 617
duke@435 618 MemoryService::add_code_heap_memory_pool(_heap);
duke@435 619
duke@435 620 // Initialize ICache flush mechanism
duke@435 621 // This service is needed for os::register_code_area
duke@435 622 icache_init();
duke@435 623
duke@435 624 // Give OS a chance to register generated code area.
duke@435 625 // This is used on Windows 64 bit platforms to register
duke@435 626 // Structured Exception Handlers for our generated code.
duke@435 627 os::register_code_area(_heap->low_boundary(), _heap->high_boundary());
duke@435 628 }
duke@435 629
duke@435 630
duke@435 631 void codeCache_init() {
duke@435 632 CodeCache::initialize();
duke@435 633 }
duke@435 634
duke@435 635 //------------------------------------------------------------------------------------------------
duke@435 636
duke@435 637 int CodeCache::number_of_nmethods_with_dependencies() {
duke@435 638 return _number_of_nmethods_with_dependencies;
duke@435 639 }
duke@435 640
duke@435 641 void CodeCache::clear_inline_caches() {
duke@435 642 assert_locked_or_safepoint(CodeCache_lock);
duke@435 643 FOR_ALL_ALIVE_NMETHODS(nm) {
duke@435 644 nm->clear_inline_caches();
duke@435 645 }
duke@435 646 }
duke@435 647
duke@435 648 #ifndef PRODUCT
duke@435 649 // used to keep track of how much time is spent in mark_for_deoptimization
duke@435 650 static elapsedTimer dependentCheckTime;
duke@435 651 static int dependentCheckCount = 0;
duke@435 652 #endif // PRODUCT
duke@435 653
duke@435 654
duke@435 655 int CodeCache::mark_for_deoptimization(DepChange& changes) {
duke@435 656 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
duke@435 657
duke@435 658 #ifndef PRODUCT
duke@435 659 dependentCheckTime.start();
duke@435 660 dependentCheckCount++;
duke@435 661 #endif // PRODUCT
duke@435 662
duke@435 663 int number_of_marked_CodeBlobs = 0;
duke@435 664
duke@435 665 // search the hierarchy looking for nmethods which are affected by the loading of this class
duke@435 666
duke@435 667 // then search the interfaces this class implements looking for nmethods
duke@435 668 // which might be dependent of the fact that an interface only had one
duke@435 669 // implementor.
duke@435 670
duke@435 671 { No_Safepoint_Verifier nsv;
duke@435 672 for (DepChange::ContextStream str(changes, nsv); str.next(); ) {
coleenp@4037 673 Klass* d = str.klass();
coleenp@4037 674 number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes);
duke@435 675 }
duke@435 676 }
duke@435 677
duke@435 678 if (VerifyDependencies) {
duke@435 679 // Turn off dependency tracing while actually testing deps.
duke@435 680 NOT_PRODUCT( FlagSetting fs(TraceDependencies, false) );
duke@435 681 FOR_ALL_ALIVE_NMETHODS(nm) {
duke@435 682 if (!nm->is_marked_for_deoptimization() &&
duke@435 683 nm->check_all_dependencies()) {
duke@435 684 ResourceMark rm;
duke@435 685 tty->print_cr("Should have been marked for deoptimization:");
duke@435 686 changes.print();
duke@435 687 nm->print();
duke@435 688 nm->print_dependencies();
duke@435 689 }
duke@435 690 }
duke@435 691 }
duke@435 692
duke@435 693 #ifndef PRODUCT
duke@435 694 dependentCheckTime.stop();
duke@435 695 #endif // PRODUCT
duke@435 696
duke@435 697 return number_of_marked_CodeBlobs;
duke@435 698 }
duke@435 699
duke@435 700
duke@435 701 #ifdef HOTSWAP
duke@435 702 int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) {
duke@435 703 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
duke@435 704 int number_of_marked_CodeBlobs = 0;
duke@435 705
duke@435 706 // Deoptimize all methods of the evolving class itself
coleenp@4037 707 Array<Method*>* old_methods = dependee->methods();
duke@435 708 for (int i = 0; i < old_methods->length(); i++) {
duke@435 709 ResourceMark rm;
coleenp@4037 710 Method* old_method = old_methods->at(i);
duke@435 711 nmethod *nm = old_method->code();
duke@435 712 if (nm != NULL) {
duke@435 713 nm->mark_for_deoptimization();
duke@435 714 number_of_marked_CodeBlobs++;
duke@435 715 }
duke@435 716 }
duke@435 717
duke@435 718 FOR_ALL_ALIVE_NMETHODS(nm) {
duke@435 719 if (nm->is_marked_for_deoptimization()) {
duke@435 720 // ...Already marked in the previous pass; don't count it again.
duke@435 721 } else if (nm->is_evol_dependent_on(dependee())) {
duke@435 722 ResourceMark rm;
duke@435 723 nm->mark_for_deoptimization();
duke@435 724 number_of_marked_CodeBlobs++;
duke@435 725 } else {
coleenp@4037 726 // flush caches in case they refer to a redefined Method*
duke@435 727 nm->clear_inline_caches();
duke@435 728 }
duke@435 729 }
duke@435 730
duke@435 731 return number_of_marked_CodeBlobs;
duke@435 732 }
duke@435 733 #endif // HOTSWAP
duke@435 734
duke@435 735
duke@435 736 // Deoptimize all methods
duke@435 737 void CodeCache::mark_all_nmethods_for_deoptimization() {
duke@435 738 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
duke@435 739 FOR_ALL_ALIVE_NMETHODS(nm) {
iveresov@7146 740 if (!nm->method()->is_method_handle_intrinsic()) {
iveresov@7146 741 nm->mark_for_deoptimization();
iveresov@7146 742 }
duke@435 743 }
duke@435 744 }
duke@435 745
duke@435 746
coleenp@4037 747 int CodeCache::mark_for_deoptimization(Method* dependee) {
duke@435 748 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
duke@435 749 int number_of_marked_CodeBlobs = 0;
duke@435 750
duke@435 751 FOR_ALL_ALIVE_NMETHODS(nm) {
duke@435 752 if (nm->is_dependent_on_method(dependee)) {
duke@435 753 ResourceMark rm;
duke@435 754 nm->mark_for_deoptimization();
duke@435 755 number_of_marked_CodeBlobs++;
duke@435 756 }
duke@435 757 }
duke@435 758
duke@435 759 return number_of_marked_CodeBlobs;
duke@435 760 }
duke@435 761
duke@435 762 void CodeCache::make_marked_nmethods_not_entrant() {
duke@435 763 assert_locked_or_safepoint(CodeCache_lock);
duke@435 764 FOR_ALL_ALIVE_NMETHODS(nm) {
duke@435 765 if (nm->is_marked_for_deoptimization()) {
duke@435 766 nm->make_not_entrant();
duke@435 767 }
duke@435 768 }
duke@435 769 }
duke@435 770
duke@435 771 void CodeCache::verify() {
duke@435 772 _heap->verify();
duke@435 773 FOR_ALL_ALIVE_BLOBS(p) {
duke@435 774 p->verify();
duke@435 775 }
duke@435 776 }
duke@435 777
sla@5237 778 void CodeCache::report_codemem_full() {
sla@5237 779 _codemem_full_count++;
sla@5237 780 EventCodeCacheFull event;
sla@5237 781 if (event.should_commit()) {
sla@5237 782 event.set_startAddress((u8)low_bound());
sla@5237 783 event.set_commitedTopAddress((u8)high());
sla@5237 784 event.set_reservedTopAddress((u8)high_bound());
sla@5237 785 event.set_entryCount(nof_blobs());
sla@5237 786 event.set_methodCount(nof_nmethods());
sla@5237 787 event.set_adaptorCount(nof_adapters());
sla@5237 788 event.set_unallocatedCapacity(unallocated_capacity()/K);
sla@5237 789 event.set_fullCount(_codemem_full_count);
sla@5237 790 event.commit();
sla@5237 791 }
sla@5237 792 }
sla@5237 793
duke@435 794 //------------------------------------------------------------------------------------------------
duke@435 795 // Non-product version
duke@435 796
duke@435 797 #ifndef PRODUCT
duke@435 798
duke@435 799 void CodeCache::verify_if_often() {
duke@435 800 if (VerifyCodeCacheOften) {
duke@435 801 _heap->verify();
duke@435 802 }
duke@435 803 }
duke@435 804
jrose@1424 805 void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
jrose@1424 806 if (PrintCodeCache2) { // Need to add a new flag
jrose@1424 807 ResourceMark rm;
jrose@1424 808 if (size == 0) size = cb->size();
drchase@6680 809 tty->print_cr("CodeCache %s: addr: " INTPTR_FORMAT ", size: 0x%x", event, p2i(cb), size);
jrose@1424 810 }
jrose@1424 811 }
jrose@1424 812
duke@435 813 void CodeCache::print_internals() {
duke@435 814 int nmethodCount = 0;
duke@435 815 int runtimeStubCount = 0;
duke@435 816 int adapterCount = 0;
duke@435 817 int deoptimizationStubCount = 0;
duke@435 818 int uncommonTrapStubCount = 0;
duke@435 819 int bufferBlobCount = 0;
duke@435 820 int total = 0;
duke@435 821 int nmethodAlive = 0;
duke@435 822 int nmethodNotEntrant = 0;
duke@435 823 int nmethodZombie = 0;
duke@435 824 int nmethodUnloaded = 0;
duke@435 825 int nmethodJava = 0;
duke@435 826 int nmethodNative = 0;
duke@435 827 int maxCodeSize = 0;
duke@435 828 ResourceMark rm;
duke@435 829
duke@435 830 CodeBlob *cb;
duke@435 831 for (cb = first(); cb != NULL; cb = next(cb)) {
duke@435 832 total++;
duke@435 833 if (cb->is_nmethod()) {
duke@435 834 nmethod* nm = (nmethod*)cb;
duke@435 835
duke@435 836 if (Verbose && nm->method() != NULL) {
duke@435 837 ResourceMark rm;
duke@435 838 char *method_name = nm->method()->name_and_sig_as_C_string();
duke@435 839 tty->print("%s", method_name);
duke@435 840 if(nm->is_alive()) { tty->print_cr(" alive"); }
duke@435 841 if(nm->is_not_entrant()) { tty->print_cr(" not-entrant"); }
duke@435 842 if(nm->is_zombie()) { tty->print_cr(" zombie"); }
duke@435 843 }
duke@435 844
duke@435 845 nmethodCount++;
duke@435 846
duke@435 847 if(nm->is_alive()) { nmethodAlive++; }
duke@435 848 if(nm->is_not_entrant()) { nmethodNotEntrant++; }
duke@435 849 if(nm->is_zombie()) { nmethodZombie++; }
duke@435 850 if(nm->is_unloaded()) { nmethodUnloaded++; }
duke@435 851 if(nm->is_native_method()) { nmethodNative++; }
duke@435 852
duke@435 853 if(nm->method() != NULL && nm->is_java_method()) {
duke@435 854 nmethodJava++;
twisti@2103 855 if (nm->insts_size() > maxCodeSize) {
twisti@2103 856 maxCodeSize = nm->insts_size();
duke@435 857 }
duke@435 858 }
duke@435 859 } else if (cb->is_runtime_stub()) {
duke@435 860 runtimeStubCount++;
duke@435 861 } else if (cb->is_deoptimization_stub()) {
duke@435 862 deoptimizationStubCount++;
duke@435 863 } else if (cb->is_uncommon_trap_stub()) {
duke@435 864 uncommonTrapStubCount++;
duke@435 865 } else if (cb->is_adapter_blob()) {
duke@435 866 adapterCount++;
duke@435 867 } else if (cb->is_buffer_blob()) {
duke@435 868 bufferBlobCount++;
duke@435 869 }
duke@435 870 }
duke@435 871
duke@435 872 int bucketSize = 512;
duke@435 873 int bucketLimit = maxCodeSize / bucketSize + 1;
zgu@3900 874 int *buckets = NEW_C_HEAP_ARRAY(int, bucketLimit, mtCode);
duke@435 875 memset(buckets,0,sizeof(int) * bucketLimit);
duke@435 876
duke@435 877 for (cb = first(); cb != NULL; cb = next(cb)) {
duke@435 878 if (cb->is_nmethod()) {
duke@435 879 nmethod* nm = (nmethod*)cb;
duke@435 880 if(nm->is_java_method()) {
twisti@2103 881 buckets[nm->insts_size() / bucketSize]++;
duke@435 882 }
duke@435 883 }
duke@435 884 }
duke@435 885 tty->print_cr("Code Cache Entries (total of %d)",total);
duke@435 886 tty->print_cr("-------------------------------------------------");
duke@435 887 tty->print_cr("nmethods: %d",nmethodCount);
duke@435 888 tty->print_cr("\talive: %d",nmethodAlive);
duke@435 889 tty->print_cr("\tnot_entrant: %d",nmethodNotEntrant);
duke@435 890 tty->print_cr("\tzombie: %d",nmethodZombie);
duke@435 891 tty->print_cr("\tunloaded: %d",nmethodUnloaded);
duke@435 892 tty->print_cr("\tjava: %d",nmethodJava);
duke@435 893 tty->print_cr("\tnative: %d",nmethodNative);
duke@435 894 tty->print_cr("runtime_stubs: %d",runtimeStubCount);
duke@435 895 tty->print_cr("adapters: %d",adapterCount);
duke@435 896 tty->print_cr("buffer blobs: %d",bufferBlobCount);
duke@435 897 tty->print_cr("deoptimization_stubs: %d",deoptimizationStubCount);
duke@435 898 tty->print_cr("uncommon_traps: %d",uncommonTrapStubCount);
duke@435 899 tty->print_cr("\nnmethod size distribution (non-zombie java)");
duke@435 900 tty->print_cr("-------------------------------------------------");
duke@435 901
duke@435 902 for(int i=0; i<bucketLimit; i++) {
duke@435 903 if(buckets[i] != 0) {
duke@435 904 tty->print("%d - %d bytes",i*bucketSize,(i+1)*bucketSize);
duke@435 905 tty->fill_to(40);
duke@435 906 tty->print_cr("%d",buckets[i]);
duke@435 907 }
duke@435 908 }
duke@435 909
zgu@3900 910 FREE_C_HEAP_ARRAY(int, buckets, mtCode);
duke@435 911 }
duke@435 912
vladidan@4438 913 #endif // !PRODUCT
vladidan@4438 914
duke@435 915 void CodeCache::print() {
vladidan@4438 916 print_summary(tty);
vladidan@4438 917
vladidan@4438 918 #ifndef PRODUCT
vladidan@4438 919 if (!Verbose) return;
vladidan@4438 920
duke@435 921 CodeBlob_sizes live;
duke@435 922 CodeBlob_sizes dead;
duke@435 923
duke@435 924 FOR_ALL_BLOBS(p) {
duke@435 925 if (!p->is_alive()) {
duke@435 926 dead.add(p);
duke@435 927 } else {
duke@435 928 live.add(p);
duke@435 929 }
duke@435 930 }
duke@435 931
duke@435 932 tty->print_cr("CodeCache:");
duke@435 933
drchase@6680 934 tty->print_cr("nmethod dependency checking time %f, per dependent %f", dependentCheckTime.seconds(),
duke@435 935 dependentCheckTime.seconds() / dependentCheckCount);
duke@435 936
duke@435 937 if (!live.is_empty()) {
duke@435 938 live.print("live");
duke@435 939 }
duke@435 940 if (!dead.is_empty()) {
duke@435 941 dead.print("dead");
duke@435 942 }
duke@435 943
duke@435 944
vladidan@4438 945 if (WizardMode) {
duke@435 946 // print the oop_map usage
duke@435 947 int code_size = 0;
duke@435 948 int number_of_blobs = 0;
duke@435 949 int number_of_oop_maps = 0;
duke@435 950 int map_size = 0;
duke@435 951 FOR_ALL_BLOBS(p) {
duke@435 952 if (p->is_alive()) {
duke@435 953 number_of_blobs++;
twisti@2103 954 code_size += p->code_size();
duke@435 955 OopMapSet* set = p->oop_maps();
duke@435 956 if (set != NULL) {
duke@435 957 number_of_oop_maps += set->size();
twisti@2103 958 map_size += set->heap_size();
duke@435 959 }
duke@435 960 }
duke@435 961 }
duke@435 962 tty->print_cr("OopMaps");
duke@435 963 tty->print_cr(" #blobs = %d", number_of_blobs);
duke@435 964 tty->print_cr(" code size = %d", code_size);
duke@435 965 tty->print_cr(" #oop_maps = %d", number_of_oop_maps);
duke@435 966 tty->print_cr(" map size = %d", map_size);
duke@435 967 }
duke@435 968
vladidan@4438 969 #endif // !PRODUCT
duke@435 970 }
duke@435 971
vladidan@4438 972 void CodeCache::print_summary(outputStream* st, bool detailed) {
vladidan@4438 973 size_t total = (_heap->high_boundary() - _heap->low_boundary());
vladidan@4438 974 st->print_cr("CodeCache: size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT
neliasso@4952 975 "Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb",
vladidan@4438 976 total/K, (total - unallocated_capacity())/K,
neliasso@4952 977 maxCodeCacheUsed/K, unallocated_capacity()/K);
never@2262 978
vladidan@4438 979 if (detailed) {
vladidan@4438 980 st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
drchase@6680 981 p2i(_heap->low_boundary()),
drchase@6680 982 p2i(_heap->high()),
drchase@6680 983 p2i(_heap->high_boundary()));
vladidan@4438 984 st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
vladidan@4438 985 " adapters=" UINT32_FORMAT,
vladidan@4438 986 nof_blobs(), nof_nmethods(), nof_adapters());
vladidan@4438 987 st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
vladidan@4438 988 "enabled" : Arguments::mode() == Arguments::_int ?
vladidan@4438 989 "disabled (interpreter mode)" :
vladidan@4438 990 "disabled (not enough contiguous free space left)");
vladidan@4438 991 }
never@2262 992 }
kvn@2635 993
kvn@2635 994 void CodeCache::log_state(outputStream* st) {
kvn@2635 995 st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
neliasso@4952 996 " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
kvn@2635 997 nof_blobs(), nof_nmethods(), nof_adapters(),
neliasso@4952 998 unallocated_capacity());
kvn@2635 999 }
never@2739 1000

mercurial