Title: [165855] trunk/Source/_javascript_Core
Revision
165855
Author
[email protected]
Date
2014-03-18 16:53:49 -0700 (Tue, 18 Mar 2014)

Log Message

Update RegExp Tracing code
https://bugs.webkit.org/show_bug.cgi?id=130381

Reviewed by Andreas Kling.

Updated the regular _expression_ tracing code for 8/16 bit JIT as
well as match only entry points.  Also added average string length
metric.

* runtime/RegExp.cpp:
(JSC::RegExp::RegExp):
(JSC::RegExp::match):
(JSC::RegExp::printTraceData):
* runtime/RegExp.h:
* runtime/VM.cpp:
(JSC::VM::addRegExpToTrace):
(JSC::VM::dumpRegExpTrace):
* runtime/VM.h:
* yarr/YarrJIT.h:
(JSC::Yarr::YarrCodeBlock::get8BitMatchOnlyAddr):
(JSC::Yarr::YarrCodeBlock::get16BitMatchOnlyAddr):
(JSC::Yarr::YarrCodeBlock::get8BitMatchAddr):
(JSC::Yarr::YarrCodeBlock::get16BitMatchAddr):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (165854 => 165855)


--- trunk/Source/_javascript_Core/ChangeLog	2014-03-18 23:09:44 UTC (rev 165854)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-03-18 23:53:49 UTC (rev 165855)
@@ -1,3 +1,29 @@
+2014-03-18  Michael Saboff  <[email protected]>
+
+        Update RegExp Tracing code
+        https://bugs.webkit.org/show_bug.cgi?id=130381
+
+        Reviewed by Andreas Kling.
+
+        Updated the regular _expression_ tracing code for 8/16 bit JIT as
+        well as match only entry points.  Also added average string length
+        metric.
+
+        * runtime/RegExp.cpp:
+        (JSC::RegExp::RegExp):
+        (JSC::RegExp::match):
+        (JSC::RegExp::printTraceData):
+        * runtime/RegExp.h:
+        * runtime/VM.cpp:
+        (JSC::VM::addRegExpToTrace):
+        (JSC::VM::dumpRegExpTrace):
+        * runtime/VM.h:
+        * yarr/YarrJIT.h:
+        (JSC::Yarr::YarrCodeBlock::get8BitMatchOnlyAddr):
+        (JSC::Yarr::YarrCodeBlock::get16BitMatchOnlyAddr):
+        (JSC::Yarr::YarrCodeBlock::get8BitMatchAddr):
+        (JSC::Yarr::YarrCodeBlock::get16BitMatchAddr):
+
 2014-03-17  Filip Pizlo  <[email protected]>
 
         Add CompareStrictEq(StringIdent:, NotStringVar:) and CompareStrictEq(String:, Untyped:)

Modified: trunk/Source/_javascript_Core/runtime/RegExp.cpp (165854 => 165855)


--- trunk/Source/_javascript_Core/runtime/RegExp.cpp	2014-03-18 23:09:44 UTC (rev 165854)
+++ trunk/Source/_javascript_Core/runtime/RegExp.cpp	2014-03-18 23:53:49 UTC (rev 165855)
@@ -227,6 +227,10 @@
     , m_constructionError(0)
     , m_numSubpatterns(0)
 #if ENABLE(REGEXP_TRACING)
+    , m_rtMatchOnlyTotalSubjectStringLen(0.0)
+    , m_rtMatchTotalSubjectStringLen(0.0)
+    , m_rtMatchOnlyCallCount(0)
+    , m_rtMatchOnlyFoundCount(0)
     , m_rtMatchCallCount(0)
     , m_rtMatchFoundCount(0)
 #endif
@@ -324,6 +328,7 @@
 {
 #if ENABLE(REGEXP_TRACING)
     m_rtMatchCallCount++;
+    m_rtMatchTotalSubjectStringLen += (double)(s.length() - startOffset);
 #endif
 
     ASSERT(m_state != ParseError);
@@ -445,7 +450,8 @@
 MatchResult RegExp::match(VM& vm, const String& s, unsigned startOffset)
 {
 #if ENABLE(REGEXP_TRACING)
-    m_rtMatchCallCount++;
+    m_rtMatchOnlyCallCount++;
+    m_rtMatchOnlyTotalSubjectStringLen += (double)(s.length() - startOffset);
 #endif
 
     ASSERT(m_state != ParseError);
@@ -458,7 +464,7 @@
             m_regExpJITCode.execute(s.characters16(), startOffset, s.length());
 #if ENABLE(REGEXP_TRACING)
         if (!result)
-            m_rtMatchFoundCount++;
+            m_rtMatchOnlyFoundCount++;
 #endif
         return result;
     }
@@ -476,7 +482,7 @@
 
     if (r >= 0) {
 #if ENABLE(REGEXP_TRACING)
-        m_rtMatchFoundCount++;
+        m_rtMatchOnlyFoundCount++;
 #endif
         return MatchResult(r, reinterpret_cast<unsigned*>(offsetVector)[1]);
     }
@@ -563,16 +569,32 @@
         Yarr::YarrCodeBlock& codeBlock = m_regExpJITCode;
 
         const size_t jitAddrSize = 20;
-        char jitAddr[jitAddrSize];
-        if (m_state == JITCode)
-            snprintf(jitAddr, jitAddrSize, "fallback");
-        else
-            snprintf(jitAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.getAddr()));
+        char jit8BitMatchOnlyAddr[jitAddrSize];
+        char jit16BitMatchOnlyAddr[jitAddrSize];
+        char jit8BitMatchAddr[jitAddrSize];
+        char jit16BitMatchAddr[jitAddrSize];
+        if (m_state == ByteCode) {
+            snprintf(jit8BitMatchOnlyAddr, jitAddrSize, "fallback    ");
+            snprintf(jit16BitMatchOnlyAddr, jitAddrSize, "----      ");
+            snprintf(jit8BitMatchAddr, jitAddrSize, "fallback    ");
+            snprintf(jit16BitMatchAddr, jitAddrSize, "----      ");
+        } else {
+            snprintf(jit8BitMatchOnlyAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get8BitMatchOnlyAddr()));
+            snprintf(jit16BitMatchOnlyAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get16BitMatchOnlyAddr()));
+            snprintf(jit8BitMatchAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get8BitMatchAddr()));
+            snprintf(jit16BitMatchAddr, jitAddrSize, "0x%014lx", reinterpret_cast<unsigned long int>(codeBlock.get16BitMatchAddr()));
+        }
 #else
-        const char* jitAddr = "JIT Off";
+        const char* jit8BitMatchOnlyAddr = "JIT Off";
+        const char* jit16BitMatchOnlyAddr = "";
+        const char* jit8BitMatchAddr = "JIT Off";
+        const char* jit16BitMatchAddr = "";
 #endif
+        unsigned averageMatchOnlyStringLen = (unsigned)(m_rtMatchOnlyTotalSubjectStringLen / m_rtMatchOnlyCallCount);
+        unsigned averageMatchStringLen = (unsigned)(m_rtMatchTotalSubjectStringLen / m_rtMatchCallCount);
 
-        printf("%-40.40s %16.16s %10d %10d\n", formattedPattern, jitAddr, m_rtMatchCallCount, m_rtMatchFoundCount);
+        printf("%-40.40s %16.16s %16.16s %10d %10d %10u\n", formattedPattern, jit8BitMatchOnlyAddr, jit16BitMatchOnlyAddr, m_rtMatchOnlyCallCount, m_rtMatchOnlyFoundCount, averageMatchOnlyStringLen);
+        printf("                                         %16.16s %16.16s %10d %10d %10u\n", jit8BitMatchAddr, jit16BitMatchAddr, m_rtMatchCallCount, m_rtMatchFoundCount, averageMatchStringLen);
     }
 #endif
 

Modified: trunk/Source/_javascript_Core/runtime/RegExp.h (165854 => 165855)


--- trunk/Source/_javascript_Core/runtime/RegExp.h	2014-03-18 23:09:44 UTC (rev 165854)
+++ trunk/Source/_javascript_Core/runtime/RegExp.h	2014-03-18 23:53:49 UTC (rev 165855)
@@ -117,6 +117,10 @@
         const char* m_constructionError;
         unsigned m_numSubpatterns;
 #if ENABLE(REGEXP_TRACING)
+        double m_rtMatchOnlyTotalSubjectStringLen;
+        double m_rtMatchTotalSubjectStringLen;
+        unsigned m_rtMatchOnlyCallCount;
+        unsigned m_rtMatchOnlyFoundCount;
         unsigned m_rtMatchCallCount;
         unsigned m_rtMatchFoundCount;
 #endif

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (165854 => 165855)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2014-03-18 23:09:44 UTC (rev 165854)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2014-03-18 23:53:49 UTC (rev 165855)
@@ -849,6 +849,7 @@
 #if ENABLE(REGEXP_TRACING)
 void VM::addRegExpToTrace(RegExp* regExp)
 {
+    gcProtect(regExp);
     m_rtTraceList->add(regExp);
 }
 
@@ -859,14 +860,16 @@
     
     if (iter != m_rtTraceList->end()) {
         dataLogF("\nRegExp Tracing\n");
-        dataLogF("                                                            match()    matches\n");
-        dataLogF("Regular _expression_                          JIT Address      calls      found\n");
-        dataLogF("----------------------------------------+----------------+----------+----------\n");
+        dataLogF("Regular _expression_                              8 Bit          16 Bit        match()    Matches    Average\n");
+        dataLogF(" <Match only / Match>                         JIT Addr      JIT Address       calls      found   String len\n");
+        dataLogF("----------------------------------------+----------------+----------------+----------+----------+-----------\n");
     
         unsigned reCount = 0;
     
-        for (; iter != m_rtTraceList->end(); ++iter, ++reCount)
+        for (; iter != m_rtTraceList->end(); ++iter, ++reCount) {
             (*iter)->printTraceData();
+            gcUnprotect(*iter);
+        }
 
         dataLogF("%d Regular Expressions\n", reCount);
     }

Modified: trunk/Source/_javascript_Core/runtime/VM.h (165854 => 165855)


--- trunk/Source/_javascript_Core/runtime/VM.h	2014-03-18 23:09:44 UTC (rev 165854)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2014-03-18 23:53:49 UTC (rev 165855)
@@ -458,7 +458,7 @@
         BumpPointerAllocator m_regExpAllocator;
 
 #if ENABLE(REGEXP_TRACING)
-        typedef ListHashSet<RefPtr<RegExp>> RTTraceList;
+        typedef ListHashSet<RegExp*> RTTraceList;
         RTTraceList* m_rtTraceList;
 #endif
 
@@ -473,7 +473,7 @@
         JS_EXPORT_PRIVATE void dumpSampleData(ExecState* exec);
         RegExpCache* regExpCache() { return m_regExpCache; }
 #if ENABLE(REGEXP_TRACING)
-        void addRegExpToTrace(PassRefPtr<RegExp> regExp);
+        void addRegExpToTrace(RegExp*);
 #endif
         JS_EXPORT_PRIVATE void dumpRegExpTrace();
 

Modified: trunk/Source/_javascript_Core/yarr/YarrJIT.h (165854 => 165855)


--- trunk/Source/_javascript_Core/yarr/YarrJIT.h	2014-03-18 23:09:44 UTC (rev 165854)
+++ trunk/Source/_javascript_Core/yarr/YarrJIT.h	2014-03-18 23:53:49 UTC (rev 165855)
@@ -108,7 +108,37 @@
     }
 
 #if ENABLE(REGEXP_TRACING)
-    void *getAddr() { return m_ref.code().executableAddress(); }
+    void *get8BitMatchOnlyAddr()
+    {
+        if (!has8BitCodeMatchOnly())
+            return 0;
+
+        return m_matchOnly8.code().executableAddress();
+    }
+
+    void *get16BitMatchOnlyAddr()
+    {
+        if (!has16BitCodeMatchOnly())
+            return 0;
+
+        return m_matchOnly16.code().executableAddress();
+    }
+
+    void *get8BitMatchAddr()
+    {
+        if (!has8BitCode())
+            return 0;
+
+        return m_ref8.code().executableAddress();
+    }
+
+    void *get16BitMatchAddr()
+    {
+        if (!has16BitCode())
+            return 0;
+
+        return m_ref16.code().executableAddress();
+    }
 #endif
 
     void clear()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to