On Fri, 26 Apr 2024 21:16:03 GMT, Vladimir Kozlov <k...@openjdk.org> wrote:

> Move immutable nmethod's data from CodeCache to C heap. It includes 
> `dependencies, nul_chk_table, handler_table, scopes_pcs, scopes_data, 
> speculations, jvmci_data`. It amounts for about 30% (optimized VM) of space 
> in CodeCache.
> 
> Use HotSpot's `os::malloc()` to allocate memory in C heap for immutable 
> nmethod's data. Bail out compilation if allocation failed.
> 
> Shuffle fields order and change some fields size from 4 to 2 bytes to avoid 
> nmethod's header size increase.
> 
> Tested tier1-5, stress,xcomp

src/hotspot/share/code/nmethod.cpp line 117:

> 115:   result = static_cast<T>(thing); \
> 116:   assert(static_cast<int>(result) == thing, "failed: %d != %d", 
> static_cast<int>(result), thing);
> 117: 

I replaced `checked_cast<>()` with this macro because of next issues:
 - The existing assert points to `utilities/checkedCast.hpp` file where this 
method is located and not where failed cast. It does not help when it is used 
several times in one method (for example, in `nmethod()` constructors).
 - The existing assert does not print values

src/hotspot/share/code/nmethod.cpp line 1324:

> 1322: 
> 1323:     // native wrapper does not have read-only data but we need unique 
> not null address
> 1324:     _immutable_data          = data_end();

I can't use nullptr because VM expects not null address when it checks, for 
example, `dependencies_begin()` even so sizes are 0.
I used `data_end()` instead of nullptr in other places too.

src/hotspot/share/code/nmethod.hpp line 583:

> 581:   int dependencies_size  () const { return int(          
> dependencies_end () -           dependencies_begin ()); }
> 582:   int handler_table_size () const { return int(          
> handler_table_end() -           handler_table_begin()); }
> 583:   int nul_chk_table_size () const { return int(          
> nul_chk_table_end() -           nul_chk_table_begin()); }

Shift by one space to aline code.

test/hotspot/jtreg/compiler/c1/TestLinearScanOrderMain.java line 29:

> 27:  * @compile TestLinearScanOrder.jasm
> 28:  * @run main/othervm -Xcomp -XX:+TieredCompilation -XX:TieredStopAtLevel=1
> 29:  *                   -XX:+IgnoreUnrecognizedVMOptions 
> -XX:NMethodSizeLimit=655360

This test caught one `check_cast<>` issue during development but only on 
aarch64.
On x64 the test bailed out compilation before that because default 
`NMethodSizeLimit` was not big enough ((64*K)*wordSize = 524288).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18984#discussion_r1581561933
PR Review Comment: https://git.openjdk.org/jdk/pull/18984#discussion_r1581565762
PR Review Comment: https://git.openjdk.org/jdk/pull/18984#discussion_r1581558637
PR Review Comment: https://git.openjdk.org/jdk/pull/18984#discussion_r1581557756

Reply via email to