mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +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
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Bytecode/Interpreter.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Lexer.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
|
@ -173,26 +172,19 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(VM& vm, StringView source_tex
|
|||
// 17. If result.[[Type]] is normal, then
|
||||
if (!eval_result.is_throw_completion()) {
|
||||
// a. Set result to the result of evaluating body.
|
||||
if (auto* bytecode_interpreter = vm.bytecode_interpreter_if_exists()) {
|
||||
auto maybe_executable = Bytecode::compile(vm, program, FunctionKind::Normal, "ShadowRealmEval"sv);
|
||||
if (maybe_executable.is_error())
|
||||
result = maybe_executable.release_error();
|
||||
else {
|
||||
auto executable = maybe_executable.release_value();
|
||||
auto maybe_executable = Bytecode::compile(vm, program, FunctionKind::Normal, "ShadowRealmEval"sv);
|
||||
if (maybe_executable.is_error())
|
||||
result = maybe_executable.release_error();
|
||||
else {
|
||||
auto executable = maybe_executable.release_value();
|
||||
|
||||
auto value_and_frame = bytecode_interpreter->run_and_return_frame(eval_realm, *executable, nullptr);
|
||||
if (value_and_frame.value.is_error()) {
|
||||
result = value_and_frame.value.release_error();
|
||||
} else {
|
||||
// Resulting value is in the accumulator.
|
||||
result = value_and_frame.frame->registers.at(0).value_or(js_undefined());
|
||||
}
|
||||
auto value_and_frame = vm.bytecode_interpreter().run_and_return_frame(eval_realm, *executable, nullptr);
|
||||
if (value_and_frame.value.is_error()) {
|
||||
result = value_and_frame.value.release_error();
|
||||
} else {
|
||||
// Resulting value is in the accumulator.
|
||||
result = value_and_frame.frame->registers.at(0).value_or(js_undefined());
|
||||
}
|
||||
} else {
|
||||
// FIXME: Remove once everything uses the VM's current realm.
|
||||
auto eval_realm_interpreter = Interpreter::create_with_existing_realm(eval_realm);
|
||||
|
||||
result = program->execute(*eval_realm_interpreter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue