Skip to content

[custom-descriptors] Update struct.new parsing and validation #7643

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

Merged
merged 14 commits into from
Jun 10, 2025

Conversation

tlively
Copy link
Member

@tlively tlively commented Jun 6, 2025

When allocating structs that have custom descriptors, struct.new and
struct.new_default must take an additional operand for the descriptor.

When allocating structs that have custom descriptors, struct.new and
struct.new_default must take an additional operand for the descriptor.
@tlively tlively requested a review from kripken June 6, 2025 22:53
src/wasm.h Outdated

bool isWithDefault() {
return hasDescriptor() ? (operands.size() == 1) : operands.empty();
}
Copy link
Member

Choose a reason for hiding this comment

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

The comment on line 1670 should be updated?

But, perhaps another option is to add a designated field for this?

Expression* descriptor = nullptr;

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, adding an optional designated field probably makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

Following offline discussion I'll work towards that in this branch.

Copy link
Member

Choose a reason for hiding this comment

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

@tlively done, ptal

Copy link
Member Author

@tlively tlively left a comment

Choose a reason for hiding this comment

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

Great, LGTM % comment. Thanks for taking this over. (GH won't let me hit the approve button because it's my PR originally.)

curr.operands.resize(type.getStruct().fields.size());
CHECK_ERR(visitStructNew(&curr));
push(builder.makeStructNew(type, std::move(curr.operands)));
CHECK_ERR(ChildPopper{*this}.visitStructNew(&curr));
Copy link
Member Author

Choose a reason for hiding this comment

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

Since the ChildPopper visitor doesn't take any additional arguments, this can remain simply visitStructNew here and below.

@tlively tlively merged commit 2b989ae into main Jun 10, 2025
16 checks passed
@tlively tlively deleted the struct-new-desc branch June 10, 2025 06:59
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.

2 participants