[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

msaboff at apple.com msaboff at apple.com
Wed Dec 22 13:15:55 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 02931f0efc427f5be04a9588148eea0caef3a87d
Author: msaboff at apple.com <msaboff at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 10 02:10:37 2010 +0000

    2010-09-09  Michael Saboff  <msaboff at apple.com>
    
            Reviewed by Gavin Barraclough.
    
            Added a regular expression tracing facility.  This tracing is connected
            to jsc.  Every compiled regular expression object is added to a list.
            When the process exits, each regular expression dumps its pattern,
            JIT address, number of times it was executed and the number of matches.
            This tracing is controlled by the macro ENABLE_REGEXP_TRACING in
            wtf/Platform.h.
            https://bugs.webkit.org/show_bug.cgi?id=45401
    
            * JavaScriptCore.exp:
            * jsc.cpp:
            (runWithScripts):
            * runtime/JSGlobalData.cpp:
            (JSC::JSGlobalData::JSGlobalData):
            (JSC::JSGlobalData::~JSGlobalData):
            (JSC::JSGlobalData::addRegExpToTrace):
            (JSC::JSGlobalData::dumpRegExpTrace):
            * runtime/JSGlobalData.h:
            * runtime/RegExp.cpp:
            (JSC::RegExp::RegExp):
            (JSC::RegExp::create):
            (JSC::RegExp::match):
            * runtime/RegExp.h:
            * wtf/Platform.h:
            * yarr/RegexJIT.h:
            (JSC::Yarr::RegexCodeBlock::getAddr):
    2010-09-09  Michael Saboff  <msaboff at apple.com>
    
            Reviewed by Gavin Barraclough.
    
            Added ListHashSet.h as an exported header in support of RegExp tracing.
            https://bugs.webkit.org/show_bug.cgi?id=45401
    
            * ForwardingHeaders/wtf/ListHashSet.h: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67146 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 5a4e645..85860d8 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-09-09  Michael Saboff  <msaboff at apple.com>
+
+        Reviewed by Gavin Barraclough.
+
+        Added a regular expression tracing facility.  This tracing is connected
+        to jsc.  Every compiled regular expression object is added to a list.
+        When the process exits, each regular expression dumps its pattern,
+        JIT address, number of times it was executed and the number of matches.
+        This tracing is controlled by the macro ENABLE_REGEXP_TRACING in
+        wtf/Platform.h.
+        https://bugs.webkit.org/show_bug.cgi?id=45401
+
+        * JavaScriptCore.exp:
+        * jsc.cpp:
+        (runWithScripts):
+        * runtime/JSGlobalData.cpp:
+        (JSC::JSGlobalData::JSGlobalData):
+        (JSC::JSGlobalData::~JSGlobalData):
+        (JSC::JSGlobalData::addRegExpToTrace):
+        (JSC::JSGlobalData::dumpRegExpTrace):
+        * runtime/JSGlobalData.h:
+        * runtime/RegExp.cpp:
+        (JSC::RegExp::RegExp):
+        (JSC::RegExp::create):
+        (JSC::RegExp::match):
+        * runtime/RegExp.h:
+        * wtf/Platform.h:
+        * yarr/RegexJIT.h:
+        (JSC::Yarr::RegexCodeBlock::getAddr):
+
 2010-09-09  John Therrell  <jtherrell at apple.com>
 
         32-bit build fix.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 58959ff..ee0bfb7 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -129,6 +129,7 @@ __ZN3JSC12JSGlobalData13startSamplingEv
 __ZN3JSC12JSGlobalData14dumpSampleDataEPNS_9ExecStateE
 __ZN3JSC12JSGlobalData14resetDateCacheEv
 __ZN3JSC12JSGlobalData14sharedInstanceEv
+__ZN3JSC12JSGlobalData15dumpRegExpTraceEv
 __ZN3JSC12JSGlobalData6createENS_15ThreadStackTypeE
 __ZN3JSC12JSGlobalDataD1Ev
 __ZN3JSC12RegisterFile18committedByteCountEv
diff --git a/JavaScriptCore/jsc.cpp b/JavaScriptCore/jsc.cpp
index 8b535a9..d756a0c 100644
--- a/JavaScriptCore/jsc.cpp
+++ b/JavaScriptCore/jsc.cpp
@@ -408,6 +408,9 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr
 #if ENABLE(SAMPLING_COUNTERS)
     AbstractSamplingCounter::dump();
 #endif
+#if ENABLE(REGEXP_TRACING)
+    globalData->dumpRegExpTrace();
+#endif
     return success;
 }
 
diff --git a/JavaScriptCore/runtime/JSGlobalData.cpp b/JavaScriptCore/runtime/JSGlobalData.cpp
index 97f9be5..5eaa59b 100644
--- a/JavaScriptCore/runtime/JSGlobalData.cpp
+++ b/JavaScriptCore/runtime/JSGlobalData.cpp
@@ -51,6 +51,10 @@
 #include "Parser.h"
 #include "RegExpCache.h"
 #include <wtf/WTFThreadData.h>
+#if ENABLE(REGEXP_TRACING)
+#include "RegExp.h"
+#endif
+
 
 #if ENABLE(JSC_MULTIPLE_THREADS)
 #include <wtf/Threading.h>
@@ -145,6 +149,9 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
     , cachedUTCOffset(NaN)
     , maxReentryDepth(threadStackType == ThreadStackTypeSmall ? MaxSmallThreadReentryDepth : MaxLargeThreadReentryDepth)
     , m_regExpCache(new RegExpCache(this))
+#if ENABLE(REGEXP_TRACING)
+    , m_rtTraceList(new RTTraceList())
+#endif
 #ifndef NDEBUG
     , exclusiveThread(0)
 #endif
@@ -218,6 +225,9 @@ JSGlobalData::~JSGlobalData()
 
     delete clientData;
     delete m_regExpCache;
+#if ENABLE(REGEXP_TRACING)
+    delete m_rtTraceList;
+#endif
 }
 
 PassRefPtr<JSGlobalData> JSGlobalData::createContextGroup(ThreadStackType type)
@@ -301,4 +311,38 @@ void JSGlobalData::dumpSampleData(ExecState* exec)
     interpreter->dumpSampleData(exec);
 }
 
+
+#if ENABLE(REGEXP_TRACING)
+void JSGlobalData::addRegExpToTrace(PassRefPtr<RegExp> regExp)
+{
+    m_rtTraceList->add(regExp);
+}
+
+void JSGlobalData::dumpRegExpTrace()
+{
+    // The first RegExp object is ignored.  It is create by the RegExpPrototype ctor and not used.
+    RTTraceList::iterator iter = ++m_rtTraceList->begin();
+    
+    if (iter != m_rtTraceList->end()) {
+        printf("\nRegExp Tracing\n");
+        printf("                                                            match()    matches\n");
+        printf("Regular Expression                          JIT Address      calls      found\n");
+        printf("----------------------------------------+----------------+----------+----------\n");
+    
+        unsigned reCount = 0;
+    
+        for (; iter != m_rtTraceList->end(); ++iter, ++reCount)
+            (*iter)->printTraceData();
+
+        printf("%d Regular Expressions\n", reCount);
+    }
+    
+    m_rtTraceList->clear();
+}
+#else
+void JSGlobalData::dumpRegExpTrace()
+{
+}
+#endif
+
 } // namespace JSC
diff --git a/JavaScriptCore/runtime/JSGlobalData.h b/JavaScriptCore/runtime/JSGlobalData.h
index 43c4bab..8e2ed61 100644
--- a/JavaScriptCore/runtime/JSGlobalData.h
+++ b/JavaScriptCore/runtime/JSGlobalData.h
@@ -46,6 +46,9 @@
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
 #include <wtf/ThreadSpecific.h>
+#if ENABLE(REGEXP_TRACING)
+#include <wtf/ListHashSet.h>
+#endif
 
 struct OpaqueJSClass;
 struct OpaqueJSClassContextData;
@@ -64,6 +67,9 @@ namespace JSC {
     class Stringifier;
     class Structure;
     class UString;
+#if ENABLE(REGEXP_TRACING)
+    class RegExp;
+#endif
 
     struct HashTable;
     struct Instruction;    
@@ -222,6 +228,11 @@ namespace JSC {
         BumpPointerAllocator m_regexAllocator;
 #endif
 
+#if ENABLE(REGEXP_TRACING)
+        typedef ListHashSet<RefPtr<RegExp> > RTTraceList;
+        RTTraceList* m_rtTraceList;
+#endif
+
 #ifndef NDEBUG
         ThreadIdentifier exclusiveThread;
 #endif
@@ -234,6 +245,10 @@ namespace JSC {
         void stopSampling();
         void dumpSampleData(ExecState* exec);
         RegExpCache* regExpCache() { return m_regExpCache; }
+#if ENABLE(REGEXP_TRACING)
+        void addRegExpToTrace(PassRefPtr<RegExp> regExp);
+#endif
+        void dumpRegExpTrace();
     private:
         JSGlobalData(GlobalDataType, ThreadStackType);
         static JSGlobalData*& sharedInstanceInternal();
diff --git a/JavaScriptCore/runtime/RegExp.cpp b/JavaScriptCore/runtime/RegExp.cpp
index cb9342c..d4545cb 100644
--- a/JavaScriptCore/runtime/RegExp.cpp
+++ b/JavaScriptCore/runtime/RegExp.cpp
@@ -68,6 +68,10 @@ inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const US
     , m_flagBits(0)
     , m_constructionError(0)
     , m_numSubpatterns(0)
+#if ENABLE(REGEXP_TRACING)
+    , m_rtMatchCallCount(0)
+    , m_rtMatchFoundCount(0)
+#endif
     , m_representation(adoptPtr(new RegExpRepresentation))
 {
     // NOTE: The global flag is handled on a case-by-case basis by functions like
@@ -89,7 +93,11 @@ RegExp::~RegExp()
 
 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags)
 {
-    return adoptRef(new RegExp(globalData, pattern, flags));
+    RefPtr<RegExp> res = adoptRef(new RegExp(globalData, pattern, flags));
+#if ENABLE(REGEXP_TRACING)
+    globalData->addRegExpToTrace(res);
+#endif
+    return res.release();
 }
 
 #if ENABLE(YARR)
@@ -109,6 +117,10 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
         startOffset = 0;
     if (ovector)
         ovector->resize(0);
+    
+#if ENABLE(REGEXP_TRACING)
+    m_rtMatchCallCount++;
+#endif
 
     if (static_cast<unsigned>(startOffset) > s.length() || s.isNull())
         return -1;
@@ -149,6 +161,11 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
                 ovector->clear();
         }
         
+#if ENABLE(REGEXP_TRACING)
+        if (result != -1)
+            m_rtMatchFoundCount++;
+#endif
+
         return result;
     }
 
@@ -167,6 +184,10 @@ void RegExp::compile(JSGlobalData*)
 
 int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
 {
+#if ENABLE(REGEXP_TRACING)
+    m_rtMatchCallCount++;
+#endif
+    
     if (startOffset < 0)
         startOffset = 0;
     if (ovector)
@@ -202,12 +223,45 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
             return -1;
         }
 
+#if ENABLE(REGEXP_TRACING)
+        m_rtMatchFoundCount++;
+#endif
+        
         return offsetVector[0];
     }
 
     return -1;
 }
-
+    
 #endif
 
+#if ENABLE(REGEXP_TRACING)
+    void RegExp::printTraceData()
+    {
+        char formattedPattern[41];
+        char rawPattern[41];
+        
+        strncpy(rawPattern, m_pattern.utf8().data(), 40);
+        rawPattern[40]= '\0';
+        
+        int pattLen = strlen(rawPattern);
+        
+        snprintf(formattedPattern, 41, (pattLen <= 38) ? "/%.38s/" : "/%.36s...", rawPattern);
+
+#if ENABLE(YARR_JIT)
+        Yarr::RegexCodeBlock& codeBlock = m_representation->m_regExpJITCode;
+
+        char jitAddr[20];
+        if (codeBlock.getFallback())
+            sprintf(jitAddr, "fallback");
+        else
+            sprintf(jitAddr, "0x%014lx", (uintptr_t)codeBlock.getAddr());
+#else
+        const char* jitAddr = "JIT Off";
+#endif
+        
+        printf("%-40.40s %16.16s %10d %10d\n", formattedPattern, jitAddr, m_rtMatchCallCount, m_rtMatchFoundCount);
+    }
+#endif
+    
 } // namespace JSC
diff --git a/JavaScriptCore/runtime/RegExp.h b/JavaScriptCore/runtime/RegExp.h
index befbb8e..e6e2fbc 100644
--- a/JavaScriptCore/runtime/RegExp.h
+++ b/JavaScriptCore/runtime/RegExp.h
@@ -48,6 +48,10 @@ namespace JSC {
 
         int match(const UString&, int startOffset, Vector<int, 32>* ovector = 0);
         unsigned numSubpatterns() const { return m_numSubpatterns; }
+        
+#if ENABLE(REGEXP_TRACING)
+        void printTraceData();
+#endif
 
     private:
         RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags);
@@ -60,7 +64,11 @@ namespace JSC {
         int m_flagBits;
         const char* m_constructionError;
         unsigned m_numSubpatterns;
-        
+#if ENABLE(REGEXP_TRACING)
+        unsigned m_rtMatchCallCount;
+        unsigned m_rtMatchFoundCount;
+#endif
+
         OwnPtr<RegExpRepresentation> m_representation;
     };
 
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h
index 69de151..6749e04 100644
--- a/JavaScriptCore/wtf/Platform.h
+++ b/JavaScriptCore/wtf/Platform.h
@@ -1006,6 +1006,9 @@
 #define ENABLE_COMPUTED_GOTO_INTERPRETER 1
 #endif
 
+/* Regular Expression Tracing - Set to 1 to trace RegExp's in jsc.  Results dumped at exit */
+#define ENABLE_REGEXP_TRACING 0
+
 /* Yet Another Regex Runtime - turned on by default for JIT enabled ports. */
 #if ENABLE(JIT) && !defined(ENABLE_YARR) && !defined(ENABLE_YARR_JIT)
 #define ENABLE_YARR 1
diff --git a/JavaScriptCore/yarr/RegexJIT.h b/JavaScriptCore/yarr/RegexJIT.h
index 7f9c16e..5d587b2 100644
--- a/JavaScriptCore/yarr/RegexJIT.h
+++ b/JavaScriptCore/yarr/RegexJIT.h
@@ -73,6 +73,10 @@ public:
     {
         return reinterpret_cast<RegexJITCode>(m_ref.m_code.executableAddress())(input, start, length, output);
     }
+    
+#if ENABLE(REGEXP_TRACING)
+    void *getAddr() { return m_ref.m_code.executableAddress(); }
+#endif
 
 private:
     MacroAssembler::CodeRef m_ref;
diff --git a/JavaScriptGlue/ChangeLog b/JavaScriptGlue/ChangeLog
index 8695806..3a50e56 100644
--- a/JavaScriptGlue/ChangeLog
+++ b/JavaScriptGlue/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-09  Michael Saboff  <msaboff at apple.com>
+
+        Reviewed by Gavin Barraclough.
+
+        Added ListHashSet.h as an exported header in support of RegExp tracing.
+        https://bugs.webkit.org/show_bug.cgi?id=45401
+
+        * ForwardingHeaders/wtf/ListHashSet.h: Added.
+
 2010-09-07  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/ListHashSet.h b/JavaScriptGlue/ForwardingHeaders/wtf/ListHashSet.h
new file mode 100644
index 0000000..4aef773
--- /dev/null
+++ b/JavaScriptGlue/ForwardingHeaders/wtf/ListHashSet.h
@@ -0,0 +1 @@
+#include <JavaScriptCore/ListHashSet.h>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list