Ignore:
Timestamp:
Sep 9, 2010, 7:10:37 PM (15 years ago)
Author:
[email protected]
Message:

2010-09-09 Michael Saboff <[email protected]>

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 <[email protected]>

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/RegExp.cpp

    r66936 r67146  
    6969    , m_constructionError(0)
    7070    , m_numSubpatterns(0)
     71#if ENABLE(REGEXP_TRACING)
     72    , m_rtMatchCallCount(0)
     73    , m_rtMatchFoundCount(0)
     74#endif
    7175    , m_representation(adoptPtr(new RegExpRepresentation))
    7276{
     
    9094PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags)
    9195{
    92     return adoptRef(new RegExp(globalData, pattern, flags));
     96    RefPtr<RegExp> res = adoptRef(new RegExp(globalData, pattern, flags));
     97#if ENABLE(REGEXP_TRACING)
     98    globalData->addRegExpToTrace(res);
     99#endif
     100    return res.release();
    93101}
    94102
     
    110118    if (ovector)
    111119        ovector->resize(0);
     120   
     121#if ENABLE(REGEXP_TRACING)
     122    m_rtMatchCallCount++;
     123#endif
    112124
    113125    if (static_cast<unsigned>(startOffset) > s.length() || s.isNull())
     
    150162        }
    151163       
     164#if ENABLE(REGEXP_TRACING)
     165        if (result != -1)
     166            m_rtMatchFoundCount++;
     167#endif
     168
    152169        return result;
    153170    }
     
    168185int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
    169186{
     187#if ENABLE(REGEXP_TRACING)
     188    m_rtMatchCallCount++;
     189#endif
     190   
    170191    if (startOffset < 0)
    171192        startOffset = 0;
     
    203224        }
    204225
     226#if ENABLE(REGEXP_TRACING)
     227        m_rtMatchFoundCount++;
     228#endif
     229       
    205230        return offsetVector[0];
    206231    }
     
    208233    return -1;
    209234}
    210 
    211 #endif
    212 
     235   
     236#endif
     237
     238#if ENABLE(REGEXP_TRACING)
     239    void RegExp::printTraceData()
     240    {
     241        char formattedPattern[41];
     242        char rawPattern[41];
     243       
     244        strncpy(rawPattern, m_pattern.utf8().data(), 40);
     245        rawPattern[40]= '\0';
     246       
     247        int pattLen = strlen(rawPattern);
     248       
     249        snprintf(formattedPattern, 41, (pattLen <= 38) ? "/%.38s/" : "/%.36s...", rawPattern);
     250
     251#if ENABLE(YARR_JIT)
     252        Yarr::RegexCodeBlock& codeBlock = m_representation->m_regExpJITCode;
     253
     254        char jitAddr[20];
     255        if (codeBlock.getFallback())
     256            sprintf(jitAddr, "fallback");
     257        else
     258            sprintf(jitAddr, "0x%014lx", (uintptr_t)codeBlock.getAddr());
     259#else
     260        const char* jitAddr = "JIT Off";
     261#endif
     262       
     263        printf("%-40.40s %16.16s %10d %10d\n", formattedPattern, jitAddr, m_rtMatchCallCount, m_rtMatchFoundCount);
     264    }
     265#endif
     266   
    213267} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.