Skip to content

Commit b37f123

Browse files
committedJan 13, 2025
8347407: [BACKOUT] C1/C2 don't handle allocation failure properly during initialization (RuntimeStub::new_runtime_stub fatal crash)
Reviewed-by: thartmann, kvn
1 parent 1f7925c commit b37f123

9 files changed

+18
-39
lines changed
 

‎src/hotspot/share/c1/c1_Compilation.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
3030
#include "code/exceptionHandlerTable.hpp"
3131
#include "compiler/compiler_globals.hpp"
3232
#include "compiler/compilerDefinitions.inline.hpp"
33+
#include "compiler/compilerDirectives.hpp"
3334
#include "runtime/deoptimization.hpp"
3435

3536
class CompilationFailureInfo;

‎src/hotspot/share/c1/c1_IR.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
2727

2828
#include "c1/c1_Instruction.hpp"
2929
#include "ci/ciExceptionHandler.hpp"
30+
#include "ci/ciStreams.hpp"
3031
#include "memory/allocation.hpp"
3132

3233
// An XHandler is a C1 internal description for an exception handler

‎src/hotspot/share/code/codeCache.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -206,7 +206,7 @@ void CodeCache::initialize_heaps() {
206206
const bool cache_size_set = FLAG_IS_CMDLINE(ReservedCodeCacheSize);
207207
const size_t ps = page_size(false, 8);
208208
const size_t min_size = MAX2(os::vm_allocation_granularity(), ps);
209-
const size_t min_cache_size = CompilerConfig::min_code_cache_size(); // Make sure we have enough space for VM internal code
209+
const size_t min_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); // Make sure we have enough space for VM internal code
210210
size_t cache_size = align_up(ReservedCodeCacheSize, min_size);
211211

212212
// Prerequisites

‎src/hotspot/share/compiler/compilationPolicy.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -455,7 +455,7 @@ void CompilationPolicy::initialize() {
455455
c2_size = C2Compiler::initial_code_buffer_size();
456456
#endif
457457
size_t buffer_size = c1_only ? c1_size : (c1_size/3 + 2*c2_size/3);
458-
int max_count = (ReservedCodeCacheSize - (int)CompilerConfig::min_code_cache_size()) / (int)buffer_size;
458+
int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size;
459459
if (count > max_count) {
460460
// Lower the compiler count such that all buffers fit into the code cache
461461
count = MAX2(max_count, c1_only ? 1 : 2);

‎src/hotspot/share/compiler/compilerDefinitions.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -475,7 +475,8 @@ void CompilerConfig::set_jvmci_specific_flags() {
475475

476476
bool CompilerConfig::check_args_consistency(bool status) {
477477
// Check lower bounds of the code cache
478-
size_t min_code_cache_size = CompilerConfig::min_code_cache_size();
478+
// Template Interpreter code is approximately 3X larger in debug builds.
479+
uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
479480
if (ReservedCodeCacheSize < InitialCodeCacheSize) {
480481
jio_fprintf(defaultStream::error_stream(),
481482
"Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",

‎src/hotspot/share/compiler/compilerDefinitions.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -148,8 +148,6 @@ class CompilerConfig : public AllStatic {
148148
inline static bool is_c2_or_jvmci_compiler_only();
149149
inline static bool is_c2_or_jvmci_compiler_enabled();
150150

151-
inline static size_t min_code_cache_size();
152-
153151
private:
154152
static bool is_compilation_mode_selected();
155153
static void set_compilation_policy_flags();

‎src/hotspot/share/compiler/compilerDefinitions.inline.hpp

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,6 @@
2525
#ifndef SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP
2626
#define SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP
2727

28-
#ifdef COMPILER1
29-
#include "c1/c1_Compiler.hpp"
30-
#endif
31-
#ifdef COMPILER2
32-
#include "opto/c2compiler.hpp"
33-
#endif
3428
#include "compiler/compilerDefinitions.hpp"
3529
#include "compiler/compiler_globals.hpp"
3630
#include "runtime/arguments.hpp"
@@ -136,13 +130,4 @@ inline bool CompilerConfig::is_c2_or_jvmci_compiler_enabled() {
136130
return is_c2_enabled() || is_jvmci_compiler_enabled();
137131
}
138132

139-
inline size_t CompilerConfig::min_code_cache_size() {
140-
size_t min_code_cache_size = CodeCacheMinimumUseSpace;
141-
// Template Interpreter code is approximately 3X larger in debug builds.
142-
DEBUG_ONLY(min_code_cache_size *= 3);
143-
COMPILER1_PRESENT(min_code_cache_size += Compiler::code_buffer_size());
144-
COMPILER2_PRESENT(min_code_cache_size += C2Compiler::initial_code_buffer_size());
145-
return min_code_cache_size;
146-
}
147-
148133
#endif // SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP

‎test/hotspot/jtreg/ProblemList.txt

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInf
7171
compiler/floatingpoint/TestSubnormalFloat.java 8317810 generic-i586
7272
compiler/floatingpoint/TestSubnormalDouble.java 8317810 generic-i586
7373

74+
compiler/startup/StartupOutput.java 8347406 generic-x64
75+
7476
compiler/codecache/CodeCacheFullCountTest.java 8332954 generic-all
7577

7678
compiler/interpreter/Test6833129.java 8335266 generic-i586

‎test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -189,17 +189,8 @@ public static void main(String[] args) throws Exception {
189189

190190
// Fails if not enough space for VM internal code
191191
long minUseSpace = WHITE_BOX.getUintxVMFlag("CodeCacheMinimumUseSpace");
192-
long nMethodSizeLimit = WHITE_BOX.getIntxVMFlag("NMethodSizeLimit");
193-
long codeEntryAlignment = WHITE_BOX.getIntxVMFlag("CodeEntryAlignment");
194-
long c1MinCodeCacheSize = 11 * nMethodSizeLimit / 10;
195-
long c2MinCodeCacheSize = 2048 /* PhaseOutput::MAX_inst_size */ +
196-
128 /* PhaseOutput::MAX_stubs_size */ +
197-
4 * 1024 /* initial_const_capacity */ +
198-
2 * Math.max(64, codeEntryAlignment) /* 2 * CodeSection::end_slop() */ +
199-
2 * 128 /* sizeof(relocInfo) * PhaseOutput::MAX_locs_size */;
200-
// minimum size: CompilerConfig::min_code_cache_size =
201-
// CodeCacheMinimumUseSpace DEBUG_ONLY(* 3) + Compiler::code_buffer_size() + C2Compiler::initial_code_buffer_size())
202-
long minSize = minUseSpace * (Platform.isDebugBuild() ? 3 : 1) + c1MinCodeCacheSize + c2MinCodeCacheSize;
192+
// minimum size: CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)
193+
long minSize = (Platform.isDebugBuild() ? 3 : 1) * minUseSpace;
203194
pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache",
204195
"-XX:NonNMethodCodeHeapSize=" + minSize,
205196
"-XX:ReservedCodeCacheSize=" + minSize,

0 commit comments

Comments
 (0)
Please sign in to comment.