-
Notifications
You must be signed in to change notification settings - Fork 38
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
test: Add more call tests #571
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,32 @@ TEST(execute_call, call_with_arguments) | |
EXPECT_THAT(execute(parse(wasm), 1, {}), Result(4)); | ||
} | ||
|
||
TEST(execute_call, call_shared_stack_space) | ||
{ | ||
/* wat2wasm | ||
(module | ||
(func $double (param i32) (result i32) | ||
local.get 0 | ||
local.get 0 | ||
i32.add | ||
) | ||
|
||
(func $main (param i32) (param i32) (result i32) | ||
local.get 1 | ||
local.get 0 | ||
i32.add | ||
call $double | ||
) | ||
) | ||
*/ | ||
const auto wasm = from_hex( | ||
"0061736d01000000010c0260017f017f60027f7f017f03030200010a13020700200020006a0b0900200120006a" | ||
"10000b"); | ||
|
||
auto instance = instantiate(parse(wasm)); | ||
EXPECT_THAT(execute(*instance, 1, {2, 3}), Result(10)); // double(2+3) | ||
} | ||
|
||
TEST(execute_call, call_indirect) | ||
{ | ||
/* wat2wasm | ||
|
@@ -205,6 +231,34 @@ TEST(execute_call, call_indirect_uninited_table) | |
EXPECT_THAT(execute(module, 3, {4}), Traps()); | ||
} | ||
|
||
TEST(execute_call, call_indirect_shared_stack_space) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to be a dup of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both are simplified variants of it. They can detect an implementation defect in #572, so I keep them as they are. |
||
{ | ||
/* wat2wasm | ||
(module | ||
(type $ft (func (param i32) (result i32))) | ||
(func $double (param i32) (result i32) | ||
local.get 0 | ||
local.get 0 | ||
i32.add | ||
) | ||
|
||
(func $main (param i32) (param i32) (result i32) | ||
local.get 1 | ||
local.get 0 | ||
call_indirect (type $ft) | ||
) | ||
|
||
(table anyfunc (elem $double)) | ||
) | ||
*/ | ||
const auto wasm = from_hex( | ||
"0061736d01000000010c0260017f017f60027f7f017f0303020001040501700101010907010041000b01000a13" | ||
"020700200020006a0b0900200120001100000b"); | ||
|
||
auto instance = instantiate(parse(wasm)); | ||
EXPECT_THAT(execute(*instance, 1, {0, 10}), Result(20)); // double(10) | ||
} | ||
|
||
TEST(execute_call, imported_function_call) | ||
{ | ||
/* wat2wasm | ||
|
@@ -261,16 +315,16 @@ TEST(execute_call, imported_functions_call_indirect) | |
(func $sqr (import "env" "sqr") (param i32) (result i64)) | ||
(func $isqrt (import "env" "isqrt") (param i32) (result i64)) | ||
(func $double (param i32) (result i64) | ||
get_local 0 | ||
i64.extend_u/i32 | ||
get_local 0 | ||
i64.extend_u/i32 | ||
local.get 0 | ||
i64.extend_i32_u | ||
local.get 0 | ||
i64.extend_i32_u | ||
i64.add | ||
) | ||
|
||
(func $main (param i32) (param i32) (result i64) | ||
get_local 1 | ||
get_local 0 | ||
local.get 1 | ||
local.get 0 | ||
call_indirect (type $ft) | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the point of this test that the same local is used twice?