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

Pulley: Add memory access instructions with 64-bit offsets #9085

Merged

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Aug 7, 2024

I had trimmed these instructions from the original upstreaming of the Pulley interpreter because I had mistakenly believed that they were unused. Turns out they are needed for Cranelift's Pulley backend to allow for lowering certain address modes to a single instruction. The alternative, lowering the address modes to a sequence of instructions, would be a bit annoying and these instructions seem generally useful.

@fitzgen fitzgen requested a review from a team as a code owner August 7, 2024 19:13
@fitzgen fitzgen requested review from alexcrichton and removed request for a team August 7, 2024 19:13
@fitzgen fitzgen force-pushed the pulley-memory-access-big-offset branch from 59958c6 to 06fdfb1 Compare August 7, 2024 19:27
@github-actions github-actions bot added the pulley Issues related to the Pulley interpreter label Aug 7, 2024
Copy link

github-actions bot commented Aug 7, 2024

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "pulley"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: pulley

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Comment on lines 954 to 895
fn load32_u_offset64(&mut self, dst: XReg, ptr: XReg, offset: i64) -> Self::Return {
let val = unsafe {
self.state
.x(ptr)
.get_ptr::<u32>()
.byte_offset(offset as isize)
.read_unaligned()
};
self.state.x_mut(dst).set_u64(u64::from(val));
Continuation::Continue
}
Copy link
Member

Choose a reason for hiding this comment

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

Would it perhaps make sense to add a generlized helper load32_u_offset which takes offset: usize which no-offset/offset8/offset64 all call? (and would presumably get inlined and not actually matter at runtime)

Copy link
Member Author

Choose a reason for hiding this comment

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

Mayyybe. Right now some of the offset-to-isize conversions are .into() and some are as isize which is a small hiccup, but probably inconsequential. All said, I think I'd prefer to just leave it as-is for now and see what the future brings.

@fitzgen fitzgen added this pull request to the merge queue Aug 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 9, 2024
I had trimmed these instructions from the original upstreaming of the Pulley
interpreter because I had mistakenly believed that they were unused. Turns out
they are needed for Cranelift's Pulley backend to allow for lowering certain
address modes to a single instruction. The alternative, lowering the address
modes to a sequence of instructions, would be a bit annoying and these
instructions seem generally useful.
@fitzgen fitzgen force-pushed the pulley-memory-access-big-offset branch from 06fdfb1 to ef3fab2 Compare August 14, 2024 17:37
@fitzgen fitzgen enabled auto-merge August 14, 2024 17:37
@fitzgen fitzgen added this pull request to the merge queue Aug 14, 2024
Merged via the queue into bytecodealliance:main with commit 6008577 Aug 14, 2024
33 checks passed
@fitzgen fitzgen deleted the pulley-memory-access-big-offset branch August 14, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pulley Issues related to the Pulley interpreter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants