-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Create memory in wasm by default #12790
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,6 +204,25 @@ WebAssembly.instantiate(Module['wasm'], imports).then(function(output) { | |
/*** ASM_MODULE_EXPORTS ***/ | ||
#endif | ||
wasmTable = asm['__indirect_function_table']; | ||
#if ASSERTIONS | ||
assert(wasmTable); | ||
#endif | ||
|
||
#if !IMPORTED_MEMORY | ||
wasmMemory = asm['memory']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that users cannot implement a function named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do agree in general, and there as been discussion about this in upstream llvm in the past. The problem is that the name of the memory import/export is determined my wasm-ld. We have the BTW, this doesn't effect all users who have functions called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is indeed true.. still feels a bit sloppy I must admit, would be nice to be strict about namespacing :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also not that with the current situation we already reserve the name We should attempt to re-name |
||
#if ASSERTIONS | ||
assert(wasmMemory); | ||
assert(wasmMemory.buffer.byteLength === {{{ INITIAL_MEMORY }}}); | ||
#endif | ||
updateGlobalBufferAndViews(wasmMemory.buffer); | ||
#endif | ||
|
||
#if MEM_INIT_METHOD == 1 && !MEM_INIT_IN_WASM && !SINGLE_FILE | ||
#if ASSERTIONS | ||
if (!Module['mem']) throw 'Must load memory initializer as an ArrayBuffer in to variable Module.mem before adding compiled output .js script to the DOM'; | ||
#endif | ||
HEAPU8.set(new Uint8Array(Module['mem']), {{{ GLOBAL_BASE }}}); | ||
#endif | ||
|
||
initRuntime(asm); | ||
#if USE_PTHREADS && PTHREAD_POOL_SIZE | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 563, | ||
"a.html.gz": 377, | ||
"a.js": 4957, | ||
"a.js.gz": 2373, | ||
"a.wasm": 10893, | ||
"a.wasm.gz": 6923, | ||
"total": 16413, | ||
"total_gz": 9673 | ||
"a.js": 4927, | ||
"a.js.gz": 2352, | ||
"a.wasm": 10895, | ||
"a.wasm.gz": 6927, | ||
"total": 16385, | ||
"total_gz": 9656 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 588, | ||
"a.html.gz": 386, | ||
"a.js": 21297, | ||
"a.js.gz": 8263, | ||
"a.js": 21317, | ||
"a.js.gz": 8276, | ||
"a.mem": 3171, | ||
"a.mem.gz": 2715, | ||
"total": 25056, | ||
"total_gz": 11364 | ||
"total": 25076, | ||
"total_gz": 11377 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 563, | ||
"a.html.gz": 377, | ||
"a.js": 4444, | ||
"a.js.gz": 2199, | ||
"a.wasm": 10893, | ||
"a.wasm.gz": 6923, | ||
"total": 15900, | ||
"total_gz": 9499 | ||
"a.js": 4410, | ||
"a.js.gz": 2172, | ||
"a.wasm": 10895, | ||
"a.wasm.gz": 6927, | ||
"total": 15868, | ||
"total_gz": 9476 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 588, | ||
"a.html.gz": 386, | ||
"a.js": 20785, | ||
"a.js.gz": 8102, | ||
"a.js": 20801, | ||
"a.js.gz": 8114, | ||
"a.mem": 3171, | ||
"a.mem.gz": 2715, | ||
"total": 24544, | ||
"total_gz": 11203 | ||
"total": 24560, | ||
"total_gz": 11215 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"a.html": 665, | ||
"a.html.gz": 427, | ||
"a.js": 360, | ||
"a.js.gz": 281, | ||
"a.wasm": 102, | ||
"a.wasm.gz": 114, | ||
"total": 1127, | ||
"total_gz": 822 | ||
"a.js": 322, | ||
"a.js.gz": 259, | ||
"a.wasm": 104, | ||
"a.wasm.gz": 112, | ||
"total": 1091, | ||
"total_gz": 798 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to read this code. This new function starts here, but the PR doesn't seem to end it? Maybe I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks funny because I create new function, but removed the internal nesting within the function, replacing it with an early return.
So the overall level of nesting remained constant even though a function was added.