RFR: 8337939: ZGC: Make assertions and checks less convoluted and explicit
Stefan Karlsson
stefank at openjdk.org
Wed Aug 7 14:17:32 UTC 2024
On Tue, 6 Aug 2024 15:15:57 GMT, Joel Sikström <duke at openjdk.org> wrote:
> There are currently cases where calls to type converters are made only to assert whether the conversion is reasonable or not and then discarding the result. For example, to_zaddress(...) is used to check if the pointer passed to it is a valid zaddress or not, whilst discarding the result of the conversion.
>
> Additionally, a call like oopDesc::is_oop(to_oop(o)) is convoluted since a similar check to is_oop() is already done inside to_oop(), which should be a separate operation in its entirety.
>
> Asserts/checks in affected places should be separated so that assertion/checking can be explicitly made and not done more than necessary.
>
> Tested with tiers 1-7 on linux64 and linux64-debug.
Changes requested by stefank (Reviewer).
src/hotspot/share/gc/z/zVerify.cpp line 122:
> 120: const oop obj = cast_to_oop(o);
> 121: guarantee(oopDesc::is_oop(obj), BAD_OOP_ARG(o, p));
> 122: }
I pre-reviewed this part, but I realize now that I'd like to update the parameter name for the zaddress. Would you mind updating the code this?
Suggestion:
static void z_verify_root_oop_object(zaddress addr, void* p) {
const oop obj = cast_to_oop(addr);
guarantee(oopDesc::is_oop(obj), BAD_OOP_ARG(addr, p));
}
-------------
PR Review: https://git.openjdk.org/jdk/pull/20478#pullrequestreview-2225333707
PR Review Comment: https://git.openjdk.org/jdk/pull/20478#discussion_r1707089369
More information about the hotspot-gc-dev
mailing list