Changeset 49615 in webkit
- Timestamp:
- Oct 15, 2009 2:31:11 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r49614 r49615 1 2009-10-14 Mikhail Naganov <mnaganov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Migrate profiles to the injected script-based schema. 6 7 https://bugs.webkit.org/show_bug.cgi?id=30328 8 9 * bindings/js/JSInspectorBackendCustom.cpp: 10 * bindings/v8/custom/V8CustomBinding.h: 11 * inspector/InspectorBackend.cpp: 12 (WebCore::InspectorBackend::getProfileHeaders): 13 (WebCore::InspectorBackend::getProfile): 14 * inspector/InspectorBackend.h: 15 * inspector/InspectorBackend.idl: 16 * inspector/InspectorController.cpp: 17 (WebCore::InspectorController::addProfile): 18 (WebCore::InspectorController::getProfileHeaders): 19 (WebCore::InspectorController::getProfile): 20 (WebCore::InspectorController::createProfileHeader): 21 * inspector/InspectorController.h: 22 * inspector/InspectorFrontend.cpp: 23 (WebCore::InspectorFrontend::addProfileHeader): 24 (WebCore::InspectorFrontend::didGetProfileHeaders): 25 (WebCore::InspectorFrontend::didGetProfile): 26 * inspector/InspectorFrontend.h: 27 * inspector/JavaScriptProfileNode.cpp: 28 (WebCore::ProfileNodeClass): 29 * inspector/front-end/ProfileView.js: 30 (WebInspector.ProfileView.profileCallback): 31 (WebInspector.ProfileView): 32 (WebInspector.ProfileView.prototype._mouseDownInDataGrid): 33 (WebInspector.ProfileView.prototype._assignParentsInProfile): 34 * inspector/front-end/ProfilesPanel.js: 35 (WebInspector.ProfilesPanel.prototype.addProfileHeader): 36 * inspector/front-end/inspector.js: 37 (WebInspector.addProfileHeader): 38 1 39 2009-10-14 Pavel Feldman <pfeldman@chromium.org> 2 40 -
trunk/WebCore/bindings/js/JSInspectorBackendCustom.cpp
r49560 r49615 67 67 #include "JavaScriptCallFrame.h" 68 68 #include "JavaScriptDebugServer.h" 69 #include "JavaScriptProfile.h"70 69 #include "JSJavaScriptCallFrame.h" 71 #include <profiler/Profile.h>72 #include <profiler/Profiler.h>73 70 #endif 74 71 … … 254 251 } 255 252 256 JSValue JSInspectorBackend::profiles(JSC::ExecState* exec, const JSC::ArgList&)257 {258 JSLock lock(SilenceAssertionsOnly);259 MarkedArgumentBuffer result;260 InspectorController* ic = impl()->inspectorController();261 if (!ic)262 return jsUndefined();263 const Vector<RefPtr<Profile> >& profiles = ic->profiles();264 265 for (size_t i = 0; i < profiles.size(); ++i)266 result.append(toJS(exec, profiles[i].get()));267 268 return constructArray(exec, result);269 }270 271 253 #endif 272 254 -
trunk/WebCore/bindings/v8/custom/V8CustomBinding.h
r49560 r49615 462 462 DECLARE_CALLBACK(TreeWalkerPreviousSibling); 463 463 464 DECLARE_CALLBACK(InspectorBackendProfiles);465 464 DECLARE_CALLBACK(InspectorBackendHighlightDOMNode); 466 465 DECLARE_CALLBACK(InspectorBackendAddResourceSourceToFrame); -
trunk/WebCore/inspector/InspectorBackend.cpp
r49565 r49615 279 279 280 280 #if ENABLE(JAVASCRIPT_DEBUGGER) 281 const ProfilesArray& InspectorBackend::profiles() const282 {283 if (m_inspectorController)284 return m_inspectorController->profiles();285 return m_emptyProfiles;286 }287 288 281 void InspectorBackend::startProfiling() 289 282 { … … 315 308 return m_inspectorController->profilerEnabled(); 316 309 return false; 310 } 311 312 void InspectorBackend::getProfileHeaders(long callId) 313 { 314 if (m_inspectorController) 315 m_inspectorController->getProfileHeaders(callId); 316 } 317 318 void InspectorBackend::getProfile(long callId, unsigned uid) 319 { 320 if (m_inspectorController) 321 m_inspectorController->getProfile(callId, uid); 317 322 } 318 323 -
trunk/WebCore/inspector/InspectorBackend.h
r49565 r49615 101 101 102 102 #if ENABLE(JAVASCRIPT_DEBUGGER) 103 const ProfilesArray& profiles() const;104 105 103 void startProfiling(); 106 104 void stopProfiling(); … … 109 107 void disableProfiler(bool always); 110 108 bool profilerEnabled(); 109 110 void getProfileHeaders(long callId); 111 void getProfile(long callId, unsigned uid); 111 112 112 113 void enableDebugger(bool always); … … 172 173 InspectorController* m_inspectorController; 173 174 InspectorClient* m_client; 174 #if ENABLE(JAVASCRIPT_DEBUGGER)175 ProfilesArray m_emptyProfiles;176 #endif177 175 }; 178 176 -
trunk/WebCore/inspector/InspectorBackend.idl
r49565 r49615 101 101 void stopProfiling(); 102 102 103 [Custom] Array profiles(); 103 void getProfileHeaders(in long callId); 104 void getProfile(in long callId, in unsigned long uid); 104 105 #endif 105 106 void dispatchOnInjectedScript(in long callId, in DOMString methodName, in DOMString arguments, in boolean async); -
trunk/WebCore/inspector/InspectorController.cpp
r49614 r49615 1338 1338 1339 1339 RefPtr<Profile> profile = prpProfile; 1340 m_profiles.a ppend(profile);1340 m_profiles.add(profile->uid(), profile); 1341 1341 1342 1342 if (m_frontend) { 1343 1343 JSLock lock(SilenceAssertionsOnly); 1344 m_frontend->addProfile (toJS(m_scriptState, profile.get()));1344 m_frontend->addProfileHeader(createProfileHeader(*profile)); 1345 1345 } 1346 1346 … … 1370 1370 message += "#0\" started."; 1371 1371 addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); 1372 } 1373 1374 void InspectorController::getProfileHeaders(long callId) 1375 { 1376 if (!m_frontend) 1377 return; 1378 ScriptArray result = m_frontend->newScriptArray(); 1379 ProfilesMap::iterator profilesEnd = m_profiles.end(); 1380 int i = 0; 1381 for (ProfilesMap::iterator it = m_profiles.begin(); it != profilesEnd; ++it) 1382 result.set(i++, createProfileHeader(*it->second)); 1383 m_frontend->didGetProfileHeaders(callId, result); 1384 } 1385 1386 void InspectorController::getProfile(long callId, unsigned uid) 1387 { 1388 if (!m_frontend) 1389 return; 1390 ProfilesMap::iterator it = m_profiles.find(uid); 1391 if (it != m_profiles.end()) 1392 m_frontend->didGetProfile(callId, toJS(m_scriptState, it->second.get())); 1393 } 1394 1395 ScriptObject InspectorController::createProfileHeader(const JSC::Profile& profile) 1396 { 1397 ScriptObject header = m_frontend->newScriptObject(); 1398 header.set("title", profile.title()); 1399 header.set("uid", profile.uid()); 1400 return header; 1372 1401 } 1373 1402 -
trunk/WebCore/inspector/InspectorController.h
r49565 r49615 266 266 void addProfileFinishedMessageToConsole(PassRefPtr<JSC::Profile>, unsigned lineNumber, const JSC::UString& sourceURL); 267 267 void addStartProfilingMessageToConsole(const JSC::UString& title, unsigned lineNumber, const JSC::UString& sourceURL); 268 const ProfilesArray& profiles() const { return m_profiles; }269 268 270 269 bool isRecordingUserInitiatedProfile() const { return m_recordingUserInitiatedProfile; } … … 316 315 317 316 #if ENABLE(JAVASCRIPT_DEBUGGER) 317 typedef HashMap<unsigned int, RefPtr<JSC::Profile> > ProfilesMap; 318 318 319 void startUserInitiatedProfilingSoon(); 319 320 void toggleRecordButton(bool); 320 321 void enableDebuggerFromFrontend(bool always); 322 void getProfileHeaders(long callId); 323 void getProfile(long callId, unsigned uid); 324 ScriptObject createProfileHeader(const JSC::Profile& profile); 321 325 #endif 322 326 #if ENABLE(DATABASE) … … 395 399 unsigned m_nextUserInitiatedProfileNumber; 396 400 Timer<InspectorController> m_startProfiling; 397 Profiles Arraym_profiles;401 ProfilesMap m_profiles; 398 402 #endif 399 403 }; -
trunk/WebCore/inspector/InspectorFrontend.cpp
r49565 r49615 262 262 } 263 263 264 void InspectorFrontend::addProfile (const JSC::JSValue& profile)265 { 266 OwnPtr<ScriptFunctionCall> function(newFunctionCall("addProfile "));264 void InspectorFrontend::addProfileHeader(const ScriptValue& profile) 265 { 266 OwnPtr<ScriptFunctionCall> function(newFunctionCall("addProfileHeader")); 267 267 function->appendArgument(profile); 268 268 function->call(); … … 273 273 OwnPtr<ScriptFunctionCall> function(newFunctionCall("setRecordingProfile")); 274 274 function->appendArgument(isProfiling); 275 function->call(); 276 } 277 278 void InspectorFrontend::didGetProfileHeaders(int callId, const ScriptArray& headers) 279 { 280 OwnPtr<ScriptFunctionCall> function(newFunctionCall("didGetProfileHeaders")); 281 function->appendArgument(callId); 282 function->appendArgument(headers); 283 function->call(); 284 } 285 286 void InspectorFrontend::didGetProfile(int callId, const ScriptValue& profile) 287 { 288 OwnPtr<ScriptFunctionCall> function(newFunctionCall("didGetProfile")); 289 function->appendArgument(callId); 290 function->appendArgument(profile); 275 291 function->call(); 276 292 } -
trunk/WebCore/inspector/InspectorFrontend.h
r49565 r49615 90 90 void parsedScriptSource(const JSC::SourceCode&); 91 91 void failedToParseScriptSource(const JSC::SourceCode&, int errorLine, const JSC::UString& errorMessage); 92 void addProfile (const JSC::JSValue& profile);92 void addProfileHeader(const ScriptValue& profile); 93 93 void setRecordingProfile(bool isProfiling); 94 void didGetProfileHeaders(int callId, const ScriptArray& headers); 95 void didGetProfile(int callId, const ScriptValue& profile); 94 96 void pausedScript(const ScriptValue& callFrames); 95 97 void resumedScript(); -
trunk/WebCore/inspector/JavaScriptProfileNode.cpp
r49560 r49615 105 105 } 106 106 107 static JSValueRef getTotalPercent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)108 {109 JSC::JSLock lock(SilenceAssertionsOnly);110 111 if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))112 return JSValueMakeUndefined(ctx);113 114 ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));115 return JSValueMakeNumber(ctx, profileNode->totalPercent());116 }117 118 static JSValueRef getSelfPercent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)119 {120 JSC::JSLock lock(SilenceAssertionsOnly);121 122 if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))123 return JSValueMakeUndefined(ctx);124 125 ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));126 return JSValueMakeNumber(ctx, profileNode->selfPercent());127 }128 129 107 static JSValueRef getNumberOfCalls(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) 130 108 { … … 185 163 } 186 164 187 static JSValueRef getParent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)188 {189 JSC::JSLock lock(SilenceAssertionsOnly);190 191 if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))192 return JSValueMakeUndefined(ctx);193 194 ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));195 ExecState* exec = toJS(ctx);196 return toRef(exec, toJS(exec, profileNode->parent()));197 }198 199 static JSValueRef getHead(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)200 {201 JSC::JSLock lock(SilenceAssertionsOnly);202 203 if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))204 return JSValueMakeUndefined(ctx);205 206 ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));207 ExecState* exec = toJS(ctx);208 return toRef(exec, toJS(exec, profileNode->head()));209 }210 211 165 static JSValueRef getVisible(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) 212 166 { … … 246 200 { "totalTime", getTotalTime, 0, kJSPropertyAttributeNone }, 247 201 { "selfTime", getSelfTime, 0, kJSPropertyAttributeNone }, 248 { "totalPercent", getTotalPercent, 0, kJSPropertyAttributeNone },249 { "selfPercent", getSelfPercent, 0, kJSPropertyAttributeNone },250 202 { "numberOfCalls", getNumberOfCalls, 0, kJSPropertyAttributeNone }, 251 203 { "children", getChildren, 0, kJSPropertyAttributeNone }, 252 { "parent", getParent, 0, kJSPropertyAttributeNone },253 { "head", getHead, 0, kJSClassAttributeNone },254 204 { "visible", getVisible, 0, kJSPropertyAttributeNone }, 255 205 { "callUID", getCallUID, 0, kJSPropertyAttributeNone }, -
trunk/WebCore/inspector/front-end/ProfileView.js
r49560 r49615 79 79 this.profile = profile; 80 80 81 this.profileDataGridTree = this.bottomUpProfileDataGridTree; 82 this.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyComparator("selfTime", false)); 83 84 this.refresh(); 85 86 this._updatePercentButton(); 81 var self = this; 82 function profileCallback(profile) 83 { 84 self.profile = profile; 85 self._assignParentsInProfile(); 86 87 self.profileDataGridTree = self.bottomUpProfileDataGridTree; 88 self.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyComparator("selfTime", false)); 89 90 self.refresh(); 91 92 self._updatePercentButton(); 93 } 94 95 var callId = WebInspector.Callback.wrap(profileCallback); 96 InspectorController.getProfile(callId, this.profile.uid); 87 97 } 88 98 … … 534 544 event.preventDefault(); 535 545 event.stopPropagation(); 546 }, 547 548 _assignParentsInProfile: function() 549 { 550 var head = this.profile.head; 551 head.parent = null; 552 head.head = null; 553 var nodesToTraverse = [ { parent: head, children: head.children } ]; 554 while (nodesToTraverse.length > 0) { 555 var pair = nodesToTraverse.shift(); 556 var parent = pair.parent; 557 var children = pair.children; 558 var length = children.length; 559 for (var i = 0; i < length; ++i) { 560 children[i].head = head; 561 children[i].parent = parent; 562 if (children[i].children.length > 0) 563 nodesToTraverse.push({ parent: children[i], children: children[i].children }); 564 } 565 } 536 566 } 537 567 } -
trunk/WebCore/inspector/front-end/ProfilesPanel.js
r49560 r49615 162 162 }, 163 163 164 addProfile : function(profile)164 addProfileHeader: function(profile) 165 165 { 166 166 this._profiles.push(profile); … … 402 402 return; 403 403 404 var profiles = InspectorController.profiles(); 405 var profilesLength = profiles.length; 406 for (var i = 0; i < profilesLength; ++i) { 407 var profile = profiles[i]; 408 this.addProfile(profile); 409 } 410 411 if (cpuProfiles.children[0]) 412 cpuProfiles.children[0].select(); 404 function populateCallback(profileHeaders) { 405 profileHeaders.sort(function(a, b) { return a.uid - b.uid; }); 406 var profileHeadersLength = profileHeaders.length; 407 for (var i = 0; i < profileHeadersLength; ++i) 408 WebInspector.addProfileHeader(profileHeaders[i]); 409 if (cpuProfiles.children[0]) 410 cpuProfiles.children[0].select(); 411 } 412 413 var callId = WebInspector.Callback.wrap(populateCallback); 414 InspectorController.getProfileHeaders(callId); 413 415 414 416 delete this._shouldPopulateProfiles; … … 536 538 537 539 WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; 540 541 WebInspector.didGetProfileHeaders = WebInspector.Callback.processCallback; 542 WebInspector.didGetProfile = WebInspector.Callback.processCallback; -
trunk/WebCore/inspector/front-end/inspector.js
r49560 r49615 1263 1263 } 1264 1264 1265 WebInspector.addProfile = function(profile)1266 { 1267 this.panels.profiles.addProfile (profile);1265 WebInspector.addProfileHeader = function(profile) 1266 { 1267 this.panels.profiles.addProfileHeader(profile); 1268 1268 } 1269 1269
Note: See TracChangeset
for help on using the changeset viewer.