Changeset 34090 in webkit for trunk/JavaScriptCore/VM/Machine.cpp


Ignore:
Timestamp:
May 23, 2008, 2:28:31 PM (17 years ago)
Author:
[email protected]
Message:

2008-05-23 Geoffrey Garen <[email protected]>

Rolling back in r34085, with performance resolved.


Apparently, passing the eval function to callEval gave GCC a hernia.

Reviewed by Darin Adler, Kevin McCullough, and Oliver Hunt.


Fixed <rdar://problem/5959447> Crashes and incorrect reporting in the
JavaScript profiler

  • VM/Machine.cpp: (KJS::callEval): Made this profiler hooks slightly faster by passing in the eval function.


(KJS::Machine::unwindCallFrame): Fixed incorrect reporting / a crash
when unwinding from inside eval and/or program code: detect the
difference, and do the right thing. Also, be sure to notify the profiler
*before* deref'ing the scope chain, since the profiler uses the scope chain.

(KJS::Machine::execute): Fixed incorrect reporting / crash when calling
a JS function re-entrently: Machine::execute(FunctionBodyNode*...)
should not invoke the didExecute hook, because op_ret already does that.
Also, use the new function's ExecState when calling out to the profiler.
(Not important now, but could have become a subtle bug later.)

(KJS::Machine::privateExecute): Fixed a hard to reproduce crash when
profiling JS functions: notify the profiler *before* deref'ing the scope
chain, since the profiler uses the scope chain.

  • kjs/object.cpp: (KJS::JSObject::call): Removed these hooks, because they are now unnecessary.
  • profiler/Profile.cpp: Added a comment to explain a subtlety that only Kevin and I understood previously. (Now, the whole world can understand!)
  • profiler/Profiler.cpp: (KJS::shouldExcludeFunction): Don't exclude .call and .apply. That was a hack to fix bugs that no longer exist.

Finally, sped things up a little bit by changing the "Is the profiler
running?" check into an ASSERT, since we only call into the profiler
when it's running:

(KJS::Profiler::willExecute):
(KJS::Profiler::didExecute):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/Machine.cpp

    r34086 r34090  
    441441{
    442442    Profiler** profiler = Profiler::enabledProfilerReference();
    443     JSObject* evalFunction = scopeChain->globalObject()->evalFunction();
    444443    if (*profiler)
    445         (*profiler)->willExecute(exec, evalFunction);
     444        (*profiler)->willExecute(exec, scopeChain->globalObject()->evalFunction());
    446445
    447446    JSValue* x = argc >= 2 ? r[argv + 1].u.jsValue : jsUndefined();
     
    470469
    471470    if ((*profiler))
    472         (*profiler)->didExecute(exec, evalFunction);
     471        (*profiler)->didExecute(exec, scopeChain->globalObject()->evalFunction());
    473472
    474473    return result;
     
    577576    }
    578577
     578    Register* callFrame = r - oldCodeBlock->numLocals - CallFrameHeaderSize;
     579   
     580    if (Profiler* profiler = *Profiler::enabledProfilerReference()) {
     581        if (!isGlobalCallFrame(registerBase, r) && callFrame[Callee].u.jsObject) // Check for global and eval code
     582            profiler->didExecute(exec, callFrame[Callee].u.jsObject);
     583        else
     584            profiler->didExecute(exec, codeBlock->ownerNode->sourceURL(), codeBlock->ownerNode->lineNo());
     585    }
     586
    579587    if (oldCodeBlock->needsFullScopeChain)
    580588        scopeChain->deref();
     
    583591        return false;
    584592
    585     Register* callFrame = r - oldCodeBlock->numLocals - CallFrameHeaderSize;
    586    
    587593    codeBlock = callFrame[CallerCodeBlock].u.codeBlock;
    588594    if (!codeBlock)
     
    602608    vPC = callFrame[ReturnVPC].u.vPC;
    603609
    604     if (Profiler* profiler = *Profiler::enabledProfilerReference())
    605         profiler->didExecute(exec, callFrame[Callee].u.jsObject);
    606610    return true;
    607611}
     
    669673        scopeChain = scopeChain->copy();
    670674
     675    ExecState newExec(exec, this, registerFile, scopeChain, -1);
     676
    671677    Profiler** profiler = Profiler::enabledProfilerReference();
    672678    if (*profiler)
    673679        (*profiler)->willExecute(exec, programNode->sourceURL(), programNode->lineNo());
    674 
    675     ExecState newExec(exec, this, registerFile, scopeChain, -1);
    676680
    677681    m_reentryDepth++;
     
    739743    JSValue* result = privateExecute(Normal, &newExec, registerFile, r, scopeChain, newCodeBlock, exception);
    740744    m_reentryDepth--;
    741 
    742     if (*profiler)
    743         (*profiler)->didExecute(exec, function);
    744745
    745746    registerFile->shrink(oldSize);
     
    19761977        }
    19771978
     1979        if (*enabledProfilerReference)
     1980            (*enabledProfilerReference)->didExecute(exec, callFrame[Callee].u.jsObject);
     1981
    19781982        if (codeBlock->needsFullScopeChain)
    19791983            scopeChain->deref();
     
    19962000        int r0 = callFrame[ReturnValueRegister].u.i;
    19972001        r[r0].u.jsValue = returnValue;
    1998 
    1999         if (*enabledProfilerReference)
    2000             (*enabledProfilerReference)->didExecute(exec, callFrame[Callee].u.jsObject);
    20012002
    20022003        NEXT_OPCODE;
Note: See TracChangeset for help on using the changeset viewer.