diff --git a/src/passes/StackCheck.cpp b/src/passes/StackCheck.cpp index 183420fba26..4388705e633 100644 --- a/src/passes/StackCheck.cpp +++ b/src/passes/StackCheck.cpp @@ -36,10 +36,7 @@ namespace wasm { static Name STACK_BASE("__stack_base"); // The limit is the farthest it can grow to, which is the lowest valid address. static Name STACK_LIMIT("__stack_limit"); -// Old version, which sets the limit. -// TODO: remove this -static Name SET_STACK_LIMIT("__set_stack_limit"); -// New version, which sets the base and the limit. +// Exported function to set the base and the limit. static Name SET_STACK_LIMITS("__set_stack_limits"); static void importStackOverflowHandler(Module& module, Name name) { @@ -65,14 +62,6 @@ static void addExportedFunction(Module& module, Function* function) { static void generateSetStackLimitFunctions(Module& module) { Builder builder(module); - // One-parameter version - Function* limitFunc = - builder.makeFunction(SET_STACK_LIMIT, Signature(Type::i32, Type::none), {}); - LocalGet* getArg = builder.makeLocalGet(0, Type::i32); - Expression* store = builder.makeGlobalSet(STACK_LIMIT, getArg); - limitFunc->body = store; - addExportedFunction(module, limitFunc); - // Two-parameter version Function* limitsFunc = builder.makeFunction( SET_STACK_LIMITS, Signature({Type::i32, Type::i32}, Type::none), {}); LocalGet* getBase = builder.makeLocalGet(0, Type::i32); diff --git a/test/lld/basic_safe_stack.wat.out b/test/lld/basic_safe_stack.wat.out index 9e6a916da4b..74a2355ddb9 100644 --- a/test/lld/basic_safe_stack.wat.out +++ b/test/lld/basic_safe_stack.wat.out @@ -1,7 +1,7 @@ (module (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) (type $i32_=>_i32 (func (param i32) (result i32))) + (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_none (func (param i32 i32))) (import "env" "__handle_stack_overflow" (func $__handle_stack_overflow)) (memory $0 2) @@ -16,7 +16,6 @@ (export "stackAlloc" (func $stackAlloc)) (export "main" (func $main)) (export "__data_end" (global $global$1)) - (export "__set_stack_limit" (func $__set_stack_limit)) (export "__set_stack_limits" (func $__set_stack_limits)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__wasm_call_ctors @@ -80,11 +79,6 @@ (func $main (nop) ) - (func $__set_stack_limit (param $0 i32) - (global.set $__stack_limit - (local.get $0) - ) - ) (func $__set_stack_limits (param $0 i32) (param $1 i32) (global.set $__stack_base (local.get $0) @@ -117,7 +111,6 @@ "stackRestore", "stackAlloc", "main", - "__set_stack_limit", "__set_stack_limits", "__growWasmMemory" ], diff --git a/test/lld/recursive_safe_stack.wat.out b/test/lld/recursive_safe_stack.wat.out index cceca00aba0..d70611220a2 100644 --- a/test/lld/recursive_safe_stack.wat.out +++ b/test/lld/recursive_safe_stack.wat.out @@ -1,7 +1,6 @@ (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_none (func (param i32 i32))) (type $none_=>_i32 (func (result i32))) (type $i32_=>_i32 (func (param i32) (result i32))) @@ -20,7 +19,6 @@ (export "__heap_base" (global $global$1)) (export "__data_end" (global $global$2)) (export "main" (func $main)) - (export "__set_stack_limit" (func $__set_stack_limit)) (export "__set_stack_limits" (func $__set_stack_limits)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__wasm_call_ctors @@ -167,11 +165,6 @@ (func $main (param $0 i32) (param $1 i32) (result i32) (call $__original_main) ) - (func $__set_stack_limit (param $0 i32) - (global.set $__stack_limit - (local.get $0) - ) - ) (func $__set_stack_limits (param $0 i32) (param $1 i32) (global.set $__stack_base (local.get $0) @@ -203,7 +196,6 @@ "exports": [ "__wasm_call_ctors", "main", - "__set_stack_limit", "__set_stack_limits", "__growWasmMemory" ], diff --git a/test/lld/safe_stack_standalone-wasm.wat.out b/test/lld/safe_stack_standalone-wasm.wat.out index 51b88661b90..3f1cdeb3c3c 100644 --- a/test/lld/safe_stack_standalone-wasm.wat.out +++ b/test/lld/safe_stack_standalone-wasm.wat.out @@ -1,7 +1,6 @@ (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_none (func (param i32 i32))) (type $none_=>_i32 (func (result i32))) (type $i32_=>_i32 (func (param i32) (result i32))) @@ -19,7 +18,6 @@ (export "__heap_base" (global $global$1)) (export "__data_end" (global $global$2)) (export "main" (func $main)) - (export "__set_stack_limit" (func $__set_stack_limit)) (export "__set_stack_limits" (func $__set_stack_limits)) (export "__growWasmMemory" (func $__growWasmMemory)) (func $__wasm_call_ctors @@ -166,11 +164,6 @@ (func $main (param $0 i32) (param $1 i32) (result i32) (call $__original_main) ) - (func $__set_stack_limit (param $0 i32) - (global.set $__stack_limit - (local.get $0) - ) - ) (func $__set_stack_limits (param $0 i32) (param $1 i32) (global.set $__stack_base (local.get $0) @@ -201,7 +194,6 @@ "exports": [ "__wasm_call_ctors", "main", - "__set_stack_limit", "__set_stack_limits", "__growWasmMemory" ], diff --git a/test/passes/stack-check_enable-mutable-globals.txt b/test/passes/stack-check_enable-mutable-globals.txt index 52ee091effe..c89f112a8f4 100644 --- a/test/passes/stack-check_enable-mutable-globals.txt +++ b/test/passes/stack-check_enable-mutable-globals.txt @@ -1,12 +1,10 @@ (module - (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_none (func (param i32 i32))) (type $none_=>_i32 (func (result i32))) (import "env" "__stack_pointer" (global $sp (mut i32))) (global $__stack_base (mut i32) (i32.const 0)) (global $__stack_limit (mut i32) (i32.const 0)) (export "use_stack" (func $0)) - (export "__set_stack_limit" (func $__set_stack_limit)) (export "__set_stack_limits" (func $__set_stack_limits)) (func $0 (result i32) (local $0 i32) @@ -32,11 +30,6 @@ ) (global.get $sp) ) - (func $__set_stack_limit (param $0 i32) - (global.set $__stack_limit - (local.get $0) - ) - ) (func $__set_stack_limits (param $0 i32) (param $1 i32) (global.set $__stack_base (local.get $0)