comparison src/share/vm/memory/allocation.inline.hpp @ 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 bf29934d2f4f
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.
30 // Explicit C-heap memory management 30 // Explicit C-heap memory management
31 31
32 void trace_heap_malloc(size_t size, const char* name, void *p); 32 void trace_heap_malloc(size_t size, const char* name, void *p);
33 void trace_heap_free(void *p); 33 void trace_heap_free(void *p);
34 34
35 // Increments unsigned long value for statistics (not atomic on MP).
36 inline void inc_stat_counter(volatile julong* dest, julong add_value) {
37 julong value = Atomic::load((volatile jlong*)dest);
38 value += add_value;
39 Atomic::store((jlong)value, (volatile jlong*)dest);
40 }
35 41
36 // allocate using malloc; will fail if no memory available 42 // allocate using malloc; will fail if no memory available
37 inline char* AllocateHeap(size_t size, const char* name = NULL) { 43 inline char* AllocateHeap(size_t size, const char* name = NULL) {
38 char* p = (char*) os::malloc(size); 44 char* p = (char*) os::malloc(size);
39 #ifdef ASSERT 45 #ifdef ASSERT