diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-21 19:33:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 19:33:11 -0700 |
commit | 8be82627c6a8cbded0dab67ad1f31906a54ba78c (patch) | |
tree | b7b14f1899ffe39a7562007474a58948685146c8 /src/asm2wasm.h | |
parent | 7292ef9c863a0766c697cc0a77516447ff652820 (diff) | |
parent | 740e36eab98d679387fea60cd642591a69ce809f (diff) | |
download | binaryen-8be82627c6a8cbded0dab67ad1f31906a54ba78c.tar.gz binaryen-8be82627c6a8cbded0dab67ad1f31906a54ba78c.tar.bz2 binaryen-8be82627c6a8cbded0dab67ad1f31906a54ba78c.zip |
Merge pull request #703 from WebAssembly/spec-update
Spec update - get us passing the 0xc spec tests (minus stacky stuff)
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index bce67a582..1c528d7f3 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -177,6 +177,7 @@ private: else if (type == f64) value = Literal(double(0)); else WASM_UNREACHABLE(); global->init = wasm.allocator.alloc<Const>()->set(value); + global->mutable_ = true; wasm.addGlobal(global); } @@ -502,9 +503,20 @@ void Asm2WasmBuilder::processAsm(Ref ast) { type = WasmType::f64; } if (type != WasmType::none) { + // we need imported globals to be mutable, but wasm doesn't support that yet, so we must + // import an immutable and create a mutable global initialized to its value + import->name = Name(std::string(import->name.str) + "$asm2wasm$import"); import->kind = Import::Global; import->globalType = type; mappedGlobals.emplace(name, type); + { + auto global = new Global(); + global->name = name; + global->type = type; + global->init = builder.makeGetGlobal(import->name, type); + global->mutable_ = true; + wasm.addGlobal(global); + } } else { import->kind = Import::Function; } |