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

Don't force veneers on island emission #6902

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

alexcrichton
Copy link
Member

This commit is a follow-up to #6804 with the discussion on #6818. This undoes some of the changes from #6804, such as bringing a size parameter back to emit_island, and implements the changes discussed in #6818. Namely fixups are now tracked in a pending_fixups list for editing and modification and then during island emission they're flushed into a BinaryHeap tracked as fixup_records. Additionally calculation of the size of the pending island is now done as a single calculation rather than updating metadata as we go along. This is required because fixups are no longer entirely cleared during island emission so the previous logic of "reset the island size to zero" and have it get recalculated as the island is emitted is no longer applicable. I opted to go with a simplistic version of this for now which assumes that all veneers are the worst case size, but if necessary I think this could be more optimal by tracking each veneer in a counter.

Closes #6818

This commit is a follow-up to bytecodealliance#6804 with the discussion on bytecodealliance#6818. This
undoes some of the changes from bytecodealliance#6804, such as bringing a size parameter
back to `emit_island`, and implements the changes discussed in bytecodealliance#6818.
Namely fixups are now tracked in a `pending_fixups` list for editing and
modification and then during island emission they're flushed into a
`BinaryHeap` tracked as `fixup_records`. Additionally calculation of the
size of the pending island is now done as a single calculation rather
than updating metadata as we go along. This is required because fixups
are no longer entirely cleared during island emission so the previous
logic of "reset the island size to zero" and have it get recalculated as
the island is emitted is no longer applicable. I opted to go with a
simplistic version of this for now which assumes that all veneers are
the worst case size, but if necessary I think this could be more optimal
by tracking each veneer in a counter.

Closes bytecodealliance#6818
@alexcrichton alexcrichton requested a review from a team as a code owner August 24, 2023 16:45
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team August 24, 2023 16:45
@fitzgen fitzgen requested a review from cfallin August 24, 2023 18:09
@fitzgen
Copy link
Member

fitzgen commented Aug 24, 2023

Redirecting review to @cfallin since I'm not super familiar with these bits of code.

@fitzgen fitzgen removed their request for review August 24, 2023 18:10
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on!

The new version looks correct; I have some thoughts on performance below.

cranelift/codegen/src/machinst/buffer.rs Outdated Show resolved Hide resolved
cranelift/codegen/src/machinst/buffer.rs Show resolved Hide resolved
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen labels Aug 24, 2023
Update this as pending fixups are added and then clear this out when
islands are emitted.
Instead process them immediately if they're ready.
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

LGTM!

@cfallin cfallin added this pull request to the merge queue Aug 24, 2023
Merged via the queue into bytecodealliance:main with commit f8c03d5 Aug 25, 2023
@alexcrichton alexcrichton deleted the update-fixups branch August 25, 2023 14:12
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Sep 6, 2023
* Don't force veneers on island emission

This commit is a follow-up to bytecodealliance#6804 with the discussion on bytecodealliance#6818. This
undoes some of the changes from bytecodealliance#6804, such as bringing a size parameter
back to `emit_island`, and implements the changes discussed in bytecodealliance#6818.
Namely fixups are now tracked in a `pending_fixups` list for editing and
modification and then during island emission they're flushed into a
`BinaryHeap` tracked as `fixup_records`. Additionally calculation of the
size of the pending island is now done as a single calculation rather
than updating metadata as we go along. This is required because fixups
are no longer entirely cleared during island emission so the previous
logic of "reset the island size to zero" and have it get recalculated as
the island is emitted is no longer applicable. I opted to go with a
simplistic version of this for now which assumes that all veneers are
the worst case size, but if necessary I think this could be more optimal
by tracking each veneer in a counter.

Closes bytecodealliance#6818

* Keep a running count for pending fixup deadline

Update this as pending fixups are added and then clear this out when
islands are emitted.

* Don't force all fixups to go through a binary heap

Instead process them immediately if they're ready.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cranelift: should we do branch optimizations in MachBuffer?
3 participants