Changeset 157746 in webkit
- Timestamp:
- Oct 21, 2013, 3:00:40 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r157737 r157746 1 2013-10-20 Mark Lam <mark.lam@apple.com> 2 3 Avoid JSC debugger overhead unless needed. 4 https://bugs.webkit.org/show_bug.cgi?id=123084. 5 6 Reviewed by Geoffrey Garen. 7 8 - If no breakpoints are set, we now avoid calling the debug hook callbacks. 9 - If no break on exception is set, we also avoid exception event debug callbacks. 10 - When we return from the ScriptDebugServer to the JSC::Debugger, we may no 11 longer call the debug hook callbacks if not needed. Hence, the m_currentCallFrame 12 pointer in the ScriptDebugServer may become stale. To avoid this issue, before 13 returning, the ScriptDebugServer will clear its m_currentCallFrame if 14 needsOpDebugCallbacks() is false. 15 16 * debugger/Debugger.cpp: 17 (JSC::Debugger::Debugger): 18 (JSC::Debugger::setNeedsExceptionCallbacks): 19 (JSC::Debugger::setShouldPause): 20 (JSC::Debugger::updateNumberOfBreakpoints): 21 (JSC::Debugger::updateNeedForOpDebugCallbacks): 22 * debugger/Debugger.h: 23 * interpreter/Interpreter.cpp: 24 (JSC::Interpreter::unwind): 25 (JSC::Interpreter::debug): 26 * jit/JITOpcodes.cpp: 27 (JSC::JIT::emit_op_debug): 28 * jit/JITOpcodes32_64.cpp: 29 (JSC::JIT::emit_op_debug): 30 * llint/LLIntOffsetsExtractor.cpp: 31 * llint/LowLevelInterpreter.asm: 32 1 33 2013-10-21 Brent Fulgham <bfulgham@apple.com> 2 34 -
trunk/Source/JavaScriptCore/debugger/Debugger.cpp
r157468 r157746 92 92 namespace JSC { 93 93 94 Debugger::Debugger() 95 : m_needsExceptionCallbacks(false) 96 , m_needsOpDebugCallbacks(false) 97 , m_shouldPause(false) 98 , m_numberOfBreakpoints(0) 99 { 100 } 101 94 102 Debugger::~Debugger() 95 103 { … … 113 121 } 114 122 123 void Debugger::setNeedsExceptionCallbacks(bool value) 124 { 125 m_needsExceptionCallbacks = value; 126 } 127 128 void Debugger::setShouldPause(bool value) 129 { 130 m_shouldPause = value; 131 updateNeedForOpDebugCallbacks(); 132 } 133 115 134 void Debugger::recompileAllJSFunctions(VM* vm) 116 135 { … … 128 147 } 129 148 149 void Debugger::updateNumberOfBreakpoints(int numberOfBreakpoints) 150 { 151 ASSERT(numberOfBreakpoints >= 0); 152 m_numberOfBreakpoints = numberOfBreakpoints; 153 updateNeedForOpDebugCallbacks(); 154 } 155 156 void Debugger::updateNeedForOpDebugCallbacks() 157 { 158 m_needsOpDebugCallbacks = m_shouldPause || m_numberOfBreakpoints; 159 } 160 130 161 } // namespace JSC -
trunk/Source/JavaScriptCore/debugger/Debugger.h
r156936 r157746 38 38 class JS_EXPORT_PRIVATE Debugger { 39 39 public: 40 Debugger(); 40 41 virtual ~Debugger(); 42 43 bool needsOpDebugCallbacks() const { return m_needsOpDebugCallbacks; } 44 static ptrdiff_t needsOpDebugCallbacksOffset() { return OBJECT_OFFSETOF(Debugger, m_needsOpDebugCallbacks); } 45 46 bool shouldPause() const { return m_shouldPause; } 47 void setShouldPause(bool); 48 49 bool needsExceptionCallbacks() const { return m_needsExceptionCallbacks; } 50 void setNeedsExceptionCallbacks(bool); 51 52 void incNumberOfBreakpoints() { updateNumberOfBreakpoints(m_numberOfBreakpoints + 1); } 53 void decNumberOfBreakpoints() { updateNumberOfBreakpoints(m_numberOfBreakpoints - 1); } 54 void updateNumberOfBreakpoints(int); 41 55 42 56 void attach(JSGlobalObject*); … … 57 71 58 72 private: 73 void updateNeedForOpDebugCallbacks(); 74 59 75 HashSet<JSGlobalObject*> m_globalObjects; 76 77 bool m_needsExceptionCallbacks; 78 bool m_needsOpDebugCallbacks; 79 bool m_shouldPause; 80 int m_numberOfBreakpoints; 81 82 friend class LLIntOffsetsExtractor; 60 83 }; 61 84 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r156984 r157746 651 651 ASSERT(!exceptionValue.isObject() || asObject(exceptionValue)->hasProperty(callFrame, callFrame->vm().propertyNames->stack)); 652 652 653 if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) { 653 Debugger* debugger = callFrame->dynamicGlobalObject()->debugger(); 654 if (debugger && debugger->needsExceptionCallbacks()) { 654 655 // We need to clear the exception and the exception stack here in order to see if a new exception happens. 655 656 // Afterwards, the values are put back to continue processing this error. … … 1252 1253 { 1253 1254 Debugger* debugger = callFrame->dynamicGlobalObject()->debugger(); 1254 if (!debugger )1255 if (!debugger || !debugger->needsOpDebugCallbacks()) 1255 1256 return; 1256 1257 -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r157636 r157746 31 31 #include "Arguments.h" 32 32 #include "CopiedSpaceInlines.h" 33 #include "Debugger.h" 33 34 #include "Heap.h" 34 35 #include "JITInlines.h" … … 728 729 breakpoint(); 729 730 #else 731 JSGlobalObject* globalObject = codeBlock()->globalObject(); 732 Debugger* debugger = globalObject->debugger(); 733 char* debuggerAddress = reinterpret_cast<char*>(globalObject) + JSGlobalObject::debuggerOffset(); 734 Jump noDebugger = branchTestPtr(Zero, AbsoluteAddress(debuggerAddress)); 735 char* flagAddress = reinterpret_cast<char*>(debugger) + Debugger::needsOpDebugCallbacksOffset(); 736 Jump skipDebugHook = branchTest8(Zero, AbsoluteAddress(flagAddress)); 730 737 callOperation(operationDebug, currentInstruction[1].u.operand); 738 skipDebugHook.link(this); 739 noDebugger.link(this); 731 740 #endif 732 741 } -
trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
r157636 r157746 32 32 33 33 #include "CCallHelpers.h" 34 #include "Debugger.h" 34 35 #include "JITInlines.h" 35 36 #include "JSArray.h" … … 1052 1053 breakpoint(); 1053 1054 #else 1055 JSGlobalObject* globalObject = codeBlock()->globalObject(); 1056 Debugger* debugger = globalObject->debugger(); 1057 char* debuggerAddress = reinterpret_cast<char*>(globalObject) + JSGlobalObject::debuggerOffset(); 1058 loadPtr(debuggerAddress, regT0); 1059 Jump noDebugger = branchTestPtr(Zero, regT0); 1060 char* flagAddress = reinterpret_cast<char*>(debugger) + Debugger::needsOpDebugCallbacksOffset(); 1061 Jump skipDebugHook = branchTest8(Zero, AbsoluteAddress(flagAddress)); 1054 1062 callOperation(operationDebug, currentInstruction[1].u.operand); 1063 skipDebugHook.link(this); 1064 noDebugger.link(this); 1055 1065 #endif 1056 1066 } -
trunk/Source/JavaScriptCore/llint/LLIntOffsetsExtractor.cpp
r148696 r157746 28 28 #include "ArrayProfile.h" 29 29 #include "CodeBlock.h" 30 #include "Debugger.h" 30 31 #include "Executable.h" 31 32 #include "Heap.h" -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r157474 r157746 798 798 _llint_op_debug: 799 799 traceExecution() 800 loadp CodeBlock[cfr], t0 801 loadp CodeBlock::m_globalObject[t0], t0 802 loadp JSGlobalObject::m_debugger[t0], t0 803 btiz t0, .opDebugDone 804 loadb Debugger::m_needsOpDebugCallbacks[t0], t0 805 btbz t0, .opDebugDone 806 800 807 callSlowPath(_llint_slow_path_debug) 808 .opDebugDone: 801 809 dispatch(2) 802 810 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r157267 r157746 468 468 Debugger* debugger() const { return m_debugger; } 469 469 void setDebugger(Debugger* debugger) { m_debugger = debugger; } 470 static ptrdiff_t debuggerOffset() { return OBJECT_OFFSETOF(JSGlobalObject, m_debugger); } 470 471 471 472 const GlobalObjectMethodTable* globalObjectMethodTable() const { return m_globalObjectMethodTable; } -
trunk/Source/WebCore/ChangeLog
r157739 r157746 1 2013-10-20 Mark Lam <mark.lam@apple.com> 2 3 Avoid JSC debugger overhead unless needed. 4 https://bugs.webkit.org/show_bug.cgi?id=123084. 5 6 Reviewed by Geoffrey Garen. 7 8 No new tests. 9 10 - If no breakpoints are set, we now avoid calling the debug hook callbacks. 11 - If no break on exception is set, we also avoid exception event debug callbacks. 12 - When we return from the ScriptDebugServer to the JSC::Debugger, we may no 13 longer call the debug hook callbacks if not needed. Hence, the m_currentCallFrame 14 pointer in the ScriptDebugServer may become stale. To avoid this issue, before 15 returning, the ScriptDebugServer will clear its m_currentCallFrame if 16 needsOpDebugCallbacks() is false. 17 18 * bindings/js/ScriptDebugServer.cpp: 19 (WebCore::ScriptDebugServer::setBreakpoint): 20 (WebCore::ScriptDebugServer::removeBreakpoint): 21 (WebCore::ScriptDebugServer::clearBreakpoints): 22 (WebCore::ScriptDebugServer::setPauseOnExceptionsState): 23 (WebCore::ScriptDebugServer::setPauseOnNextStatement): 24 (WebCore::ScriptDebugServer::breakProgram): 25 (WebCore::ScriptDebugServer::stepIntoStatement): 26 (WebCore::ScriptDebugServer::dispatchDidContinue): 27 (WebCore::ScriptDebugServer::exception): 28 (WebCore::ScriptDebugServer::didReachBreakpoint): 29 * inspector/InspectorDebuggerAgent.cpp: 30 (WebCore::InspectorDebuggerAgent::reset): 31 1 32 2013-10-21 Myles C. Maxfield <mmaxfield@apple.com> 2 33 -
trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp
r157215 r157746 116 116 } 117 117 breaksVector.append(scriptBreakpoint); 118 incNumberOfBreakpoints(); 118 119 119 120 *actualLineNumber = scriptBreakpoint.lineNumber; … … 151 152 if (breaksVector.at(i).columnNumber == static_cast<int>(columnNumber)) { 152 153 breaksVector.remove(i); 154 decNumberOfBreakpoints(); 153 155 break; 154 156 } … … 246 248 { 247 249 m_sourceIdToBreakpoints.clear(); 250 updateNumberOfBreakpoints(0); 248 251 } 249 252 … … 256 259 { 257 260 m_pauseOnExceptionsState = pause; 261 setNeedsExceptionCallbacks(pause != DontPauseOnExceptions); 258 262 } 259 263 … … 261 265 { 262 266 m_pauseOnNextStatement = pause; 267 if (pause) 268 setShouldPause(true); 263 269 } 264 270 … … 269 275 270 276 m_pauseOnNextStatement = true; 277 setShouldPause(true); 271 278 pauseIfNeeded(m_currentCallFrame); 272 279 } … … 287 294 288 295 m_pauseOnNextStatement = true; 296 setShouldPause(true); 289 297 m_doneProcessingDebuggerEvents = true; 290 298 } … … 354 362 { 355 363 listener->didContinue(); 364 if (!m_pauseOnNextStatement && !m_pauseOnCallFrame) { 365 setShouldPause(false); 366 if (!needsOpDebugCallbacks()) 367 m_currentCallFrame = 0; 368 } 356 369 } 357 370 … … 477 490 updateCallFrame(callFrame); 478 491 pauseIfNeeded(callFrame); 492 if (!needsOpDebugCallbacks()) 493 m_currentCallFrame = 0; 479 494 } 480 495 … … 530 545 void ScriptDebugServer::callEvent(CallFrame* callFrame) 531 546 { 532 if (!m_paused) { 533 updateCallFrame(callFrame); 534 pauseIfNeeded(callFrame); 535 } 547 if (!m_paused) 548 updateCallFrameAndPauseIfNeeded(callFrame); 536 549 } 537 550 … … 565 578 return; 566 579 567 if (m_pauseOnExceptionsState == PauseOnAllExceptions || (m_pauseOnExceptionsState == PauseOnUncaughtExceptions && !hasHandler)) 580 if (m_pauseOnExceptionsState == PauseOnAllExceptions || (m_pauseOnExceptionsState == PauseOnUncaughtExceptions && !hasHandler)) { 568 581 m_pauseOnNextStatement = true; 582 setShouldPause(true); 583 } 569 584 570 585 updateCallFrameAndPauseIfNeeded(callFrame); … … 573 588 void ScriptDebugServer::willExecuteProgram(CallFrame* callFrame) 574 589 { 575 if (!m_paused) { 576 updateCallFrame(callFrame); 577 pauseIfNeeded(callFrame); 578 } 590 if (!m_paused) 591 updateCallFrameAndPauseIfNeeded(callFrame); 579 592 } 580 593 … … 603 616 604 617 m_pauseOnNextStatement = true; 618 setShouldPause(true); 605 619 updateCallFrameAndPauseIfNeeded(callFrame); 606 620 } -
trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp
r157653 r157746 824 824 void InspectorDebuggerAgent::reset() 825 825 { 826 scriptDebugServer().clearBreakpoints(); 826 827 m_scripts.clear(); 827 828 m_breakpointIdToDebugServerBreakpointIds.clear(); -
trunk/Source/WebKit/mac/ChangeLog
r157697 r157746 1 2013-10-20 Mark Lam <mark.lam@apple.com> 2 3 Avoid JSC debugger overhead unless needed. 4 https://bugs.webkit.org/show_bug.cgi?id=123084. 5 6 Reviewed by Geoffrey Garen. 7 8 * WebView/WebScriptDebugger.mm: 9 (WebScriptDebugger::WebScriptDebugger): 10 1 11 2013-10-19 Jer Noble <jer.noble@apple.com> 2 12 -
trunk/Source/WebKit/mac/WebView/WebScriptDebugger.mm
r157215 r157746 77 77 { 78 78 attach(globalObject); 79 setNeedsExceptionCallbacks(true); 79 80 } 80 81
Note:
See TracChangeset
for help on using the changeset viewer.