From 0b7fcac9f8a7ba57421fae2377621010ba1a1bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 24 May 2022 14:03:40 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=91=B7=20-falign-functions=3D32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index badb0bb74..61d762d13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ cable_add_compile_options( -Wduplicate-enum -Wlogical-op -Wno-unknown-attributes + -falign-functions=32 ) if(CMAKE_CXX_COMPILER_ID MATCHES Clang) From dcd8e2fc951d18dbb5bbaecf9266f9e4ec0e32e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 24 May 2022 14:12:41 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=91=B7=20-mbranches-within-32B-bounda?= =?UTF-8?q?ries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61d762d13..8b892d527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ cable_add_compile_options( -Wlogical-op -Wno-unknown-attributes -falign-functions=32 + -mbranches-within-32B-boundaries ) if(CMAKE_CXX_COMPILER_ID MATCHES Clang) From 90bd0636c49f1c88136871c6d76b0e5702349940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 1 Oct 2020 13:34:04 +0200 Subject: [PATCH 3/3] Optimize call result push to the stack --- lib/fizzy/execute.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/fizzy/execute.cpp b/lib/fizzy/execute.cpp index 1992d720d..1650a24e8 100644 --- a/lib/fizzy/execute.cpp +++ b/lib/fizzy/execute.cpp @@ -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(); - // 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)); // Push back the result - if (num_outputs != 0) + if (ret.has_value) stack.push(ret.value); return true;