Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8348858: [leyden] Bump the default code buffer sizes to store more generated code #28

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp
Original file line number Diff line number Diff line change
@@ -542,7 +542,7 @@ void G1BarrierSetC2::emit_stubs(CodeBuffer& cb) const {
GrowableArray<G1BarrierStubC2*>* const stubs = barrier_set_state()->stubs();
for (int i = 0; i < stubs->length(); i++) {
// Make sure there is enough space in the code buffer
if (cb.insts()->maybe_expand_to_ensure_remaining(PhaseOutput::MAX_inst_gcstub_size) && cb.blob() == nullptr) {
if (cb.insts()->maybe_expand_to_ensure_remaining(PhaseOutput::max_inst_gcstub_size()) && cb.blob() == nullptr) {
ciEnv::current()->record_failure("CodeCache is full");
return;
}
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
Original file line number Diff line number Diff line change
@@ -315,7 +315,7 @@ void ZBarrierSetC2::emit_stubs(CodeBuffer& cb) const {

for (int i = 0; i < stubs->length(); i++) {
// Make sure there is enough space in the code buffer
if (cb.insts()->maybe_expand_to_ensure_remaining(PhaseOutput::MAX_inst_gcstub_size) && cb.blob() == nullptr) {
if (cb.insts()->maybe_expand_to_ensure_remaining(PhaseOutput::max_inst_gcstub_size()) && cb.blob() == nullptr) {
ciEnv::current()->record_failure("CodeCache is full");
return;
}
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/c2compiler.cpp
Original file line number Diff line number Diff line change
@@ -887,5 +887,5 @@ int C2Compiler::initial_code_buffer_size(int const_size) {
// See Compile::init_scratch_buffer_blob
int locs_size = sizeof(relocInfo) * PhaseOutput::MAX_locs_size;
int slop = 2 * CodeSection::end_slop(); // space between sections
return PhaseOutput::MAX_inst_size + PhaseOutput::MAX_stubs_size + const_size + slop + locs_size;
return PhaseOutput::max_inst_size() + PhaseOutput::MAX_stubs_size + const_size + slop + locs_size;
}
22 changes: 18 additions & 4 deletions src/hotspot/share/opto/output.cpp
Original file line number Diff line number Diff line change
@@ -1370,7 +1370,7 @@ CodeBuffer* PhaseOutput::init_buffer() {
int exception_handler_req = HandlerImpl::size_exception_handler() + MAX_stubs_size; // add marginal slop for handler
int deopt_handler_req = HandlerImpl::size_deopt_handler() + MAX_stubs_size; // add marginal slop for handler
stub_req += MAX_stubs_size; // ensure per-stub margin
code_req += MAX_inst_size; // ensure per-instruction margin
code_req += max_inst_size(); // ensure per-instruction margin

if (StressCodeBuffers)
code_req = const_req = stub_req = exception_handler_req = deopt_handler_req = 0x10; // force expansion
@@ -1567,7 +1567,7 @@ void PhaseOutput::fill_buffer(C2_MacroAssembler* masm, uint* blk_starts) {
last_inst++;
C->cfg()->map_node_to_block(nop, block);
// Ensure enough space.
masm->code()->insts()->maybe_expand_to_ensure_remaining(MAX_inst_size);
masm->code()->insts()->maybe_expand_to_ensure_remaining(max_inst_size());
if ((masm->code()->blob() == nullptr) || (!CompileBroker::should_compile_new_jobs())) {
C->record_failure("CodeCache is full");
return;
@@ -1696,7 +1696,7 @@ void PhaseOutput::fill_buffer(C2_MacroAssembler* masm, uint* blk_starts) {
}

// Verify that there is sufficient space remaining
masm->code()->insts()->maybe_expand_to_ensure_remaining(MAX_inst_size);
masm->code()->insts()->maybe_expand_to_ensure_remaining(max_inst_size());
if ((masm->code()->blob() == nullptr) || (!CompileBroker::should_compile_new_jobs())) {
C->record_failure("CodeCache is full");
return;
@@ -3353,7 +3353,7 @@ uint PhaseOutput::scratch_emit_size(const Node* n) {
// expensive, since it has to grab the code cache lock.
BufferBlob* blob = this->scratch_buffer_blob();
assert(blob != nullptr, "Initialize BufferBlob at start");
assert(blob->size() > MAX_inst_size, "sanity");
assert(blob->size() > max_inst_size(), "sanity");
relocInfo* locs_buf = scratch_locs_memory();
address blob_begin = blob->content_begin();
address blob_end = (address)locs_buf;
@@ -3667,3 +3667,17 @@ void PhaseOutput::print_statistics() {
Scheduling::print_statistics();
}
#endif

int PhaseOutput::max_inst_size() {
if (SCCache::is_on_for_write()) {
// See the comment in output.hpp.
return 16384;
} else {
return mainline_MAX_inst_size;
}
}

int PhaseOutput::max_inst_gcstub_size() {
assert(mainline_MAX_inst_size <= max_inst_size(), "Sanity");
return mainline_MAX_inst_size;
}
15 changes: 10 additions & 5 deletions src/hotspot/share/opto/output.hpp
Original file line number Diff line number Diff line change
@@ -185,23 +185,28 @@ class PhaseOutput : public Phase {
// SCCache::write_nmethod bails when nmethod buffer is expanded.
// Large methods would routinely expand the buffer, making themselves
// ineligible for SCCache stores. In order to minimize this effect,
// we default to larger default sizes.
// we default to larger default sizes. We do this only when SCC dumping
// is active, to avoid impact on default configuration.
//
// Additionally, GC barrier stubs expand up to MAX_inst_size in mainline,
// which also forced resizes often. Current code replaces it with
// MAX_inst_gcstub_size, which equals to old MAX_inst_size, so GC stubs
// max_inst_gcstub_size, which equals to old MAX_inst_size, so GC stubs
// still fit nicely, and do not force the resizes too often.
//
// The old enum is renamed, so direct misuse in new code from mainline would
// be caught as build failure.
//
// TODO: Revert this back to mainline once SCCache is fixed.
enum ScratchBufferBlob {
MAX_inst_size = 16384,
MAX_inst_gcstub_size= 2048,
mainline_MAX_inst_size = 2048,
MAX_locs_size = 128, // number of relocInfo elements
MAX_const_size = 128,
MAX_stubs_size = 128
};

static_assert(MAX_inst_gcstub_size <= MAX_inst_size, "sanity");
// Current uses of MAX_inst_size should be replaced with these getters:
static int max_inst_size();
static int max_inst_gcstub_size();

int frame_slots() const { return _frame_slots; }
int frame_size_in_words() const; // frame_slots in units of the polymorphic 'words'