From 3bb06cc7195ce56b41175d3250592d2a05e03d65 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 8 Aug 2023 07:10:39 +0200 Subject: [PATCH] Fuzzers: Use the LibJS bytecode VM --- Meta/Lagom/Fuzzers/FuzzJs.cpp | 9 +++++---- Meta/Lagom/Fuzzers/FuzzilliJs.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Meta/Lagom/Fuzzers/FuzzJs.cpp b/Meta/Lagom/Fuzzers/FuzzJs.cpp index bb5ab8203a..11158f7c2f 100644 --- a/Meta/Lagom/Fuzzers/FuzzJs.cpp +++ b/Meta/Lagom/Fuzzers/FuzzJs.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -19,10 +19,11 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (!Utf8View(js).validate()) return 0; auto vm = MUST(JS::VM::create()); - auto interpreter = JS::Interpreter::create(*vm); - auto parse_result = JS::Script::parse(js, interpreter->realm()); + auto root_execution_context = JS::create_simple_execution_context(*vm); + auto& realm = *root_execution_context->realm; + auto parse_result = JS::Script::parse(js, realm); if (!parse_result.is_error()) - (void)interpreter->run(parse_result.value()); + (void)vm->bytecode_interpreter().run(parse_result.value()); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp index d0192959b8..4d1feee974 100644 --- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp +++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -188,7 +188,8 @@ int main(int, char**) VERIFY(reprl_input != MAP_FAILED); auto vm = MUST(JS::VM::create()); - auto interpreter = JS::Interpreter::create(*vm); + auto root_execution_context = JS::create_simple_execution_context(*vm); + auto& realm = *root_execution_context->realm; while (true) { unsigned action; @@ -211,11 +212,11 @@ int main(int, char**) if (!Utf8View(js).validate()) { result = 1; } else { - auto parse_result = JS::Script::parse(js, interpreter->realm()); + auto parse_result = JS::Script::parse(js, realm); if (parse_result.is_error()) { result = 1; } else { - auto completion = interpreter->run(parse_result.value()); + auto completion = vm->bytecode_interpreter().run(parse_result.value()); if (completion.is_error()) { result = 1; }