Skip to content

Multi-Memories improvements to binaryen-c.cpp #4940

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 3 commits into from
Aug 19, 2022
Merged

Multi-Memories improvements to binaryen-c.cpp #4940

merged 3 commits into from
Aug 19, 2022

Conversation

ashleynh
Copy link
Collaborator

@ashleynh ashleynh commented Aug 19, 2022

Resolving a couple of issues from the multi-memories PR landing:

Note: CI will not pass until #4939 lands.

Copy link
Member

@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.

LGTM with getMemoryName simplified.

static Name getMemoryName(BinaryenModuleRef module, const char* memName) {
const char* memoryName = memName;
if (memName == nullptr && module->memories.size() == 1) {
memoryName = module->memories[0]->name.c_str();
Copy link
Member

Choose a reason for hiding this comment

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

We can save some unnecessary conversions between char* and Name here.

Suggested change
memoryName = module->memories[0]->name.c_str();
return module->memories[0]->name;

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

lgtm % comment

Comment on lines 1076 to 1078
static Name getMemoryName(BinaryenModuleRef module, const char* memName) {
const char* memoryName = memName;
if (memName == nullptr && module->memories.size() == 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static Name getMemoryName(BinaryenModuleRef module, const char* memName) {
const char* memoryName = memName;
if (memName == nullptr && module->memories.size() == 1) {
static Name getMemoryName(BinaryenModuleRef module, const char* memoryName) {
if (memoryName == nullptr && module->memories.size() == 1) {

The parameter can be reused.

@ashleynh ashleynh merged commit f128ac4 into main Aug 19, 2022
@ashleynh ashleynh deleted the memName branch August 19, 2022 21:21
@MaxGraey
Copy link
Contributor

I tried Binaryen with this API update. Unfortunately if you set 0 (nullptr) for memoryName for BinaryenLoad / BinaryenStore then Binaryen crashes with assert error here:
https://github.com/WebAssembly/binaryen/blob/main/src/emscripten-optimizer/istring.h#L65

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.

Add helper func for case of a single memory to binaryen-c Use memName as parameter label instead of name
4 participants