From aa2916c21b2aa30bfab2036259094b79529de726 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 9 Jun 2021 20:31:07 +0430 Subject: [PATCH] LibWasm: ALWAYS_INLINE some very hot functions These function couldn't be inlined before because the compiler would've started flagging invalid paths in Variant as maybe-uninitialized. --- .../AbstractMachine/AbstractMachine.cpp | 3 +++ .../LibWasm/AbstractMachine/AbstractMachine.h | 8 ++++---- .../LibWasm/AbstractMachine/Configuration.h | 20 +++++++++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp index 80ec5a619c..49580e31b1 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp @@ -457,6 +457,9 @@ void Linker::link(HashMap const& exports) if (m_unresolved_imports.is_empty()) return; + if (exports.is_empty()) + return; + HashTable resolved_imports; for (auto& import_ : m_unresolved_imports) { auto export_ = exports.get(import_); diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h index f5a04db05d..1d3bd0a776 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h @@ -472,10 +472,10 @@ public: Stack() = default; [[nodiscard]] ALWAYS_INLINE bool is_empty() const { return m_data.is_empty(); } - FLATTEN void push(EntryType entry) { m_data.append(move(entry)); } - FLATTEN auto pop() { return m_data.take_last(); } - FLATTEN auto& peek() const { return m_data.last(); } - FLATTEN auto& peek() { return m_data.last(); } + ALWAYS_INLINE void push(EntryType entry) { m_data.append(move(entry)); } + ALWAYS_INLINE auto pop() { return m_data.take_last(); } + ALWAYS_INLINE auto& peek() const { return m_data.last(); } + ALWAYS_INLINE auto& peek() { return m_data.last(); } ALWAYS_INLINE auto size() const { return m_data.size(); } ALWAYS_INLINE auto& entries() const { return m_data; } diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h index fa206c309c..04cef62746 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.h @@ -25,16 +25,16 @@ public: m_stack.push(move(frame)); m_stack.push(label); } - auto& frame() const { return m_stack.entries()[m_current_frame_index].get(); } - auto& frame() { return m_stack.entries()[m_current_frame_index].get(); } - auto& ip() const { return m_ip; } - auto& ip() { return m_ip; } - auto& depth() const { return m_depth; } - auto& depth() { return m_depth; } - auto& stack() const { return m_stack; } - auto& stack() { return m_stack; } - auto& store() const { return m_store; } - auto& store() { return m_store; } + ALWAYS_INLINE auto& frame() const { return m_stack.entries()[m_current_frame_index].get(); } + ALWAYS_INLINE auto& frame() { return m_stack.entries()[m_current_frame_index].get(); } + ALWAYS_INLINE auto& ip() const { return m_ip; } + ALWAYS_INLINE auto& ip() { return m_ip; } + ALWAYS_INLINE auto& depth() const { return m_depth; } + ALWAYS_INLINE auto& depth() { return m_depth; } + ALWAYS_INLINE auto& stack() const { return m_stack; } + ALWAYS_INLINE auto& stack() { return m_stack; } + ALWAYS_INLINE auto& store() const { return m_store; } + ALWAYS_INLINE auto& store() { return m_store; } struct CallFrameHandle { explicit CallFrameHandle(Configuration& configuration)