Ignore:
Timestamp:
Dec 20, 2007, 9:42:50 AM (17 years ago)
Author:
Darin Adler
Message:

Reviewed by Eric.

SuSpider shows 2.4% speedup.

Stop using completions in the execution engine.
Instead, the completion type and label target are both
stored in the ExecState.

  • API/JSContextRef.cpp: Removed unneeded include of "completion.h".
  • bindings/runtime_method.cpp: Removed unused execute function.
  • bindings/runtime_method.h: Ditto.
  • kjs/ExecState.h: Added completionType, breakOrContinueTarget, setCompletionType, setNormalCompletion, setBreakCompletion, setContinueCompletion, setReturnValueCompletion, setThrowCompletion, setInterruptedCompletion, m_completionType, and m_breakOrContinueTarget.
  • kjs/completion.h: Removed constructor and getter for target for break and continue from Completion. This class is now only used for the public API to Interpreter and such.
  • kjs/date_object.h: Removed unused execute function.
  • kjs/function.cpp: (KJS::FunctionImp::callAsFunction): Removed some unneeded exception processing. Updated to call the new execute function and to get the completion type from the ExecState. Merged in the execute function, which repeated some of the same logic and was called only from here. (KJS::GlobalFuncImp::callAsFunction): More of the same for eval.
  • kjs/function.h: Removed execute.
  • kjs/interpreter.cpp: (KJS::Interpreter::evaluate): Added code to convert the result of execut into a Completion.
  • kjs/nodes.cpp: (KJS::Node::setErrorCompletion): Renamed from createErrorCompletion. Now sets the completion type in the ExecState. (KJS::Node::rethrowException): Now sets the completion type in the ExecState. (KJS::StatementNode::hitStatement): Now sets the completion type in the ExecState. (KJS::VarStatementNode::execute): Updated to put completion type in the ExecState instead of a Completion object. (KJS::statementListExecute): Ditto. Also changed the for loop to use indices instead of iterators. (KJS::BlockNode::execute): Updated return type. (KJS::EmptyStatementNode::execute): Updated to put completion type in the ExecState instead of a Completion object. (KJS::ExprStatementNode::execute): Ditto. (KJS::IfNode::execute): Ditto. (KJS::DoWhileNode::execute): Ditto. Also streamlined the logic a little to make the normal case a little faster and moved the end outside the loop so that "break" can do a break. (KJS::WhileNode::execute): Ditto. (KJS::ForNode::execute): Ditto. (KJS::ForInNode::execute): Ditto. (KJS::ContinueNode::execute): Updated to put completion type in the ExecState instead of a Completion object. (KJS::BreakNode::execute): Ditto. (KJS::ReturnNode::execute): Ditto. (KJS::WithNode::execute): Ditto. (KJS::CaseClauseNode::executeStatements): Ditto. Also renamed to have execute in its name to reflect the fact that it's a member of the same family of functions. (KJS::CaseBlockNode::executeBlock): Ditto. (KJS::SwitchNode::execute): Ditto. (KJS::LabelNode::execute): Ditto. (KJS::ThrowNode::execute): Ditto. (KJS::TryNode::execute): Ditto. (KJS::ProgramNode::execute): Ditto. (KJS::EvalNode::execute): Ditto. (KJS::FunctionBodyNode::execute): Ditto. (KJS::FuncDeclNode::execute): Ditto.
  • kjs/nodes.h: Renamed setErrorCompletion to createErrorCompletion, made hitStatement protected, changed return value of execute to a JSValue, renamed evalStatements to executeStatements, and evalBlock to executeBlock.
  • kjs/number_object.h: Removed unused execute function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/function.cpp

    r28884 r28887  
    7171JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    7272{
    73   // enter a new execution context
    74   ExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), FunctionCode, exec, exec->dynamicGlobalObject()->currentExec(), this, &args);
    75   if (exec->hadException())
    76     newExec.setException(exec->exception());
    77 
    78   Completion comp = execute(&newExec);
    79 
    80   // if an exception occured, propogate it back to the previous execution object
    81   if (newExec.hadException())
    82     comp = Completion(Throw, newExec.exception());
    83 
    84   if (comp.complType() == Throw) {
    85     exec->setException(comp.value());
    86     return comp.value();
    87   }
    88   else if (comp.complType() == ReturnValue)
    89     return comp.value();
    90   else
     73    ExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), FunctionCode, exec, exec->dynamicGlobalObject()->currentExec(), this, &args);
     74    JSValue* result = body->execute(&newExec);
     75    if (newExec.completionType() == Throw) {
     76        exec->setException(result);
     77        return result;
     78    }
     79    if (newExec.completionType() == ReturnValue)
     80        return result;
    9181    return jsUndefined();
    9282}
     
    213203  else
    214204    return obj;
    215 }
    216 
    217 Completion FunctionImp::execute(ExecState* exec)
    218 {
    219   Completion result = body->execute(exec);
    220 
    221   if (result.complType() == Throw || result.complType() == ReturnValue)
    222       return result;
    223   return Completion(Normal, jsUndefined()); // TODO: or ReturnValue ?
    224205}
    225206
     
    719700        JSObject* thisVal = static_cast<JSObject*>(exec->thisValue());
    720701        ExecState newExec(globalObject, thisVal, evalNode.get(), EvalCode, exec, globalObject->currentExec());
    721         if (exec->hadException())
    722             newExec.setException(exec->exception());
    723702         
    724703        if (switchGlobal) {
     
    726705            newExec.setVariableObject(static_cast<JSGlobalObject*>(thisObj));
    727706        }
    728        
    729         Completion c = evalNode->execute(&newExec);
    730          
     707        JSValue* value = evalNode->execute(&newExec);
    731708        if (switchGlobal)
    732709            newExec.popScope();
    733710
    734         // if an exception occured, propogate it back to the previous execution object
    735         if (newExec.hadException())
    736           exec->setException(newExec.exception());
    737 
    738         res = jsUndefined();
    739         if (c.complType() == Throw)
    740           exec->setException(c.value());
    741         else if (c.isValueCompletion())
    742             res = c.value();
     711        if (exec->completionType() == Throw) {
     712            exec->setException(value);
     713            return value;
     714        }
     715        return value ? value : jsUndefined();
    743716      }
    744       break;
    745717    }
    746718  case ParseInt:
Note: See TracChangeset for help on using the changeset viewer.