Changeset 133281 in webkit
- Timestamp:
- Nov 2, 2012 3:24:40 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r133279 r133281 1 2012-11-02 Peter Wang <peter.wang@torchmobile.com.cn> 2 3 Web Inspector: [JSC] implement WorkerScriptDebugServer 4 https://bugs.webkit.org/show_bug.cgi?id=99801 5 6 Reviewed by Yury Semikhatsky. 7 8 To implement Worker Inspector for JSC. 9 The virtual function "runEventLoopWhilePaused" is defined, since there are different ways to block 10 the JS running in worker-context and normal page-context. 11 The function "isContentScript" now is virtual because the original invoked functions are useless 12 and cause problem in worker-context. 13 In function "WebCore::WorkerScriptController::attachDebugger", we invoke "initScriptIfNeeded" to 14 ensure the JSGloblalObject exist in the case of attaching Debugger before executing the worker 15 JS code (Pause on start). 16 17 No new test case. 18 19 * bindings/js/PageScriptDebugServer.cpp: 20 (WebCore::PageScriptDebugServer::runEventLoopWhilePaused): 21 (WebCore): 22 * bindings/js/PageScriptDebugServer.h: 23 (PageScriptDebugServer): 24 * bindings/js/ScriptDebugServer.cpp: 25 (WebCore::ScriptDebugServer::isContentScript): 26 (WebCore::ScriptDebugServer::pauseIfNeeded): 27 * bindings/js/ScriptDebugServer.h: 28 (JSC): 29 (ScriptDebugServer): 30 * bindings/js/WorkerScriptController.cpp: 31 (WebCore::WorkerScriptController::attachDebugger): 32 (WebCore): 33 (WebCore::WorkerScriptController::detachDebugger): 34 * bindings/js/WorkerScriptController.h: 35 (WorkerScriptController): 36 * bindings/js/WorkerScriptDebugServer.cpp: 37 (WebCore::WorkerScriptDebugServer::WorkerScriptDebugServer): 38 (WebCore): 39 (WebCore::WorkerScriptDebugServer::addListener): 40 (WebCore::WorkerScriptDebugServer::recompileAllJSFunctions): 41 (WebCore::WorkerScriptDebugServer::removeListener): 42 (WebCore::WorkerScriptDebugServer::runEventLoopWhilePaused): 43 * bindings/js/WorkerScriptDebugServer.h: 44 (WorkerScriptDebugServer): 45 (WebCore::WorkerScriptDebugServer::getListenersForGlobalObject): 46 (WebCore::WorkerScriptDebugServer::isContentScript): 47 1 48 2012-11-02 KyungTae Kim <ktf.kim@samsung.com> 2 49 -
trunk/Source/WebCore/bindings/js/PageScriptDebugServer.cpp
r131826 r133281 35 35 #include "PageScriptDebugServer.h" 36 36 37 #include "EventLoop.h" 37 38 #include "Frame.h" 38 39 #include "FrameView.h" … … 164 165 } 165 166 167 void PageScriptDebugServer::runEventLoopWhilePaused() 168 { 169 EventLoop loop; 170 while (!m_doneProcessingDebuggerEvents && !loop.ended()) 171 loop.cycle(); 172 } 173 166 174 void PageScriptDebugServer::setJavaScriptPaused(const PageGroup& pageGroup, bool paused) 167 175 { -
trunk/Source/WebCore/bindings/js/PageScriptDebugServer.h
r116917 r133281 64 64 virtual void didContinue(JSC::JSGlobalObject*); 65 65 66 virtual void runEventLoopWhilePaused(); 67 66 68 void didRemoveLastListener(Page*); 67 69 -
trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp
r130615 r133281 35 35 36 36 #include "ContentSearchUtils.h" 37 #include "EventLoop.h"38 37 #include "Frame.h" 39 38 #include "JSJavaScriptCallFrame.h" … … 335 334 } 336 335 337 static boolisContentScript(ExecState* exec)336 bool ScriptDebugServer::isContentScript(ExecState* exec) 338 337 { 339 338 return currentWorld(exec) != mainThreadNormalWorld(); … … 443 442 TimerBase::fireTimersInNestedEventLoop(); 444 443 445 EventLoop loop;446 444 m_doneProcessingDebuggerEvents = false; 447 while (!m_doneProcessingDebuggerEvents && !loop.ended()) 448 loop.cycle(); 445 runEventLoopWhilePaused(); 449 446 450 447 didContinue(dynamicGlobalObject); -
trunk/Source/WebCore/bindings/js/ScriptDebugServer.h
r130615 r133281 47 47 class DebuggerCallFrame; 48 48 class JSGlobalObject; 49 class ExecState; 49 50 } 50 51 namespace WebCore { … … 114 115 virtual void didContinue(JSC::JSGlobalObject*) = 0; 115 116 117 virtual void runEventLoopWhilePaused() = 0; 118 119 virtual bool isContentScript(JSC::ExecState*); 120 116 121 bool hasBreakpoint(intptr_t sourceID, const TextPosition&) const; 117 122 -
trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp
r132143 r133281 39 39 #include "WorkerContext.h" 40 40 #include "WorkerObjectProxy.h" 41 #include "WorkerScriptDebugServer.h" 41 42 #include "WorkerThread.h" 42 43 #include <heap/StrongInlines.h> … … 198 199 } 199 200 201 void WorkerScriptController::attachDebugger(JSC::Debugger* debugger) 202 { 203 initScriptIfNeeded(); 204 debugger->attach(m_workerContextWrapper->globalObject()); 205 } 206 207 void WorkerScriptController::detachDebugger(JSC::Debugger* debugger) 208 { 209 debugger->detach(m_workerContextWrapper->globalObject()); 210 } 211 200 212 } // namespace WebCore 201 213 -
trunk/Source/WebCore/bindings/js/WorkerScriptController.h
r128670 r133281 30 30 31 31 #if ENABLE(WORKERS) 32 32 #include <debugger/Debugger.h> 33 33 #include <heap/Strong.h> 34 34 #include <wtf/Forward.h> … … 80 80 JSC::JSGlobalData* globalData() { return m_globalData.get(); } 81 81 82 void attachDebugger(JSC::Debugger*); 83 void detachDebugger(JSC::Debugger*); 84 82 85 private: 83 86 void initScriptIfNeeded() -
trunk/Source/WebCore/bindings/js/WorkerScriptDebugServer.cpp
r108344 r133281 32 32 33 33 #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(WORKERS) 34 #include "WorkerScriptDebugServer.h" 34 35 35 #include "WorkerScriptDebugServer.h" 36 #include "WorkerContext.h" 37 #include "WorkerDebuggerAgent.h" 38 #include "WorkerRunLoop.h" 39 #include "WorkerThread.h" 40 36 41 #include <wtf/PassOwnPtr.h> 37 42 … … 40 45 const char* WorkerScriptDebugServer::debuggerTaskMode = "debugger"; 41 46 42 WorkerScriptDebugServer::WorkerScriptDebugServer(WorkerContext* )47 WorkerScriptDebugServer::WorkerScriptDebugServer(WorkerContext* context) 43 48 : ScriptDebugServer() 49 , m_workerContext(context) 44 50 { 45 51 } 46 52 47 void WorkerScriptDebugServer::addListener(ScriptDebugListener* )53 void WorkerScriptDebugServer::addListener(ScriptDebugListener* listener) 48 54 { 55 if (!listener) 56 return; 57 58 if (m_listeners.isEmpty()) 59 m_workerContext->script()->attachDebugger(this); 60 m_listeners.add(listener); 61 recompileAllJSFunctions(0); 49 62 } 50 63 51 void WorkerScriptDebugServer::re moveListener(ScriptDebugListener*)64 void WorkerScriptDebugServer::recompileAllJSFunctions(Timer<ScriptDebugServer>*) 52 65 { 66 JSC::JSGlobalData* globalData = m_workerContext->script()->globalData(); 67 68 JSC::JSLockHolder lock(globalData); 69 // If JavaScript stack is not empty postpone recompilation. 70 if (globalData->dynamicGlobalObject) 71 recompileAllJSFunctionsSoon(); 72 else 73 JSC::Debugger::recompileAllJSFunctions(globalData); 74 } 75 76 void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener) 77 { 78 if (!listener) 79 return; 80 81 m_listeners.remove(listener); 82 if (m_listeners.isEmpty()) 83 m_workerContext->script()->detachDebugger(this); 84 } 85 86 void WorkerScriptDebugServer::runEventLoopWhilePaused() 87 { 88 MessageQueueWaitResult result; 89 do { 90 result = m_workerContext->thread()->runLoop().runInMode(m_workerContext, WorkerDebuggerAgent::debuggerTaskMode); 91 // Keep waiting until execution is resumed. 92 } while (result != MessageQueueTerminated && !m_doneProcessingDebuggerEvents); 53 93 } 54 94 -
trunk/Source/WebCore/bindings/js/WorkerScriptDebugServer.h
r108344 r133281 53 53 void interruptAndRunTask(PassOwnPtr<ScriptDebugServer::Task>); 54 54 55 void recompileAllJSFunctions(Timer<ScriptDebugServer>*); 56 55 57 private: 56 virtual void recompileAllJSFunctions(Timer<ScriptDebugServer>*) { } 57 virtual ListenerSet* getListenersForGlobalObject(JSC::JSGlobalObject*) { return 0; } 58 virtual ListenerSet* getListenersForGlobalObject(JSC::JSGlobalObject*) { return &m_listeners; } 58 59 virtual void didPause(JSC::JSGlobalObject*) { } 59 60 virtual void didContinue(JSC::JSGlobalObject*) { } 61 62 virtual bool isContentScript(JSC::ExecState*) { return false; } 63 64 virtual void runEventLoopWhilePaused(); 65 66 WorkerContext* m_workerContext; 67 ListenerSet m_listeners; 60 68 }; 61 69
Note: See TracChangeset
for help on using the changeset viewer.