1 /* |
1 /* |
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2011, 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. |
37 |
37 |
38 IndexSet::BitBlock IndexSet::_empty_block = IndexSet::BitBlock(); |
38 IndexSet::BitBlock IndexSet::_empty_block = IndexSet::BitBlock(); |
39 |
39 |
40 #ifdef ASSERT |
40 #ifdef ASSERT |
41 // Initialize statistics counters |
41 // Initialize statistics counters |
42 uint IndexSet::_alloc_new = 0; |
42 julong IndexSet::_alloc_new = 0; |
43 uint IndexSet::_alloc_total = 0; |
43 julong IndexSet::_alloc_total = 0; |
44 |
44 |
45 long IndexSet::_total_bits = 0; |
45 julong IndexSet::_total_bits = 0; |
46 long IndexSet::_total_used_blocks = 0; |
46 julong IndexSet::_total_used_blocks = 0; |
47 long IndexSet::_total_unused_blocks = 0; |
47 julong IndexSet::_total_unused_blocks = 0; |
48 |
48 |
49 // Per set, or all sets operation tracing |
49 // Per set, or all sets operation tracing |
50 int IndexSet::_serial_count = 1; |
50 int IndexSet::_serial_count = 1; |
51 #endif |
51 #endif |
52 |
52 |
389 #ifdef ASSERT |
389 #ifdef ASSERT |
390 //---------------------------- IndexSet::tally_iteration_statistics() ----------------------------- |
390 //---------------------------- IndexSet::tally_iteration_statistics() ----------------------------- |
391 // Update block/bit counts to reflect that this set has been iterated over. |
391 // Update block/bit counts to reflect that this set has been iterated over. |
392 |
392 |
393 void IndexSet::tally_iteration_statistics() const { |
393 void IndexSet::tally_iteration_statistics() const { |
394 _total_bits += count(); |
394 inc_stat_counter(&_total_bits, count()); |
395 |
395 |
396 for (uint i = 0; i < _max_blocks; i++) { |
396 for (uint i = 0; i < _max_blocks; i++) { |
397 if (_blocks[i] != &_empty_block) { |
397 if (_blocks[i] != &_empty_block) { |
398 _total_used_blocks++; |
398 inc_stat_counter(&_total_used_blocks, 1); |
399 } else { |
399 } else { |
400 _total_unused_blocks++; |
400 inc_stat_counter(&_total_unused_blocks, 1); |
401 } |
401 } |
402 } |
402 } |
403 } |
403 } |
404 |
404 |
405 //---------------------------- IndexSet::print_statistics() ----------------------------- |
405 //---------------------------- IndexSet::print_statistics() ----------------------------- |
406 // Print statistics about IndexSet usage. |
406 // Print statistics about IndexSet usage. |
407 |
407 |
408 void IndexSet::print_statistics() { |
408 void IndexSet::print_statistics() { |
409 long total_blocks = _total_used_blocks + _total_unused_blocks; |
409 julong total_blocks = _total_used_blocks + _total_unused_blocks; |
410 tty->print_cr ("Accumulated IndexSet usage statistics:"); |
410 tty->print_cr ("Accumulated IndexSet usage statistics:"); |
411 tty->print_cr ("--------------------------------------"); |
411 tty->print_cr ("--------------------------------------"); |
412 tty->print_cr (" Iteration:"); |
412 tty->print_cr (" Iteration:"); |
413 tty->print_cr (" blocks visited: %d", total_blocks); |
413 tty->print_cr (" blocks visited: " UINT64_FORMAT, total_blocks); |
414 tty->print_cr (" blocks empty: %4.2f%%", 100.0*_total_unused_blocks/total_blocks); |
414 tty->print_cr (" blocks empty: %4.2f%%", 100.0*(double)_total_unused_blocks/total_blocks); |
415 tty->print_cr (" bit density (bits/used blocks): %4.2f%%", (double)_total_bits/_total_used_blocks); |
415 tty->print_cr (" bit density (bits/used blocks): %4.2f", (double)_total_bits/_total_used_blocks); |
416 tty->print_cr (" bit density (bits/all blocks): %4.2f%%", (double)_total_bits/total_blocks); |
416 tty->print_cr (" bit density (bits/all blocks): %4.2f", (double)_total_bits/total_blocks); |
417 tty->print_cr (" Allocation:"); |
417 tty->print_cr (" Allocation:"); |
418 tty->print_cr (" blocks allocated: %d", _alloc_new); |
418 tty->print_cr (" blocks allocated: " UINT64_FORMAT, _alloc_new); |
419 tty->print_cr (" blocks used/reused: %d", _alloc_total); |
419 tty->print_cr (" blocks used/reused: " UINT64_FORMAT, _alloc_total); |
420 } |
420 } |
421 |
421 |
422 //---------------------------- IndexSet::verify() ----------------------------- |
422 //---------------------------- IndexSet::verify() ----------------------------- |
423 // Expensive test of IndexSet sanity. Ensure that the count agrees with the |
423 // Expensive test of IndexSet sanity. Ensure that the count agrees with the |
424 // number of bits in the blocks. Make sure the iterator is seeing all elements |
424 // number of bits in the blocks. Make sure the iterator is seeing all elements |