ScriptExecutionContext::vm() should return a reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Mar 2014 20:21:05 +0000 (20:21 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Mar 2014 20:21:05 +0000 (20:21 +0000)
<https://webkit.org/b/129611>

Every ScriptExecutionContext has a VM, so this can never return null.
Made WorkerScriptController::vm() return a reference as well, since
that was needed for this change.

Reviewed by Geoffrey Garen.

* bindings/js/WorkerScriptController.h:
(WebCore::WorkerScriptController::vm):
* bindings/js/WorkerScriptDebugServer.cpp:
(WebCore::WorkerScriptDebugServer::recompileAllJSFunctions):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::ruleMatches):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::vm):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createImageBuffer):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::dropProtection):
* testing/Internals.cpp:
(WebCore::Internals::parserMetaData):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/WorkerScriptController.h
Source/WebCore/bindings/js/WorkerScriptDebugServer.cpp
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/dom/SelectorQuery.cpp
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in

index fee41ef8f8f75bdcf334ec2250f8e5d865f94b22..5922fe20fe4b3b9ae37d3d7ce53dc30fd72133c3 100644 (file)
@@ -1,3 +1,32 @@
+2014-03-16  Andreas Kling  <akling@apple.com>
+
+        ScriptExecutionContext::vm() should return a reference.
+        <https://webkit.org/b/129611>
+
+        Every ScriptExecutionContext has a VM, so this can never return null.
+        Made WorkerScriptController::vm() return a reference as well, since
+        that was needed for this change.
+
+        Reviewed by Geoffrey Garen.
+
+        * bindings/js/WorkerScriptController.h:
+        (WebCore::WorkerScriptController::vm):
+        * bindings/js/WorkerScriptDebugServer.cpp:
+        (WebCore::WorkerScriptDebugServer::recompileAllJSFunctions):
+        * css/ElementRuleCollector.cpp:
+        (WebCore::ElementRuleCollector::ruleMatches):
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::vm):
+        * dom/ScriptExecutionContext.h:
+        * dom/SelectorQuery.cpp:
+        (WebCore::SelectorDataList::execute):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createImageBuffer):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::dropProtection):
+        * testing/Internals.cpp:
+        (WebCore::Internals::parserMetaData):
+
 2014-03-16  Zan Dobersek  <zdobersek@igalia.com>
 
         Remove OwnPtr.h, PassOwnPtr.h header inclusions in Source/WebCore/html/parser/ code
index 1dffde0fda9d9afbfaecfa88c1e79c3e7f924e5e..ec7ba3a9709e28372bfcdf953ae402ddc94846fd 100644 (file)
@@ -79,7 +79,7 @@ namespace WebCore {
 
         void disableEval(const String& errorMessage);
 
-        JSC::VM* vm() { return m_vm.get(); }
+        JSC::VM& vm() { return *m_vm; }
 
         void attachDebugger(JSC::Debugger*);
         void detachDebugger(JSC::Debugger*);
index 7758dcb7de5d495232f2032c518140a568456a4e..b5a352b0b625a46d2b8da6058c98e0aa67431fc7 100644 (file)
@@ -84,10 +84,10 @@ void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener, bool
 
 void WorkerScriptDebugServer::recompileAllJSFunctions()
 {
-    JSC::VM* vm = m_workerGlobalScope->script()->vm();
+    JSC::VM& vm = m_workerGlobalScope->script()->vm();
 
     JSC::JSLockHolder lock(vm);
-    JSC::Debugger::recompileAllJSFunctions(vm);
+    JSC::Debugger::recompileAllJSFunctions(&vm);
 }
 
 void WorkerScriptDebugServer::runEventLoopWhilePaused()
index 26e3821995f8ee7812e215954a21fc01fd92f131..a25a1ca001b62e6f5c0a1728fb6ff4435aebf693 100644 (file)
@@ -288,10 +288,10 @@ inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, PseudoId
 #if ENABLE(CSS_SELECTOR_JIT)
     void* compiledSelectorChecker = ruleData.compiledSelectorCodeRef().code().executableAddress();
     if (!compiledSelectorChecker && ruleData.compilationStatus() == SelectorCompilationStatus::NotCompiled) {
-        JSC::VM* vm = m_element.document().scriptExecutionContext()->vm();
+        JSC::VM& vm = m_element.document().scriptExecutionContext()->vm();
         SelectorCompilationStatus compilationStatus;
         JSC::MacroAssemblerCodeRef compiledSelectorCodeRef;
-        compilationStatus = SelectorCompiler::compileSelector(ruleData.selector(), vm, SelectorCompiler::SelectorContext::RuleCollector, compiledSelectorCodeRef);
+        compilationStatus = SelectorCompiler::compileSelector(ruleData.selector(), &vm, SelectorCompiler::SelectorContext::RuleCollector, compiledSelectorCodeRef);
 
         ruleData.setCompiledSelector(compilationStatus, compiledSelectorCodeRef);
         compiledSelectorChecker = ruleData.compiledSelectorCodeRef().code().executableAddress();
index e90e02683f6bd38c170cdeb28a5c96c54596af96..619f953b94d150bed2bfc4d1dfa1fca91a1d25aa 100644 (file)
@@ -403,16 +403,12 @@ ScriptExecutionContext::Task::~Task()
 {
 }
 
-JSC::VM* ScriptExecutionContext::vm()
+JSC::VM& ScriptExecutionContext::vm()
 {
      if (isDocument())
-        return &JSDOMWindow::commonVM();
+        return JSDOMWindow::commonVM();
 
-    if (isWorkerGlobalScope())
-        return toWorkerGlobalScope(this)->script()->vm();
-
-    ASSERT_NOT_REACHED();
-    return 0;
+    return toWorkerGlobalScope(*this).script()->vm();
 }
 
 #if ENABLE(SQL_DATABASE)
index edc5494db5721330eb005b23fb4b049e3fd94bbd..40e4b7973b129326eea14eee236efa52ae3eb5e1 100644 (file)
@@ -143,7 +143,7 @@ public:
     void removeTimeout(int timeoutId) { m_timeouts.remove(timeoutId); }
     DOMTimer* findTimeout(int timeoutId) { return m_timeouts.get(timeoutId); }
 
-    JSC::VM* vm();
+    JSC::VM& vm();
 
     // Interval is in seconds.
     void adjustMinimumTimerInterval(double oldMinimumTimerInterval);
index 9bc0a83ddc55d045497a2eadd7a6b81f64706457..2f978b2efdefdec16370700166ad3faea3d795cf 100644 (file)
@@ -399,8 +399,8 @@ ALWAYS_INLINE void SelectorDataList::execute(ContainerNode& rootNode, typename S
         const SelectorData& selectorData = m_selectors.first();
         ASSERT(m_matchType == RightMostWithIdMatch || selectorData.compilationStatus == SelectorCompilationStatus::NotCompiled);
 
-        JSC::VM* vm = searchRootNode->document().scriptExecutionContext()->vm();
-        selectorData.compilationStatus = SelectorCompiler::compileSelector(selectorData.selector, vm, SelectorCompiler::SelectorContext::QuerySelector, selectorData.compiledSelectorCodeRef);
+        JSC::VM& vm = searchRootNode->document().scriptExecutionContext()->vm();
+        selectorData.compilationStatus = SelectorCompiler::compileSelector(selectorData.selector, &vm, SelectorCompiler::SelectorContext::QuerySelector, selectorData.compiledSelectorCodeRef);
         RELEASE_ASSERT(selectorData.compilationStatus != SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
 
         if (selectorData.compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker) {
index 10218dd88b96f1979ebbc61e7037e7bf59a528e0..31d5ebd22d6b66dad66d619a74d7fd4a2c56648b 100644 (file)
@@ -598,7 +598,7 @@ void HTMLCanvasElement::createImageBuffer() const
 
     JSC::JSLockHolder lock(scriptExecutionContext()->vm());
     size_t numBytes = 4 * m_imageBuffer->internalSize().width() * m_imageBuffer->internalSize().height();
-    scriptExecutionContext()->vm()->heap.reportExtraMemoryCost(numBytes);
+    scriptExecutionContext()->vm().heap.reportExtraMemoryCost(numBytes);
 
 #if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
     if (m_context && m_context->is2d())
index 411aba3aa1a171ebbdd5f0e8ea35e08ff1ff702a..1e2bdafe3325143360d3592a9ad287df79e660a9 100644 (file)
@@ -1198,8 +1198,8 @@ private:
 
 String Internals::parserMetaData(Deprecated::ScriptValue value)
 {
-    JSC::VM* vm = contextDocument()->vm();
-    JSC::ExecState* exec = vm->topCallFrame;
+    JSC::VM& vm = contextDocument()->vm();
+    JSC::ExecState* exec = vm.topCallFrame;
     JSC::JSValue code = value.jsValue();
     ScriptExecutable* executable;
 
index 351f185a1994a273bb478fb4e6f7520697ba900f..e3de46d71459d911e797aff3faf3a65d55a534bb 100644 (file)
@@ -932,9 +932,9 @@ void XMLHttpRequest::dropProtection()
     // out. But it is protected from GC while loading, so this
     // can't be recouped until the load is done, so only
     // report the extra cost at that point.
-    JSC::VM* vm = scriptExecutionContext()->vm();
+    JSC::VM& vm = scriptExecutionContext()->vm();
     JSC::JSLockHolder lock(vm);
-    vm->heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);
+    vm.heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);
 
     unsetPendingActivity(this);
 }
index d78716eeffad1c538956b04084d168fdd33471c5..8c41cd7c16a39312eac955022975fa3302276c5d 100644 (file)
@@ -471,7 +471,7 @@ EXPORTS
         symbolWithPointer(?storeUpdatedQuotaForOrigin@ApplicationCacheStorage@WebCore@@QAE_NPBVSecurityOrigin@2@_J@Z, ?storeUpdatedQuotaForOrigin@ApplicationCacheStorage@WebCore@@QEAA_NPEBVSecurityOrigin@2@_J@Z)
         symbolWithPointer(?cacheStorage@WebCore@@YAAAVApplicationCacheStorage@1@XZ, ?cacheStorage@WebCore@@YAAEAVApplicationCacheStorage@1@XZ)
         symbolWithPointer(?setDefaultOriginQuota@ApplicationCacheStorage@WebCore@@QAEX_J@Z, ?setDefaultOriginQuota@ApplicationCacheStorage@WebCore@@QEAAX_J@Z)
-        symbolWithPointer(?vm@ScriptExecutionContext@WebCore@@QAEPAVVM@JSC@@XZ, ?vm@ScriptExecutionContext@WebCore@@QEAAPEAVVM@JSC@@XZ)
+        symbolWithPointer(?vm@ScriptExecutionContext@WebCore@@QAEAAVVM@JSC@@XZ, ?vm@ScriptExecutionContext@WebCore@@QEAAAEAVVM@JSC@@XZ)
         symbolWithPointer(?completeURL@Document@WebCore@@UBE?AVURL@2@ABVString@WTF@@@Z, ?completeURL@Document@WebCore@@UEBA?AVURL@2@AEBVString@WTF@@@Z)
         symbolWithPointer(??1DOMWindow@WebCore@@UAE@XZ, ??1DOMWindow@WebCore@@UEAA@XZ)
         symbolWithPointer(?visibleContentRect@ScrollableArea@WebCore@@QBE?AVIntRect@2@W4VisibleContentRectBehavior@12@@Z, ?visibleContentRect@ScrollableArea@WebCore@@QEBA?AVIntRect@2@W4VisibleContentRectBehavior@12@@Z)