mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:38:10 +00:00
LibJS: Rip out the AST interpreter :^)
This has been superseded by the bytecode VM, which is both faster and more capable.
This commit is contained in:
parent
fcc72a787b
commit
2eaa528a0e
41 changed files with 147 additions and 3734 deletions
|
@ -17,10 +17,10 @@
|
|||
#include <LibJS/Bytecode/Generator.h>
|
||||
#include <LibJS/Bytecode/Interpreter.h>
|
||||
#include <LibJS/Contrib/Test262/GlobalObject.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibJS/Script.h>
|
||||
#include <LibJS/SourceTextModule.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
@ -206,27 +206,28 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
|
|||
|
||||
auto vm = MUST(JS::VM::create());
|
||||
vm->enable_default_host_import_module_dynamically_hook();
|
||||
auto ast_interpreter = JS::Interpreter::create<JS::Test262::GlobalObject>(*vm);
|
||||
auto& realm = ast_interpreter->realm();
|
||||
|
||||
auto program_or_error = parse_program(realm, source, filepath, metadata.program_type);
|
||||
JS::GCPtr<JS::Realm> realm;
|
||||
JS::GCPtr<JS::Test262::GlobalObject> global_object;
|
||||
auto root_execution_context = MUST(JS::Realm::initialize_host_defined_realm(
|
||||
*vm,
|
||||
[&](JS::Realm& realm_) -> JS::GlobalObject* {
|
||||
realm = &realm_;
|
||||
global_object = vm->heap().allocate_without_realm<JS::Test262::GlobalObject>(realm_);
|
||||
return global_object;
|
||||
},
|
||||
nullptr));
|
||||
|
||||
auto program_or_error = parse_program(*realm, source, filepath, metadata.program_type);
|
||||
if (program_or_error.is_error())
|
||||
return program_or_error.release_error();
|
||||
|
||||
auto* bytecode_interpreter = vm->bytecode_interpreter_if_exists();
|
||||
|
||||
auto run_with_interpreter = [&](ScriptOrModuleProgram& program) {
|
||||
if (bytecode_interpreter)
|
||||
return run_program(*bytecode_interpreter, program);
|
||||
return run_program(*ast_interpreter, program);
|
||||
};
|
||||
|
||||
for (auto& harness_file : metadata.harness_files) {
|
||||
auto harness_program_or_error = parse_harness_files(realm, harness_file);
|
||||
auto harness_program_or_error = parse_harness_files(*realm, harness_file);
|
||||
if (harness_program_or_error.is_error())
|
||||
return harness_program_or_error.release_error();
|
||||
ScriptOrModuleProgram harness_program { harness_program_or_error.release_value() };
|
||||
auto result = run_with_interpreter(harness_program);
|
||||
auto result = run_program(vm->bytecode_interpreter(), harness_program);
|
||||
if (result.is_error()) {
|
||||
return TestError {
|
||||
NegativePhase::Harness,
|
||||
|
@ -237,7 +238,7 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
|
|||
}
|
||||
}
|
||||
|
||||
return run_with_interpreter(program_or_error.value());
|
||||
return run_program(vm->bytecode_interpreter(), program_or_error.value());
|
||||
}
|
||||
|
||||
static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue