JavaScriptCore:
authorkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Apr 2008 17:20:01 +0000 (17:20 +0000)
committerkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Apr 2008 17:20:01 +0000 (17:20 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@32495 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/kjs/JSGlobalObject.cpp
JavaScriptCore/kjs/JSGlobalObject.h
JavaScriptCore/profiler/Profiler.cpp
JavaScriptCore/profiler/Profiler.h
WebCore/ChangeLog
WebCore/bindings/js/kjs_proxy.cpp
WebCore/page/Console.cpp
WebCore/page/PageGroup.cpp
WebCore/page/PageGroup.h

index b2362e8..06596b7 100644 (file)
@@ -1,3 +1,26 @@
+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.
index 74e0a58..5935368 100644 (file)
@@ -195,7 +195,7 @@ __ZN3KJS8JSObject9putDirectERKNS_10IdentifierEii
 __ZN3KJS8jsStringEPKc
 __ZN3KJS8jsStringERKNS_7UStringE
 __ZN3KJS8Profiler13stopProfilingEv
-__ZN3KJS8Profiler14startProfilingEv
+__ZN3KJS8Profiler14startProfilingEj
 __ZN3KJS8Profiler8profilerEv
 __ZN3KJS9Collector15recordExtraCostEm
 __ZN3KJS9Collector17globalObjectCountEv
index 5457357..66a933a 100644 (file)
@@ -143,6 +143,8 @@ void JSGlobalObject::init()
     d()->activations = newStackNode;
     d()->activationCount = 0;
 
+    d()->pageGroupIdentifier = 0;
+
     reset(prototype());
 }
 
index 5c99947..b87dae3 100644 (file)
@@ -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&);
 
index cec9248..560300d 100644 (file)
@@ -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;
index 0b23185..3732994 100644 (file)
@@ -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.
index 5e8413e..e3ec255 100644 (file)
@@ -1,3 +1,24 @@
+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
         * loader/appcache/ApplicationCacheGroup.h:
         (WebCore::ApplicationCacheGroup::finishedLoadingMainResource):
 
->>>>>>> .r32341
 2008-04-21  MorganL  <morganl.webkit@yahoo.com>
 
         Reviewed by eseidel.  Landed by eseidel.
index bb0f4c2..58e8c1f 100644 (file)
@@ -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();
 }
index 088dfb6..3f596bf 100644 (file)
 #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
index 178169a..f82b13f 100644 (file)
 
 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);
index fd51e4c..380b550 100644 (file)
@@ -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