Ignore:
Timestamp:
Jan 29, 2018, 2:43:13 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

JSC Sampling Profiler: Detect tester and testee when sampling in RegExp JIT
https://bugs.webkit.org/show_bug.cgi?id=152729

Reviewed by Saam Barati.

JSTests:

  • stress/sampling-profiler-regexp.js: Added.

(platformSupportsSamplingProfiler.test):
(platformSupportsSamplingProfiler.baz):
(platformSupportsSamplingProfiler):

Source/JavaScriptCore:

This patch extends SamplingProfiler to recognize JIT RegExp execution. We record
executing RegExp in VM so that SamplingProfiler can detect it. This is better
than the previous VM::isExecutingInRegExpJIT flag approach since

  1. isExecutingInRegExpJIT is set after starting executing JIT RegExp code. Thus,

if we suspend the thread just before executing this flag, or just after clearing
this flag, SamplingProfiler gets invalid frame, and frame validation fails. We
should set such a flag before and after executing JIT RegExp code.

  1. This removes VM dependency from YarrJIT which is not essential one.

We add ExecutionContext enum to RegExp::matchInline not to mark execution if it
is done in non JS thread.

  • bytecode/BytecodeDumper.cpp:

(JSC::regexpName):
(JSC::BytecodeDumper<Block>::dumpRegExps):
(JSC::regexpToSourceString): Deleted.

  • heap/Heap.cpp:

(JSC::Heap::addCoreConstraints):

  • runtime/RegExp.cpp:

(JSC::RegExp::compile):
(JSC::RegExp::match):
(JSC::RegExp::matchConcurrently):
(JSC::RegExp::compileMatchOnly):
(JSC::RegExp::toSourceString const):

  • runtime/RegExp.h:
  • runtime/RegExpInlines.h:

(JSC::RegExp::matchInline):

  • runtime/RegExpMatchesArray.h:

(JSC::createRegExpMatchesArray):

  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::SamplingProfiler):
(JSC::SamplingProfiler::timerLoop):
(JSC::SamplingProfiler::takeSample):
(JSC::SamplingProfiler::processUnverifiedStackTraces):
(JSC::SamplingProfiler::StackFrame::nameFromCallee):
(JSC::SamplingProfiler::StackFrame::displayName):
(JSC::SamplingProfiler::StackFrame::displayNameForJSONTests):
(JSC::SamplingProfiler::StackFrame::functionStartLine):
(JSC::SamplingProfiler::StackFrame::functionStartColumn):
(JSC::SamplingProfiler::StackFrame::sourceID):
(JSC::SamplingProfiler::StackFrame::url):
(WTF::printInternal):
(JSC::SamplingProfiler::~SamplingProfiler): Deleted.

  • runtime/SamplingProfiler.h:
  • runtime/VM.h:
  • yarr/YarrJIT.cpp:

(JSC::Yarr::YarrGenerator::generateEnter):
(JSC::Yarr::YarrGenerator::generateReturn):
(JSC::Yarr::YarrGenerator::YarrGenerator):
(JSC::Yarr::jitCompile):

  • yarr/YarrJIT.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.cpp

    r226928 r227725  
    251251}
    252252
    253 static CString regexpToSourceString(RegExp* regExp)
    254 {
    255     char postfix[7] = { '/', 0, 0, 0, 0, 0, 0 };
    256     int index = 1;
    257     if (regExp->global())
    258         postfix[index++] = 'g';
    259     if (regExp->ignoreCase())
    260         postfix[index++] = 'i';
    261     if (regExp->multiline())
    262         postfix[index] = 'm';
    263     if (regExp->dotAll())
    264         postfix[index++] = 's';
    265     if (regExp->unicode())
    266         postfix[index++] = 'u';
    267     if (regExp->sticky())
    268         postfix[index++] = 'y';
    269 
    270     return toCString("/", regExp->pattern().impl(), postfix);
    271 }
    272 
    273253static CString regexpName(int re, RegExp* regexp)
    274254{
    275     return toCString(regexpToSourceString(regexp), "(@re", re, ")");
     255    return toCString(regexp->toSourceString(), "(@re", re, ")");
    276256}
    277257
     
    17491729        size_t i = 0;
    17501730        do {
    1751             out.printf("  re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(block()->regexp(i)).data());
     1731            out.print("  re", i, " = ", block()->regexp(i)->toSourceString(), "\n");
    17521732            ++i;
    17531733        } while (i < count);
Note: See TracChangeset for help on using the changeset viewer.