mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8235998: [c2] Memory leaks during tracing after '8224193: stringStream should not use Resource Area'
Reviewed-by: dholmes, kvn
This commit is contained in:
parent
4deb35453f
commit
51abf67ce1
4 changed files with 33 additions and 3 deletions
|
@ -4280,6 +4280,13 @@ Node* Compile::constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt*
|
|||
return phase->transform(new ConvI2LNode(value, ltype));
|
||||
}
|
||||
|
||||
void Compile::print_inlining_stream_free() {
|
||||
if (_print_inlining_stream != NULL) {
|
||||
_print_inlining_stream->~stringStream();
|
||||
_print_inlining_stream = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// The message about the current inlining is accumulated in
|
||||
// _print_inlining_stream and transfered into the _print_inlining_list
|
||||
// once we know whether inlining succeeds or not. For regular
|
||||
|
@ -4290,13 +4297,21 @@ Node* Compile::constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt*
|
|||
// when the inlining is attempted again.
|
||||
void Compile::print_inlining_init() {
|
||||
if (print_inlining() || print_intrinsics()) {
|
||||
// print_inlining_init is actually called several times.
|
||||
print_inlining_stream_free();
|
||||
_print_inlining_stream = new stringStream();
|
||||
// Watch out: The memory initialized by the constructor call PrintInliningBuffer()
|
||||
// will be copied into the only initial element. The default destructor of
|
||||
// PrintInliningBuffer will be called when leaving the scope here. If it
|
||||
// would destuct the enclosed stringStream _print_inlining_list[0]->_ss
|
||||
// would be destructed, too!
|
||||
_print_inlining_list = new (comp_arena())GrowableArray<PrintInliningBuffer>(comp_arena(), 1, 1, PrintInliningBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
void Compile::print_inlining_reinit() {
|
||||
if (print_inlining() || print_intrinsics()) {
|
||||
print_inlining_stream_free();
|
||||
// Re allocate buffer when we change ResourceMark
|
||||
_print_inlining_stream = new stringStream();
|
||||
}
|
||||
|
@ -4310,7 +4325,7 @@ void Compile::print_inlining_commit() {
|
|||
assert(print_inlining() || print_intrinsics(), "PrintInlining off?");
|
||||
// Transfer the message from _print_inlining_stream to the current
|
||||
// _print_inlining_list buffer and clear _print_inlining_stream.
|
||||
_print_inlining_list->at(_print_inlining_idx).ss()->write(_print_inlining_stream->as_string(), _print_inlining_stream->size());
|
||||
_print_inlining_list->at(_print_inlining_idx).ss()->write(_print_inlining_stream->base(), _print_inlining_stream->size());
|
||||
print_inlining_reset();
|
||||
}
|
||||
|
||||
|
@ -4391,9 +4406,16 @@ void Compile::process_print_inlining() {
|
|||
if (do_print_inlining) {
|
||||
ResourceMark rm;
|
||||
stringStream ss;
|
||||
assert(_print_inlining_list != NULL, "process_print_inlining should be called only once.");
|
||||
for (int i = 0; i < _print_inlining_list->length(); i++) {
|
||||
ss.print("%s", _print_inlining_list->adr_at(i)->ss()->as_string());
|
||||
_print_inlining_list->at(i).freeStream();
|
||||
}
|
||||
// Reset _print_inlining_list, it only contains destructed objects.
|
||||
// It is on the arena, so it will be freed when the arena is reset.
|
||||
_print_inlining_list = NULL;
|
||||
// _print_inlining_stream won't be used anymore, either.
|
||||
print_inlining_stream_free();
|
||||
size_t end = ss.size();
|
||||
_print_inlining_output = NEW_ARENA_ARRAY(comp_arena(), char, end+1);
|
||||
strncpy(_print_inlining_output, ss.base(), end+1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue