diff options
author | jgravelle-google <jgravelle@google.com> | 2016-11-30 15:34:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 15:34:39 -0800 |
commit | 4caea4872aed6d1cb7ef42c9a2364870eb574e41 (patch) | |
tree | fdaf20b77bd46d1da14d57a7401525ddf9f6850e /test | |
parent | 36be3e0151dd7357e47b2d8f432bdd706a30466c (diff) | |
download | binaryen-4caea4872aed6d1cb7ef42c9a2364870eb574e41.tar.gz binaryen-4caea4872aed6d1cb7ef42c9a2364870eb574e41.tar.bz2 binaryen-4caea4872aed6d1cb7ef42c9a2364870eb574e41.zip |
Handle importing globals in s2wasm (#843)
* Handle importing globals in s2wasm
* Make importedGlobals a set of Names, make Names hashable
* Revert "Make importedGlobals a set of Names, make Names hashable"
This reverts commit 1d0ca7a5e3839b15ca60593330979864c9c3ed60.
* Refactor relocation parsing to handle expressions directly
* PR Feedback
- Move comment where it belongs
- Add comment about ownership to addRelocation
- Remove do-nothing parseImportGlobal
* Reword "imported globals" to "imported objects"
- Flip isObjectImported to isObjectImplemented, for consistency
* Add tests for s2wasm globals.
Also implement import relocation expression handling
* Simplify globals.s test
* Fix memory leak of relocation
* Use unique_ptr instead of delete in getRelocatableExpression
Diffstat (limited to 'test')
-rw-r--r-- | test/dot_s/globals.s | 72 | ||||
-rw-r--r-- | test/dot_s/globals.wast | 81 |
2 files changed, 153 insertions, 0 deletions
diff --git a/test/dot_s/globals.s b/test/dot_s/globals.s new file mode 100644 index 000000000..4ea8041a9 --- /dev/null +++ b/test/dot_s/globals.s @@ -0,0 +1,72 @@ + .text + .globl globals + .type globals,@function +globals: + i32.const $push0=, 0 + i32.const $push1=, 7 + i32.store local_global($pop0), $pop1 + i32.const $push2=, 0 + i32.load $drop=, local_global($pop2) + i32.const $drop=, local_global + .endfunc +.Lfunc_end0: + .size globals, .Lfunc_end0-globals + + .globl import_globals + .type import_globals,@function +import_globals: + i32.const $push0=, 0 + i32.const $push1=, 7 + i32.store imported_global($pop0), $pop1 + i32.const $push2=, 0 + i32.load $drop=, imported_global($pop2) + i32.const $drop=, imported_global + .endfunc +.Lfunc_end0: + .size import_globals, .Lfunc_end0-import_globals + + .globl globals_offset + .type globals_offset,@function +globals_offset: + i32.const $push0=, 4 + i32.const $push1=, 7 + i32.store local_global+12($pop0), $pop1 + i32.const $push2=, 8 + i32.load $drop=, local_global-4($pop2) + i32.const $drop=, local_global+16 + .endfunc +.Lfunc_end0: + .size globals_offset, .Lfunc_end0-globals_offset + + .globl import_globals_offset + .type import_globals_offset,@function +import_globals_offset: + i32.const $push0=, 4 + i32.const $push1=, 7 + i32.store imported_global+12($pop0), $pop1 + i32.const $push2=, 8 + i32.load $drop=, imported_global-4($pop2) + i32.const $drop=, imported_global+16 + .endfunc +.Lfunc_end0: + .size import_globals_offset, .Lfunc_end0-import_globals_offset + + .type local_global,@object + .p2align 2 +local_global: + .int32 17 + .size local_global, 4 + + .type initialized_with_global,@object + .p2align 2 +initialized_with_global: + .int32 local_global + .size initialized_with_global, 4 + + .type initialized_with_global_offset,@object + .p2align 2 +initialized_with_global_offset: + .int32 local_global+2 + .size initialized_with_global_offset, 4 + + .import_global imported_global diff --git a/test/dot_s/globals.wast b/test/dot_s/globals.wast new file mode 100644 index 000000000..d6a164de6 --- /dev/null +++ b/test/dot_s/globals.wast @@ -0,0 +1,81 @@ +(module + (import "env" "memory" (memory $0 1)) + (import "env" "imported_global" (global $imported_global i32)) + (table 0 anyfunc) + (data (i32.const 12) "\11\00\00\00") + (data (i32.const 16) "\0c\00\00\00") + (data (i32.const 20) "\0e\00\00\00") + (export "globals" (func $globals)) + (export "import_globals" (func $import_globals)) + (export "globals_offset" (func $globals_offset)) + (export "import_globals_offset" (func $import_globals_offset)) + (func $globals + (i32.store offset=12 + (i32.const 0) + (i32.const 7) + ) + (drop + (i32.load offset=12 + (i32.const 0) + ) + ) + (drop + (i32.const 12) + ) + ) + (func $import_globals + (i32.store + (get_global $imported_global) + (i32.const 7) + ) + (drop + (i32.load + (get_global $imported_global) + ) + ) + (drop + (get_global $imported_global) + ) + ) + (func $globals_offset + (i32.store offset=24 + (i32.const 4) + (i32.const 7) + ) + (drop + (i32.load offset=8 + (i32.const 8) + ) + ) + (drop + (i32.const 28) + ) + ) + (func $import_globals_offset + (i32.store offset=12 + (i32.add + (i32.const 4) + (get_global $imported_global) + ) + (i32.const 7) + ) + (drop + (i32.load + (i32.add + (i32.const 8) + (i32.add + (i32.const -4) + (get_global $imported_global) + ) + ) + ) + ) + (drop + (i32.add + (i32.const 16) + (get_global $imported_global) + ) + ) + ) +) +;; METADATA: { "asmConsts": {},"staticBump": 24, "initializers": [] } |