diff options
author | jgravelle-google <jgravelle@google.com> | 2017-06-28 09:53:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 09:53:37 -0700 |
commit | 14bcc443282146cb85ef2798c36fcb2fe6fa74fa (patch) | |
tree | 9b954ab0ab6b9f87ce752c1b781cf050b9b5f703 /src | |
parent | 21e08eeef1ccc489cd06495e4370e1dffccfe088 (diff) | |
download | binaryen-14bcc443282146cb85ef2798c36fcb2fe6fa74fa.tar.gz binaryen-14bcc443282146cb85ef2798c36fcb2fe6fa74fa.tar.bz2 binaryen-14bcc443282146cb85ef2798c36fcb2fe6fa74fa.zip |
Runtime.stackAlloc should grow down for wasm (#1073)
* Runtime.stackAlloc should grow down for wasm
* stackAlloc should align properly; update tests
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-emscripten.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/wasm-emscripten.cpp b/src/wasm-emscripten.cpp index 43366e410..7463ec594 100644 --- a/src/wasm-emscripten.cpp +++ b/src/wasm-emscripten.cpp @@ -119,16 +119,12 @@ void generateStackAllocFunction(LinkerObject& linker) { SetLocal* setStackLocal = builder.makeSetLocal(1, loadStack); GetLocal* getStackLocal = builder.makeGetLocal(1, i32); GetLocal* getSizeArg = builder.makeGetLocal(0, i32); - Binary* add = builder.makeBinary(AddInt32, getStackLocal, getSizeArg); + Binary* sub = builder.makeBinary(SubInt32, getStackLocal, getSizeArg); const static uint32_t bitAlignment = 16; const static uint32_t bitMask = bitAlignment - 1; - Const* addConst = builder.makeConst(Literal(bitMask)); - Binary* maskedAdd = builder.makeBinary( - AndInt32, - builder.makeBinary(AddInt32, add, addConst), - builder.makeConst(Literal(~bitMask)) - ); - Store* storeStack = generateStoreStackPointer(builder, linker, maskedAdd); + Const* subConst = builder.makeConst(Literal(~bitMask)); + Binary* maskedSub = builder.makeBinary(AndInt32, sub, subConst); + Store* storeStack = generateStoreStackPointer(builder, linker, maskedSub); Block* block = builder.makeBlock(); block->list.push_back(setStackLocal); |