mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
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.
This commit is contained in:
parent
8b0f05c540
commit
6b50425013
Notes:
sideshowbarker
2024-07-17 05:09:37 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/6b50425013 Pull-request: https://github.com/SerenityOS/serenity/pull/15769
1 changed files with 3 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/FileStream.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibLine/Editor.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibWasm/AbstractMachine/AbstractMachine.h>
|
||||
|
@ -245,13 +246,13 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi
|
|||
|
||||
static Optional<Wasm::Module> 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!");
|
||||
|
|
Loading…
Reference in a new issue