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


Ignore:
Timestamp:
May 26, 2008, 11:50:55 AM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Darin Adler.


Fixed <rdar://problem/5960859> After an eval of a non-string or a syntax
error, all profile stack frames are incorrect


SunSpider reports a .3% speedup, possibly because eval of a string is a
little more efficient now.

  • VM/Machine.cpp: (KJS::callEval): Make sure to call didExecute when returning early. I simplified this function to remove one early return, making the job of adding special code to early returns easier.

(KJS::Machine::execute): Use the new function ExecState when notifying
the profiler. (This doesn't change behavior now, but it might lead to
subtle errors in the future.)

File:
1 edited

Legend:

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

    r34095 r34135  
    440440static NEVER_INLINE JSValue* callEval(ExecState* exec, JSObject* thisObj, ScopeChainNode* scopeChain, RegisterFile* registerFile, Register* r, int argv, int argc, JSValue*& exceptionValue)
    441441{
     442    if (argc < 2)
     443        return jsUndefined();
     444
     445    JSValue* program = r[argv + 1].u.jsValue;
     446   
     447    if (!program->isString())
     448        return program;
     449   
    442450    Profiler** profiler = Profiler::enabledProfilerReference();
    443451    if (*profiler)
    444452        (*profiler)->willExecute(exec, scopeChain->globalObject()->evalFunction());
    445453
    446     JSValue* x = argc >= 2 ? r[argv + 1].u.jsValue : jsUndefined();
    447    
    448     if (!x->isString())
    449         return x;
    450    
    451     UString s = x->toString(exec);
    452     if (exec->hadException()) {
    453         exceptionValue = exec->exception();
    454         exec->clearException();
    455         return 0;
    456     }
    457 
    458454    int sourceId;
    459455    int errLine;
    460456    UString errMsg;
    461     RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(exec, UString(), 0, UStringSourceProvider::create(s), &sourceId, &errLine, &errMsg);
     457    RefPtr<EvalNode> evalNode = parser().parse<EvalNode>(exec, UString(), 0, UStringSourceProvider::create(static_cast<StringImp*>(program)->value()), &sourceId, &errLine, &errMsg);
    462458   
    463459    if (!evalNode) {
    464460        exceptionValue = Error::create(exec, SyntaxError, errMsg, errLine, sourceId, NULL);
     461        if (*profiler)
     462            (*profiler)->didExecute(exec, scopeChain->globalObject()->evalFunction());
    465463        return 0;
    466464    }
     
    468466    JSValue* result = machine().execute(evalNode.get(), exec, thisObj, registerFile, r - (*registerFile->basePointer()) + argv + argc, scopeChain, &exceptionValue);
    469467
    470     if ((*profiler))
     468    if (*profiler)
    471469        (*profiler)->didExecute(exec, scopeChain->globalObject()->evalFunction());
    472470
     
    795793        scopeChain = scopeChain->copy();
    796794
     795    ExecState newExec(exec, this, registerFile, scopeChain, -1);
     796
    797797    Profiler** profiler = Profiler::enabledProfilerReference();
    798798    if (*profiler)
    799799        (*profiler)->willExecute(exec, evalNode->sourceURL(), evalNode->lineNo());
    800 
    801     ExecState newExec(exec, this, registerFile, scopeChain, -1);
    802800
    803801    m_reentryDepth++;
Note: See TracChangeset for help on using the changeset viewer.