Mercurial > hg > truffle
comparison src/share/vm/opto/indexSet.cpp @ 2250:f7de3327c683
7017124: Fix some VM stats to avoid 32-bit overflow
Summary: Added new method inc_stat_counter() to increment long statistic values and use atomic long load and store.
Reviewed-by: dholmes, jrose, phh, never
author | kvn |
---|---|
date | Mon, 07 Feb 2011 10:34:39 -0800 |
parents | f95d63e2154a |
children |
comparison
equal
deleted
inserted
replaced
2249:3763ca6579b7 | 2250:f7de3327c683 |
---|---|
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 |
139 | 139 |
140 compile->set_indexSet_free_block_list(free); | 140 compile->set_indexSet_free_block_list(free); |
141 | 141 |
142 #ifdef ASSERT | 142 #ifdef ASSERT |
143 if (CollectIndexSetStatistics) { | 143 if (CollectIndexSetStatistics) { |
144 _alloc_new += bitblock_alloc_chunk_size; | 144 inc_stat_counter(&_alloc_new, bitblock_alloc_chunk_size); |
145 } | 145 } |
146 #endif | 146 #endif |
147 } | 147 } |
148 | 148 |
149 | 149 |
152 // prime it. | 152 // prime it. |
153 | 153 |
154 IndexSet::BitBlock *IndexSet::alloc_block() { | 154 IndexSet::BitBlock *IndexSet::alloc_block() { |
155 #ifdef ASSERT | 155 #ifdef ASSERT |
156 if (CollectIndexSetStatistics) { | 156 if (CollectIndexSetStatistics) { |
157 _alloc_total++; | 157 inc_stat_counter(&_alloc_total, 1); |
158 } | 158 } |
159 #endif | 159 #endif |
160 Compile *compile = Compile::current(); | 160 Compile *compile = Compile::current(); |
161 BitBlock* free_list = (BitBlock*)compile->indexSet_free_block_list(); | 161 BitBlock* free_list = (BitBlock*)compile->indexSet_free_block_list(); |
162 if (free_list == NULL) { | 162 if (free_list == NULL) { |
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 |