Changeset 107170 in webkit
- Timestamp:
- Feb 8, 2012 7:34:29 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107168 r107170 1 2012-02-08 Adam Klein <adamk@chromium.org> 2 3 DOM mutations should not be delivered on worker threads 4 https://bugs.webkit.org/show_bug.cgi?id=77898 5 6 Reviewed by Dmitry Titov. 7 8 In V8RecursionScope, only call WebKitMutationObserver::deliverAllMutations 9 if in a Document context. 10 11 This is accomplished through a change to V8Proxy::instrumentedCallFunction 12 (which now takes a Frame* instead of a Page*), requiring an update to all 13 callers of that function (accounting for the majority of files changed 14 in this patch). 15 16 Added ASSERT(isMainThread()) in a deliverAllMutations to confirm that 17 it's no longer called on worker threads, and in enqueueMutationRecord, 18 where the same global store of active observers is accessed. 19 20 See also http://crbug.com/112586, where the problem was initially 21 reported. 22 23 * bindings/v8/ScriptFunctionCall.cpp: 24 (WebCore::ScriptCallback::call): 25 * bindings/v8/V8NodeFilterCondition.cpp: 26 (WebCore::V8NodeFilterCondition::acceptNode): 27 * bindings/v8/V8Proxy.cpp: 28 (WebCore::V8Proxy::runScript): 29 (WebCore::V8Proxy::callFunction): 30 (WebCore::V8Proxy::instrumentedCallFunction): 31 * bindings/v8/V8Proxy.h: 32 (WebCore): 33 (V8Proxy): 34 * bindings/v8/V8RecursionScope.cpp: 35 (WebCore::V8RecursionScope::didLeaveScriptContext): 36 * bindings/v8/V8RecursionScope.h: 37 (WebCore): 38 (WebCore::V8RecursionScope::V8RecursionScope): 39 (V8RecursionScope): 40 (WebCore::V8RecursionScope::~V8RecursionScope): 41 * bindings/v8/V8WindowErrorHandler.cpp: 42 (WebCore::V8WindowErrorHandler::callListenerFunction): 43 * bindings/v8/custom/V8CustomVoidCallback.cpp: 44 (WebCore::invokeCallback): 45 * bindings/v8/custom/V8CustomXPathNSResolver.cpp: 46 (WebCore::V8CustomXPathNSResolver::lookupNamespaceURI): 47 * dom/WebKitMutationObserver.cpp: 48 (WebCore::WebKitMutationObserver::enqueueMutationRecord): 49 (WebCore::WebKitMutationObserver::deliverAllMutations): 50 1 51 2012-02-08 Anders Carlsson <andersca@apple.com> 2 52 -
trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp
r101490 r107170 198 198 args[i] = m_arguments[i].v8Value(); 199 199 200 v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(0 /* page */, function, object, m_arguments.size(), args.get());200 v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(0 /* frame */, function, object, m_arguments.size(), args.get()); 201 201 202 202 if (exceptionCatcher.HasCaught()) { -
trunk/Source/WebCore/bindings/v8/V8NodeFilterCondition.cpp
r101490 r107170 84 84 args[0] = toV8(node); 85 85 86 v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(0 /* page */, callback, object, 1, args.get());86 v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(0 /* frame */, callback, object, 1, args.get()); 87 87 88 88 if (exceptionCatcher.HasCaught()) { -
trunk/Source/WebCore/bindings/v8/V8Proxy.cpp
r106698 r107170 379 379 tryCatch.SetVerbose(true); 380 380 { 381 V8RecursionScope recursionScope ;381 V8RecursionScope recursionScope(frame()->document()); 382 382 result = script->Run(); 383 383 } … … 405 405 // Keep Frame (and therefore ScriptController and V8Proxy) alive. 406 406 RefPtr<Frame> protect(frame()); 407 return V8Proxy::instrumentedCallFunction( m_frame->page(), function, receiver, argc, args);408 } 409 410 v8::Local<v8::Value> V8Proxy::instrumentedCallFunction( Page* page, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])407 return V8Proxy::instrumentedCallFunction(frame(), function, receiver, argc, args); 408 } 409 410 v8::Local<v8::Value> V8Proxy::instrumentedCallFunction(Frame* frame, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]) 411 411 { 412 412 V8GCController::checkMemoryUsage(); … … 416 416 417 417 InspectorInstrumentationCookie cookie; 418 if (InspectorInstrumentation::hasFrontends() ) {418 if (InspectorInstrumentation::hasFrontends() && frame) { 419 419 String resourceName("undefined"); 420 420 int lineNumber = 1; … … 424 424 lineNumber = function->GetScriptLineNumber() + 1; 425 425 } 426 cookie = InspectorInstrumentation::willCallFunction( page, resourceName, lineNumber);426 cookie = InspectorInstrumentation::willCallFunction(frame->page(), resourceName, lineNumber); 427 427 } 428 428 429 429 v8::Local<v8::Value> result; 430 430 { 431 V8RecursionScope recursionScope ;431 V8RecursionScope recursionScope(frame ? frame->document() : 0); 432 432 result = function->Call(receiver, argc, args); 433 433 } -
trunk/Source/WebCore/bindings/v8/V8Proxy.h
r105815 r107170 58 58 class Frame; 59 59 class Node; 60 class Page;61 60 class ScriptExecutionContext; 62 61 class ScriptSourceCode; … … 163 162 164 163 // call the function with the given receiver and arguments and report times to DevTools. 165 static v8::Local<v8::Value> instrumentedCallFunction( Page*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]);164 static v8::Local<v8::Value> instrumentedCallFunction(Frame*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]); 166 165 167 166 // Call the function as constructor with the given arguments. -
trunk/Source/WebCore/bindings/v8/V8RecursionScope.cpp
r102067 r107170 33 33 34 34 #include "IDBPendingTransactionMonitor.h" 35 #include "ScriptExecutionContext.h" 35 36 #include "WebKitMutationObserver.h" 36 37 37 38 namespace WebCore { 38 39 39 void V8RecursionScope::didLeaveScriptContext( )40 void V8RecursionScope::didLeaveScriptContext(ScriptExecutionContext* context) 40 41 { 41 42 // FIXME: Instrument any work that takes place when script exits to c++ (e.g. Mutation Observers). … … 49 50 50 51 #if ENABLE(MUTATION_OBSERVERS) 51 WebKitMutationObserver::deliverAllMutations(); 52 if (context && context->isDocument()) 53 WebKitMutationObserver::deliverAllMutations(); 52 54 #endif 53 55 } -
trunk/Source/WebCore/bindings/v8/V8RecursionScope.h
r102067 r107170 36 36 namespace WebCore { 37 37 38 class ScriptExecutionContext; 39 38 40 class V8RecursionScope { 39 41 WTF_MAKE_NONCOPYABLE(V8RecursionScope); 40 42 public: 41 V8RecursionScope() { V8BindingPerIsolateData::current()->incrementRecursionLevel(); } 43 explicit V8RecursionScope(ScriptExecutionContext* context) 44 : m_context(context) 45 { 46 V8BindingPerIsolateData::current()->incrementRecursionLevel(); 47 } 48 42 49 ~V8RecursionScope() 43 50 { 44 51 if (!V8BindingPerIsolateData::current()->decrementRecursionLevel()) 45 didLeaveScriptContext( );52 didLeaveScriptContext(m_context); 46 53 } 47 54 … … 49 56 50 57 private: 51 static void didLeaveScriptContext(); 58 static void didLeaveScriptContext(ScriptExecutionContext*); 59 60 ScriptExecutionContext* m_context; 52 61 }; 53 62 -
trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp
r101716 r107170 59 59 v8::TryCatch tryCatch; 60 60 tryCatch.SetVerbose(true); 61 returnValue = V8Proxy::instrumentedCallFunction(0 /* page */, callFunction, thisValue, 3, parameters);61 returnValue = V8Proxy::instrumentedCallFunction(0 /* frame */, callFunction, thisValue, 3, parameters); 62 62 } 63 63 return returnValue; -
trunk/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp
r95901 r107170 84 84 v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global(); 85 85 86 Page* page = scriptExecutionContext && scriptExecutionContext->isDocument() ? static_cast<Document*>(scriptExecutionContext)->page() : 0;87 v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction( page, callbackFunction, thisObject, argc, argv);86 Frame* frame = scriptExecutionContext && scriptExecutionContext->isDocument() ? static_cast<Document*>(scriptExecutionContext)->frame() : 0; 87 v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(frame, callbackFunction, thisObject, argc, argv); 88 88 89 89 callbackReturnValue = !result.IsEmpty() && result->BooleanValue(); -
trunk/Source/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp
r104803 r107170 80 80 v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; 81 81 82 v8::Handle<v8::Value> retval = V8Proxy::instrumentedCallFunction(0 /* page */, function, m_resolver, argc, argv);82 v8::Handle<v8::Value> retval = V8Proxy::instrumentedCallFunction(0 /* frame */, function, m_resolver, argc, argv); 83 83 84 84 // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR. -
trunk/Source/WebCore/dom/WebKitMutationObserver.cpp
r103001 r107170 42 42 #include "Node.h" 43 43 #include <wtf/ListHashSet.h> 44 #include <wtf/MainThread.h> 44 45 45 46 namespace WebCore { … … 116 117 void WebKitMutationObserver::enqueueMutationRecord(PassRefPtr<MutationRecord> mutation) 117 118 { 119 ASSERT(isMainThread()); 118 120 m_records.append(mutation); 119 121 activeMutationObservers().add(this); … … 133 135 void WebKitMutationObserver::deliverAllMutations() 134 136 { 137 ASSERT(isMainThread()); 135 138 static bool deliveryInProgress = false; 136 139 if (deliveryInProgress) -
trunk/Source/WebKit/chromium/ChangeLog
r107166 r107170 1 2012-02-08 Adam Klein <adamk@chromium.org> 2 3 DOM mutations should not be delivered on worker threads 4 https://bugs.webkit.org/show_bug.cgi?id=77898 5 6 Reviewed by Dmitry Titov. 7 8 * src/WebDevToolsFrontendImpl.cpp: 9 (WebKit::WebDevToolsFrontendImpl::dispatchOnInspectorFrontend): 10 1 11 2012-02-08 Scott Graham <scottmg@chromium.org> 2 12 -
trunk/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp
r101503 r107170 124 124 v8::TryCatch tryCatch; 125 125 tryCatch.SetVerbose(true); 126 V8Proxy::instrumentedCallFunction(frame->frame() ->page(), function, inspectorBackend, args.size(), args.data());126 V8Proxy::instrumentedCallFunction(frame->frame(), function, inspectorBackend, args.size(), args.data()); 127 127 } 128 128
Note: See TracChangeset
for help on using the changeset viewer.