Integrated: 8257513: C2: assert((constant_addr - _masm.code()->consts()->start()) == con.offset())

Christian Hagedorn chagedorn at openjdk.java.net
Mon Dec 21 08:10:59 UTC 2020


On Wed, 16 Dec 2020 14:09:20 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

> Running the testcase with `-XX:+StressCodeBuffers` initializes the code buffer with a small size:
> https://github.com/openjdk/jdk/blob/0c8cc2cde47bed3d5c3edc203869068a0676812b/src/hotspot/share/opto/output.cpp#L1339-L1340
> This leads to more frequent expansions in `ConstantTable::emit()` when calling the `_masm.*_constant()` methods. In the `T_VOID` case, we additionally fill the jump-table with dummy words:
> https://github.com/openjdk/jdk/blob/0c8cc2cde47bed3d5c3edc203869068a0676812b/src/hotspot/share/opto/constantTable.cpp#L146-L150
> 
> When there is an expansion during this loop, then `constant_addr` is still pointing to an outdated address before expanding the code buffer and relocating the data. This lets the assertion fail when subtracting the new address `_masm.code()->consts()->start()` after the expansion.
> 
> I extended this assertion for `T_VOID` to take an expansion into account. 
> 
> There is a second issue that is currently not handled correctly. The `_masm.*_constant()` methods could return `NULL` when we failed to allocate new space in an expansion which, however, rarely happens. But when running with `-XX:+StressCodeBuffers`, `NULL` is much more likely to be returned because we intentionally free a blob from time to time:
> https://github.com/openjdk/jdk/blob/0c8cc2cde47bed3d5c3edc203869068a0676812b/src/hotspot/share/asm/codeBuffer.cpp#L846-L854
> 
> I therefore suggest to also change the associated assertions in `ConstantTable::emit()` into bailout code to handle this case (as also done in the `LIR_Assembler` using the `AbstractAssembler::*_constant()` methods).
> 
> Thanks,
> Christian

This pull request has now been integrated.

Changeset: 8e42efaa
Author:    Christian Hagedorn <chagedorn at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/8e42efaa
Stats:     91 lines in 4 files changed: 82 ins; 0 del; 9 mod

8257513: C2: assert((constant_addr - _masm.code()->consts()->start()) == con.offset())

Reviewed-by: kvn, thartmann

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

PR: https://git.openjdk.java.net/jdk/pull/1803


More information about the hotspot-compiler-dev mailing list