mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 09:50:27 +00:00
The bytecode interpreter only needed the running execution context, but still threaded a separate Interpreter object through both the C++ and asm entry points. Move that state and the bytecode execution helpers onto VM instead, and teach the asm generator and slow paths to use VM directly.
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Runtime/ECMAScriptFunctionObject.h>
|
|
#include <LibJS/Runtime/GeneratorObject.h>
|
|
#include <LibJS/Runtime/Object.h>
|
|
#include <LibJS/Runtime/Promise.h>
|
|
#include <LibJS/Runtime/VM.h>
|
|
|
|
namespace JS {
|
|
|
|
class AsyncFunctionDriverWrapper final : public Promise {
|
|
JS_OBJECT(AsyncFunctionDriverWrapper, Promise);
|
|
GC_DECLARE_ALLOCATOR(AsyncFunctionDriverWrapper);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<Promise> create(Realm&, GeneratorObject*);
|
|
|
|
virtual ~AsyncFunctionDriverWrapper() override = default;
|
|
void visit_edges(Cell::Visitor&) override;
|
|
|
|
void continue_async_execution(VM&, Value, bool is_successful);
|
|
void schedule_resume(Value, bool is_fulfilled);
|
|
|
|
private:
|
|
AsyncFunctionDriverWrapper(Realm&, GC::Ref<GeneratorObject>, GC::Ref<Promise> top_level_promise);
|
|
ThrowCompletionOr<void> await(Value);
|
|
|
|
GC::Ref<GeneratorObject> m_generator_object;
|
|
GC::Ref<Promise> m_top_level_promise;
|
|
GC::Ptr<Promise> m_current_promise { nullptr };
|
|
OwnPtr<ExecutionContext> m_suspended_execution_context;
|
|
|
|
GC::Ptr<NativeFunction> m_on_settled;
|
|
bool m_is_initial_execution { true };
|
|
};
|
|
|
|
}
|