Changeset 48905 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Sep 29, 2009, 2:48:52 PM (16 years ago)
Author:
[email protected]
Message:

Tidy up codeblock sampler
https://bugs.webkit.org/show_bug.cgi?id=29836

Reviewed by Gavin Barraclough.

Some rather simple refactoring of codeblock sampler so that
it's easier for us to use it to find problems in non-jsc
environments

Location:
trunk/JavaScriptCore/interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r48774 r48905  
    364364
    365365Interpreter::Interpreter()
    366     : m_sampler(0)
     366    : m_sampleEntryDepth(0)
    367367    , m_reentryDepth(0)
    368368{
    369369    privateExecute(InitializeAndReturn, 0, 0, 0);
     370#if ENABLE(OPCODE_SAMPLING)
     371    enableSampler();
     372#endif
    370373}
    371374
     
    649652    JSValue result;
    650653    {
    651         SamplingTool::CallRecord callRecord(m_sampler);
     654        SamplingTool::CallRecord callRecord(m_sampler.get());
    652655
    653656        m_reentryDepth++;
     
    715718    JSValue result;
    716719    {
    717         SamplingTool::CallRecord callRecord(m_sampler);
     720        SamplingTool::CallRecord callRecord(m_sampler.get());
    718721
    719722        m_reentryDepth++;
     
    783786    JSValue result;
    784787    {
    785         SamplingTool::CallRecord callRecord(m_sampler);
     788        SamplingTool::CallRecord callRecord(m_sampler.get());
    786789       
    787790        m_reentryDepth++;
     
    877880    JSValue result;
    878881    {
    879         SamplingTool::CallRecord callRecord(m_sampler);
     882        SamplingTool::CallRecord callRecord(m_sampler.get());
    880883
    881884        m_reentryDepth++;
     
    30573060            JSValue returnValue;
    30583061            {
    3059                 SamplingTool::HostCallRecord callRecord(m_sampler);
     3062                SamplingTool::HostCallRecord callRecord(m_sampler.get());
    30603063                returnValue = callData.native.function(newCallFrame, asObject(v), thisValue, args);
    30613064            }
     
    32113214            JSValue returnValue;
    32123215            {
    3213                 SamplingTool::HostCallRecord callRecord(m_sampler);
     3216                SamplingTool::HostCallRecord callRecord(m_sampler.get());
    32143217                returnValue = callData.native.function(newCallFrame, asObject(v), thisValue, args);
    32153218            }
     
    34633466            JSValue returnValue;
    34643467            {
    3465                 SamplingTool::HostCallRecord callRecord(m_sampler);
     3468                SamplingTool::HostCallRecord callRecord(m_sampler.get());
    34663469                returnValue = constructData.native.function(newCallFrame, asObject(v), args);
    34673470            }
     
    39153918}
    39163919
     3920void Interpreter::enableSampler()
     3921{
     3922#if ENABLE(OPCODE_SAMPLING)
     3923    if (!m_sampler) {
     3924        m_sampler.set(new SamplingTool(this));
     3925        m_sampler->setup();
     3926    }
     3927#endif
     3928}
     3929void Interpreter::dumpSampleData(ExecState* exec)
     3930{
     3931#if ENABLE(OPCODE_SAMPLING)
     3932    if (m_sampler)
     3933        m_sampler->dump(exec);
     3934#else
     3935    UNUSED_PARAM(exec);
     3936#endif
     3937}
     3938void Interpreter::startSampling()
     3939{
     3940#if ENABLE(SAMPLING_THREAD)
     3941    if (!m_sampleEntryDepth)
     3942        SamplingThread::start();
     3943
     3944    m_sampleEntryDepth++;
     3945#endif
     3946}
     3947void Interpreter::stopSampling()
     3948{
     3949#if ENABLE(SAMPLING_THREAD)
     3950    m_sampleEntryDepth--;
     3951    if (!m_sampleEntryDepth)
     3952        SamplingThread::stop();
     3953#endif
     3954}
     3955
    39173956} // namespace JSC
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r47412 r48905  
    106106        void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
    107107       
    108         void setSampler(SamplingTool* sampler) { m_sampler = sampler; }
    109         SamplingTool* sampler() { return m_sampler; }
     108        SamplingTool* sampler() { return m_sampler.get(); }
    110109
    111110        NEVER_INLINE JSValue callEval(CallFrame*, RegisterFile*, Register* argv, int argc, int registerOffset, JSValue& exceptionValue);
     
    113112        NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine);
    114113
     114        void dumpSampleData(ExecState* exec);
     115        void startSampling();
     116        void stopSampling();
    115117    private:
    116118        enum ExecutionFlag { Normal, InitializeAndReturn };
     
    150152        bool isCallBytecode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval); }
    151153
    152         SamplingTool* m_sampler;
     154        void enableSampler();
     155        int m_sampleEntryDepth;
     156        OwnPtr<SamplingTool> m_sampler;
    153157
    154158        int m_reentryDepth;
Note: See TracChangeset for help on using the changeset viewer.