From 6b5042501346197c192371105e5f111af3fb8fd0 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 24 Oct 2022 04:01:40 +0330 Subject: [PATCH] wasm: Map the entire input wasm file instead of using Core::File This is a 30x (!) speedup in parsing time as we don't lose time to Core::File's silly memmove()-into-provided-buffer stuff anymore. --- Userland/Utilities/wasm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp index d690cb6e6ff..2e521464a8a 100644 --- a/Userland/Utilities/wasm.cpp +++ b/Userland/Utilities/wasm.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -245,13 +246,13 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi static Optional parse(StringView filename) { - auto result = Core::File::open(filename, Core::OpenMode::ReadOnly); + auto result = Core::MappedFile::map(filename); if (result.is_error()) { warnln("Failed to open {}: {}", filename, result.error()); return {}; } - auto stream = Core::InputFileStream(result.release_value()); + InputMemoryStream stream { ReadonlyBytes { result.value()->data(), result.value()->size() } }; auto parse_result = Wasm::Module::parse(stream); if (parse_result.is_error()) { warnln("Something went wrong, either the file is invalid, or there's a bug with LibWasm!");