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

winch: Drop FuncEnv trait #6443

Merged

Conversation

saulecabrera
Copy link
Member

This commit is a small cleanup to drop the usage of the FuncEnv trait.

In #6358, we agreed on making winch-codegen directly depend on wasmtime-environ.

Introducing a direct relatioship between winch-codegen and wasmtime-environ means that the FuncEnv trait is no longer serving its original purpose, and we can drop the usage of the trait and use the types exposed from winch-codegen directly instead.

Even though this change drops the FuncEnv trait, it still keeps a FuncEnv struct, which is used during code generation.

@saulecabrera saulecabrera requested a review from alexcrichton May 24, 2023 13:38
@saulecabrera saulecabrera requested review from a team as code owners May 24, 2023 13:38
@saulecabrera saulecabrera requested review from elliottt and removed request for a team and elliottt May 24, 2023 13:38
@github-actions github-actions bot added the winch Winch issues or pull requests label May 24, 2023
@github-actions
Copy link

Subscribe to Label Action

cc @saulecabrera

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

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

  • saulecabrera: winch

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

Learn more.

@saulecabrera saulecabrera force-pushed the winch-drop-func-env branch from 5c5f0db to 50b1048 Compare May 24, 2023 13:52
Comment on lines 23 to +25
M: MacroAssembler,
A: ABI,
P: PtrSize,
Copy link
Member

Choose a reason for hiding this comment

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

I'm not all that familiar with the design of these generics, but I would naively expect that a choice of either MacroAssembler or ABI would imply PtrSize. If that's the case would it perhaps be possible to have P be an associated type of either prior trait?

Or would it, for example, make sense to put both ABI and PtrSize inside of the MacroAssembler trait as an associated type?

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. Taking a closer look, I'm leaning towards having the PtrSize as an associated type inside the ABI trait, which already provides similar information (e.g. word_bytes).

Copy link
Member Author

Choose a reason for hiding this comment

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

Upon a second look, having both of these as associated types in the MacroAssembler makes more sense I think, and it's going to result in quite a decent cut in boilerplate. I started working on the change, but I'm anticipating that it's going to be a decent amount of changes unrelated to this PR, so I think I prefer landing this and putting the refactor once this lands.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's also in my todo to standardize the signatures in the ABI trait (e.g. there's no reason to have them borrow &self), so I'm thinking I'll bundle those improvements in the refactoring too.

@saulecabrera saulecabrera added this pull request to the merge queue May 24, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 24, 2023
This commit is a small cleanup to drop the usage of the `FuncEnv` trait.

In bytecodealliance#6358, we agreed on
making `winch-codegen` directly depend on `wasmtime-environ`.

Introducing a direct relatioship between `winch-codegen` and
`wasmtime-environ` means that the `FuncEnv` trait is no longer serving
its original purpose, and we can drop the usage of the trait and use the
types exposed from `winch-codegen` directly instead.

Even though this change drops the `FuncEnv` trait, it still keeps
a `FuncEnv` struct, which is used during code generation.
@saulecabrera saulecabrera force-pushed the winch-drop-func-env branch from 50b1048 to 85de546 Compare May 24, 2023 17:08
@saulecabrera saulecabrera added this pull request to the merge queue May 24, 2023
Merged via the queue into bytecodealliance:main with commit afde47c May 24, 2023
@saulecabrera saulecabrera deleted the winch-drop-func-env branch May 24, 2023 18:16
saulecabrera added a commit to saulecabrera/wasmtime that referenced this pull request May 24, 2023
This commit is a follow up to bytecodealliance#6443,
in which we discussed potentially having `PtrSize` and `ABI` as
associated types to the `MacroAssembler` trait.

I considered having `PtrSize` associated to the `ABI`, but given the
amount of ABI details needed at the `MacroAssembler` level, I decided to
go with the approach in this change.

The chosen approach ended up cutting a decent amount of boilerplate from
the `MacroAssembler` itself, but also from each of the touchpoints where
the `MacroAssembler` is used.

This change also standardizes the signatures of the `ABI` trait. Some of
them borrowed `&self` and some didn't, but in practice, there's no need
to have any of them borrow `&self`.
saulecabrera added a commit to saulecabrera/wasmtime that referenced this pull request May 24, 2023
This commit is a follow up to bytecodealliance#6443,
in which we discussed potentially having `PtrSize` and `ABI` as
associated types to the `MacroAssembler` trait.

I considered having `PtrSize` associated to the `ABI`, but given the
amount of ABI details needed at the `MacroAssembler` level, I decided to
go with the approach in this change.

The chosen approach ended up cutting a decent amount of boilerplate from
the `MacroAssembler` itself, but also from each of the touchpoints where
the `MacroAssembler` is used.

This change also standardizes the signatures of the `ABI` trait. Some of
them borrowed `&self` and some didn't, but in practice, there's no need
to have any of them borrow `&self`.
saulecabrera added a commit to saulecabrera/wasmtime that referenced this pull request May 24, 2023
This commit is a follow up to bytecodealliance#6443,
in which we discussed potentially having `PtrSize` and `ABI` as
associated types to the `MacroAssembler` trait.

I considered having `PtrSize` associated to the `ABI`, but given the
amount of ABI details needed at the `MacroAssembler` level, I decided to
go with the approach in this change.

The chosen approach ended up cutting a decent amount of boilerplate from
the `MacroAssembler` itself, but also from each of the touchpoints where
the `MacroAssembler` is used.

This change also standardizes the signatures of the `ABI` trait. Some of
them borrowed `&self` and some didn't, but in practice, there's no need
to have any of them borrow `&self`.
saulecabrera added a commit to saulecabrera/wasmtime that referenced this pull request May 24, 2023
This commit is a follow up to bytecodealliance#6443,
in which we discussed potentially having `PtrSize` and `ABI` as
associated types to the `MacroAssembler` trait.

I considered having `PtrSize` associated to the `ABI`, but given the
amount of ABI details needed at the `MacroAssembler` level, I decided to
go with the approach in this change.

The chosen approach ended up cutting a decent amount of boilerplate from
the `MacroAssembler` itself, but also from each of the touchpoints where
the `MacroAssembler` is used.

This change also standardizes the signatures of the `ABI` trait. Some of
them borrowed `&self` and some didn't, but in practice, there's no need
to have any of them borrow `&self`.
saulecabrera added a commit that referenced this pull request May 25, 2023
This commit is a follow up to #6443,
in which we discussed potentially having `PtrSize` and `ABI` as
associated types to the `MacroAssembler` trait.

I considered having `PtrSize` associated to the `ABI`, but given the
amount of ABI details needed at the `MacroAssembler` level, I decided to
go with the approach in this change.

The chosen approach ended up cutting a decent amount of boilerplate from
the `MacroAssembler` itself, but also from each of the touchpoints where
the `MacroAssembler` is used.

This change also standardizes the signatures of the `ABI` trait. Some of
them borrowed `&self` and some didn't, but in practice, there's no need
to have any of them borrow `&self`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
winch Winch issues or pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants