Skip to content

Commit a6464b7

Browse files
mhaessigSendaoYan
authored andcommitted
8358578: Small -XX:NMethodSizeLimit triggers "not in CodeBuffer memory" assert in C1
Reviewed-by: kvn, syan, thartmann
1 parent 0dd50db commit a6464b7

File tree

6 files changed

+7
-55
lines changed

6 files changed

+7
-55
lines changed

src/hotspot/share/c1/c1_Compilation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) {
330330
char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
331331
code->insts()->initialize_shared_locs((relocInfo*)locs_buffer,
332332
locs_buffer_size / sizeof(relocInfo));
333-
code->initialize_consts_size(Compilation::desired_max_constant_size());
333+
code->initialize_consts_size(Compilation::desired_max_constant_size);
334334
// Call stubs + two deopt handlers (regular and MH) + exception handler
335335
int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size()) +
336336
LIR_Assembler::exception_handler_size() +

src/hotspot/share/c1/c1_Compilation.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,8 @@ class Compilation: public StackObj {
216216
const char* bailout_msg() const { return _bailout_msg; }
217217
const CompilationFailureInfo* first_failure_details() const { return _first_failure_details; }
218218

219-
static uint desired_max_code_buffer_size() {
220-
return (uint)NMethodSizeLimit; // default 64K
221-
}
222-
static uint desired_max_constant_size() {
223-
return desired_max_code_buffer_size() / 10;
224-
}
219+
const static uint desired_max_code_buffer_size = 64*K * wordSize;
220+
const static uint desired_max_constant_size = desired_max_code_buffer_size / 10;
225221

226222
static bool setup_code_buffer(CodeBuffer* cb, int call_stub_estimate);
227223

src/hotspot/share/c1/c1_Compiler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,15 @@ void Compiler::initialize() {
7979
}
8080

8181
uint Compiler::code_buffer_size() {
82-
return Compilation::desired_max_code_buffer_size() + Compilation::desired_max_constant_size();
82+
return Compilation::desired_max_code_buffer_size + Compilation::desired_max_constant_size;
8383
}
8484

8585
BufferBlob* Compiler::init_buffer_blob() {
8686
// Allocate buffer blob once at startup since allocation for each
8787
// compilation seems to be too expensive (at least on Intel win32).
8888
assert (CompilerThread::current()->get_buffer_blob() == nullptr, "Should initialize only once");
8989

90-
// setup CodeBuffer. Preallocate a BufferBlob of size
91-
// NMethodSizeLimit plus some extra space for constants.
90+
// Setup CodeBuffer.
9291
BufferBlob* buffer_blob = BufferBlob::create("C1 temporary CodeBuffer", code_buffer_size());
9392
if (buffer_blob != nullptr) {
9493
CompilerThread::current()->set_buffer_blob(buffer_blob);

src/hotspot/share/c1/c1_globals.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,6 @@
274274
develop(bool, InstallMethods, true, \
275275
"Install methods at the end of successful compilations") \
276276
\
277-
/* The compiler assumes, in many places, that methods are at most 1MB. */ \
278-
/* Therefore, we restrict this flag to at most 1MB. */ \
279-
develop(intx, NMethodSizeLimit, (64*K)*wordSize, \
280-
"Maximum size of a compiled method.") \
281-
range(0, 1*M) \
282-
\
283277
develop(intx, InstructionCountCutoff, 37000, \
284278
"If GraphBuilder adds this many instructions, bails out") \
285279
range(0, max_jint) \

test/hotspot/jtreg/compiler/arguments/TestC1Globals.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 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
@@ -21,42 +21,6 @@
2121
* questions.
2222
*/
2323

24-
/**
25-
* @test
26-
* @bug 8316653
27-
* @requires vm.debug
28-
* @summary Test flag with max value.
29-
*
30-
* @run main/othervm -XX:NMethodSizeLimit=1M
31-
* compiler.arguments.TestC1Globals
32-
*/
33-
34-
/**
35-
* @test
36-
* @bug 8318817
37-
* @requires vm.debug
38-
* @requires os.family == "linux"
39-
* @summary Test flag with max value combined with transparent huge pages on
40-
* Linux.
41-
*
42-
* @run main/othervm -XX:NMethodSizeLimit=1M
43-
* -XX:+UseTransparentHugePages
44-
* compiler.arguments.TestC1Globals
45-
*/
46-
47-
/**
48-
* @test
49-
* @bug 8320682
50-
* @requires vm.debug
51-
* @summary Test flag with max value and specific compilation.
52-
*
53-
* @run main/othervm -XX:NMethodSizeLimit=1M
54-
* -XX:CompileOnly=java.util.HashMap::putMapEntries
55-
* -Xcomp
56-
* compiler.arguments.TestC1Globals
57-
*
58-
*/
59-
6024
/**
6125
* @test
6226
* @bug 8322781

test/hotspot/jtreg/compiler/c1/TestLinearScanOrderMain.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 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
@@ -26,7 +26,6 @@
2626
* @bug 8207355
2727
* @compile TestLinearScanOrder.jasm
2828
* @run main/othervm -Xcomp -XX:+TieredCompilation -XX:TieredStopAtLevel=1
29-
* -XX:+IgnoreUnrecognizedVMOptions -XX:NMethodSizeLimit=655360
3029
* -XX:CompileCommand=compileonly,compiler.c1.TestLinearScanOrder::test
3130
* compiler.c1.TestLinearScanOrderMain
3231
*/

0 commit comments

Comments
 (0)