@@ -58,12 +58,11 @@ G1NUMA* G1NUMA::create() {
58
58
}
59
59
60
60
// Returns memory node ids
61
- const int * G1NUMA::node_ids () const {
61
+ const uint * G1NUMA::node_ids () const {
62
62
return _node_ids;
63
63
}
64
64
65
- uint G1NUMA::index_of_node_id (int node_id) const {
66
- assert (node_id >= 0 , " invalid node id %d" , node_id);
65
+ uint G1NUMA::index_of_node_id (uint node_id) const {
67
66
assert (node_id < _len_node_id_to_index_map, " invalid node id %d" , node_id);
68
67
uint node_index = _node_id_to_index_map[node_id];
69
68
assert (node_index != G1NUMA::UnknownNodeIndex,
@@ -80,7 +79,7 @@ G1NUMA::G1NUMA() :
80
79
void G1NUMA::initialize_without_numa () {
81
80
// If NUMA is not enabled or supported, initialize as having a single node.
82
81
_num_active_node_ids = 1 ;
83
- _node_ids = NEW_C_HEAP_ARRAY (int , _num_active_node_ids, mtGC);
82
+ _node_ids = NEW_C_HEAP_ARRAY (uint , _num_active_node_ids, mtGC);
84
83
_node_ids[0 ] = 0 ;
85
84
// Map index 0 to node 0
86
85
_len_node_id_to_index_map = 1 ;
@@ -98,10 +97,10 @@ void G1NUMA::initialize(bool use_numa) {
98
97
size_t num_node_ids = os::numa_get_groups_num ();
99
98
100
99
// Create an array of active node ids.
101
- _node_ids = NEW_C_HEAP_ARRAY (int , num_node_ids, mtGC);
102
- _num_active_node_ids = ( uint) os::numa_get_leaf_groups (_node_ids, num_node_ids);
100
+ _node_ids = NEW_C_HEAP_ARRAY (uint , num_node_ids, mtGC);
101
+ _num_active_node_ids = checked_cast< uint>( os::numa_get_leaf_groups (reinterpret_cast < int *>( _node_ids) , num_node_ids) );
103
102
104
- int max_node_id = 0 ;
103
+ uint max_node_id = 0 ;
105
104
for (uint i = 0 ; i < _num_active_node_ids; i++) {
106
105
max_node_id = MAX2 (max_node_id, _node_ids[i]);
107
106
}
@@ -111,7 +110,7 @@ void G1NUMA::initialize(bool use_numa) {
111
110
_node_id_to_index_map = NEW_C_HEAP_ARRAY (uint, _len_node_id_to_index_map, mtGC);
112
111
113
112
// Set all indices with unknown node id.
114
- for (int i = 0 ; i < _len_node_id_to_index_map; i++) {
113
+ for (uint i = 0 ; i < _len_node_id_to_index_map; i++) {
115
114
_node_id_to_index_map[i] = G1NUMA::UnknownNodeIndex;
116
115
}
117
116
@@ -125,8 +124,8 @@ void G1NUMA::initialize(bool use_numa) {
125
124
126
125
G1NUMA::~G1NUMA () {
127
126
delete _stats;
128
- FREE_C_HEAP_ARRAY (int , _node_id_to_index_map);
129
- FREE_C_HEAP_ARRAY (int , _node_ids);
127
+ FREE_C_HEAP_ARRAY (uint , _node_id_to_index_map);
128
+ FREE_C_HEAP_ARRAY (uint , _node_ids);
130
129
}
131
130
132
131
void G1NUMA::set_region_info (size_t region_size, size_t page_size) {
@@ -159,7 +158,7 @@ uint G1NUMA::preferred_node_index_for_index(uint region_index) const {
159
158
}
160
159
}
161
160
162
- int G1NUMA::numa_id (int index) const {
161
+ uint G1NUMA::numa_id (uint index) const {
163
162
assert (index < _len_node_id_to_index_map, " Index %d out of range: [0,%d)" ,
164
163
index, _len_node_id_to_index_map);
165
164
return _node_ids[index];
@@ -170,7 +169,7 @@ uint G1NUMA::index_of_address(HeapWord *address) const {
170
169
if (numa_id == -1 ) {
171
170
return UnknownNodeIndex;
172
171
} else {
173
- return index_of_node_id (numa_id);
172
+ return index_of_node_id (checked_cast<uint>( numa_id) );
174
173
}
175
174
}
176
175
@@ -218,9 +217,9 @@ void G1NUMA::request_memory_on_node(void* aligned_address, size_t size_in_bytes,
218
217
assert (is_aligned (aligned_address, page_size ()), " Given address (" PTR_FORMAT " ) should be aligned." , p2i (aligned_address));
219
218
assert (is_aligned (size_in_bytes, page_size ()), " Given size (" SIZE_FORMAT " ) should be aligned." , size_in_bytes);
220
219
221
- log_trace (gc, heap, numa)(" Request memory [" PTR_FORMAT " , " PTR_FORMAT " ) to be NUMA id (%d )" ,
220
+ log_trace (gc, heap, numa)(" Request memory [" PTR_FORMAT " , " PTR_FORMAT " ) to be NUMA id (%u )" ,
222
221
p2i (aligned_address), p2i ((char *)aligned_address + size_in_bytes), _node_ids[node_index]);
223
- os::numa_make_local ((char *)aligned_address, size_in_bytes, _node_ids[node_index]);
222
+ os::numa_make_local ((char *)aligned_address, size_in_bytes, checked_cast< int >( _node_ids[node_index]) );
224
223
}
225
224
226
225
uint G1NUMA::max_search_depth () const {
@@ -279,9 +278,9 @@ G1NodeIndexCheckClosure::G1NodeIndexCheckClosure(const char* desc, G1NUMA* numa,
279
278
280
279
G1NodeIndexCheckClosure::~G1NodeIndexCheckClosure () {
281
280
_ls->print (" %s: NUMA region verification (id: matched/mismatched/total): " , _desc);
282
- const int * numa_ids = _numa->node_ids ();
281
+ const uint * numa_ids = _numa->node_ids ();
283
282
for (uint i = 0 ; i < _numa->num_active_nodes (); i++) {
284
- _ls->print (" %d : %u/%u/%u " , numa_ids[i], _matched[i], _mismatched[i], _total[i]);
283
+ _ls->print (" %u : %u/%u/%u " , numa_ids[i], _matched[i], _mismatched[i], _total[i]);
285
284
}
286
285
287
286
FREE_C_HEAP_ARRAY (uint, _matched);
0 commit comments