RFR: 8354887: Preserve runtime blobs in AOT code cache
Vladimir Kozlov
kvn at openjdk.org
Sat May 3 17:46:49 UTC 2025
On Sat, 3 May 2025 04:10:01 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:
> [8350209](https://bugs.openjdk.org/browse/JDK-8350209) introduced the framework for storing code in aot code cache and used it for caching i2c/c2i adapters.
> This PR extends the `AOTCodeCache` infrastructure and stores various runtime blobs (shared blobs, C1 and C2 runtime blobs) in the AOT code cache. It adds a new diagnostic flag `AOTStubCaching` to enable/disable the caching of these blobs.
> `AOTCodeFlags.java` test is extended to cover `AOTStubCaching`.
Few comments.
src/hotspot/cpu/x86/x86_64.ad line 1868:
> 1866: } else {
> 1867: __ mov64(r10, (int64_t) $meth$$method);
> 1868: }
I think we should do it always, not conditionally. On AArch64 it is unconditional - relocation processing know how to do that.
src/hotspot/share/asm/codeBuffer.hpp line 303:
> 301: os::free((void*)_string);
> 302: _string = nullptr;
> 303: }
Move it into `.cpp` so you don't need to include `os.hpp` here.
src/hotspot/share/code/aotCodeCache.cpp line 27:
> 25: #ifdef COMPILER1
> 26: #include "c1/c1_Runtime1.hpp"
> 27: #endif
Conditional includes are placed at the end of includes.
src/hotspot/share/code/aotCodeCache.cpp line 414:
> 412: log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with CompressedOops::base() = %p vs current %p", _compressedOopBase, CompressedOops::base());
> 413: return false;
> 414: }
I think we have relocation for CompressedOops::base() so we can patch. No need to bailout.
Do you have stub/blob which missed relocation?
src/hotspot/share/code/aotCodeCache.cpp line 422:
> 420: log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with CompressedKlassPointers::base() = %p vs current %p", _compressedKlassBase, CompressedKlassPointers::base());
> 421: return false;
> 422: }
I would suggest to use relocation for klass's base too but not in these changes. I think bailout is fine here.
src/hotspot/share/code/aotCodeCache.cpp line 774:
> 772: return false;
> 773: }
> 774: log_info(aot, codecache, stubs)("Writing blob '%s' (id=%u, kind=%s) to AOT Code Cache", name, id, AOTCodeEntry::kind_string(entry_kind));
Please, use `log_debug()` in final changes.
src/hotspot/share/code/aotCodeCache.cpp line 880:
> 878: CodeBlob* blob = reader.compile_code_blob(name, entry_offset_count, entry_offsets);
> 879:
> 880: log_info(aot, codecache, stubs)("Read blob '%s' (id=%u, kind=%s) from AOT Code Cache", name, id, AOTCodeEntry::kind_string(entry_kind));
Use `log_debug()`
src/hotspot/share/code/aotCodeCache.cpp line 1119:
> 1117: uint n = write_bytes(&offset, sizeof(uint));
> 1118: if (n != sizeof(uint)) {
> 1119: return false;
Consider using `id_for_C_string()` and record ID instead of coping string. These strings should be recorded in C strings table already.
If `id_for_C_string()` does not find - assert. We should add `add_C_string()` in missing place.
src/hotspot/share/code/aotCodeCache.cpp line 1158:
> 1156: log_trace(aot, codecache, stubs)("dbg string=%s", str);
> 1157: uint len = (uint)strlen(str) + 1; // including '\0' char
> 1158: uint n = write_bytes(str, len);
Same here
src/hotspot/share/opto/runtime.cpp line 161:
> 159: C2_STUB_C_FUNC(name), \
> 160: C2_STUB_NAME(name), \
> 161: (int)C2_STUB_ID(name), \
Please, align ``
src/hotspot/share/opto/runtime.cpp line 175:
> 173: C2_JVMTI_STUB_C_FUNC(name), \
> 174: C2_STUB_NAME(name), \
> 175: (int)C2_STUB_ID(name), \
Here too.
-------------
PR Review: https://git.openjdk.org/jdk/pull/25019#pullrequestreview-2813266337
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072427336
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072427806
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072431635
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072433399
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072433955
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072434259
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072434351
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072435358
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072435774
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072428528
PR Review Comment: https://git.openjdk.org/jdk/pull/25019#discussion_r2072428575
More information about the hotspot-runtime-dev
mailing list