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 2c998392f0a959e0d4b0328f3ba42c94147641fe..cc91234bbd07fa1389a55a63ac28e7270037048b 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 76a47fb3afaa7eff70fa3ea517cd0aba3afe25f8..d8d69a25417211afb876c00deb488435fcd38e3a 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 2bc6e2994a9d2da186e2ea8bad0721370bd6ea18..d6c1eea20041e7681eca19f876175a7812b0af24 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 2f9a29ae6a8df5cd78a5f41993d3e52e511ed03d..126189e312762011ccde003c107e1e9a8c16c8a6 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 b02cb07896972d8351f4dffd81900569941a717f..d87fd2a6feb8728ce2e54615593dc5236c7fcf5d 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 5de631c6a581062eef71cd2a7cf8f16995051b54..afa68c479d257fbd2c008d9e7651d419504fe5da 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 114f8d29ba20f94886412bb8edf343552da1c030..e0191ae734df1362077648e53579ae4609f40228 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 b6b296995b6479ddab561a427a1ae2f6358cd9ff..03a3455c898f7dadf40b9f2aa804661f83e2180a 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 eb3e1eb49abb7817ca1e1705f5791a492786cbe7..3dd25e18c14f614a48381272ba529a92ddb0a1e6 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 618b5080ab676e4f75fd64175fbe1f0842921d47..401a9bc60d662e12ce1480d31969838d8480af7e 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 ba70d4a069d5dc997e3730e316cbd91556bd38b1..dbef6a5c6973c77b0a6d56ec05aeaa5687065076 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 525b1cab2259320d792fe630cb33f83c2947605b..521e43557dc27e4e28b682918203519ab771c32e 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 c8de41bb3be4be2b6b76793034f80707f78e77f3..58eb9a190d71f2a4e4a6a1e17d13f852ed1d4e42 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 79ca890eed1408b483c5c515a93eb0ff58b90845..6183f2eedf44d8ecdd6c80da422ff51a51bbdfbd 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 fb4c601bc2ac4a8bedfc8636cd3f48f23a94a8bc..f1c27e33a27a0af32bb4657264fb1f5885b98ac1 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 b5fc83e99701c3142cfc2b2dbde64b3dc3b2748b..fc07c4c52185c535177d8f2ee74d0fa5836c01f3 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 e7626122c33d7e2917dcd2916b9dc80c87fb7d26..709c303a850afb91c5314d18b4de1b21b3eb19d1 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 337ac9f9802efa892dabb4a8a40343830aa8adf2..a951b8805bb79e80682edca89ec43369ef15398f 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 19add3fe825ce8f1da37181eb06aacfbf212ec6d..c1f628f9b4f334126a3d6c3755e6677009ffe43b 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 5c1941e64adf384f60d7a8499993101042b35fb9..972697de78d99dda2523deabab6ca224f398256f 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 87e95de0f8b4416694a6cd1e0fddf31a8136ce6c..98998a72cb5de5792f4f9edd7f9d1e02e0ee5deb 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 1cd0063b2db35e5d6cb03239193233c6b63f251c..3bfa90793bd87bdf1cdd59701b416f3171cb114a 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 2d74a381a6d74073328920a21f57a4a78b5dba80..c2c4edc56f7b4861baec235f4624d1e369c3f95a 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 524f4d2819bc900780cf8f257883bb49117de473..1879dbc29504ec23134792f735b6501812a6a8d2 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 0b2f70829e930034f41963bcde63901848c6bee8..386842804326c5b4a690bcfc026d58c6cf90ae65 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 86916fcee8996fa9eddff765a3e5ba9e6b20943b..a188614afe8138c590e299b1c6175665c30fae49 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 9e8427ba8345f85a25e13606a9daf16396868d2a..bad4a83a9a53c20f52cca927b454cbf83cbdaf4a 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 fd47c74070dd544bddbe31b26b1d7089259ff25c..f002c49632352ae7b6c3cc74f0799464a1f2a975 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 152b4dcad93453b5bd8bcb413fcf563f497a65a0..bd0379584078b74b1aaaea84ff18b5d181034734 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 5c2d8614b0ab3dbe72e8658d10cd19f742ddc3a7..274e670b94206400581527c4655415ae2ac5de0a 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 d4d298443e1e13ec2d1ab51a7d27da051d7fe8e3..3acc90ea4cc40a0bd3ea1ccad99b7d18df028451 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 8a7530cd27e6350b02a9e2fe80539b0150eb6bb0..6aff2691eacc41d8abb59b517250eca2da5ba541 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 f45877c0fe6ca19ae913f92b255e07dbba077da6..db1c57fae4318650cafeab3bb0246a39d324873c 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 bb3677dda6ad5cfe2d1914f6abc9ac2e75754e88..7622cc9fec3ad665d682586739242b0202b6ede8 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 72458f30fcd513c6e37ce650f8c54a4e1fe0792a..85fd7bda53c44f389a95f137543e8fed06dd7af9 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 e115ddb0b3db1f6521e0798d4e4102736d335cd2..3bca73e21cf0ad084a850b0789e3f3b63ea19132 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 03356ccfcbbe933aaa7338478d1cf7f4e535c9fa..269c1fc066c7cfef560a3d4f6e7812e62d5e9854 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 9dd0d01c35af74ca874b216cdcd68c7948b2f5a1..1b83925e74fa5bb3489fae332c7ab8bcc9e08546 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 98f4431c7bfdb16831327dffe9a5638f95a72e70..7cc617ab3c50607dbe60f1c6ea03b55a369b6dc2 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 c21b67a4f9c2a85a4700599b71b097f1dc20dab7..7cb70d4a68bf1a9e66341dc46e0a5b2413fda83a 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 076faefb1c6ba9e77ca62d17bfa786375bdce807..15287f2b44688664675d25e32e4c7cea3c265609 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 9181a16e27cf5e0c198c0129084647d5c2f40466..768730d416da1fcc937a48983d6253569e131c74 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 90b5591ece52afef9e3fabeefae91a48977cbbc7..dff815be9dab86b6866c4a42f204d4ec5a0016c5 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 2894cd4dfffcaa53154b1322b8db2adf3ec9bcc2..43cf582097624f8e5b92691d23db749211fea926 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 a7d2aeb3e7d46151e3139b308eaaf454b9d24407..3be9fcf0fb1b8709794f55db7634472e861800f7 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();