Ignore:
Timestamp:
Jan 29, 2018, 2:43:13 AM (7 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/runtime/SamplingProfiler.h

    r226295 r227725  
    4040namespace JSC {
    4141
     42class RegExp;
    4243class VM;
    4344class ExecutableBase;
     
    6970        Executable,
    7071        Host,
     72        RegExp,
    7173        C,
    7274        Unknown
     
    8688        ExecutableBase* executable { nullptr };
    8789        JSObject* callee { nullptr };
     90        RegExp* regExp { nullptr };
    8891
    8992        struct CodeLocation {
     
    142145        bool topFrameIsLLInt;
    143146        void* llintPC;
     147        RegExp* regExp;
    144148        Vector<UnprocessedStackFrame> frames;
    145149    };
     
    157161
    158162    SamplingProfiler(VM&, RefPtr<Stopwatch>&&);
    159     ~SamplingProfiler();
     163    ~SamplingProfiler() = default;
    160164    void noticeJSLockAcquisition();
    161165    void noticeVMEntry();
     
    186190    void createThreadIfNecessary(const AbstractLocker&);
    187191    void timerLoop();
    188     void takeSample(const AbstractLocker&, Seconds& stackTraceProcessingTime);
     192    Seconds takeSample(const AbstractLocker&);
    189193
    190194    VM& m_vm;
     
    198202    RefPtr<Thread> m_thread;
    199203    RefPtr<Thread> m_jscExecutionThread;
    200     bool m_isPaused;
    201     bool m_isShutDown;
     204    bool m_isPaused { false };
     205    bool m_isShutDown { false };
    202206    bool m_needsReportAtExit { false };
    203207    HashSet<JSCell*> m_liveCellPointers;
Note: See TracChangeset for help on using the changeset viewer.