Skip to content

Commit 4a6a2f7

Browse files
committed
use strToStack for js setFunctionTable and update wasm.js et al
1 parent 410b556 commit 4a6a2f7

File tree

6 files changed

+35
-32
lines changed

6 files changed

+35
-32
lines changed

bin/wasm.js

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/binaryen.js-post.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,15 +1131,9 @@ Module['Module'] = function(module) {
11311131
};
11321132
this['setFunctionTable'] = function(funcNames) {
11331133
return preserveStack(function() {
1134-
return Module['_BinaryenSetFunctionTable'](
1135-
module,
1136-
i32sToStack(
1137-
funcNames.map(function(funcName) {
1138-
return allocate(funcName, 'i8', ALLOC_STACK);
1139-
})
1140-
),
1141-
funcNames.length
1142-
);
1134+
return Module['_BinaryenSetFunctionTable'](module, i32sToStack(
1135+
funcNames.map(strToStack)
1136+
), funcNames.length);
11431137
});
11441138
};
11451139
this['setMemory'] = function(initial, maximum, exportName, segments) {
@@ -1532,6 +1526,11 @@ Module['getFunctionInfo'] = function(func) {
15321526
};
15331527
};
15341528

1529+
// Obtains name for a 'Function'
1530+
Module['getFunctionName'] = function(func) {
1531+
return Pointer_stringify(Module['_BinaryenFunctionGetName'](func));
1532+
};
1533+
15351534
// Obtains information about an 'Import'
15361535
Module['getImportInfo'] = function(import_) {
15371536
return {

test/binaryen.js/emit_asmjs.js.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ function asmFunc(global, env, buffer) {
3131
};
3232
}
3333

34+
const memasmFunc = new ArrayBuffer(65536);
35+
const retasmFunc = asmFunc({Math,Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,NaN,Infinity}, {abort:function() { throw new Error('abort'); }},memasmFunc);
36+

test/binaryen.js/kitchen-sink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ function test_core() {
250250

251251
// Function table. One per module
252252

253-
module.setFunctionTable([ Binaryen.getFunctionInfo(sinker).name ]);
253+
module.setFunctionTable([ Binaryen.getFunctionName(sinker) ]);
254254

255255
// Memory. One per module
256256

test/binaryen.js/kitchen-sink.js.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,10 @@ getExpressionInfo(f64.const)={"id":15,"type":4,"value":9.5}
14561456
}
14571457
imports[0] = BinaryenAddFunctionImport(the_module, "an-imported", "module", "base", functionTypes[1]);
14581458
exports[0] = BinaryenAddFunctionExport(the_module, "kitchen()sinker", "kitchen_sinker");
1459+
BinaryenFunctionGetName(functions[0]);
14591460
{
1460-
BinaryenFunctionRef funcs[] = { functions[0] };
1461-
BinaryenSetFunctionTable(the_module, funcs, 1);
1461+
const char* funcNames[] = { "kitchen()sinker" };
1462+
BinaryenSetFunctionTable(the_module, funcNames, 1);
14621463
}
14631464
expressions[256] = BinaryenConst(the_module, BinaryenLiteralInt32(10));
14641465
{

test/example/c-api-kitchen-sink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void test_core() {
253253
BinaryenAddFunctionExport(module, "kitchen()sinker", "kitchen_sinker");
254254

255255
// Function table. One per module
256-
const char** funcNames[] = { BinaryenFunctionGetName(sinker) };
256+
const char* funcNames[] = { BinaryenFunctionGetName(sinker) };
257257
BinaryenSetFunctionTable(module, funcNames, 1);
258258

259259
// Memory. One per module

0 commit comments

Comments
 (0)