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

cranelift: Remove next_fixed_nonallocatable and with_allocs methods #8566

Merged

Conversation

jameysharp
Copy link
Contributor

The next_fixed_nonallocatable method doesn't do anything any more and doesn't return anything so calls to it can just be deleted.

The with_allocs, allocate, and to_string_with_alloc methods are all trivial at this point, so inline them. The bulk of this change was performed this way:

git grep -lF '.with_allocs(' | xargs sed -i 's/\.with_allocs([^)]*)/.clone()/g'

In a couple cases, this makes the AllocationConsumer unused at these methods' call sites. Rather than changing function signatures in this PR, just mark those arguments as deliberately unused.

The number of structures being cloned here is unfortunate, and unnecessary now that we don't need to mutate any of them. But switching to borrowing them is a bigger change than I want to include here.

The `next_fixed_nonallocatable` method doesn't do anything any more and
doesn't return anything so calls to it can just be deleted.

The `with_allocs`, `allocate`, and `to_string_with_alloc` methods are
all trivial at this point, so inline them. The bulk of this change was
performed this way:

git grep -lF '.with_allocs(' | xargs sed -i 's/\.with_allocs([^)]*)/.clone()/g'

In a couple cases, this makes the `AllocationConsumer` unused at these
methods' call sites. Rather than changing function signatures in this
PR, just mark those arguments as deliberately unused.

The number of structures being cloned here is unfortunate, and
unnecessary now that we don't need to mutate any of them. But switching
to borrowing them is a bigger change than I want to include here.
@jameysharp jameysharp requested a review from a team as a code owner May 7, 2024 08:30
@jameysharp jameysharp requested review from cfallin and removed request for a team May 7, 2024 08:30
@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 May 7, 2024
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, thanks!

Re: cloning, I agree that taking borrows instead is the next step, but (as I'm sure you've thought through but stating for the record here) the original .with_allocs() also returned a copy so this shouldn't be a regression at least. I'm very much in favor of the incremental approach here :-)

@jameysharp jameysharp added this pull request to the merge queue May 7, 2024
Merged via the queue into bytecodealliance:main with commit d449755 May 7, 2024
27 checks passed
@jameysharp jameysharp deleted the remove-trivial-methods branch May 7, 2024 17:42
jameysharp added a commit to jameysharp/wasmtime that referenced this pull request May 13, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 13, 2024
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.

2 participants