No cool pictures, but I’ve enhanced and exposed the global reader/writer understanding of javascript code. In other words, pecobro now does a passable job at telling you what global variables a given javascript file reads from/writes to, and who else writes to/reads from those variables. False negatives are expected (don’t rely on things to be exhaustive), and false positives are quite conceivable.
As an example starting point, take a look at messageWindow.js’s global reads or global writes. From either of these you can click on other files in the sidebar to go to them. There is no execution trace, so the overview diagram won’t be any help. Be sure you have some free memory available and won’t try and hurt me if Firefox does something crazy. Note: for long documents, some delay is expected as it attempts to apply various fix-ups. Also note: clicking on things in the global reads/global writes tab won’t get you anywhere for now.
A quick example of a global read from that file (and who writes to that global):
gDBView
- Top Level: commandglue.js
- Function: ClearThreadPane (in commandglue.js)
- Function: CreateBareDBView (in commandglue.js)
- Function: RerootFolder (in commandglue.js)
- Function: SwitchView (in commandglue.js)
- Function: openFolderTab (in mailWindowOverlay.js)
- Function: setMailTabState (in mailWindowOverlay.js)
- Function: restorePreSearchView (in searchBar.js)
- Function: MsgGroupBySort (in threadPane.js)
A quick example of a global write from that file (and who reads from that global):
SelectFolder
- Function: OpenMessageByHeader (in mailContextMenus.js)
- Function: OpenInboxForServer (in mailWindow.js)
- Function: selectFolder (in mailWindow.js)
- Function: openFolderTab (in mailWindowOverlay.js)
- Function: LoadNavigatedToMessage (in messageWindow.js)
- Function: LoadNavigatedToMessage (in msgMail3PaneWindow.js)
- Function: OnLocationTreeSelect (in msgMail3PaneWindow.js)
- Function: SelectServer (in msgMail3PaneWindow.js)
- Function: loadStartFolder (in msgMail3PaneWindow.js)
- Function: RenameFolder (in widgetglue.js)
- Function: loadInboxForNewAccount (in accountUtils.js)
- Function: DropOnFolderTree (in messengerdnd.js)
- Function: CrossFolderNavigation (in msgViewNavigation.js)
The code, as always, is available at http://hg.mozilla.org/users/bugmail_asutherland.org/pecobro/
Are you finding that global accesses are a performance issue? Those should have got a ton better in 1.9, so if they’re still a pain point please let me know!
This post is mainly about aiding user comprehension. I don’t think the DTrace probes used for the performance side of the game have the granularity to actually distinguish if global accesses are a problem. (Although one could conceivably use the information available to hypothesize that’s a problem, I certainly have seen nothing to suggest it’s a problem.)
Sorry, I think I over-rotated on the “performance” word in the title. When I read context, I understand things better — film at 11.
Pingback: visophyte: data made shiny :: dxrpy with references against mailnews, plus bespin wishes