summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp')
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp
index ac93f77507..9823f2093e 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp
+++ b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp
@@ -6,6 +6,7 @@
#include <LibWasm/AbstractMachine/Configuration.h>
#include <LibWasm/AbstractMachine/Interpreter.h>
+#include <LibWasm/Printer/Printer.h>
namespace Wasm {
@@ -24,6 +25,9 @@ Optional<Label> Configuration::nth_label(size_t i)
void Configuration::unwind(Badge<CallFrameHandle>, const CallFrameHandle& frame_handle)
{
+ if (m_stack.size() == frame_handle.stack_size && frame_handle.frame_index == m_current_frame_index)
+ return;
+
VERIFY(m_stack.size() > frame_handle.stack_size);
m_stack.entries().remove(frame_handle.stack_size, m_stack.size() - frame_handle.stack_size);
m_current_frame_index = frame_handle.frame_index;
@@ -82,29 +86,21 @@ Result Configuration::execute(Interpreter& interpreter)
void Configuration::dump_stack()
{
+ auto print_value = []<typename... Ts>(CheckedFormatString<Ts...> format, Ts... vs)
+ {
+ DuplexMemoryStream memory_stream;
+ Printer { memory_stream }.print(vs...);
+ dbgln(format.view(), StringView(memory_stream.copy_into_contiguous_buffer()).trim_whitespace());
+ };
for (const auto& entry : stack().entries()) {
entry.visit(
- [](const Value& v) {
- v.value().visit([]<typename T>(const T& v) {
- if constexpr (IsIntegral<T> || IsFloatingPoint<T>)
- dbgln(" {}", v);
- else if constexpr (IsSame<Value::Null, T>)
- dbgln(" *null");
- else
- dbgln(" *{}", v.value());
- });
+ [&](const Value& v) {
+ print_value(" {}", v);
},
- [](const Frame& f) {
+ [&](const Frame& f) {
dbgln(" frame({})", f.arity());
for (auto& local : f.locals()) {
- local.value().visit([]<typename T>(const T& v) {
- if constexpr (IsIntegral<T> || IsFloatingPoint<T>)
- dbgln(" {}", v);
- else if constexpr (IsSame<Value::Null, T>)
- dbgln(" *null");
- else
- dbgln(" *{}", v.value());
- });
+ print_value(" {}", local);
}
},
[](const Label& l) {