RFR: 8307521: Introduce check_oop infrastructure to check oops in the oop class

Stefan Karlsson stefank at openjdk.org
Fri May 5 08:39:21 UTC 2023


I'd like to add some extra verification to our C++ usages of oops. The intention is to quickly find when we are passing around an oop that wasn't fetched via a required load barrier. We have found this kind of verification crucial when developing Generational ZGC.

My proposal is to hook into the CHECK_UNHANDLED_OOPS code, which is only compiled when building fastdebug builds. In release and slowdebug builds, `oops` are simple `oopDesc*`, but with CHECK_UNHANDLED_OOPS oop is a class where we can easily hook in verification code.

The actual verification code is not included in the patch, but the required infrastructure is. Then when we deliver Generational ZGC, it will install a verification function pointer during initialization. See: https://github.com/openjdk/zgc/blob/349cf9ae38664991879402a90c5e23e291f1c1c3/src/hotspot/share/gc/z/zAddress.cpp#L92


static void initialize_check_oop_function() {
#ifdef CHECK_UNHANDLED_OOPS
  if (ZVerifyOops) {
    // Enable extra verification of usages of oops in oopsHierarchy.hpp
    check_oop_function = [](oopDesc* obj) {
      (void)to_zaddress(obj);
    };
  }
#endif
}


We've separated out this code from the larger Generational ZGC PR, so that it can get a proper review without being hidden together with all other changes.

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

Commit messages:
 - 8307521: Introduce check_oop infrastructure to check oops in the oop class

Changes: https://git.openjdk.org/jdk/pull/13825/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13825&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8307521
  Stats: 26 lines in 2 files changed: 11 ins; 0 del; 15 mod
  Patch: https://git.openjdk.org/jdk/pull/13825.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13825/head:pull/13825

PR: https://git.openjdk.org/jdk/pull/13825


More information about the hotspot-dev mailing list