JSDOMWindow::commonVM() should return a reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Mar 2014 05:10:15 +0000 (05:10 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Mar 2014 05:10:15 +0000 (05:10 +0000)
<https://webkit.org/b/129293>

Source/JavaScriptCore:

Added a DropAllLocks constructor that takes VM& without null checks.

Reviewed by Geoff Garen.

Source/WebCore:

Since this function always returns a VM and never null, make it
return a reference instead. There are more VM getters that never
return null, but I tried to keep the patch from snowballing.

Reviewed by Geoff Garen.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164968 268f45cc-cd09-0410-ab3c-d52691b4dbfc

45 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h
Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.cpp
Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.h
Source/JavaScriptCore/runtime/JSLock.cpp
Source/JavaScriptCore/runtime/JSLock.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/DOMWrapperWorld.cpp
Source/WebCore/bindings/js/DOMWrapperWorld.h
Source/WebCore/bindings/js/GCController.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/JSDOMWindowBase.h
Source/WebCore/bindings/js/JSDOMWindowShell.cpp
Source/WebCore/bindings/js/JSEventListener.h
Source/WebCore/bindings/js/PageScriptDebugServer.cpp
Source/WebCore/bindings/js/ScheduledAction.h
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/js/WebCoreJSClientData.h
Source/WebCore/dom/CollectionIndexCache.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/html/HTMLImageLoader.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.h
Source/WebCore/inspector/WorkerRuntimeAgent.cpp
Source/WebCore/inspector/WorkerRuntimeAgent.h
Source/WebCore/testing/MemoryInfo.h
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/mac/Misc/WebCoreStatistics.mm
Source/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
Source/WebKit/win/WebCoreStatistics.cpp
Source/WebKit/win/WebJavaScriptCollector.cpp
Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp
Source/WebKit2/Shared/mac/WebMemorySampler.mac.mm
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebProcess.cpp

index 2c99839..cc91234 100644 (file)
@@ -1,3 +1,12 @@
+2014-02-25  Andreas Kling  <akling@apple.com>
+
+        JSDOMWindow::commonVM() should return a reference.
+        <https://webkit.org/b/129293>
+
+        Added a DropAllLocks constructor that takes VM& without null checks.
+
+        Reviewed by Geoff Garen.
+
 2014-03-02  Mark Lam  <mark.lam@apple.com>
 
         CodeBlock::hasDebuggerRequests() should returning a bool instead of an int.
index 76a47fb..d8d69a2 100644 (file)
@@ -84,11 +84,11 @@ static PassRefPtr<Inspector::TypeBuilder::Runtime::ErrorRange> buildErrorRangeOb
 
 void InspectorRuntimeAgent::parse(ErrorString*, const String& expression, Inspector::TypeBuilder::Runtime::SyntaxErrorType::Enum* result, Inspector::TypeBuilder::OptOutput<String>* message, RefPtr<Inspector::TypeBuilder::Runtime::ErrorRange>& range)
 {
-    VM* vm = globalVM();
+    VM& vm = globalVM();
     JSLockHolder lock(vm);
 
     ParserError error;
-    checkSyntax(*vm, JSC::makeSource(expression), error);
+    checkSyntax(vm, JSC::makeSource(expression), error);
 
     switch (error.m_syntaxErrorType) {
     case ParserError::SyntaxErrorNone:
index 2bc6e29..d6c1eea 100644 (file)
@@ -76,7 +76,7 @@ protected:
 
     InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; }
 
-    virtual JSC::VM* globalVM() = 0;
+    virtual JSC::VM& globalVM() = 0;
     virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0;
 
     virtual void muteConsole() = 0;
index 2f9a29a..126189e 100644 (file)
@@ -54,9 +54,9 @@ void JSGlobalObjectRuntimeAgent::willDestroyFrontendAndBackend(InspectorDisconne
     m_backendDispatcher.clear();
 }
 
-VM* JSGlobalObjectRuntimeAgent::globalVM()
+VM& JSGlobalObjectRuntimeAgent::globalVM()
 {
-    return &m_globalObject.vm();
+    return m_globalObject.vm();
 }
 
 InjectedScript JSGlobalObjectRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId)
index b02cb07..d87fd2a 100644 (file)
@@ -44,7 +44,7 @@ public:
     virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) override;
     virtual void willDestroyFrontendAndBackend(InspectorDisconnectReason) override;
 
-    virtual JSC::VM* globalVM() override;
+    virtual JSC::VM& globalVM() override;
     virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) override;
 
     // FIXME: JavaScript inspector does not yet have a console object to mute.
index 5de631c..afa68c4 100644 (file)
@@ -246,6 +246,14 @@ JSLock::DropAllLocks::DropAllLocks(VM* vm)
     m_droppedLockCount = m_vm->apiLock().dropAllLocks(this);
 }
 
+JSLock::DropAllLocks::DropAllLocks(VM& vm)
+    : m_droppedLockCount(0)
+    , m_vm(&vm)
+{
+    RELEASE_ASSERT(!m_vm->isCollectorBusy());
+    m_droppedLockCount = m_vm->apiLock().dropAllLocks(this);
+}
+
 JSLock::DropAllLocks::~DropAllLocks()
 {
     if (!m_vm)
index 114f8d2..e0191ae 100644 (file)
@@ -110,6 +110,7 @@ namespace JSC {
         public:
             JS_EXPORT_PRIVATE DropAllLocks(ExecState*);
             JS_EXPORT_PRIVATE DropAllLocks(VM*);
+            JS_EXPORT_PRIVATE DropAllLocks(VM&);
             JS_EXPORT_PRIVATE ~DropAllLocks();
             
             void setDropDepth(unsigned depth) { m_dropDepth = depth; }
index b6b2969..03a3455 100644 (file)
@@ -1,3 +1,14 @@
+2014-02-25  Andreas Kling  <akling@apple.com>
+
+        JSDOMWindow::commonVM() should return a reference.
+        <https://webkit.org/b/129293>
+
+        Since this function always returns a VM and never null, make it
+        return a reference instead. There are more VM getters that never
+        return null, but I tried to keep the patch from snowballing.
+
+        Reviewed by Geoff Garen.
+
 2014-03-02  Timothy Hatcher  <timothy@apple.com>
 
         Remove ASSERT in ~IDBRequest since it is firing during legitimate uses in Web Inspector.
index eb3e1eb..3dd25e1 100644 (file)
@@ -30,18 +30,18 @@ using namespace JSC;
 
 namespace WebCore {
 
-DOMWrapperWorld::DOMWrapperWorld(JSC::VM* vm, bool isNormal)
+DOMWrapperWorld::DOMWrapperWorld(JSC::VM& vm, bool isNormal)
     : m_vm(vm)
     , m_isNormal(isNormal)
 {
-    VM::ClientData* clientData = m_vm->clientData;
+    VM::ClientData* clientData = m_vm.clientData;
     ASSERT(clientData);
     static_cast<WebCoreJSClientData*>(clientData)->rememberWorld(*this);
 }
 
 DOMWrapperWorld::~DOMWrapperWorld()
 {
-    VM::ClientData* clientData = m_vm->clientData;
+    VM::ClientData* clientData = m_vm.clientData;
     ASSERT(clientData);
     static_cast<WebCoreJSClientData*>(clientData)->forgetWorld(*this);
 
@@ -69,7 +69,7 @@ DOMWrapperWorld& normalWorld(JSC::VM& vm)
 DOMWrapperWorld& mainThreadNormalWorld()
 {
     ASSERT(isMainThread());
-    static DOMWrapperWorld& cachedNormalWorld = normalWorld(*JSDOMWindow::commonVM());
+    static DOMWrapperWorld& cachedNormalWorld = normalWorld(JSDOMWindow::commonVM());
     return cachedNormalWorld;
 }
 
index 618b508..401a9bc 100644 (file)
@@ -36,7 +36,7 @@ typedef HashMap<void*, JSC::Weak<JSC::JSObject>> DOMObjectWrapperMap;
 
 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
 public:
-    static PassRefPtr<DOMWrapperWorld> create(JSC::VM* vm, bool isNormal = false)
+    static PassRefPtr<DOMWrapperWorld> create(JSC::VM& vm, bool isNormal = false)
     {
         return adoptRef(new DOMWrapperWorld(vm, isNormal));
     }
@@ -54,13 +54,13 @@ public:
 
     bool isNormal() const { return m_isNormal; }
 
-    JSC::VM* vm() const { return m_vm; }
+    JSC::VM& vm() const { return m_vm; }
 
 protected:
-    DOMWrapperWorld(JSC::VM*, bool isNormal);
+    DOMWrapperWorld(JSC::VM&, bool isNormal);
 
 private:
-    JSC::VM* m_vm;
+    JSC::VM& m_vm;
     HashSet<ScriptController*> m_scriptControllersWithWindowShells;
     bool m_isNormal;
 };
index ba70d4a..dbef6a5 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 static void collect(void*)
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    JSDOMWindow::commonVM()->heap.collectAllGarbage();
+    JSDOMWindow::commonVM().heap.collectAllGarbage();
 }
 
 GCController& gcController()
@@ -64,7 +64,7 @@ void GCController::garbageCollectSoon()
     // able to use reportAbandonedObjectGraph on more platforms.
 #if USE(CF)
     JSLockHolder lock(JSDOMWindow::commonVM());
-    JSDOMWindow::commonVM()->heap.reportAbandonedObjectGraph();
+    JSDOMWindow::commonVM().heap.reportAbandonedObjectGraph();
 #else
     if (!m_GCTimer.isActive())
         m_GCTimer.startOneShot(0);
@@ -87,8 +87,8 @@ void GCController::garbageCollectNow()
     if (!JSDOMWindow::commonVMExists())
         return;
 #endif
-    if (!JSDOMWindow::commonVM()->heap.isBusy())
-        JSDOMWindow::commonVM()->heap.collectAllGarbage();
+    if (!JSDOMWindow::commonVM().heap.isBusy())
+        JSDOMWindow::commonVM().heap.collectAllGarbage();
 }
 
 void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone)
@@ -116,24 +116,24 @@ void GCController::releaseExecutableMemory()
 
     // We shouldn't have any javascript running on our stack when this function is called. The
     // following line asserts that.
-    ASSERT(!JSDOMWindow::commonVM()->entryScope);
+    ASSERT(!JSDOMWindow::commonVM().entryScope);
 
     // But be safe in release builds just in case...
-    if (JSDOMWindow::commonVM()->entryScope)
+    if (JSDOMWindow::commonVM().entryScope)
         return;
 
-    JSDOMWindow::commonVM()->releaseExecutableMemory();
+    JSDOMWindow::commonVM().releaseExecutableMemory();
 }
 
 void GCController::setJavaScriptGarbageCollectorTimerEnabled(bool enable)
 {
-    JSDOMWindow::commonVM()->heap.setGarbageCollectionTimerEnabled(enable);
+    JSDOMWindow::commonVM().heap.setGarbageCollectionTimerEnabled(enable);
 }
 
 void GCController::discardAllCompiledCode()
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    JSDOMWindow::commonVM()->discardAllCode();
+    JSDOMWindow::commonVM().discardAllCode();
 }
 
 } // namespace WebCore
index 525b1ca..521e435 100644 (file)
@@ -54,7 +54,7 @@ STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DOMConstructorWithDocument);
 
 void addImpureProperty(const AtomicString& propertyName)
 {
-    JSDOMWindow::commonVM()->addImpureProperty(propertyName);
+    JSDOMWindow::commonVM().addImpureProperty(propertyName);
 }
 
 const JSC::HashTable& getHashTableForGlobalData(VM& vm, const JSC::HashTable& staticTable)
index c8de41b..58eb9a1 100644 (file)
@@ -117,7 +117,7 @@ template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::VM& vm,
 
 inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld& world, JSC::ArrayBuffer*)
 {
-    return static_cast<WebCoreTypedArrayController*>(world.vm()->m_typedArrayController.get())->wrapperOwner();
+    return static_cast<WebCoreTypedArrayController*>(world.vm().m_typedArrayController.get())->wrapperOwner();
 }
 
 inline void* wrapperContext(DOMWrapperWorld& world, JSC::ArrayBuffer*)
index 79ca890..6183f2e 100644 (file)
@@ -204,7 +204,7 @@ JSDOMWindowShell* JSDOMWindowBase::shell() const
     return m_shell;
 }
 
-VM* JSDOMWindowBase::commonVM()
+VM& JSDOMWindowBase::commonVM()
 {
     ASSERT(isMainThread());
 
@@ -229,7 +229,7 @@ VM* JSDOMWindowBase::commonVM()
         initNormalWorldClientData(vm);
     }
 
-    return vm;
+    return *vm;
 }
 
 #if PLATFORM(IOS)
index fb4c601..f1c27e3 100644 (file)
@@ -71,7 +71,7 @@ namespace WebCore {
 
         JSDOMWindowShell* shell() const;
 
-        static JSC::VM* commonVM();
+        static JSC::VM& commonVM();
 #if PLATFORM(IOS)
         static bool commonVMExists();
         static JSC::VM*& commonVMInternal();
index b5fc83e..fc07c4c 100644 (file)
@@ -78,7 +78,7 @@ void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow)
     // when we allocate the global object. (Once the global object is fully
     // constructed, it can mark its own prototype.)
     
-    VM& vm = *JSDOMWindow::commonVM();
+    VM& vm = JSDOMWindow::commonVM();
     Structure* prototypeStructure = JSDOMWindowPrototype::createStructure(vm, 0, jsNull());
     Strong<JSDOMWindowPrototype> prototype(vm, JSDOMWindowPrototype::create(vm, 0, prototypeStructure));
 
index e762612..709c303 100644 (file)
@@ -80,7 +80,7 @@ namespace WebCore {
         // initializeJSFunction can trigger code that deletes this event listener
         // before we're done. It should always return 0 in this case.
         Ref<JSEventListener> protect(const_cast<JSEventListener&>(*this));
-        JSC::Strong<JSC::JSObject> wrapper(*m_isolatedWorld->vm(), m_wrapper.get());
+        JSC::Strong<JSC::JSObject> wrapper(m_isolatedWorld->vm(), m_wrapper.get());
 
         if (!m_jsFunction) {
             JSC::JSObject* function = initializeJSFunction(scriptExecutionContext);
index 337ac9f..a951b88 100644 (file)
@@ -123,7 +123,7 @@ void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page*
 void PageScriptDebugServer::recompileAllJSFunctions()
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    Debugger::recompileAllJSFunctions(JSDOMWindow::commonVM());
+    Debugger::recompileAllJSFunctions(&JSDOMWindow::commonVM());
 }
 
 ScriptDebugServer::ListenerSet* PageScriptDebugServer::getListenersForGlobalObject(JSGlobalObject* globalObject)
index 19add3f..c1f628f 100644 (file)
@@ -53,7 +53,7 @@ namespace WebCore {
     private:
         ScheduledAction(JSC::ExecState*, JSC::JSValue function, DOMWrapperWorld& isolatedWorld);
         ScheduledAction(const String& code, DOMWrapperWorld& isolatedWorld)
-            : m_function(*isolatedWorld.vm())
+            : m_function(isolatedWorld.vm())
             , m_code(code)
             , m_isolatedWorld(&isolatedWorld)
         {
index 5c1941e..972697d 100644 (file)
@@ -109,7 +109,7 @@ JSDOMWindowShell* ScriptController::createWindowShell(DOMWrapperWorld& world)
 {
     ASSERT(!m_windowShells.contains(&world));
 
-    VM& vm = *world.vm();
+    VM& vm = world.vm();
 
     Structure* structure = JSDOMWindowShell::createStructure(vm, jsNull());
     Strong<JSDOMWindowShell> windowShell(vm, JSDOMWindowShell::create(vm, m_frame.document()->domWindow(), structure, world));
@@ -170,7 +170,7 @@ PassRefPtr<DOMWrapperWorld> ScriptController::createWorld()
 
 void ScriptController::getAllWorlds(Vector<Ref<DOMWrapperWorld>>& worlds)
 {
-    static_cast<WebCoreJSClientData*>(JSDOMWindow::commonVM()->clientData)->getAllWorlds(worlds);
+    static_cast<WebCoreJSClientData*>(JSDOMWindow::commonVM().clientData)->getAllWorlds(worlds);
 }
 
 void ScriptController::clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoPageCache)
@@ -469,7 +469,7 @@ Deprecated::ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld&
 
 bool ScriptController::shouldBypassMainWorldContentSecurityPolicy()
 {
-    CallFrame* callFrame = JSDOMWindow::commonVM()->topCallFrame;
+    CallFrame* callFrame = JSDOMWindow::commonVM().topCallFrame;
     if (callFrame == CallFrame::noCaller()) 
         return false;
     DOMWrapperWorld& domWrapperWorld = currentWorld(callFrame);
index 87e95de..98998a7 100644 (file)
@@ -83,7 +83,7 @@ inline void initNormalWorldClientData(JSC::VM* vm)
 {
     WebCoreJSClientData* webCoreJSClientData = new WebCoreJSClientData;
     vm->clientData = webCoreJSClientData; // ~VM deletes this pointer.
-    webCoreJSClientData->m_normalWorld = DOMWrapperWorld::create(vm, true);
+    webCoreJSClientData->m_normalWorld = DOMWrapperWorld::create(*vm, true);
     vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController());
 }
 
index 1cd0063..3bfa907 100644 (file)
@@ -32,9 +32,9 @@ namespace WebCore {
 
 void reportExtraMemoryCostForCollectionIndexCache(size_t cost)
 {
-    JSC::VM* vm = JSDOMWindowBase::commonVM();
+    JSC::VM& vm = JSDOMWindowBase::commonVM();
     JSC::JSLockHolder lock(vm);
-    vm->heap.reportExtraMemoryCost(cost);
+    vm.heap.reportExtraMemoryCost(cost);
 }
 
 }
index 2d74a38..c2c4edc 100644 (file)
@@ -408,7 +408,7 @@ ScriptExecutionContext::Task::~Task()
 JSC::VM* ScriptExecutionContext::vm()
 {
      if (isDocument())
-        return JSDOMWindow::commonVM();
+        return &JSDOMWindow::commonVM();
 
     if (isWorkerGlobalScope())
         return toWorkerGlobalScope(this)->script()->vm();
index 524f4d2..1879dbc 100644 (file)
@@ -79,9 +79,9 @@ void HTMLImageLoader::notifyFinished(CachedResource*)
     bool loadError = cachedImage->errorOccurred() || cachedImage->response().httpStatusCode() >= 400;
     if (!loadError) {
         if (!element().inDocument()) {
-            JSC::VM* vm = JSDOMWindowBase::commonVM();
+            JSC::VM& vm = JSDOMWindowBase::commonVM();
             JSC::JSLockHolder lock(vm);
-            vm->heap.reportExtraMemoryCost(cachedImage->encodedSize());
+            vm.heap.reportExtraMemoryCost(cachedImage->encodedSize());
         }
     }
 
index 0b2f708..3868428 100644 (file)
@@ -716,7 +716,7 @@ void HTMLMediaElement::removedFrom(ContainerNode& insertionPoint)
             exitFullscreen();
 
         if (m_player) {
-            JSC::VM* vm = JSDOMWindowBase::commonVM();
+            JSC::VM& vm = JSDOMWindowBase::commonVM();
             JSC::JSLockHolder lock(vm);
 
             size_t extraMemoryCost = m_player->extraMemoryCost();
@@ -724,7 +724,7 @@ void HTMLMediaElement::removedFrom(ContainerNode& insertionPoint)
             m_reportedExtraMemoryCost = extraMemoryCost;
 
             if (extraMemoryCostDelta > 0)
-                vm->heap.reportExtraMemoryCost(extraMemoryCostDelta);
+                vm.heap.reportExtraMemoryCost(extraMemoryCostDelta);
         }
     }
 
index 86916fc..a188614 100644 (file)
@@ -562,7 +562,7 @@ void InspectorTimelineAgent::innerAddRecordToTimeline(PassRefPtr<InspectorObject
 
 static size_t usedHeapSize()
 {
-    return JSDOMWindow::commonVM()->heap.size();
+    return JSDOMWindow::commonVM().heap.size();
 }
 
 void InspectorTimelineAgent::setFrameIdentifier(InspectorObject* record, Frame* frame)
index 9e8427b..bad4a83 100644 (file)
@@ -121,7 +121,7 @@ void PageRuntimeAgent::didCreateIsolatedContext(Frame* frame, JSC::ExecState* sc
     notifyContextCreated(frameId, scriptState, origin, false);
 }
 
-JSC::VM* PageRuntimeAgent::globalVM()
+JSC::VM& PageRuntimeAgent::globalVM()
 {
     return JSDOMWindowBase::commonVM();
 }
index fd47c74..f002c49 100644 (file)
@@ -66,7 +66,7 @@ public:
     void didCreateIsolatedContext(Frame*, JSC::ExecState*, SecurityOrigin*);
 
 private:
-    virtual JSC::VM* globalVM() override;
+    virtual JSC::VM& globalVM() override;
     virtual Inspector::InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) override;
     virtual void muteConsole() override;
     virtual void unmuteConsole() override;
index 152b4dc..bd03795 100644 (file)
@@ -90,7 +90,7 @@ void WorkerRuntimeAgent::run(ErrorString*)
     m_paused = false;
 }
 
-JSC::VM* WorkerRuntimeAgent::globalVM()
+JSC::VM& WorkerRuntimeAgent::globalVM()
 {
     return JSDOMWindowBase::commonVM();
 }
index 5c2d861..274e670 100644 (file)
@@ -53,7 +53,7 @@ public:
     void pauseWorkerGlobalScope(WorkerGlobalScope*);
 
 private:
-    virtual JSC::VM* globalVM() override;
+    virtual JSC::VM& globalVM() override;
     virtual Inspector::InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) override;
     virtual void muteConsole() override;
     virtual void unmuteConsole() override;
index d4d2984..3acc90e 100644 (file)
@@ -46,8 +46,8 @@ public:
 
 private:
     MemoryInfo()
-        : m_usedJSHeapSize(JSDOMWindow::commonVM()->heap.size())
-        , m_totalJSHeapSize(JSDOMWindow::commonVM()->heap.capacity())
+        : m_usedJSHeapSize(JSDOMWindow::commonVM().heap.size())
+        , m_totalJSHeapSize(JSDOMWindow::commonVM().heap.capacity())
     {
     }
 
index 8a7530c..6aff269 100644 (file)
@@ -406,7 +406,7 @@ void DumpRenderTreeSupportEfl::garbageCollectorCollectOnAlternateThread(bool wai
 
 size_t DumpRenderTreeSupportEfl::javaScriptObjectsCount()
 {
-    return WebCore::JSDOMWindow::commonVM()->heap.objectCount();
+    return WebCore::JSDOMWindow::commonVM().heap.objectCount();
 }
 
 void DumpRenderTreeSupportEfl::setDeadDecodedDataDeletionInterval(double interval)
index f45877c..db1c57f 100644 (file)
@@ -460,7 +460,7 @@ void DumpRenderTreeSupportGtk::gcCollectJavascriptObjectsOnAlternateThread(bool
 unsigned long DumpRenderTreeSupportGtk::gcCountJavascriptObjects()
 {
     JSC::JSLockHolder lock(JSDOMWindow::commonVM());
-    return JSDOMWindow::commonVM()->heap.objectCount();
+    return JSDOMWindow::commonVM().heap.objectCount();
 }
 
 void DumpRenderTreeSupportGtk::layoutFrame(WebKitWebFrame* frame)
index bb3677d..7622cc9 100644 (file)
@@ -59,25 +59,25 @@ using namespace WebCore;
 + (size_t)javaScriptObjectsCount
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    return JSDOMWindow::commonVM()->heap.objectCount();
+    return JSDOMWindow::commonVM().heap.objectCount();
 }
 
 + (size_t)javaScriptGlobalObjectsCount
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    return JSDOMWindow::commonVM()->heap.globalObjectCount();
+    return JSDOMWindow::commonVM().heap.globalObjectCount();
 }
 
 + (size_t)javaScriptProtectedObjectsCount
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    return JSDOMWindow::commonVM()->heap.protectedObjectCount();
+    return JSDOMWindow::commonVM().heap.protectedObjectCount();
 }
 
 + (size_t)javaScriptProtectedGlobalObjectsCount
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    return JSDOMWindow::commonVM()->heap.protectedGlobalObjectCount();
+    return JSDOMWindow::commonVM().heap.protectedGlobalObjectCount();
 }
 
 + (NSCountedSet *)javaScriptProtectedObjectTypeCounts
@@ -86,7 +86,7 @@ using namespace WebCore;
     
     NSCountedSet *result = [NSCountedSet set];
 
-    OwnPtr<TypeCountSet> counts(JSDOMWindow::commonVM()->heap.protectedObjectTypeCounts());
+    OwnPtr<TypeCountSet> counts(JSDOMWindow::commonVM().heap.protectedObjectTypeCounts());
     HashCountedSet<const char*>::iterator end = counts->end();
     for (HashCountedSet<const char*>::iterator it = counts->begin(); it != end; ++it)
         for (unsigned i = 0; i < it->value; ++i)
@@ -101,7 +101,7 @@ using namespace WebCore;
     
     NSCountedSet *result = [NSCountedSet set];
 
-    OwnPtr<TypeCountSet> counts(JSDOMWindow::commonVM()->heap.objectTypeCounts());
+    OwnPtr<TypeCountSet> counts(JSDOMWindow::commonVM().heap.objectTypeCounts());
     HashCountedSet<const char*>::iterator end = counts->end();
     for (HashCountedSet<const char*>::iterator it = counts->begin(); it != end; ++it)
         for (unsigned i = 0; i < it->value; ++i)
@@ -202,8 +202,8 @@ using namespace WebCore;
     WTF::FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();
     
     JSLockHolder lock(JSDOMWindow::commonVM());
-    size_t heapSize = JSDOMWindow::commonVM()->heap.size();
-    size_t heapFree = JSDOMWindow::commonVM()->heap.capacity() - heapSize;
+    size_t heapSize = JSDOMWindow::commonVM().heap.size();
+    size_t heapFree = JSDOMWindow::commonVM().heap.capacity() - heapSize;
     GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
     
     return [NSDictionary dictionaryWithObjectsAndKeys:
@@ -247,7 +247,7 @@ using namespace WebCore;
 + (size_t)javaScriptReferencedObjectsCount
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    return JSDOMWindow::commonVM()->heap.protectedObjectCount();
+    return JSDOMWindow::commonVM().heap.protectedObjectCount();
 }
 
 + (NSSet *)javaScriptRootObjectClasses
index 72458f3..85fd7bd 100644 (file)
@@ -626,7 +626,7 @@ static Identifier identifierFromIdentifierRep(IdentifierRep* identifier)
     ASSERT(identifier->isString());
   
     const char* str = identifier->string();    
-    return Identifier(JSDOMWindow::commonVM(), String::fromUTF8WithLatin1Fallback(str, strlen(str)));
+    return Identifier(&JSDOMWindow::commonVM(), String::fromUTF8WithLatin1Fallback(str, strlen(str)));
 }
 
 kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier,
index e115ddb..3bca73e 100644 (file)
@@ -841,7 +841,7 @@ bool NetscapePluginInstanceProxy::getWindowNPObject(uint32_t& objectID)
     if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
         objectID = 0;
     else
-        objectID = m_localObjects.idForObject(*pluginWorld().vm(), frame->script().windowShell(pluginWorld())->window());
+        objectID = m_localObjects.idForObject(pluginWorld().vm(), frame->script().windowShell(pluginWorld())->window());
         
     return true;
 }
@@ -853,7 +853,7 @@ bool NetscapePluginInstanceProxy::getPluginElementNPObject(uint32_t& objectID)
         return false;
     
     if (JSObject* object = frame->script().jsObjectForPluginElement([m_pluginView element]))
-        objectID = m_localObjects.idForObject(*pluginWorld().vm(), object);
+        objectID = m_localObjects.idForObject(pluginWorld().vm(), object);
     else
         objectID = 0;
     
@@ -883,7 +883,7 @@ bool NetscapePluginInstanceProxy::evaluate(uint32_t objectID, const String& scri
         return false;
 
     JSLockHolder lock(pluginWorld().vm());
-    Strong<JSGlobalObject> globalObject(*pluginWorld().vm(), frame->script().globalObject(pluginWorld()));
+    Strong<JSGlobalObject> globalObject(pluginWorld().vm(), frame->script().globalObject(pluginWorld()));
     ExecState* exec = globalObject->globalExec();
 
     UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
index 03356cc..269c1fc 100644 (file)
@@ -321,7 +321,7 @@ void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArr
 
         if (identifier->isString()) {
             const char* str = identifier->string();
-            nameArray.add(Identifier(JSDOMWindow::commonVM(), String::fromUTF8WithLatin1Fallback(str, strlen(str))));
+            nameArray.add(Identifier(&JSDOMWindow::commonVM(), String::fromUTF8WithLatin1Fallback(str, strlen(str))));
         } else
             nameArray.add(Identifier::from(exec, identifier->number()));
     }
index 9dd0d01..1b83925 100644 (file)
@@ -99,7 +99,7 @@ HRESULT STDMETHODCALLTYPE WebCoreStatistics::javaScriptObjectsCount(
         return E_POINTER;
 
     JSLockHolder lock(JSDOMWindow::commonVM());
-    *count = (UINT)JSDOMWindow::commonVM()->heap.objectCount();
+    *count = (UINT)JSDOMWindow::commonVM().heap.objectCount();
     return S_OK;
 }
 
@@ -110,7 +110,7 @@ HRESULT STDMETHODCALLTYPE WebCoreStatistics::javaScriptGlobalObjectsCount(
         return E_POINTER;
 
     JSLockHolder lock(JSDOMWindow::commonVM());
-    *count = (UINT)JSDOMWindow::commonVM()->heap.globalObjectCount();
+    *count = (UINT)JSDOMWindow::commonVM().heap.globalObjectCount();
     return S_OK;
 }
 
@@ -121,7 +121,7 @@ HRESULT STDMETHODCALLTYPE WebCoreStatistics::javaScriptProtectedObjectsCount(
         return E_POINTER;
 
     JSLockHolder lock(JSDOMWindow::commonVM());
-    *count = (UINT)JSDOMWindow::commonVM()->heap.protectedObjectCount();
+    *count = (UINT)JSDOMWindow::commonVM().heap.protectedObjectCount();
     return S_OK;
 }
 
@@ -132,7 +132,7 @@ HRESULT STDMETHODCALLTYPE WebCoreStatistics::javaScriptProtectedGlobalObjectsCou
         return E_POINTER;
 
     JSLockHolder lock(JSDOMWindow::commonVM());
-    *count = (UINT)JSDOMWindow::commonVM()->heap.protectedGlobalObjectCount();
+    *count = (UINT)JSDOMWindow::commonVM().heap.protectedGlobalObjectCount();
     return S_OK;
 }
 
@@ -140,7 +140,7 @@ HRESULT STDMETHODCALLTYPE WebCoreStatistics::javaScriptProtectedObjectTypeCounts
     /* [retval][out] */ IPropertyBag2** typeNamesAndCounts)
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    OwnPtr<TypeCountSet> jsObjectTypeNames(JSDOMWindow::commonVM()->heap.protectedObjectTypeCounts());
+    OwnPtr<TypeCountSet> jsObjectTypeNames(JSDOMWindow::commonVM().heap.protectedObjectTypeCounts());
     typedef TypeCountSet::const_iterator Iterator;
     Iterator end = jsObjectTypeNames->end();
     HashMap<String, int> typeCountMap;
index 98f4431..7cc617a 100644 (file)
@@ -112,6 +112,6 @@ HRESULT STDMETHODCALLTYPE WebJavaScriptCollector::objectCount(
     }
 
     JSLockHolder lock(JSDOMWindow::commonVM());
-    *count = (UINT)JSDOMWindow::commonVM()->heap.objectCount();
+    *count = (UINT)JSDOMWindow::commonVM().heap.objectCount();
     return S_OK;
 }
index c21b67a..7cb70d4 100644 (file)
@@ -154,8 +154,8 @@ WebMemoryStatistics WebMemorySampler::sampleWebKit() const
     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Fast Malloc Committed Memory"), fastMallocBytesCommitted);
 #endif
 
-    size_t jscHeapBytesInUse = JSDOMWindow::commonVM()->heap.size();
-    size_t jscHeapBytesCommitted = JSDOMWindow::commonVM()->heap.capacity();
+    size_t jscHeapBytesInUse = JSDOMWindow::commonVM().heap.size();
+    size_t jscHeapBytesCommitted = JSDOMWindow::commonVM().heap.capacity();
     totalBytesInUse += jscHeapBytesInUse;
     totalBytesCommitted += jscHeapBytesCommitted;
 
index 076faef..15287f2 100644 (file)
@@ -117,8 +117,8 @@ WebMemoryStatistics WebMemorySampler::sampleWebKit() const
     totalBytesCommitted += fastMallocBytesCommitted;
     
     JSLockHolder lock(JSDOMWindow::commonVM());
-    size_t jscHeapBytesInUse = JSDOMWindow::commonVM()->heap.size();
-    size_t jscHeapBytesCommitted = JSDOMWindow::commonVM()->heap.capacity();
+    size_t jscHeapBytesInUse = JSDOMWindow::commonVM().heap.size();
+    size_t jscHeapBytesCommitted = JSDOMWindow::commonVM().heap.capacity();
     totalBytesInUse += jscHeapBytesInUse;
     totalBytesCommitted += jscHeapBytesCommitted;
     
index 9181a16..768730d 100644 (file)
@@ -534,7 +534,7 @@ void InjectedBundle::garbageCollectJavaScriptObjectsOnAlternateThreadForDebuggin
 size_t InjectedBundle::javaScriptObjectsCount()
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    return JSDOMWindow::commonVM()->heap.objectCount();
+    return JSDOMWindow::commonVM().heap.objectCount();
 }
 
 void InjectedBundle::reportException(JSContextRef context, JSValueRef exception)
index 90b5591..dff815b 100644 (file)
@@ -1371,7 +1371,7 @@ NPObject* PluginView::windowScriptNPObject()
         return 0;
     }
 
-    return m_npRuntimeObjectMap.getOrCreateNPObject(*pluginWorld().vm(), frame()->script().windowShell(pluginWorld())->window());
+    return m_npRuntimeObjectMap.getOrCreateNPObject(pluginWorld().vm(), frame()->script().windowShell(pluginWorld())->window());
 }
 
 NPObject* PluginView::pluginElementNPObject()
@@ -1387,7 +1387,7 @@ NPObject* PluginView::pluginElementNPObject()
     JSObject* object = frame()->script().jsObjectForPluginElement(m_pluginElement.get());
     ASSERT(object);
 
-    return m_npRuntimeObjectMap.getOrCreateNPObject(*pluginWorld().vm(), object);
+    return m_npRuntimeObjectMap.getOrCreateNPObject(pluginWorld().vm(), object);
 }
 
 bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups)
index 2894cd4..43cf582 100644 (file)
@@ -4282,10 +4282,10 @@ void WebPage::setThumbnailScale(double thumbnailScale)
 
 void WebPage::getBytecodeProfile(uint64_t callbackID)
 {
-    ASSERT(JSDOMWindow::commonVM()->m_perBytecodeProfiler);
-    if (!JSDOMWindow::commonVM()->m_perBytecodeProfiler)
+    ASSERT(JSDOMWindow::commonVM().m_perBytecodeProfiler);
+    if (!JSDOMWindow::commonVM().m_perBytecodeProfiler)
         send(Messages::WebPageProxy::StringCallback(String(), callbackID));
-    String result = JSDOMWindow::commonVM()->m_perBytecodeProfiler->toJSON();
+    String result = JSDOMWindow::commonVM().m_perBytecodeProfiler->toJSON();
     ASSERT(result.length());
     send(Messages::WebPageProxy::StringCallback(result, callbackID));
 }
index a7d2aeb..3be9fcf 100644 (file)
@@ -922,20 +922,20 @@ void WebProcess::getWebCoreStatistics(uint64_t callbackID)
     // Gather JavaScript statistics.
     {
         JSLockHolder lock(JSDOMWindow::commonVM());
-        data.statisticsNumbers.set(ASCIILiteral("JavaScriptObjectsCount"), JSDOMWindow::commonVM()->heap.objectCount());
-        data.statisticsNumbers.set(ASCIILiteral("JavaScriptGlobalObjectsCount"), JSDOMWindow::commonVM()->heap.globalObjectCount());
-        data.statisticsNumbers.set(ASCIILiteral("JavaScriptProtectedObjectsCount"), JSDOMWindow::commonVM()->heap.protectedObjectCount());
-        data.statisticsNumbers.set(ASCIILiteral("JavaScriptProtectedGlobalObjectsCount"), JSDOMWindow::commonVM()->heap.protectedGlobalObjectCount());
+        data.statisticsNumbers.set(ASCIILiteral("JavaScriptObjectsCount"), JSDOMWindow::commonVM().heap.objectCount());
+        data.statisticsNumbers.set(ASCIILiteral("JavaScriptGlobalObjectsCount"), JSDOMWindow::commonVM().heap.globalObjectCount());
+        data.statisticsNumbers.set(ASCIILiteral("JavaScriptProtectedObjectsCount"), JSDOMWindow::commonVM().heap.protectedObjectCount());
+        data.statisticsNumbers.set(ASCIILiteral("JavaScriptProtectedGlobalObjectsCount"), JSDOMWindow::commonVM().heap.protectedGlobalObjectCount());
         
-        OwnPtr<TypeCountSet> protectedObjectTypeCounts(JSDOMWindow::commonVM()->heap.protectedObjectTypeCounts());
+        OwnPtr<TypeCountSet> protectedObjectTypeCounts(JSDOMWindow::commonVM().heap.protectedObjectTypeCounts());
         fromCountedSetToHashMap(protectedObjectTypeCounts.get(), data.javaScriptProtectedObjectTypeCounts);
         
-        OwnPtr<TypeCountSet> objectTypeCounts(JSDOMWindow::commonVM()->heap.objectTypeCounts());
+        OwnPtr<TypeCountSet> objectTypeCounts(JSDOMWindow::commonVM().heap.objectTypeCounts());
         fromCountedSetToHashMap(objectTypeCounts.get(), data.javaScriptObjectTypeCounts);
         
-        uint64_t javaScriptHeapSize = JSDOMWindow::commonVM()->heap.size();
+        uint64_t javaScriptHeapSize = JSDOMWindow::commonVM().heap.size();
         data.statisticsNumbers.set(ASCIILiteral("JavaScriptHeapSize"), javaScriptHeapSize);
-        data.statisticsNumbers.set(ASCIILiteral("JavaScriptFreeSize"), JSDOMWindow::commonVM()->heap.capacity() - javaScriptHeapSize);
+        data.statisticsNumbers.set(ASCIILiteral("JavaScriptFreeSize"), JSDOMWindow::commonVM().heap.capacity() - javaScriptHeapSize);
     }
 
     WTF::FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();