Skip to content

Conversation

@jayphelps
Copy link
Contributor

fixes #1645.

I included a changelog file per request.

std::cout << " {\n";
std::cout << " BinaryenFunctionRef funcs[] = { ";
for (BinaryenIndex i = 0; i < numFuncs; i++) {
std::cout << " const char* funcNames[] = { ";
Copy link
Contributor Author

@jayphelps jayphelps Aug 28, 2018

Choose a reason for hiding this comment

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

btw char* funcNames vs char *funcNames pointer placement isn't consistent in the codebase but I tried to be consistent with other similar contexts. Happy to follow any pattern.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we should be more consistent. I think we prefer char* funcNames (keep the type all together).

@jayphelps jayphelps force-pushed the fun-table branch 3 times, most recently from 3c9e841 to b1b0180 Compare August 28, 2018 23:47
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.

Thanks! Overall looks very good.

I think we also need to update src/js/binaryen.js-post.js for the JS API.

CHANGELOG.md Outdated

### BREAKING CHANGES

- `BinaryenSetFunctionTable` no longer accepts an array of functions, instead it accepts an array of function names, `const char **funcNames`. Previously, you could not include imported functions because they are of type `BinaryenImportRef` instead of `BinaryenFunctionRef`. [#1650](https://github.com/WebAssembly/binaryen/pull/1650)
Copy link
Member

Choose a reason for hiding this comment

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

please mention that this is in the C API

std::cout << " {\n";
std::cout << " BinaryenFunctionRef funcs[] = { ";
for (BinaryenIndex i = 0; i < numFuncs; i++) {
std::cout << " const char* funcNames[] = { ";
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we should be more consistent. I think we prefer char* funcNames (keep the type all together).

return Module['_BinaryenSetFunctionTable'](
module,
i32sToStack(
funcNames.map(function(funcName) {
Copy link
Member

Choose a reason for hiding this comment

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

can use strToStack here (see examples above in the same file)

@kripken
Copy link
Member

kripken commented Aug 30, 2018

Looks like the test failure is in the JS API code - the kitchen sink test fails on [wasm-validator error in module] unexpected false: segment name should be valid, so perhaps the name isn't being passed through properly.

@jayphelps jayphelps force-pushed the fun-table branch 2 times, most recently from 97c1e3f to 4a6a2f7 Compare August 31, 2018 01:02
@jayphelps
Copy link
Contributor Author

Updated. I had needed to rebuild the js files. 4a6a2f7 feel free to squash after review.

};

// Obtains name for a 'Function'
Module['getFunctionName'] = function(func) {
Copy link
Member

Choose a reason for hiding this comment

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

why was this added? I think the getXInfo functions are enough, you can get the name that way - otherwise we'd have a great many such small functions to add.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added for parity with the other kitchen sink demo but also cause the general info call defers to a number of other calls and I figured you’d recommend exposing this one lol. No problem! Changing 🤙

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@kripken
Copy link
Member

kripken commented Sep 1, 2018

Great, thanks!

Btw, I'm not opposed to adding new functions like that - just I was surprised it was here, I thought I'd missed something. Can discuss that in a separate issue if you want.

@kripken kripken merged commit 9750c18 into WebAssembly:master Sep 1, 2018
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.

BinaryenSetFunctionTable cannot (safely) accept imported functions

2 participants