Skip to content

Remove old stack function from StackCheck #3100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/passes/StackCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
9 changes: 1 addition & 8 deletions test/lld/basic_safe_stack.wat.out
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -117,7 +111,6 @@
"stackRestore",
"stackAlloc",
"main",
"__set_stack_limit",
"__set_stack_limits",
"__growWasmMemory"
],
Expand Down
8 changes: 0 additions & 8 deletions test/lld/recursive_safe_stack.wat.out
Original file line number Diff line number Diff line change
@@ -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)))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -203,7 +196,6 @@
"exports": [
"__wasm_call_ctors",
"main",
"__set_stack_limit",
"__set_stack_limits",
"__growWasmMemory"
],
Expand Down
8 changes: 0 additions & 8 deletions test/lld/safe_stack_standalone-wasm.wat.out
Original file line number Diff line number Diff line change
@@ -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)))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -201,7 +194,6 @@
"exports": [
"__wasm_call_ctors",
"main",
"__set_stack_limit",
"__set_stack_limits",
"__growWasmMemory"
],
Expand Down
7 changes: 0 additions & 7 deletions test/passes/stack-check_enable-mutable-globals.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down