Changeset 55816 in webkit
- Timestamp:
- Mar 10, 2010 4:08:18 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r55815 r55816 1 2010-03-10 Dmitry Titov <dimich@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Make Document::postTask to use a single queue of tasks, to fire them in order 6 https://bugs.webkit.org/show_bug.cgi?id=35943 7 8 The patch uses CFRunLoopTimer to schedule execution of tasks instead of performSelectorOnMainThread which apparently can starve other event sources. 9 The timer is used when the schedule request is coming on the main thread itself. This happens when the task is posted on the main thread or 10 when too many tasks are posted and the queue does 'stop and re-schedule' to make sure run loop has a chance to execute other events. 11 12 * wtf/mac/MainThreadMac.mm: 13 (WTF::timerFired): 14 (WTF::postTimer): 15 (WTF::scheduleDispatchFunctionsOnMainThread): Use timer posted to the current RunLoop if scheduling the task execution while on the main thread. 16 1 17 2010-03-10 Geoffrey Garen <ggaren@apple.com> 2 18 -
trunk/JavaScriptCore/wtf/mac/MainThreadMac.mm
r52046 r55816 30 30 #import "MainThread.h" 31 31 32 #import <CoreFoundation/CoreFoundation.h> 32 33 #import <Foundation/NSThread.h> 33 34 #import <wtf/Assertions.h> 35 #import <wtf/Threading.h> 34 36 35 37 @interface WTFMainThreadCaller : NSObject { … … 64 66 } 65 67 68 static bool isTimerPosted; // This is only accessed on the 'main' thread. 69 70 static void timerFired(CFRunLoopTimerRef timer, void*) 71 { 72 CFRelease(timer); 73 isTimerPosted = false; 74 WTF::dispatchFunctionsFromMainThread(); 75 } 76 77 void postTimer() 78 { 79 ASSERT(isMainThread()); 80 81 if (isTimerPosted) 82 return; 83 84 isTimerPosted = true; 85 CFRunLoopAddTimer(CFRunLoopGetCurrent(), CFRunLoopTimerCreate(0, 0, 0, 0, 0, timerFired, 0), kCFRunLoopCommonModes); 86 } 87 88 66 89 void scheduleDispatchFunctionsOnMainThread() 67 90 { 68 91 ASSERT(staticMainThreadCaller); 92 93 if (isMainThread()) { 94 postTimer(); 95 return; 96 } 97 69 98 #if USE(WEB_THREAD) 70 99 [staticMainThreadCaller performSelector:@selector(call) onThread:webThread withObject:nil waitUntilDone:NO]; -
trunk/LayoutTests/ChangeLog
r55804 r55816 1 2010-03-10 Dmitry Titov <dimich@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Make Document::postTask to use a single queue of tasks, to fire them in order 6 https://bugs.webkit.org/show_bug.cgi?id=35943 7 8 Updated the test since the order of events coming from independent task sources has changed. 9 This is a behavior change, but is consistent with the spec (which specifically says these events may be fired 10 in any order) and the last version of FF (3.5.8) which was completing the test successfully. 11 12 * http/tests/appcache/top-frame-2-expected.txt: 13 * http/tests/appcache/top-frame-2.html: 14 1 15 2010-03-10 Antonio Gomes <tonikitoo@webkit.org> 2 16 -
trunk/LayoutTests/http/tests/appcache/top-frame-2-expected.txt
r39477 r55816 3 3 Should say SUCCESS: 4 4 5 checking6 5 SUCCESS 7 6 -
trunk/LayoutTests/http/tests/appcache/top-frame-2.html
r39477 r55816 17 17 } 18 18 19 function debug(message) 20 { 21 // If running manually in the browser, print the sequence of events. 22 if (!window.layoutTestController) 23 log(message); 24 } 25 26 var receivedExpectedMessage = false; 27 var receivedCheckingEvent = false; 28 var receivedNoupdateEvent = false; 29 19 30 function test() 20 31 { … … 23 34 24 35 // When a new main resource is associated with the cache, an update should be started. 25 applicationCache.onchecking = function() { log("checking") } 36 applicationCache.onchecking = function() { debug("checking"); receivedCheckingEvent = true; checkDone(); } 37 applicationCache.onnoupdate = function() { debug("noupdate"); receivedNoupdateEvent = true; checkDone(); } 26 38 27 39 var ifr = document.createElement("iframe"); 28 40 ifr.setAttribute("src", "resources/subframe-2.html"); 29 41 document.body.appendChild(ifr); 42 } 43 44 function checkDone() 45 { 46 if (receivedExpectedMessage && receivedCheckingEvent && receivedNoupdateEvent) { 47 log("SUCCESS"); 48 if (window.layoutTestController) 49 layoutTestController.notifyDone(); 50 } 30 51 } 31 52 … … 36 57 applicationCache.onerror = function() { log("FAIL: received unexpected error event") } 37 58 38 window.addEventListener("message", function() { log("SUCCESS"); if (window.layoutTestController) layoutTestController.notifyDone()}, false);59 window.addEventListener("message", function() { debug("message"); receivedExpectedMessage = true; checkDone(); }, false); 39 60 40 61 </script> -
trunk/WebCore/ChangeLog
r55814 r55816 1 2010-03-10 Dmitry Titov <dimich@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Make Document::postTask to use a single queue of tasks, to fire them in order 6 https://bugs.webkit.org/show_bug.cgi?id=35943 7 8 Test: existing worker-cloneport.html which was broken by initial patch in http://trac.webkit.org/changeset/55593. 9 Additional test which indirectly verifies the order of execution will come as part of https://bugs.webkit.org/show_bug.cgi?id=34726 10 11 * dom/Document.cpp: 12 (WebCore::Document::postTask): Always use the same task queue, independent of what thread is posting the task. 13 1 14 2010-03-10 Sanjeev Radhakrishnan <sanjeevr@chromium.org> 2 15 -
trunk/WebCore/dom/Document.cpp
r55802 r55816 4686 4686 } 4687 4687 4688 class ScriptExecutionContextTaskTimer : public TimerBase {4689 public:4690 ScriptExecutionContextTaskTimer(PassRefPtr<Document> context, PassOwnPtr<ScriptExecutionContext::Task> task)4691 : m_context(context)4692 , m_task(task)4693 {4694 }4695 4696 private:4697 virtual void fired()4698 {4699 m_task->performTask(m_context.get());4700 delete this;4701 }4702 4703 RefPtr<Document> m_context;4704 OwnPtr<ScriptExecutionContext::Task> m_task;4705 };4706 4707 4688 struct PerformTaskContext : Noncopyable { 4708 4689 PerformTaskContext(PassRefPtr<DocumentWeakReference> documentReference, PassOwnPtr<ScriptExecutionContext::Task> task) … … 4731 4712 void Document::postTask(PassOwnPtr<Task> task) 4732 4713 { 4733 if (isMainThread()) { 4734 ScriptExecutionContextTaskTimer* timer = new ScriptExecutionContextTaskTimer(static_cast<Document*>(this), task); 4735 timer->startOneShot(0); 4736 } else { 4737 callOnMainThread(performTask, new PerformTaskContext(m_weakReference, task)); 4738 } 4714 callOnMainThread(performTask, new PerformTaskContext(m_weakReference, task)); 4739 4715 } 4740 4716
Note: See TracChangeset
for help on using the changeset viewer.