#include "config.h"
#include "CommonVM.h"
#include "Frame.h"
#include "ScriptController.h"
#include "Settings.h"
#include "WebCoreJSClientData.h"
#include <heap/HeapInlines.h>
#include "heap/MachineStackMarker.h"
#include <runtime/VM.h>
#include <wtf/MainThread.h>
#include <wtf/text/AtomicString.h>
#if PLATFORM(IOS)
#include "WebCoreThreadInternal.h"
#endif
using namespace JSC;
namespace WebCore {
VM* g_commonVMOrNull;
VM& commonVMSlow()
{
ASSERT(isMainThread());
ASSERT(!g_commonVMOrNull);
ScriptController::initializeThreading();
g_commonVMOrNull = &VM::createLeaked(LargeHeap).leakRef();
g_commonVMOrNull->heap.acquireAccess(); #if PLATFORM(IOS)
g_commonVMOrNull->setRunLoop(WebThreadRunLoop());
g_commonVMOrNull->heap.machineThreads().addCurrentThread();
#endif
g_commonVMOrNull->setGlobalConstRedeclarationShouldThrow(Settings::globalConstRedeclarationShouldThrow());
JSVMClientData::initNormalWorld(g_commonVMOrNull);
return *g_commonVMOrNull;
}
Frame* lexicalFrameFromCommonVM()
{
if (auto* topCallFrame = commonVM().topCallFrame) {
if (auto* globalObject = JSC::jsCast<JSDOMGlobalObject*>(topCallFrame->lexicalGlobalObject())) {
if (auto* window = jsDynamicDowncast<JSDOMWindow*>(commonVM(), globalObject)) {
if (auto* frame = window->wrapped().frame())
return frame;
}
}
}
return nullptr;
}
void addImpureProperty(const AtomicString& propertyName)
{
commonVM().addImpureProperty(propertyName);
}
}