Changeset 173264 in webkit
- Timestamp:
- Sep 4, 2014 10:21:39 AM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r173263 r173264 1 2014-09-04 Brian J. Burg <burg@cs.washington.edu> 2 3 Web Inspector: the profiler should not accrue time to nodes while the debugger is paused 4 https://bugs.webkit.org/show_bug.cgi?id=136352 5 6 Reviewed by Timothy Hatcher. 7 8 Hook up pause/continue events to the LegacyProfiler and any active 9 ProfilerGenerators. If the debugger is paused, all intervening call 10 entries will be created with totalTime as 0.0. 11 12 * inspector/ScriptDebugServer.cpp: 13 (Inspector::ScriptDebugServer::handlePause): 14 * profiler/LegacyProfiler.cpp: Move from typedef'd callbacks to using 15 std::function. This allows callbacks to take different argument types. 16 17 (JSC::callFunctionForProfilesWithGroup): 18 (JSC::LegacyProfiler::willExecute): 19 (JSC::LegacyProfiler::didExecute): 20 (JSC::LegacyProfiler::exceptionUnwind): 21 (JSC::LegacyProfiler::didPause): 22 (JSC::LegacyProfiler::didContinue): 23 (JSC::dispatchFunctionToProfiles): Deleted. 24 * profiler/LegacyProfiler.h: 25 * profiler/ProfileGenerator.cpp: 26 (JSC::ProfileGenerator::ProfileGenerator): 27 (JSC::ProfileGenerator::endCallEntry): 28 (JSC::ProfileGenerator::didExecute): Deleted. 29 * profiler/ProfileGenerator.h: 30 (JSC::ProfileGenerator::didPause): 31 (JSC::ProfileGenerator::didContinue): 32 1 33 2014-09-04 Commit Queue <commit-queue@webkit.org> 2 34 -
trunk/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp
r173100 r173264 39 39 #include "JSLock.h" 40 40 #include "JavaScriptCallFrame.h" 41 #include "LegacyProfiler.h" 41 42 #include "ScriptValue.h" 42 43 #include "SourceProvider.h" … … 317 318 { 318 319 dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause, vmEntryGlobalObject); 320 LegacyProfiler::profiler()->didPause(currentDebuggerCallFrame()); 319 321 didPause(vmEntryGlobalObject); 320 322 … … 323 325 324 326 didContinue(vmEntryGlobalObject); 327 LegacyProfiler::profiler()->didContinue(currentDebuggerCallFrame()); 325 328 dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue, vmEntryGlobalObject); 326 329 } -
trunk/Source/JavaScriptCore/profiler/LegacyProfiler.cpp
r171204 r173264 33 33 #include "CodeBlock.h" 34 34 #include "CommonIdentifiers.h" 35 #include "DebuggerCallFrame.h" 35 36 #include "InternalFunction.h" 36 37 #include "JSFunction.h" … … 115 116 } 116 117 117 static inline void dispatchFunctionToProfiles(ExecState* callerOrHandlerCallFrame, const Vector<RefPtr<ProfileGenerator>>& profiles, ProfileGenerator::ProfileFunction function, const CallIdentifier& callIdentifier, unsigned currentProfileTargetGroup)118 { 119 for ( size_t i = 0; i < profiles.size(); ++i) {120 if (profile s[i]->profileGroup() == currentProfileTargetGroup || !profiles[i]->origin())121 (profiles[i].get()->*function)(callerOrHandlerCallFrame, callIdentifier);118 static inline void callFunctionForProfilesWithGroup(std::function<void(ProfileGenerator*)> callback, const Vector<RefPtr<ProfileGenerator>>& profiles, unsigned targetProfileGroup) 119 { 120 for (const RefPtr<ProfileGenerator>& profile : profiles) { 121 if (profile->profileGroup() == targetProfileGroup || !profile->origin()) 122 callback(profile.get()); 122 123 } 123 124 } … … 127 128 ASSERT(!m_currentProfiles.isEmpty()); 128 129 129 dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0), callerCallFrame->lexicalGlobalObject()->profileGroup()); 130 CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0); 131 132 callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::willExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup()); 130 133 } 131 134 … … 136 139 CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, JSValue(), sourceURL, startingLineNumber, startingColumnNumber); 137 140 138 dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, callerCallFrame->lexicalGlobalObject()->profileGroup());141 callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::willExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup()); 139 142 } 140 143 … … 143 146 ASSERT(!m_currentProfiles.isEmpty()); 144 147 145 dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0), callerCallFrame->lexicalGlobalObject()->profileGroup()); 148 CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, function, StringImpl::empty(), 0, 0); 149 150 callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup()); 146 151 } 147 152 … … 150 155 ASSERT(!m_currentProfiles.isEmpty()); 151 156 152 dispatchFunctionToProfiles(callerCallFrame, m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(callerCallFrame, JSValue(), sourceURL, startingLineNumber, startingColumnNumber), callerCallFrame->lexicalGlobalObject()->profileGroup()); 157 CallIdentifier callIdentifier = createCallIdentifier(callerCallFrame, JSValue(), sourceURL, startingLineNumber, startingColumnNumber); 158 159 callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didExecute, std::placeholders::_1, callerCallFrame, callIdentifier), m_currentProfiles, callerCallFrame->lexicalGlobalObject()->profileGroup()); 153 160 } 154 161 … … 157 164 ASSERT(!m_currentProfiles.isEmpty()); 158 165 159 dispatchFunctionToProfiles(handlerCallFrame, m_currentProfiles, &ProfileGenerator::exceptionUnwind, createCallIdentifier(handlerCallFrame, JSValue(), StringImpl::empty(), 0, 0), handlerCallFrame->lexicalGlobalObject()->profileGroup()); 166 CallIdentifier callIdentifier = createCallIdentifier(handlerCallFrame, JSValue(), StringImpl::empty(), 0, 0); 167 168 callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::exceptionUnwind, std::placeholders::_1, handlerCallFrame, callIdentifier), m_currentProfiles, handlerCallFrame->lexicalGlobalObject()->profileGroup()); 169 } 170 171 void LegacyProfiler::didPause(PassRefPtr<DebuggerCallFrame> prpCallFrame) 172 { 173 if (m_currentProfiles.isEmpty()) 174 return; 175 176 RefPtr<DebuggerCallFrame> callFrame = prpCallFrame; 177 CallIdentifier callIdentifier = createCallIdentifier(callFrame->exec(), JSValue(), StringImpl::empty(), 0, 0); 178 179 callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didPause, std::placeholders::_1, callFrame, callIdentifier), m_currentProfiles, callFrame->vmEntryGlobalObject()->profileGroup()); 180 } 181 182 void LegacyProfiler::didContinue(PassRefPtr<DebuggerCallFrame> prpCallFrame) 183 { 184 if (m_currentProfiles.isEmpty()) 185 return; 186 187 RefPtr<DebuggerCallFrame> callFrame = prpCallFrame; 188 CallIdentifier callIdentifier = createCallIdentifier(callFrame->exec(), JSValue(), StringImpl::empty(), 0, 0); 189 190 callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::didContinue, std::placeholders::_1, callFrame, callIdentifier), m_currentProfiles, callFrame->vmEntryGlobalObject()->profileGroup()); 160 191 } 161 192 -
trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h
r165676 r173264 37 37 namespace JSC { 38 38 39 class DebuggerCallFrame; 39 40 class ExecState; 40 41 class VM; … … 62 63 void exceptionUnwind(ExecState* handlerCallFrame); 63 64 65 void didPause(PassRefPtr<DebuggerCallFrame>); 66 void didContinue(PassRefPtr<DebuggerCallFrame>); 67 64 68 const Vector<RefPtr<ProfileGenerator>>& currentProfiles() { return m_currentProfiles; }; 65 69 -
trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp
r173262 r173264 29 29 #include "CallFrame.h" 30 30 #include "CodeBlock.h" 31 #include "Debugger.h" 31 32 #include "JSGlobalObject.h" 32 33 #include "JSStringRef.h" … … 49 50 , m_profileGroup(exec ? exec->lexicalGlobalObject()->profileGroup() : 0) 50 51 , m_foundConsoleStartParent(false) 51 { 52 , m_debuggerPaused(false) 53 { 54 if (Debugger* debugger = exec->lexicalGlobalObject()->debugger()) 55 m_debuggerPaused = debugger->isPaused(); 56 52 57 m_profile = Profile::create(title, uid); 53 58 m_currentNode = m_rootNode = m_profile->rootNode(); … … 124 129 ASSERT(isnan(last.totalTime())); 125 130 126 last.setTotalTime( currentTime() - last.startTime());131 last.setTotalTime(m_debuggerPaused ? 0.0 : currentTime() - last.startTime()); 127 132 } 128 133 -
trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h
r173262 r173264 34 34 namespace JSC { 35 35 36 class DebuggerCallFrame; 36 37 class ExecState; 37 38 class JSGlobalObject; … … 53 54 void didExecute(ExecState* callerCallFrame, const CallIdentifier&); 54 55 void exceptionUnwind(ExecState* handlerCallFrame, const CallIdentifier&); 56 57 void didPause(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&) { m_debuggerPaused = true; } 58 void didContinue(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&) { m_debuggerPaused = false; } 55 59 56 60 void stopProfiling(); … … 74 78 RefPtr<ProfileNode> m_currentNode; 75 79 bool m_foundConsoleStartParent; 80 bool m_debuggerPaused; 76 81 }; 77 82
Note: See TracChangeset
for help on using the changeset viewer.