summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
blob: 0f17296c8bebdcc860d2adfe39bea3f3f1a0d7a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibJS/Runtime/VM.h>
#include <LibWeb/Bindings/MainThreadVM.h>

namespace Web::Bindings {

JS::VM& main_thread_vm()
{
    static RefPtr<JS::VM> vm;
    if (!vm) {
        vm = JS::VM::create(make<WebEngineCustomData>());
        static_cast<WebEngineCustomData*>(vm->custom_data())->event_loop.set_vm(*vm);
    }
    return *vm;
}

}