1 /*
2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
50 cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
51 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
52 (jlong)max_size, CHECK);
53
54 cname = PerfDataManager::counter_name(_name_space, "capacity");
55 _capacity = PerfDataManager::create_variable(SUN_GC, cname,
56 PerfData::U_Bytes,
57 initial_capacity, CHECK);
58
59 cname = PerfDataManager::counter_name(_name_space, "used");
60 _used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
61 (jlong) 0, CHECK);
62
63 cname = PerfDataManager::counter_name(_name_space, "initCapacity");
64 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
65 initial_capacity, CHECK);
66 }
67 }
68
69 HSpaceCounters::~HSpaceCounters() {
70 if (_name_space != NULL) {
71 FREE_C_HEAP_ARRAY(char, _name_space);
72 }
73 }
74
75 void HSpaceCounters::update_capacity(size_t v) {
76 _capacity->set_value(v);
77 }
78
79 void HSpaceCounters::update_used(size_t v) {
80 _used->set_value(v);
81 }
82
83 void HSpaceCounters::update_all(size_t capacity, size_t used) {
84 update_capacity(capacity);
85 update_used(used);
86 }
87
88 debug_only(
89 // for security reasons, we do not allow arbitrary reads from
90 // the counters as they may live in shared memory.
91 jlong HSpaceCounters::used() {
92 return _used->get_value();
|
1 /*
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
50 cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
51 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
52 (jlong)max_size, CHECK);
53
54 cname = PerfDataManager::counter_name(_name_space, "capacity");
55 _capacity = PerfDataManager::create_variable(SUN_GC, cname,
56 PerfData::U_Bytes,
57 initial_capacity, CHECK);
58
59 cname = PerfDataManager::counter_name(_name_space, "used");
60 _used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
61 (jlong) 0, CHECK);
62
63 cname = PerfDataManager::counter_name(_name_space, "initCapacity");
64 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
65 initial_capacity, CHECK);
66 }
67 }
68
69 HSpaceCounters::~HSpaceCounters() {
70 FREE_C_HEAP_ARRAY(char, _name_space);
71 }
72
73 void HSpaceCounters::update_capacity(size_t v) {
74 _capacity->set_value(v);
75 }
76
77 void HSpaceCounters::update_used(size_t v) {
78 _used->set_value(v);
79 }
80
81 void HSpaceCounters::update_all(size_t capacity, size_t used) {
82 update_capacity(capacity);
83 update_used(used);
84 }
85
86 debug_only(
87 // for security reasons, we do not allow arbitrary reads from
88 // the counters as they may live in shared memory.
89 jlong HSpaceCounters::used() {
90 return _used->get_value();
|