Mercurial > hg > graal-compiler
comparison src/share/vm/memory/allocation.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 | 79d8657be916 |
children | 4a9604cd7c5f |
comparison
equal
deleted
inserted
replaced
2249:3763ca6579b7 | 2250:f7de3327c683 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 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. |
155 #endif // ASSERT | 155 #endif // ASSERT |
156 | 156 |
157 | 157 |
158 void trace_heap_malloc(size_t size, const char* name, void* p) { | 158 void trace_heap_malloc(size_t size, const char* name, void* p) { |
159 // A lock is not needed here - tty uses a lock internally | 159 // A lock is not needed here - tty uses a lock internally |
160 tty->print_cr("Heap malloc " INTPTR_FORMAT " %7d %s", p, size, name == NULL ? "" : name); | 160 tty->print_cr("Heap malloc " INTPTR_FORMAT " " SIZE_FORMAT " %s", p, size, name == NULL ? "" : name); |
161 } | 161 } |
162 | 162 |
163 | 163 |
164 void trace_heap_free(void* p) { | 164 void trace_heap_free(void* p) { |
165 // A lock is not needed here - tty uses a lock internally | 165 // A lock is not needed here - tty uses a lock internally |
571 | 571 |
572 void AllocatedObj::print_value_on(outputStream* st) const { | 572 void AllocatedObj::print_value_on(outputStream* st) const { |
573 st->print("AllocatedObj(" INTPTR_FORMAT ")", this); | 573 st->print("AllocatedObj(" INTPTR_FORMAT ")", this); |
574 } | 574 } |
575 | 575 |
576 size_t Arena::_bytes_allocated = 0; | 576 julong Arena::_bytes_allocated = 0; |
577 | |
578 void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); } | |
577 | 579 |
578 AllocStats::AllocStats() { | 580 AllocStats::AllocStats() { |
579 start_mallocs = os::num_mallocs; | 581 start_mallocs = os::num_mallocs; |
580 start_frees = os::num_frees; | 582 start_frees = os::num_frees; |
581 start_malloc_bytes = os::alloc_bytes; | 583 start_malloc_bytes = os::alloc_bytes; |
582 start_res_bytes = Arena::_bytes_allocated; | 584 start_mfree_bytes = os::free_bytes; |
583 } | 585 start_res_bytes = Arena::_bytes_allocated; |
584 | 586 } |
585 int AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; } | 587 |
586 size_t AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; } | 588 julong AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; } |
587 size_t AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; } | 589 julong AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; } |
588 int AllocStats::num_frees() { return os::num_frees - start_frees; } | 590 julong AllocStats::num_frees() { return os::num_frees - start_frees; } |
591 julong AllocStats::free_bytes() { return os::free_bytes - start_mfree_bytes; } | |
592 julong AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; } | |
589 void AllocStats::print() { | 593 void AllocStats::print() { |
590 tty->print("%d mallocs (%ldK), %d frees, %ldK resrc", | 594 tty->print_cr(UINT64_FORMAT " mallocs (" UINT64_FORMAT "MB), " |
591 num_mallocs(), alloc_bytes()/K, num_frees(), resource_bytes()/K); | 595 UINT64_FORMAT" frees (" UINT64_FORMAT "MB), " UINT64_FORMAT "MB resrc", |
596 num_mallocs(), alloc_bytes()/M, num_frees(), free_bytes()/M, resource_bytes()/M); | |
592 } | 597 } |
593 | 598 |
594 | 599 |
595 // debugging code | 600 // debugging code |
596 inline void Arena::free_all(char** start, char** end) { | 601 inline void Arena::free_all(char** start, char** end) { |