|
1 | 1 | /* |
2 | | - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. |
3 | | - * Copyright (c) 2023, Red Hat, Inc. and/or its affiliates. |
| 2 | + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates. |
4 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 | 5 | * |
6 | 6 | * This code is free software; you can redistribute it and/or modify it |
@@ -394,16 +394,20 @@ void CompilationMemoryStatistic::on_end_compilation() { |
394 | 394 | ResourceMark rm; |
395 | 395 | CompilerThread* const th = Thread::current()->as_Compiler_thread(); |
396 | 396 | ArenaStatCounter* const arena_stat = th->arena_stat(); |
397 | | - const CompilerType ct = th->task()->compiler()->type(); |
| 397 | + CompileTask* const task = th->task(); |
| 398 | + const CompilerType ct = task->compiler()->type(); |
398 | 399 |
|
399 | 400 | const Method* const m = th->task()->method(); |
400 | 401 | FullMethodName fmn(m); |
401 | 402 | fmn.make_permanent(); |
402 | 403 |
|
403 | 404 | const DirectiveSet* directive = th->task()->directive(); |
404 | | - assert(directive->should_collect_memstat(), "Only call if memstat is enabled"); |
| 405 | + assert(directive->should_collect_memstat(), "Should only be called if memstat is enabled for this method"); |
405 | 406 | const bool print = directive->should_print_memstat(); |
406 | 407 |
|
| 408 | + // Store memory used in task, for later processing by JFR |
| 409 | + task->set_arena_bytes(arena_stat->peak_since_start()); |
| 410 | + |
407 | 411 | // Store result |
408 | 412 | // For this to work, we must call on_end_compilation() at a point where |
409 | 413 | // Compile|Compilation already handed over the failure string to ciEnv, |
@@ -492,7 +496,7 @@ void CompilationMemoryStatistic::on_arena_change(ssize_t diff, const Arena* aren |
492 | 496 | CompilerType ct = compiler_none; |
493 | 497 |
|
494 | 498 | // get some more info |
495 | | - const CompileTask* task = th->task(); |
| 499 | + const CompileTask* const task = th->task(); |
496 | 500 | if (task != nullptr) { |
497 | 501 | ct = task->compiler()->type(); |
498 | 502 | const DirectiveSet* directive = task->directive(); |
|
0 commit comments