RFR: 8280872: Reorder code cache segments to improve code density
Boris Ulasevich
bulasevich at openjdk.java.net
Wed Feb 23 20:04:23 UTC 2022
On Tue, 22 Feb 2022 23:53:19 GMT, Evgeny Astigeevich <duke at openjdk.java.net> wrote:
>> Currently the codecache segment order is [non-nmethod, non-profiled, profiled]. With this change we move the non-nmethod segment between two code segments. It changes nothing for any platform besides AARCH.
>>
>> In AARCH the offset limit for a branch instruction is 128MB. The bigger jumps are encoded with three instructions. Most of far branches are jumps into the non-nmethod blobs. With the non-nmethod segment in between code segments the jump distance from method to the stub becomes shorter. The result is a 4% reduction in generated code size for the CodeCache range from 128MB to 240MB.
>>
>> As a side effect, the performance of some tests is slightly improved:
>> ``ArraysFill.testCharFill 10 thrpt 15 170235.720 -> 178477.212 ops/ms``
>>
>> Testing: jdk/hotspot jtreg and microbenchmarks on AMD and AARCH
>
> src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp line 411:
>
>> 409: assert(CodeCache::find_blob(entry.target()) != NULL,
>> 410: "destination of far call not found in code cache");
>> 411: if (far_branches()) {
>
> Can we write something like this:
>
> if (is_target_far_from_heap(entry, cbuf->target_code_heap())) {
> ...
> }
>
>
> And the implementation:
>
> static inline bool is_target_far_from_heap(Address addr, CodeHeap* heap = nullptr) {
> if (!SegmentedCodeCache || heap == nullptr) {
> return ReservedCodeCacheSize > branch_range;
> }
>
> return max_dist_to_heap(addr, heap) > branch_range;
> }
Yes, inline expression is difficult to read. I added target_needs_far_branch, I hope it is better now.
> src/hotspot/share/code/codeCache.cpp line 893:
>
>> 891: }
>> 892:
>> 893: bool CodeCache::is_codestub(address addr) {
>
> Should it be named `is_non_nmethod`? According to the comments, there can be buffers, adapters and stubs.
Ok. Thanks
-------------
PR: https://git.openjdk.java.net/jdk/pull/7517
More information about the hotspot-dev
mailing list