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/ExecState.h

    r28884 r28887  
    109109
    110110        LocalStorage& localStorage() { return *m_localStorage; }
    111    
     111
     112        // These are only valid right after calling execute().
     113        ComplType completionType() const { return m_completionType; }
     114        const Identifier& breakOrContinueTarget() const
     115        {
     116            ASSERT(m_completionType == Break || m_completionType == Continue);
     117            return *m_breakOrContinueTarget;
     118        }
     119
     120        // Only for use in the implementation of execute().
     121        void setCompletionType(ComplType type)
     122        {
     123            ASSERT(type != Break);
     124            ASSERT(type != Continue);
     125            m_completionType = type;
     126        }
     127        JSValue* setNormalCompletion()
     128        {
     129            ASSERT(!hadException());
     130            m_completionType = Normal;
     131            return 0;
     132        }
     133        JSValue* setNormalCompletion(JSValue* value)
     134        {
     135            ASSERT(!hadException());
     136            m_completionType = Normal;
     137            return value;
     138        }
     139        JSValue* setBreakCompletion(const Identifier* target)
     140        {
     141            ASSERT(!hadException());
     142            m_completionType = Break;
     143            m_breakOrContinueTarget = target;
     144            return 0;
     145        }
     146        JSValue* setContinueCompletion(const Identifier* target)
     147        {
     148            ASSERT(!hadException());
     149            m_completionType = Continue;
     150            m_breakOrContinueTarget = target;
     151            return 0;
     152        }
     153        JSValue* setReturnValueCompletion(JSValue* returnValue)
     154        {
     155            ASSERT(!hadException());
     156            ASSERT(returnValue);
     157            m_completionType = ReturnValue;
     158            return returnValue;
     159        }
     160        JSValue* setThrowCompletion(JSValue* exception)
     161        {
     162            ASSERT(!hadException());
     163            ASSERT(exception);
     164            m_completionType = Throw;
     165            return exception;
     166        }
     167        JSValue* setInterruptedCompletion()
     168        {
     169            ASSERT(!hadException());
     170            m_completionType = Interrupted;
     171            return 0;
     172        }
     173
    112174    public:
    113175        ExecState(JSGlobalObject* glob, JSObject* thisV,
     
    142204        int m_switchDepth;
    143205        CodeType m_codeType;
     206
     207        ComplType m_completionType;
     208        const Identifier* m_breakOrContinueTarget;
    144209    };
    145210
Note: See TracChangeset for help on using the changeset viewer.