Skip to content

Initial support for inline types#1

Open
MichaelHaas99 wants to merge 27 commits intolworldfrom
mh/GR-57655
Open

Initial support for inline types#1
MichaelHaas99 wants to merge 27 commits intolworldfrom
mh/GR-57655

Conversation

@MichaelHaas99
Copy link
Copy Markdown
Owner

No description provided.

klass = *((Klass**) (intptr_t) (base_address + offset));
intptr_t temp = (intptr_t) *((Klass**) (intptr_t) (base_address + offset));
// clear the bits used for acmp data profiling
clear_bits(temp, 0b011);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use a constant for the bitmask please with proper doc

@MichaelHaas99 MichaelHaas99 force-pushed the mh/GR-57655 branch 2 times, most recently from 5dbf959 to 543708d Compare November 11, 2024 07:28
MichaelHaas99 pushed a commit that referenced this pull request Nov 13, 2024
MichaelHaas99 pushed a commit that referenced this pull request Nov 13, 2024
Copy link
Copy Markdown
Collaborator

@dougxc dougxc left a comment

Choose a reason for hiding this comment

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

I left a first round of comments and think they should be addressed before more reviewing. A more general comment is that new JVMCI tests should be added for as much as possible of the new JVMCI code.


call = nativeCall_at(_instructions->start() + pc_offset);
call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
if(method()->has_scalarized_args()) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Space between if and (. Same everywhere else.

if(method()->has_scalarized_args()) {
_instructions->relocate(call->instruction_address(),
virtual_call_Relocation::spec(_invoke_mark_pc),
virtual_call_Relocation::spec(_invoke_mark_pc, _oop_recorder->find_index(method())),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please find all the places in the aarch64 code that will need similar changes and try stub it out or at least put a TBD comment.

// If inline types are passed as fields, use the extended signature
// which contains the types of all (oop) fields of the inline type.
if (is_compiled_by_c2() && callee->has_scalarized_args()) {
if ((is_compiled_by_c2() || is_compiled_by_jvmci()) && callee->has_scalarized_args()) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe it's worth adding a nmethod::can_scalarize_args abstraction?

return method()->c1_needs_stack_repair();
} else if (is_compiled_by_c2()) {
} else if (is_compiled_by_c2() || is_compiled_by_jvmci()) {
return method()->c2_needs_stack_repair();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rename c2_needs_stack_repair to c2_or_jvmci_needs_stack_repair. This will hopefully prompt a follow-on discussion with the Valhalla team about a better name.

Copy link
Copy Markdown
Owner Author

@MichaelHaas99 MichaelHaas99 Mar 4, 2025

Choose a reason for hiding this comment

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

Probably change that if we are sure that Graal should also rely on the calling convention.

Bytecodes::Code byte, bool check_null_and_abstract, TRAPS);
Bytecodes::Code byte, bool check_null_or_abstract, TRAPS);

static void resolve_invoke_jvmci(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, bool check_null_or_abstract, TRAPS);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Dead code? Doesn't seem to be implemented.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yes forgot to delete it.

@Override
ResolvedJavaType getArrayClass();

default ResolvedJavaType getFlatArrayClass() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Every method in jdk.vm.ci.meta needs javadoc.

}

/**
* Checks whether this type has an identity.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does "identity" mean here? Where ever possible, cross reference core reflection classes and methods (e.g. Class.isIdentity()) that explain these concepts. The more JVMCI can lean on core Java documentation, the easier it will be to understand (and the better the chance of it staying consistent).

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Okay

@@ -0,0 +1,19 @@
package jdk.vm.ci.hotspot;

public interface SingleTypeEntry{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

javadoc for the class and all methods please

/**
* Gets the registers to be used for returning multiple values e.g. used for a scalarized inline object.
*/
default Register[] getReturnRegisters(JavaKind[] kinds, boolean includeRax) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rax cannot be mentioned here - it's x64 specific.

Copy link
Copy Markdown
Owner Author

@MichaelHaas99 MichaelHaas99 Mar 4, 2025

Choose a reason for hiding this comment

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

True, actually the bool is used to decide whether the first general return register should be included or not

Register getReturnRegister(JavaKind kind);

/**
* Gets the registers to be used for returning multiple values e.g. used for a scalarized inline object.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Needs more precise specification. How does kinds relate to the returned value? Are they the same length even when longs and doubles are involved? Providing an example can help.

Copy link
Copy Markdown
Owner Author

@MichaelHaas99 MichaelHaas99 Mar 4, 2025

Choose a reason for hiding this comment

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

Only needed to decide if the value is put into a regular or xmm register, I will add a comment. But it is just the same as with getReturnRegister just using multiple kinds.

*/
package jdk.vm.ci.meta;

import jdk.vm.ci.hotspot.HotSpotSignature;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cannot reference HotSpot specific types in VM agnostic parts of the API.

Copy link
Copy Markdown
Owner Author

@MichaelHaas99 MichaelHaas99 Mar 4, 2025

Choose a reason for hiding this comment

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

Ah yes the function that uses it can be deleted anyway (was never used actually).

Copy link
Copy Markdown
Collaborator

@dougxc dougxc left a comment

Choose a reason for hiding this comment

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

Are all the test changes ready for review by the Valhalla team?

* @param index the index of a formal parameter in the signature
* @return the instance fields as types including the is not null type
*/
default JavaType[] getScalarizedParameter(int index) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should List instead of arrays for new method, especially now that there are convenient ways to create immutable lists with the List.of(...) static methods.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Sounds reasonable


final Scenario[] scenarios = {
new Scenario(0,
/*new Scenario(0,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Commented out code will have to be removed or uncommented before merging.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

yes

@dougxc
Copy link
Copy Markdown
Collaborator

dougxc commented Jun 23, 2025

Please open a new version of this PR (in draft state) that targets https://github.com/openjdk/valhalla/tree/lworld instead of https://github.com/MichaelHaas99/valhalla/tree/lworld. The PR description should describe what state the changes are in and what needs to be done before it's ready for taking out of draft state.

@MichaelHaas99 MichaelHaas99 force-pushed the mh/GR-57655 branch 2 times, most recently from fc4d873 to d1331cc Compare September 26, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants