RFR: 8330540: Rename the enum type CompileCommand to CompileCommandEnum [v2]
Ioi Lam
iklam at openjdk.org
Fri Apr 19 00:15:17 UTC 2024
> `CompileCommand` is used both as a enum type ([compilerOracle.hpp](https://github.com/openjdk/jdk/blob/064628471b83616b4463baa78618d1b7a66d0c7c/src/hotspot/share/compiler/compilerOracle.hpp#L104)), and a global variable ([compiler_globals.hpp](https://github.com/openjdk/jdk/blob/064628471b83616b4463baa78618d1b7a66d0c7c/src/hotspot/share/compiler/compiler_globals.hpp#L304)).
>
> This makes very awkward to the enum type -- we are forced to use `enum CompileCommand` in the source code whenever a type is needed:
>
> This simple c++ file illustrates the problem:
>
> enum class CompileCommand { a, b, c };
> void foo(CompileCommand x) {}
> char* CompileCommand; // can no longer use "CompileCommand" as a type
> void good(enum CompileCommand x) {}
> void bad(CompileCommand x) {}
>
> $ g++ -c ~/enum.cpp
> /home/iklam/enum.cpp:5:6: error: variable or field ?bad? declared void
> 5 | void bad(CompileCommand x) {}
>
>
> The fix is to rename the enum type to `CompileCommandEnum`.
>
> This also makes it possible to forward-declare `CompileCommandEnum` (see vmEnum.hpp) without including compilerOracle.hpp. This improves HotSpot build time by reducing the number of .o files that include compilerOracle.hpp from 456 to 16.
Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
- Merge branch 'master' into 8330540-rename-CompileCommand-to-CompileCommandEnum
- 8330540: Rename the enum type CompileCommand to CompileCommandEnum
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/18829/files
- new: https://git.openjdk.org/jdk/pull/18829/files/b60a498f..9d1191b8
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=18829&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=18829&range=00-01
Stats: 15582 lines in 205 files changed: 4213 ins; 10559 del; 810 mod
Patch: https://git.openjdk.org/jdk/pull/18829.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/18829/head:pull/18829
PR: https://git.openjdk.org/jdk/pull/18829
More information about the graal-dev
mailing list