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.
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.