summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-09-04 10:26:45 -0700
committerGitHub <noreply@github.com>2019-09-04 10:26:45 -0700
commit3ac5416a6b070096fcd26c94fcdb7c0c144c72b4 (patch)
tree7d19c947643a42499136aa05b4110c11369b4fe0 /test
parent86507ab974542a7ac7a9e9e127321622025e3795 (diff)
downloadbinaryen-3ac5416a6b070096fcd26c94fcdb7c0c144c72b4.tar.gz
binaryen-3ac5416a6b070096fcd26c94fcdb7c0c144c72b4.tar.bz2
binaryen-3ac5416a6b070096fcd26c94fcdb7c0c144c72b4.zip
Add an option for the PostEmscripten pass to set the sbrk ptr location (which is called DYNAMICTOP_PTR in emscripten) (#2325)
The assumption is that an import env.emscripten_get_sbrk_ptr exists, and we replace the value returned from there with a constant. (We can't do all this in wasm-emscripten-finalize, as it happens before the JS compiler runs, which can add more static allocations; we only know where the sbrk ptr is later in compilation.) This just replaces the import with a function returning the constant; inlining etc. can help more later. By setting this at compile time we can reduce code size and avoid importing it at runtime, which makes us more compatible with wasi (less special imports).
Diffstat (limited to 'test')
-rw-r--r--test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.txt8
-rw-r--r--test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.wast5
2 files changed, 13 insertions, 0 deletions
diff --git a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.txt b/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.txt
new file mode 100644
index 000000000..4b8da86cd
--- /dev/null
+++ b/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.txt
@@ -0,0 +1,8 @@
+(module
+ (type $FUNCSIG$i (func (result i32)))
+ (func $internal (; 0 ;) (type $FUNCSIG$i) (result i32)
+ (i32.const 4008)
+ )
+)
+(module
+)
diff --git a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.wast b/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.wast
new file mode 100644
index 000000000..8e5a610b2
--- /dev/null
+++ b/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.wast
@@ -0,0 +1,5 @@
+(module
+ (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32)))
+)
+(module
+)