RFR: 8350097: Make Compilation::current() and Compile::current() safer
Aleksey Shipilev
shade at openjdk.org
Fri Feb 14 15:21:16 UTC 2025
On Fri, 14 Feb 2025 14:48:34 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> Somewhat trivial.
>
> I recently hunted a bug for an hour until I realized that I had accessed ciEnv::compiler_data() as C2 `Compile` when, in fact, it was C1 `Compilation`. Stupid mistake, but an assert is easy to do and saves time.
src/hotspot/share/c1/c1_Compilation.hpp line 35:
> 33: #include "compiler/compilerDirectives.hpp"
> 34: #include "runtime/deoptimization.hpp"
> 35: #include "utilities/debug.hpp"
`DEBUG_ONLY` lives in `utilities/macros.hpp`, include that one directly?
src/hotspot/share/c1/c1_Compilation.hpp line 134:
> 132:
> 133: static Compilation* current() {
> 134: DEBUG_ONLY(ciEnv::current()->check_compiler_data_c1_or_null();)
So, can it be just some sort of:
assert(CompilerThread::current()->compiler()->is_c1(), "sanity");
...without any other changes in `ciEnv`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23635#discussion_r1956304092
PR Review Comment: https://git.openjdk.org/jdk/pull/23635#discussion_r1956311599
More information about the hotspot-compiler-dev
mailing list