MacroAssembler::trampoline_call has check_emit_size parameter which enables/disables the functionality to check the size of a generated trampoline call. This functionality must only be during C2 compilation. Using it during C1 compilation can have UB because of the following: Compile::current()->output(). Compile::current is the following:
static Compile* current() {
return (Compile*) ciEnv::current()->compiler_data();
}
In case of C1 ciEnv::current()->compiler_data() returns C1 Compilation and the cast to C2 Compile is invalid.
The default value of check_emit_size is true. This leads to confusion for the cases where 'check emit size' has no meaning like C1 or stub generation and check_emit_size is not provided.
UB is not triggered because in_scratch_emit_size is short-circuited to false by is_c2_compile() if it is C1 and no call of Compile::current()->output() happens.
We can remove check_emit_size parameter if we move the functionality intended for C2 to C2_MacroAssembler. Compile::current()->output() will always have the defined behavior.
static Compile* current() {
return (Compile*) ciEnv::current()->compiler_data();
}
In case of C1 ciEnv::current()->compiler_data() returns C1 Compilation and the cast to C2 Compile is invalid.
The default value of check_emit_size is true. This leads to confusion for the cases where 'check emit size' has no meaning like C1 or stub generation and check_emit_size is not provided.
UB is not triggered because in_scratch_emit_size is short-circuited to false by is_c2_compile() if it is C1 and no call of Compile::current()->output() happens.
We can remove check_emit_size parameter if we move the functionality intended for C2 to C2_MacroAssembler. Compile::current()->output() will always have the defined behavior.
- relates to
-
JDK-8291654 AArch64: assert from JDK-8287393 causes crashes
-
- Resolved
-