Changes to the ownership of Profiles and allows multiple Profiles at a time
JavaScriptCore:
Change the Profiler to allow multiple profiles to be running at
the same time. This can happen when you have nested console.profile()
calls. This required two changes. First, the Profiler needed to keep a
Vector of current profiles, instead of one. Second, a Profile needs
to keep track of the global ExecState it started in and the page group
identifier it is tracking.
The stopProfiling call now takes the same arguments as startProfiling.
This makes sure the correct profile is stopped. Passing a null UString
as the title will stop the last profile for the matching ExecState.
<rdar://problem/5951559> Multiple pages profiling can interfere with each other
Reviewed by Kevin McCullough.
- JavaScriptCore.exp: Added new exports. Removed old symbols.
- profiler/Profile.cpp:
(KJS::Profile::Profile): New constructor arguments for the
originatingGlobalExec and pageGroupIdentifier.
(KJS::Profile::stopProfiling): Set the m_originatingGlobalExec to null.
- profiler/Profile.h:
(KJS::Profile::create): Additional arguments.
(KJS::Profile::originatingGlobalExec): Return m_originatingGlobalExec.
(KJS::Profile::pageGroupIdentifier): Return m_pageGroupIdentifier.
- profiler/Profiler.cpp:
(KJS::Profiler::findProfile): Added. Finds a Profile that matches
the ExecState and title.
(KJS::Profiler::startProfiling): Return early if there is already
a Profile with the ExecState and title. If not, create a new profile
and append it to m_currentProfiles.
(KJS::Profiler::stopProfiling): Loops through m_currentProfiles
and find the one matching the ExecState and title. If one is found
call stopProfiling and return the Profile after removing it
from m_currentProfiles.
(KJS::dispatchFunctionToProfiles): Helper inline function to loop through
m_currentProfiles and call a Profile function.
(KJS::Profiler::willExecute): Call dispatchFunctionToProfiles.
(KJS::Profiler::didExecute): Ditto.
- profiler/Profiler.h:
WebCore:
Changes to work with the new Profiler API. The Profile is now
stored by the InspectorController when Console.profileEnd is called.
This solves three issues with the previous design. First, we don't
keep profiles around unless the Inspector is enabled. Second, we
only show Profiles initiated by the Page in it's Inspector, not every
Profile for the whole process. Third, we now show Profiles in the
Inspector when they are created.
<rdar://problem/5951562> New profiles aren't added to the Inspector
as they finish
Reviewed by Kevin McCullough.
- bindings/js/JSConsoleCustom.cpp:
(WebCore::JSConsole::profileEnd): Added. Calls impl()->profileEnd()
and passes the ExecState and arguments.
- page/Console.cpp:
(WebCore::Console::profile):
(WebCore::Console::profileEnd): Accept the optional title argument
and pass it to Profilier::stopProfiling along with the ExecState.
Calls InspectorController::addProfile with the result Profile.
- page/Console.h:
- page/Console.idl: Made profileEnd Custom so we can get the ExecState.
- page/InspectorController.cpp:
(WebCore::profiles): Renamed from allProfiles. Uses the controller's
profiles vector.
(WebCore::InspectorController::addProfile): Appends to m_profiles.
Calls addScriptProfile if the window is visible.
(WebCore::InspectorController::windowScriptObjectAvailable): Renamed
allProfiles to profiles.
(WebCore::InspectorController::addScriptProfile): Calls addProfile on
the JavaScript side.
(WebCore::InspectorController::didCommitLoad): Clears m_profiles.
- page/InspectorController.h:
- page/inspector/ProfilesPanel.js: Populates the profiles sidebar the first
time the panel is shown after a rest.
- page/inspector/inspector.js: Added addProfile, calls ProfilesPanel's
addProfile function.