-
Notifications
You must be signed in to change notification settings - Fork 143
8375719: [lworld] Move reads of flat fields entirely to the runtime #1936
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
base: lworld
Are you sure you want to change the base?
8375719: [lworld] Move reads of flat fields entirely to the runtime #1936
Conversation
|
👋 Welcome back jsikstro! A progress list of the required criteria for merging this PR into |
|
@jsikstro 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: 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 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@coleenp, @Arraying) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
coleenp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a small request, but otherwise this looks great. Thank you for doing this!
|
|
||
| // If the field is nullable and is marked null, return early. | ||
| if (LayoutKindHelper::is_nullable_flat(lk) && | ||
| field_klass->is_payload_marked_as_null(cast_from_oop<address>(obj) + offset)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a way to ask this and have the address calculation be hidden in InstanceKlass, like find_field_from_offset ? So we don't have to know here if the offset includes the header or not? Or even just add a is_payload_marked_as_null(oop, offset) to hide the calculation inside of inlineKlass.inline.hpp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on trying to create something for representing an InlineKlass payload in the runtime code. It achives exactly this. Current work in progress: 5df3317
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I suggest we can hold off on this until Axel's patch is ready. I see he also takes care of similar casts + offsets in InlineKlass.cpp which is nice.
valhalla/src/hotspot/share/oops/inlineKlass.cpp
Lines 238 to 247 in a4fb7eb
| if (is_payload_marked_as_null(cast_from_oop<address>(src) + offset)) { | |
| return nullptr; | |
| } | |
| } // Fallthrough | |
| case LayoutKind::BUFFERED: | |
| case LayoutKind::NULL_FREE_ATOMIC_FLAT: | |
| case LayoutKind::NULL_FREE_NON_ATOMIC_FLAT: { | |
| Handle obj_h(THREAD, src); | |
| oop res = allocate_instance(CHECK_NULL); | |
| copy_payload_to_addr((void*)(cast_from_oop<address>(obj_h()) + offset), payload_addr(res), lk, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it this should wait for Axel's patch, which I imagine is more extensive. I think you could push this first.
Arraying
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one quick question.
| bind(failed_alloc); | ||
| pop(obj); | ||
| bind(slow_path); | ||
| call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_flat_field), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your writeup you mention call_VM_leaf is called, but I only see references to call_VM in the code yet the comments say call_VM_leaf. Do we/did we call_VM_leaf at any point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to call_VM_leaf is in the copy-path:
MacroAssembler::flat_field_copy
BarrierSetAssembler::flat_field_copy
call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy), ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thank you for clarifying.
|
I removed the Handle from |
| load_unsigned_short(tmp2, Address(entry, in_bytes(ResolvedFieldEntry::field_index_offset()))); | ||
|
|
||
| movptr(tmp1, Address(entry, ResolvedFieldEntry::field_holder_offset())); | ||
| get_inline_type_field_klass(tmp1, tmp2, field_klass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the last place where get_inline_type_field_klass() was used, so this method can be removed from the MacroAssembler class.
Note that get_inline_type_field_klass() was not used in the aarch64 implementation of read_flat_field(), but the get_inline_type_field_klass() method still exists in the aarch64 MacroAssembler. This dead code could be removed too.
Hello,
Today much of the reading of flattened values in the interpreter is implemented both in the platform-specific templateTable_XX.cpp files, and also in the runtime via InterpreterRuntime::read_flat_field. The reason we have both is becuase the interpreterlet implements a fast-path for null-free types, which attempts to allocate the buffered object inside the thread's TLAB, before moving on to copy the src payload to the buffered objected. The copying is done in the VM via a call_VM_leaf call, which notably does not safepoint-poll (nor allow anything that might GC for example).
The slow-path in the interpreterlet calls into the VM via a call_VM, which notably safepoint-point polls upon exit. The slow-path is taken when 1) the src payload is nullable or 2) the fast-path TLAB allocation fails.
I propose we redesign the dance around when and how to enter the VM by having the logic of reading a flat field exclusively inside the runtime and thus always entering the VM. This approach allows us to have one canonical way to read flat fields, without having effectively duplicate code in interpreterlets (for all supported platforms) and inside the runtime. A benefit from this is that it becomes easier for porters to port the Valhalla changes to their platform(s) and later on maintain that port, which is a plus.
Since all objects are NULLABLE in JEP 401 (disregarding F&F interface), all reads of flat fields are already entering the VM via the "slow-path". This means that this change only has a practical effect on null-free/null-restricted fields. I think we should consider if having a fast-path is worth it or not when that time comes, although I anticipate that it doesn't make much difference since the copy is always done in the VM anyway.
As a small optimization, I've added a check for nullable and marked-as-null before entering the VM.
Testing:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1936/head:pull/1936$ git checkout pull/1936Update a local copy of the PR:
$ git checkout pull/1936$ git pull https://git.openjdk.org/valhalla.git pull/1936/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1936View PR using the GUI difftool:
$ git pr show -t 1936Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1936.diff
Using Webrev
Link to Webrev Comment