Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8277417: C1 LIR instruction for load-klass #6464

Closed
wants to merge 3 commits into from

Conversation

rkennke
Copy link
Contributor

@rkennke rkennke commented Nov 18, 2021

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:

  • tier1 (x86_64)
  • tier2 (x86_64)
  • tier3 (x86_64)

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6464/head:pull/6464
$ git checkout pull/6464

Update a local copy of the PR:
$ git checkout pull/6464
$ git pull https://git.openjdk.java.net/jdk pull/6464/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6464

View PR using the GUI difftool:
$ git pr show -t 6464

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6464.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 18, 2021

👋 Welcome back rkennke! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 18, 2021

@rkennke The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Nov 18, 2021
Copy link
Contributor

@veresov veresov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you!

@openjdk
Copy link

openjdk bot commented Nov 18, 2021

@rkennke This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8277417: C1 LIR instruction for load-klass

Reviewed-by: iveresov, mdoerr, ngasson, aph

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 76 new commits pushed to the master branch:

  • d427c79: 8277428: G1: Move and inline G1STWIsAliveClosure::do_object_b
  • 32839ba: 8266593: vmTestbase/nsk/jvmti/PopFrame/popframe011 fails with "assert(java_thread == _state->get_thread()) failed: Must be"
  • 8051041: 8277534: Remove unused ReferenceProcessor::has_discovered_references
  • 3f847fe: 8277385: Zero: Enable CompactStrings support
  • ca31ed5: 8275448: [REDO] AArch64: Implement string_compare intrinsic in SVE
  • 4ff4301: 8224922: Access JavaFileObject from Element(s)
  • 0a9e76c: 8277485: Zero: Fix fast{i,f}access_0 bytecodes handling
  • 1c215f3: 8272773: Configurable card table card size
  • 1d7cef3: 8276662: Scalability bottleneck in SymbolTable::lookup_common()
  • c79a485: 8277494: [BACKOUT] JDK-8276150 Quarantined jpackage apps are labeled as "damaged"
  • ... and 66 more: https://git.openjdk.java.net/jdk/compare/b0a463fa59a1c3c554f48267525729bf89a2c5be...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 18, 2021
@rkennke rkennke marked this pull request as ready for review November 19, 2021 14:37
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 19, 2021
@mlbridge
Copy link

mlbridge bot commented Nov 19, 2021

Webrevs

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

CodeEmitInfo* info = op->info();
if (info != NULL) {
add_debug_info_for_null_check_here(info);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I pushed a fix for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we have the info != NULL check twice, now. Otherwise, good.

Copy link
Contributor

@nick-arm nick-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested tier1 on 32-bit Arm and AArch64. 32-bit Arm had some failures but they don't seem to be related to this patch.

add_debug_info_for_null_check_here(info);
}

if (UseCompressedClassPointers) { // On 32 bit arm??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably leftover from when the "arm" port supported both 32- and 64-bit.

@@ -986,14 +986,7 @@ void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch
__ ldr(dest->as_register(), as_Address(from_addr));
break;
case T_ADDRESS:
// FIXME: OMG this is a horrible kludge. Any offset from an
// address that matches klass_offset_in_bytes() will be loaded
// as a word, not a long.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! I am so glad to see this horrible kludge removed.

Copy link
Contributor

@theRealAph theRealAph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, a very welcome fix. I wish I had done something like this at the time of the AArch64 port, but I was neither brave enough nor knew enough

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change! Please remove the duplicated info != NULL check before integrating.

CodeEmitInfo* info = op->info();
if (info != NULL) {
add_debug_info_for_null_check_here(info);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we have the info != NULL check twice, now. Otherwise, good.

@rkennke
Copy link
Contributor Author

rkennke commented Nov 26, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Nov 26, 2021

Going to push as commit 99e4bda.
Since your change was applied there have been 132 commits pushed to the master branch:

  • 00a6238: 8277508: need to check has_predicated_vectors before calling scalable_predicate_reg_slots
  • 3383c0d: 8277659: [TESTBUG] Microbenchmark ThreadOnSpinWaitProducerConsumer.java hangs
  • 7e54d06: 8277165: jdeps --multi-release --print-module-deps fails if module-info.class in different versioned directories
  • eb4d886: 8277504: Use String.stripTrailing instead of hand-crafted method in SwingUtilities2
  • 9879920: 8277825: Remove unused ReferenceProcessorPhaseTimes::_sub_phases_total_time_ms
  • f788834: 8277786: G1: Rename log2_card_region_per_heap_region used in G1CardSet
  • 3034ae8: 8277631: ZGC: CriticalMetaspaceAllocation asserts
  • f0136ec: 8275687: runtime/CommandLine/PrintTouchedMethods test shouldn't catch RuntimeException
  • 21e302a: 8270435: UT: MonitorUsedDeflationThresholdTest failed: did not find too_many string in output
  • a81e4fc: 8258117: jar tool sets the time stamp of module-info.class entries to the current time
  • ... and 122 more: https://git.openjdk.java.net/jdk/compare/b0a463fa59a1c3c554f48267525729bf89a2c5be...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 26, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 26, 2021
@openjdk
Copy link

openjdk bot commented Nov 26, 2021

@rkennke Pushed as commit 99e4bda.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
5 participants