Skip to content

Commit 866e485

Browse files
committed
set_size_of_unset_code_heap
1 parent ea39f93 commit 866e485

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/hotspot/share/code/codeCache.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ static void report_cache_size_error(const CodeHeapInfo& non_nmethod, const CodeH
223223
vm_exit_during_initialization("Invalid code heap sizes", message);
224224
}
225225

226-
static size_t subtract_size(size_t cache_size, size_t known_segments_size, size_t min_size) {
227-
return (cache_size > known_segments_size + min_size) ? (cache_size - known_segments_size) : min_size;
226+
static void set_size_of_unset_code_heap(CodeHeapInfo* heap, size_t available_size, size_t known_segments_size, size_t min_size) {
227+
assert(!heap->set, "sanity");
228+
heap->size = (available_size > known_segments_size + min_size) ? (available_size - known_segments_size) : min_size;
228229
}
229230

230231
void CodeCache::initialize_heaps() {
@@ -251,12 +252,8 @@ void CodeCache::initialize_heaps() {
251252
}
252253

253254
if (!heap_available(CodeBlobType::MethodNonProfiled)) {
254-
// Compatibility
255-
non_nmethod.size += profiled.size;
256-
// Non-Profiled code heap is not available, forcibly set size to 0
257-
non_profiled.size = 0;
258-
non_profiled.set = true;
259-
non_profiled.enabled = false;
255+
// MethodNonProfiled heap is always awailable for segmented code heap
256+
ShouldNotReachHere();
260257
}
261258

262259
size_t compiler_buffer_size = 0;
@@ -273,18 +270,18 @@ void CodeCache::initialize_heaps() {
273270
}
274271

275272
if (profiled.set && !non_profiled.set) {
276-
non_profiled.size = subtract_size(cache_size, non_nmethod.size + profiled.size, min_size);
273+
set_size_of_unset_code_heap(&non_profiled, cache_size, non_nmethod.size + profiled.size, min_size);
277274
}
278275

279276
if (!profiled.set && non_profiled.set) {
280-
profiled.size = subtract_size(cache_size, non_nmethod.size + non_profiled.size, min_size);
277+
set_size_of_unset_code_heap(&profiled, cache_size, non_nmethod.size + non_profiled.size, min_size);
281278
}
282279

283280
// Compatibility.
284281
// Override Non-NMethod default size if two other segments are set explicitly
285282
size_t non_nmethod_min_size = min_cache_size + compiler_buffer_size;
286283
if (!non_nmethod.set && profiled.set && non_profiled.set) {
287-
non_nmethod.size = subtract_size(cache_size, profiled.size + non_profiled.size, non_nmethod_min_size);
284+
set_size_of_unset_code_heap(&non_nmethod, cache_size, profiled.size + non_profiled.size, non_nmethod_min_size);
288285
}
289286

290287
size_t total = non_nmethod.size + profiled.size + non_profiled.size;

0 commit comments

Comments
 (0)