Mercurial > hg > graal-compiler
comparison src/share/vm/memory/metaspaceShared.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4ca6dc0799b6 78bbf4d43a14 |
children | eaf39a954227 |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2014, 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. |
38 #include "runtime/signature.hpp" | 38 #include "runtime/signature.hpp" |
39 #include "runtime/vm_operations.hpp" | 39 #include "runtime/vm_operations.hpp" |
40 #include "runtime/vmThread.hpp" | 40 #include "runtime/vmThread.hpp" |
41 #include "utilities/hashtable.inline.hpp" | 41 #include "utilities/hashtable.inline.hpp" |
42 | 42 |
43 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC | |
43 | 44 |
44 int MetaspaceShared::_max_alignment = 0; | 45 int MetaspaceShared::_max_alignment = 0; |
45 | 46 |
46 ReservedSpace* MetaspaceShared::_shared_rs = NULL; | 47 ReservedSpace* MetaspaceShared::_shared_rs = NULL; |
47 | 48 |
335 int all_ro_count = 0; | 336 int all_ro_count = 0; |
336 int all_ro_bytes = 0; | 337 int all_ro_bytes = 0; |
337 int all_rw_count = 0; | 338 int all_rw_count = 0; |
338 int all_rw_bytes = 0; | 339 int all_rw_bytes = 0; |
339 | 340 |
340 const char *fmt = "%-20s: %8d %10d %5.1f | %8d %10d %5.1f | %8d %10d %5.1f"; | 341 // To make fmt_stats be a syntactic constant (for format warnings), use #define. |
342 #define fmt_stats "%-20s: %8d %10d %5.1f | %8d %10d %5.1f | %8d %10d %5.1f" | |
341 const char *sep = "--------------------+---------------------------+---------------------------+--------------------------"; | 343 const char *sep = "--------------------+---------------------------+---------------------------+--------------------------"; |
342 const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %"; | 344 const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %"; |
343 | 345 |
344 tty->print_cr("Detailed metadata info (rw includes md and mc):"); | 346 tty->print_cr("Detailed metadata info (rw includes md and mc):"); |
345 tty->print_cr(hdr); | 347 tty->print_cr("%s", hdr); |
346 tty->print_cr(sep); | 348 tty->print_cr("%s", sep); |
347 for (int type = 0; type < int(_number_of_types); type ++) { | 349 for (int type = 0; type < int(_number_of_types); type ++) { |
348 const char *name = type_name((Type)type); | 350 const char *name = type_name((Type)type); |
349 int ro_count = _counts[RO][type]; | 351 int ro_count = _counts[RO][type]; |
350 int ro_bytes = _bytes [RO][type]; | 352 int ro_bytes = _bytes [RO][type]; |
351 int rw_count = _counts[RW][type]; | 353 int rw_count = _counts[RW][type]; |
355 | 357 |
356 double ro_perc = 100.0 * double(ro_bytes) / double(ro_all); | 358 double ro_perc = 100.0 * double(ro_bytes) / double(ro_all); |
357 double rw_perc = 100.0 * double(rw_bytes) / double(rw_all); | 359 double rw_perc = 100.0 * double(rw_bytes) / double(rw_all); |
358 double perc = 100.0 * double(bytes) / double(ro_all + rw_all); | 360 double perc = 100.0 * double(bytes) / double(ro_all + rw_all); |
359 | 361 |
360 tty->print_cr(fmt, name, | 362 tty->print_cr(fmt_stats, name, |
361 ro_count, ro_bytes, ro_perc, | 363 ro_count, ro_bytes, ro_perc, |
362 rw_count, rw_bytes, rw_perc, | 364 rw_count, rw_bytes, rw_perc, |
363 count, bytes, perc); | 365 count, bytes, perc); |
364 | 366 |
365 all_ro_count += ro_count; | 367 all_ro_count += ro_count; |
373 | 375 |
374 double all_ro_perc = 100.0 * double(all_ro_bytes) / double(ro_all); | 376 double all_ro_perc = 100.0 * double(all_ro_bytes) / double(ro_all); |
375 double all_rw_perc = 100.0 * double(all_rw_bytes) / double(rw_all); | 377 double all_rw_perc = 100.0 * double(all_rw_bytes) / double(rw_all); |
376 double all_perc = 100.0 * double(all_bytes) / double(ro_all + rw_all); | 378 double all_perc = 100.0 * double(all_bytes) / double(ro_all + rw_all); |
377 | 379 |
378 tty->print_cr(sep); | 380 tty->print_cr("%s", sep); |
379 tty->print_cr(fmt, "Total", | 381 tty->print_cr(fmt_stats, "Total", |
380 all_ro_count, all_ro_bytes, all_ro_perc, | 382 all_ro_count, all_ro_bytes, all_ro_perc, |
381 all_rw_count, all_rw_bytes, all_rw_perc, | 383 all_rw_count, all_rw_bytes, all_rw_perc, |
382 all_count, all_bytes, all_perc); | 384 all_count, all_bytes, all_perc); |
383 | 385 |
384 assert(all_ro_bytes == ro_all, "everything should have been counted"); | 386 assert(all_ro_bytes == ro_all, "everything should have been counted"); |
385 assert(all_rw_bytes == rw_all, "everything should have been counted"); | 387 assert(all_rw_bytes == rw_all, "everything should have been counted"); |
388 #undef fmt_stats | |
386 } | 389 } |
387 | 390 |
388 // Populate the shared space. | 391 // Populate the shared space. |
389 | 392 |
390 class VM_PopulateDumpSharedSpace: public VM_Operation { | 393 class VM_PopulateDumpSharedSpace: public VM_Operation { |
512 WriteClosure wc(md_top, md_end); | 515 WriteClosure wc(md_top, md_end); |
513 MetaspaceShared::serialize(&wc); | 516 MetaspaceShared::serialize(&wc); |
514 md_top = wc.get_top(); | 517 md_top = wc.get_top(); |
515 | 518 |
516 // Print shared spaces all the time | 519 // Print shared spaces all the time |
517 const char* fmt = "%s space: %9d [ %4.1f%% of total] out of %9d bytes [%4.1f%% used] at " PTR_FORMAT; | 520 // To make fmt_space be a syntactic constant (for format warnings), use #define. |
521 #define fmt_space "%s space: %9d [ %4.1f%% of total] out of %9d bytes [%4.1f%% used] at " PTR_FORMAT | |
518 Metaspace* ro_space = _loader_data->ro_metaspace(); | 522 Metaspace* ro_space = _loader_data->ro_metaspace(); |
519 Metaspace* rw_space = _loader_data->rw_metaspace(); | 523 Metaspace* rw_space = _loader_data->rw_metaspace(); |
520 | 524 |
521 // Allocated size of each space (may not be all occupied) | 525 // Allocated size of each space (may not be all occupied) |
522 const size_t ro_alloced = ro_space->capacity_bytes_slow(Metaspace::NonClassType); | 526 const size_t ro_alloced = ro_space->capacity_bytes_slow(Metaspace::NonClassType); |
543 const double rw_u_perc = rw_bytes / double(rw_alloced) * 100.0; | 547 const double rw_u_perc = rw_bytes / double(rw_alloced) * 100.0; |
544 const double md_u_perc = md_bytes / double(md_alloced) * 100.0; | 548 const double md_u_perc = md_bytes / double(md_alloced) * 100.0; |
545 const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0; | 549 const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0; |
546 const double total_u_perc = total_bytes / double(total_alloced) * 100.0; | 550 const double total_u_perc = total_bytes / double(total_alloced) * 100.0; |
547 | 551 |
548 tty->print_cr(fmt, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, ro_space->bottom()); | 552 tty->print_cr(fmt_space, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, ro_space->bottom()); |
549 tty->print_cr(fmt, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, rw_space->bottom()); | 553 tty->print_cr(fmt_space, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, rw_space->bottom()); |
550 tty->print_cr(fmt, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, md_low); | 554 tty->print_cr(fmt_space, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, md_low); |
551 tty->print_cr(fmt, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, mc_low); | 555 tty->print_cr(fmt_space, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, mc_low); |
552 tty->print_cr("total : %9d [100.0%% of total] out of %9d bytes [%4.1f%% used]", | 556 tty->print_cr("total : %9d [100.0%% of total] out of %9d bytes [%4.1f%% used]", |
553 total_bytes, total_alloced, total_u_perc); | 557 total_bytes, total_alloced, total_u_perc); |
554 | 558 |
555 // Update the vtable pointers in all of the Klass objects in the | 559 // Update the vtable pointers in all of the Klass objects in the |
556 // heap. They should point to newly generated vtable. | 560 // heap. They should point to newly generated vtable. |
601 dac.iterate_metaspace(_loader_data->ro_metaspace(), DumpAllocClosure::RO); | 605 dac.iterate_metaspace(_loader_data->ro_metaspace(), DumpAllocClosure::RO); |
602 dac.iterate_metaspace(_loader_data->rw_metaspace(), DumpAllocClosure::RW); | 606 dac.iterate_metaspace(_loader_data->rw_metaspace(), DumpAllocClosure::RW); |
603 | 607 |
604 dac.dump_stats(int(ro_bytes), int(rw_bytes), int(md_bytes), int(mc_bytes)); | 608 dac.dump_stats(int(ro_bytes), int(rw_bytes), int(md_bytes), int(mc_bytes)); |
605 } | 609 } |
610 #undef fmt_space | |
606 } | 611 } |
607 | 612 |
608 static void link_shared_classes(Klass* obj, TRAPS) { | 613 static void link_shared_classes(Klass* obj, TRAPS) { |
609 Klass* k = obj; | 614 Klass* k = obj; |
610 if (k->oop_is_instance()) { | 615 if (k->oop_is_instance()) { |
642 // Preload classes from a list, populate the shared spaces and dump to a | 647 // Preload classes from a list, populate the shared spaces and dump to a |
643 // file. | 648 // file. |
644 void MetaspaceShared::preload_and_dump(TRAPS) { | 649 void MetaspaceShared::preload_and_dump(TRAPS) { |
645 TraceTime timer("Dump Shared Spaces", TraceStartupTime); | 650 TraceTime timer("Dump Shared Spaces", TraceStartupTime); |
646 ResourceMark rm; | 651 ResourceMark rm; |
647 | |
648 // Lock out GC - is it necessary? I don't think we care. | |
649 No_GC_Verifier no_gc; | |
650 | 652 |
651 // Preload classes to be shared. | 653 // Preload classes to be shared. |
652 // Should use some os:: method rather than fopen() here. aB. | 654 // Should use some os:: method rather than fopen() here. aB. |
653 // Construct the path to the class list (in jre/lib) | 655 // Construct the path to the class list (in jre/lib) |
654 // Walk up two directories from the location of the VM and | 656 // Walk up two directories from the location of the VM and |