RFR: 8277417: C1 LIR instruction for load-klass

Martin Doerr mdoerr at openjdk.java.net
Fri Nov 19 17:34:44 UTC 2021


On Thu, 18 Nov 2021 20:16:27 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

> In C1, the load of a Klass* out of an object is currently identified by a load of type T_ADDRESS with offset oopDest::klass_offset_in_bytes(). When encountering such load, this may be decoded when +CompressedClassPointers. This is problematic and ugly: if we ever emit a T_ADDRESS load with offset 8 or 4 (== klass_offset_in_bytes) that is not a Klass*, we would attempt to decode the result. We have been lucky so far.
> 
> Also, in Lilliput, we want to do something entirely different there, and need to be able to emit more complex code, possibly including runtime call.
> 
> The change introduces a new C1 LIR opcode OpLoadKlass, and refactors the implementations in c1_LIRAssembler_xyz.cpp to emit the code there, instead of mem2reg(). Notice that I could not test anything but x86, all other platforms only received very basic testing via GHA. It would be nice if respective maintainers could give it a try.
> 
> Testing:
>  - [x] tier1 (x86_64)
>  - [x] tier2 (x86_64)
>  - [x] tier3 (x86_64)

Looks like a nice change. I only found one problem on Power.

src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp line 2737:

> 2735:   if (info != NULL) {
> 2736:     add_debug_info_for_null_check_here(info);
> 2737:   }

I think this is incorrect for AIX. Note that the first page is not read protected on that OS. To make it consistent with other places, I suggest:

diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
index a772e48f3be..23e03cb36e3 100644
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
@@ -2733,7 +2733,11 @@ void LIR_Assembler::emit_load_klass(LIR_OpLoadKlass* op) {
 
   CodeEmitInfo* info = op->info();
   if (info != NULL) {
-    add_debug_info_for_null_check_here(info);
+    if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
+      explicit_null_check(obj, info);
+    } else {
+      add_debug_info_for_null_check_here(info);
+    }
   }
 
   if (UseCompressedClassPointers) {

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

Changes requested by mdoerr (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6464


More information about the hotspot-dev mailing list