Skip to content
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

Optimize call result push to the stack #602

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ cable_add_compile_options(
-Wduplicate-enum
-Wlogical-op
-Wno-unknown-attributes
-falign-functions=32
-mbranches-within-32B-boundaries
)

if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
Expand Down
8 changes: 3 additions & 5 deletions lib/fizzy/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,10 @@ inline bool invoke_function(const FuncType& func_type, uint32_t func_idx, Instan

stack.drop(num_args);

const auto num_outputs = func_type.outputs.size();
axic marked this conversation as resolved.
Show resolved Hide resolved
// NOTE: we can assume these two from validation
assert(num_outputs <= 1);
assert(ret.has_value == (num_outputs == 1));
// NOTE: validation ensures there is at most 1 output value
assert(func_type.outputs.size() == (ret.has_value ? 1 : 0));
axic marked this conversation as resolved.
Show resolved Hide resolved
// Push back the result
if (num_outputs != 0)
if (ret.has_value)
stack.push(ret.value);

return true;
Expand Down