diff options
7 files changed, 0 insertions, 168 deletions
diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp index aa6c90977..0c7521afc 100644 --- a/src/passes/PostEmscripten.cpp +++ b/src/passes/PostEmscripten.cpp @@ -78,58 +78,6 @@ struct OptimizeCalls : public WalkerPass<PostWalker<OptimizeCalls>> { struct PostEmscripten : public Pass { void run(PassRunner* runner, Module* module) override { - // Apply the stack pointer, if it was provided. This is needed here - // because the emscripten JS compiler can add static data allocations that - // come before the stack. - auto stackPtrStr = - runner->options.getArgumentOrDefault("stack-pointer", ""); - if (stackPtrStr != "") { - Global* stackPointer = getStackPointerGlobal(*module); - BYN_TRACE("stack_pointer: " << stackPtrStr << "\n"); - if (stackPointer && !stackPointer->imported()) { - auto stackPtr = std::stoi(stackPtrStr); - auto oldValue = stackPointer->init->cast<Const>()->value; - BYN_TRACE("updating __stack_pointer: " << oldValue.geti32() << " -> " - << stackPtr << "\n"); - stackPointer->init = Builder(*module).makeConst(int32_t(stackPtr)); - } - } - - // Apply the sbrk ptr, if it was provided. - auto sbrkPtrStr = - runner->options.getArgumentOrDefault("emscripten-sbrk-ptr", ""); - if (sbrkPtrStr != "") { - auto sbrkPtr = std::stoi(sbrkPtrStr); - ImportInfo imports(*module); - auto* func = imports.getImportedFunction(ENV, "emscripten_get_sbrk_ptr"); - if (func) { - Builder builder(*module); - func->body = builder.makeConst(int32_t(sbrkPtr)); - func->module = func->base = Name(); - } - // Apply the sbrk ptr value, if it was provided. This lets emscripten set - // up sbrk entirely in wasm, without depending on the JS side to init - // anything; this is necessary for standalone wasm mode, in which we do - // not have any JS. Otherwise, the JS would set this value during - // startup. - auto sbrkValStr = - runner->options.getArgumentOrDefault("emscripten-sbrk-val", ""); - if (sbrkValStr != "") { - uint32_t sbrkVal = std::stoi(sbrkValStr); - auto end = sbrkPtr + sizeof(sbrkVal); - // Flatten memory to make it simple to write to. Later passes can - // re-optimize it. - MemoryUtils::ensureExists(module->memory); - if (!MemoryUtils::flatten(module->memory, end, module)) { - Fatal() << "cannot apply sbrk-val since memory is not flattenable\n"; - } - auto& segment = module->memory.segments[0]; - assert(segment.offset->cast<Const>()->value.geti32() == 0); - assert(end <= segment.data.size()); - memcpy(segment.data.data() + sbrkPtr, &sbrkVal, sizeof(sbrkVal)); - } - } - // Optimize imports optimizeImports(runner, module); diff --git a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@16_pass-arg=emscripten-sbrk-val@42.txt b/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@16_pass-arg=emscripten-sbrk-val@42.txt deleted file mode 100644 index 6dfee7540..000000000 --- a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@16_pass-arg=emscripten-sbrk-val@42.txt +++ /dev/null @@ -1,60 +0,0 @@ -(module - (type $none_=>_i32 (func (result i32))) - (memory $0 1 1) - (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00*\00\00\00") - (func $internal (result i32) - (i32.const 16) - ) -) -(module - (memory $0 1 1) - (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00*\00\00\00") -) -(module - (type $none_=>_i32 (func (result i32))) - (memory $0 10 10) - (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00*\00\00\00") - (func $internal (result i32) - (i32.const 16) - ) -) -(module - (type $none_=>_i32 (func (result i32))) - (memory $0 10 10) - (data (i32.const 0) "1234567890123456*\00\00\00") - (func $internal (result i32) - (i32.const 16) - ) -) -(module - (type $none_=>_i32 (func (result i32))) - (memory $0 10 10) - (data (i32.const 0) "1234567890\00\00\00\00\00\00*\00\00\00") - (func $internal (result i32) - (i32.const 16) - ) -) -(module - (type $none_=>_i32 (func (result i32))) - (memory $0 10 10) - (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00123456*\00\00\001234567890") - (func $internal (result i32) - (i32.const 16) - ) -) -(module - (type $none_=>_i32 (func (result i32))) - (memory $0 10 10) - (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00123456*\00\00\00") - (func $internal (result i32) - (i32.const 16) - ) -) -(module - (type $none_=>_i32 (func (result i32))) - (memory $0 10 10) - (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00*\00\00\00\00\00\00\001234567890") - (func $internal (result i32) - (i32.const 16) - ) -) diff --git a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@16_pass-arg=emscripten-sbrk-val@42.wast b/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@16_pass-arg=emscripten-sbrk-val@42.wast deleted file mode 100644 index 377afbc84..000000000 --- a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@16_pass-arg=emscripten-sbrk-val@42.wast +++ /dev/null @@ -1,35 +0,0 @@ -(module - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) -(module -) -(module - (memory $0 10 10) - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) -(module - (memory $0 10 10) - (data (i32.const 0) "12345678901234567890") - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) -(module - (memory $0 10 10) - (data (i32.const 0) "1234567890") - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) -(module - (memory $0 10 10) - (data (i32.const 10) "12345678901234567890") - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) -(module - (memory $0 10 10) - (data (i32.const 10) "1234567890") - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) -(module - (memory $0 10 10) - (data (i32.const 24) "1234567890") - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) - 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 deleted file mode 100644 index 1b73273b2..000000000 --- a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.txt +++ /dev/null @@ -1,8 +0,0 @@ -(module - (type $none_=>_i32 (func (result i32))) - (func $internal (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 deleted file mode 100644 index 8e5a610b2..000000000 --- a/test/passes/post-emscripten_pass-arg=emscripten-sbrk-ptr@4008.wast +++ /dev/null @@ -1,5 +0,0 @@ -(module - (import "env" "emscripten_get_sbrk_ptr" (func $internal(result i32))) -) -(module -) diff --git a/test/passes/post-emscripten_pass-arg=stack-pointer@1234.txt b/test/passes/post-emscripten_pass-arg=stack-pointer@1234.txt deleted file mode 100644 index 7f389e2de..000000000 --- a/test/passes/post-emscripten_pass-arg=stack-pointer@1234.txt +++ /dev/null @@ -1,4 +0,0 @@ -(module - (import "env" "not_stack" (global $import$global0 i32)) - (global $should_be_stack_pointer (mut i32) (i32.const 1234)) -) diff --git a/test/passes/post-emscripten_pass-arg=stack-pointer@1234.wast b/test/passes/post-emscripten_pass-arg=stack-pointer@1234.wast deleted file mode 100644 index c96bbf4f9..000000000 --- a/test/passes/post-emscripten_pass-arg=stack-pointer@1234.wast +++ /dev/null @@ -1,4 +0,0 @@ -(module - (import "env" "not_stack" (global i32)) - (global $should_be_stack_pointer (mut i32) (i32.const 2)) -) |