Commit d9e61e09 authored by kmccullough@apple.com's avatar kmccullough@apple.com

JavaScriptCore:

2008-04-24  Kevin McCullough  <kmccullough@apple.com>

        Reviewed by Adam and Sam.

        -<rdar://problem/5770054> JavaScript profiler (10928)
        -Only profile the page group that starts profiling to avoid profiling
        tools that shouldn't be profiled unless explicitly requested to.

        * JavaScriptCore.exp: Export new signature.
        * kjs/JSGlobalObject.cpp: Add unique identifiers to the JSGlobalObject.
        (KJS::JSGlobalObject::init):
        * kjs/JSGlobalObject.h: Ditto.
        (KJS::JSGlobalObject::setPageGroupIdentifier):
        (KJS::JSGlobalObject::pageGroupIdentifier):
        * profiler/Profiler.cpp: Check the identifier of the page group of the
        lexical global exec state and only profile if it matches the given page
        group identifier.
        (KJS::Profiler::startProfiling):
        (KJS::Profiler::willExecute):
        (KJS::Profiler::didExecute):
        * profiler/Profiler.h: Ditto.
        (KJS::Profiler::Profiler):

WebCore:

2008-04-24  Kevin McCullough  <kmccullough@apple.com>

        Reviewed by Adam and Sam.

        -<rdar://problem/5770054> JavaScript profiler (10928)
        -Only profile the page group that starts profiling to avoid profiling
        tools that shouldn't be profiled unless explicitly requested to.

        * bindings/js/kjs_proxy.cpp: When a new global object is created set its
        page group identifier.
        (WebCore::KJSProxy::clear):
        (WebCore::KJSProxy::initScript):
        * page/Console.cpp: When calling console.profile set the identifier of
        the page group being profiled.
        (WebCore::Console::profile):
        * page/PageGroup.cpp: Implement unique identifiers.
        (WebCore::getUniqueIdentifier):
        (WebCore::PageGroup::PageGroup):
        * page/PageGroup.h: Ditto.
        (WebCore::PageGroup::identifier):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 48f31edd
2008-04-24 Kevin McCullough <kmccullough@apple.com>
Reviewed by Adam and Sam.
-<rdar://problem/5770054> JavaScript profiler (10928)
-Only profile the page group that starts profiling to avoid profiling
tools that shouldn't be profiled unless explicitly requested to.
* JavaScriptCore.exp: Export new signature.
* kjs/JSGlobalObject.cpp: Add unique identifiers to the JSGlobalObject.
(KJS::JSGlobalObject::init):
* kjs/JSGlobalObject.h: Ditto.
(KJS::JSGlobalObject::setPageGroupIdentifier):
(KJS::JSGlobalObject::pageGroupIdentifier):
* profiler/Profiler.cpp: Check the identifier of the page group of the
lexical global exec state and only profile if it matches the given page
group identifier.
(KJS::Profiler::startProfiling):
(KJS::Profiler::willExecute):
(KJS::Profiler::didExecute):
* profiler/Profiler.h: Ditto.
(KJS::Profiler::Profiler):
2008-04-24 Julien Chaffraix <jchaffraix@webkit.org>
Reviewed by Simon.
......
......@@ -195,7 +195,7 @@ __ZN3KJS8JSObject9putDirectERKNS_10IdentifierEii
__ZN3KJS8jsStringEPKc
__ZN3KJS8jsStringERKNS_7UStringE
__ZN3KJS8Profiler13stopProfilingEv
__ZN3KJS8Profiler14startProfilingEv
__ZN3KJS8Profiler14startProfilingEj
__ZN3KJS8Profiler8profilerEv
__ZN3KJS9Collector15recordExtraCostEm
__ZN3KJS9Collector17globalObjectCountEv
......
......@@ -143,6 +143,8 @@ void JSGlobalObject::init()
d()->activations = newStackNode;
d()->activationCount = 0;
d()->pageGroupIdentifier = 0;
reset(prototype());
}
......
......@@ -137,6 +137,8 @@ namespace KJS {
ActivationStackNode* activations;
size_t activationCount;
unsigned pageGroupIdentifier;
OwnPtr<HashSet<JSObject*> > arrayVisitedElements; // Global data shared by array prototype functions.
};
......@@ -209,6 +211,9 @@ namespace KJS {
NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; }
NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; }
void setPageGroupIdentifier(unsigned value) { d()->pageGroupIdentifier = value; }
unsigned pageGroupIdentifier() const { return d()->pageGroupIdentifier; }
void saveBuiltins(SavedBuiltins&) const;
void restoreBuiltins(const SavedBuiltins&);
......
......@@ -30,8 +30,9 @@
#include "Profiler.h"
#include "FunctionCallProfile.h"
#include <kjs/ExecState.h>
#include <kjs/function.h>
#include "JSGlobalObject.h"
#include "ExecState.h"
#include "function.h"
#include <stdio.h>
......@@ -52,11 +53,13 @@ Profiler* Profiler::profiler()
return sharedProfiler;
}
void Profiler::startProfiling()
void Profiler::startProfiling(unsigned pageGroupIdentifier)
{
if (m_profiling)
return;
m_pageGroupIdentifier = pageGroupIdentifier;
// FIXME: When multi-threading is supported this will be a vector and calls
// into the profiler will need to know which thread it is executing on.
m_callTree.set(new FunctionCallProfile("Thread_1"));
......@@ -71,7 +74,7 @@ void Profiler::stopProfiling()
void Profiler::willExecute(ExecState* exec, JSObject* calledFunction)
{
if (!m_profiling)
if (!m_profiling || exec->lexicalGlobalObject()->pageGroupIdentifier() != m_pageGroupIdentifier)
return;
Vector<UString> callStackNames;
......@@ -81,7 +84,7 @@ void Profiler::willExecute(ExecState* exec, JSObject* calledFunction)
void Profiler::willExecute(ExecState* exec, const UString& sourceURL, int startingLineNumber)
{
if (!m_profiling)
if (!m_profiling || exec->lexicalGlobalObject()->pageGroupIdentifier() != m_pageGroupIdentifier)
return;
Vector<UString> callStackNames;
......@@ -91,7 +94,7 @@ void Profiler::willExecute(ExecState* exec, const UString& sourceURL, int starti
void Profiler::didExecute(ExecState* exec, JSObject* calledFunction)
{
if (!m_profiling)
if (!m_profiling || exec->lexicalGlobalObject()->pageGroupIdentifier() != m_pageGroupIdentifier)
return;
Vector<UString> callStackNames;
......@@ -101,7 +104,7 @@ void Profiler::didExecute(ExecState* exec, JSObject* calledFunction)
void Profiler::didExecute(ExecState* exec, const UString& sourceURL, int startingLineNumber)
{
if (!m_profiling)
if (!m_profiling || exec->lexicalGlobalObject()->pageGroupIdentifier() != m_pageGroupIdentifier)
return;
Vector<UString> callStackNames;
......
......@@ -45,7 +45,7 @@ namespace KJS {
static Profiler* profiler();
static void debugLog(UString);
void startProfiling();
void startProfiling(unsigned Identifier);
void stopProfiling();
void willExecute(ExecState*, JSObject* calledFunction);
void willExecute(ExecState*, const UString& sourceURL, int startingLineNumber);
......@@ -58,12 +58,14 @@ namespace KJS {
private:
Profiler()
: m_profiling(false)
, m_pageGroupIdentifier(0)
{
}
void insertStackNamesInTree(const Vector<UString>& callStackNames);
bool m_profiling;
unsigned m_pageGroupIdentifier;
// FIXME: Make this a vector of FunctionCallProfiles where each one is the
// root of a new thread.
......
2008-04-24 Kevin McCullough <kmccullough@apple.com>
Reviewed by Adam and Sam.
-<rdar://problem/5770054> JavaScript profiler (10928)
-Only profile the page group that starts profiling to avoid profiling
tools that shouldn't be profiled unless explicitly requested to.
* bindings/js/kjs_proxy.cpp: When a new global object is created set its
page group identifier.
(WebCore::KJSProxy::clear):
(WebCore::KJSProxy::initScript):
* page/Console.cpp: When calling console.profile set the identifier of
the page group being profiled.
(WebCore::Console::profile):
* page/PageGroup.cpp: Implement unique identifiers.
(WebCore::getUniqueIdentifier):
(WebCore::PageGroup::PageGroup):
* page/PageGroup.h: Ditto.
(WebCore::PageGroup::identifier):
2008-04-24 John Sullivan <sullivan@apple.com>
Mac buid fix
......@@ -1508,7 +1529,6 @@
* loader/appcache/ApplicationCacheGroup.h:
(WebCore::ApplicationCacheGroup::finishedLoadingMainResource):
>>>>>>> .r32341
2008-04-21 MorganL <morganl.webkit@yahoo.com>
Reviewed by eseidel. Landed by eseidel.
......@@ -32,6 +32,7 @@
#include "JSDocument.h"
#include "JSDOMWindow.h"
#include "Page.h"
#include "PageGroup.h"
#include "Settings.h"
#include "kjs_events.h"
#include <kjs/debugger.h>
......@@ -110,6 +111,8 @@ void KJSProxy::clear()
// (we used to delete and re-create it, previously)
if (m_windowWrapper)
m_windowWrapper->clear();
m_windowWrapper->window()->setPageGroupIdentifier(0);
}
EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node)
......@@ -146,8 +149,10 @@ void KJSProxy::initScript()
m_windowWrapper = new JSDOMWindowWrapper(m_frame->domWindow());
if (Page* page = m_frame->page())
if (Page* page = m_frame->page()) {
attachDebugger(page->debugger());
m_windowWrapper->window()->setPageGroupIdentifier(page->group().identifier());
}
m_frame->loader()->dispatchWindowObjectAvailable();
}
......
......@@ -32,8 +32,10 @@
#include "ChromeClient.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameTree.h"
#include "InspectorController.h"
#include "Page.h"
#include "PageGroup.h"
#include "PlatformString.h"
#include <kjs/list.h>
#include <profiler/Profiler.h>
......@@ -128,7 +130,11 @@ void Console::profile(const String& /*title*/) const
{
// FIXME: Figure out something to do with the title passed in so that it can
// be displayed by the inspector.
Profiler::profiler()->startProfiling();
Page* page = m_frame->page();
if (!page)
return;
Profiler::profiler()->startProfiling(page->group().identifier());
}
void Console::profileEnd() const
......
......@@ -37,12 +37,19 @@
namespace WebCore {
static unsigned getUniqueIdentifier()
{
static unsigned currentIdentifier = 0;
return ++currentIdentifier;
}
// --------
static bool shouldTrackVisitedLinks;
PageGroup::PageGroup(Page* page)
: m_visitedLinksPopulated(false)
, m_identifier(getUniqueIdentifier())
{
ASSERT(page);
m_pages.add(page);
......
......@@ -54,6 +54,8 @@ namespace WebCore {
static void setShouldTrackVisitedLinks(bool);
static void removeAllVisitedLinks();
unsigned identifier() { return m_identifier; }
#if ENABLE(DOM_STORAGE)
LocalStorage* localStorage();
#endif
......@@ -65,6 +67,7 @@ namespace WebCore {
HashSet<unsigned, AlreadyHashed> m_visitedLinkHashes;
bool m_visitedLinksPopulated;
unsigned m_identifier;
#if ENABLE(DOM_STORAGE)
RefPtr<LocalStorage> m_localStorage;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment