Ignore:
Timestamp:
Oct 8, 2008, 5:40:43 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-08 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

Add CallFrame as a synonym for ExecState. Arguably, some day we should switch every
client over to the new name.

Use CallFrame* consistently rather than Register* or ExecState* in low-level code such
as Machine.cpp and CTI.cpp. Similarly, use callFrame rather than r as its name and use
accessor functions to get at things in the frame.

Eliminate other uses of ExecState* that aren't needed, replacing in some cases with
JSGlobalData* and in other cases eliminating them entirely.

  • API/JSObjectRef.cpp: (JSObjectMakeFunctionWithCallback): (JSObjectMakeFunction): (JSObjectHasProperty): (JSObjectGetProperty): (JSObjectSetProperty): (JSObjectDeleteProperty):
  • API/OpaqueJSString.cpp:
  • API/OpaqueJSString.h:
  • VM/CTI.cpp: (JSC::CTI::getConstant): (JSC::CTI::emitGetArg): (JSC::CTI::emitGetPutArg): (JSC::CTI::getConstantImmediateNumericArg): (JSC::CTI::printOpcodeOperandTypes): (JSC::CTI::CTI): (JSC::CTI::compileOpCall): (JSC::CTI::compileBinaryArithOp): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompile): (JSC::CTI::privateCompileGetByIdProto): (JSC::CTI::privateCompileGetByIdChain): (JSC::CTI::compileRegExp):
  • VM/CTI.h:
  • VM/CodeBlock.h:
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitEqualityOp): (JSC::CodeGenerator::emitLoad): (JSC::CodeGenerator::emitUnexpectedLoad): (JSC::CodeGenerator::emitConstruct):
  • VM/CodeGenerator.h:
  • VM/Machine.cpp: (JSC::jsLess): (JSC::jsLessEq): (JSC::jsAddSlowCase): (JSC::jsAdd): (JSC::jsTypeStringForValue): (JSC::Machine::resolve): (JSC::Machine::resolveSkip): (JSC::Machine::resolveGlobal): (JSC::inlineResolveBase): (JSC::Machine::resolveBase): (JSC::Machine::resolveBaseAndProperty): (JSC::Machine::resolveBaseAndFunc): (JSC::Machine::slideRegisterWindowForCall): (JSC::isNotObject): (JSC::Machine::callEval): (JSC::Machine::dumpCallFrame): (JSC::Machine::dumpRegisters): (JSC::Machine::unwindCallFrame): (JSC::Machine::throwException): (JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): (JSC::DynamicGlobalObjectScope::~DynamicGlobalObjectScope): (JSC::Machine::execute): (JSC::Machine::debug): (JSC::Machine::createExceptionScope): (JSC::cachePrototypeChain): (JSC::Machine::tryCachePutByID): (JSC::Machine::tryCacheGetByID): (JSC::Machine::privateExecute): (JSC::Machine::retrieveArguments): (JSC::Machine::retrieveCaller): (JSC::Machine::retrieveLastCaller): (JSC::Machine::findFunctionCallFrame): (JSC::Machine::getArgumentsData): (JSC::Machine::tryCTICachePutByID): (JSC::Machine::getCTIArrayLengthTrampoline): (JSC::Machine::getCTIStringLengthTrampoline): (JSC::Machine::tryCTICacheGetByID): (JSC::Machine::cti_op_convert_this): (JSC::Machine::cti_op_end): (JSC::Machine::cti_op_add): (JSC::Machine::cti_op_pre_inc): (JSC::Machine::cti_timeout_check): (JSC::Machine::cti_op_loop_if_less): (JSC::Machine::cti_op_loop_if_lesseq): (JSC::Machine::cti_op_new_object): (JSC::Machine::cti_op_put_by_id): (JSC::Machine::cti_op_put_by_id_second): (JSC::Machine::cti_op_put_by_id_generic): (JSC::Machine::cti_op_put_by_id_fail): (JSC::Machine::cti_op_get_by_id): (JSC::Machine::cti_op_get_by_id_second): (JSC::Machine::cti_op_get_by_id_generic): (JSC::Machine::cti_op_get_by_id_fail): (JSC::Machine::cti_op_instanceof): (JSC::Machine::cti_op_del_by_id): (JSC::Machine::cti_op_mul): (JSC::Machine::cti_op_new_func): (JSC::Machine::cti_op_call_JSFunction): (JSC::Machine::cti_vm_compile): (JSC::Machine::cti_op_push_activation): (JSC::Machine::cti_op_call_NotJSFunction): (JSC::Machine::cti_op_create_arguments): (JSC::Machine::cti_op_tear_off_activation): (JSC::Machine::cti_op_tear_off_arguments): (JSC::Machine::cti_op_ret_profiler): (JSC::Machine::cti_op_ret_scopeChain): (JSC::Machine::cti_op_new_array): (JSC::Machine::cti_op_resolve): (JSC::Machine::cti_op_construct_JSConstruct): (JSC::Machine::cti_op_construct_NotJSConstruct): (JSC::Machine::cti_op_get_by_val): (JSC::Machine::cti_op_resolve_func): (JSC::Machine::cti_op_sub): (JSC::Machine::cti_op_put_by_val): (JSC::Machine::cti_op_put_by_val_array): (JSC::Machine::cti_op_lesseq): (JSC::Machine::cti_op_loop_if_true): (JSC::Machine::cti_op_negate): (JSC::Machine::cti_op_resolve_base): (JSC::Machine::cti_op_resolve_skip): (JSC::Machine::cti_op_resolve_global): (JSC::Machine::cti_op_div): (JSC::Machine::cti_op_pre_dec): (JSC::Machine::cti_op_jless): (JSC::Machine::cti_op_not): (JSC::Machine::cti_op_jtrue): (JSC::Machine::cti_op_post_inc): (JSC::Machine::cti_op_eq): (JSC::Machine::cti_op_lshift): (JSC::Machine::cti_op_bitand): (JSC::Machine::cti_op_rshift): (JSC::Machine::cti_op_bitnot): (JSC::Machine::cti_op_resolve_with_base): (JSC::Machine::cti_op_new_func_exp): (JSC::Machine::cti_op_mod): (JSC::Machine::cti_op_less): (JSC::Machine::cti_op_neq): (JSC::Machine::cti_op_post_dec): (JSC::Machine::cti_op_urshift): (JSC::Machine::cti_op_bitxor): (JSC::Machine::cti_op_new_regexp): (JSC::Machine::cti_op_bitor): (JSC::Machine::cti_op_call_eval): (JSC::Machine::cti_op_throw): (JSC::Machine::cti_op_get_pnames): (JSC::Machine::cti_op_next_pname): (JSC::Machine::cti_op_push_scope): (JSC::Machine::cti_op_pop_scope): (JSC::Machine::cti_op_typeof): (JSC::Machine::cti_op_to_jsnumber): (JSC::Machine::cti_op_in): (JSC::Machine::cti_op_push_new_scope): (JSC::Machine::cti_op_jmp_scopes): (JSC::Machine::cti_op_put_by_index): (JSC::Machine::cti_op_switch_imm): (JSC::Machine::cti_op_switch_char): (JSC::Machine::cti_op_switch_string): (JSC::Machine::cti_op_del_by_val): (JSC::Machine::cti_op_put_getter): (JSC::Machine::cti_op_put_setter): (JSC::Machine::cti_op_new_error): (JSC::Machine::cti_op_debug): (JSC::Machine::cti_vm_throw):
  • VM/Machine.h:
  • VM/Register.h:
  • VM/RegisterFile.h:
  • kjs/Arguments.h:
  • kjs/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::functionName): (JSC::DebuggerCallFrame::type): (JSC::DebuggerCallFrame::thisObject): (JSC::DebuggerCallFrame::evaluate):
  • kjs/DebuggerCallFrame.h:
  • kjs/ExecState.cpp: (JSC::CallFrame::thisValue):
  • kjs/ExecState.h:
  • kjs/FunctionConstructor.cpp: (JSC::constructFunction):
  • kjs/JSActivation.cpp: (JSC::JSActivation::JSActivation): (JSC::JSActivation::argumentsGetter):
  • kjs/JSActivation.h:
  • kjs/JSGlobalObject.cpp: (JSC::JSGlobalObject::init):
  • kjs/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval):
  • kjs/JSVariableObject.h:
  • kjs/Parser.cpp: (JSC::Parser::parse):
  • kjs/RegExpConstructor.cpp: (JSC::constructRegExp):
  • kjs/RegExpPrototype.cpp: (JSC::regExpProtoFuncCompile):
  • kjs/Shell.cpp: (prettyPrintScript):
  • kjs/StringPrototype.cpp: (JSC::stringProtoFuncMatch): (JSC::stringProtoFuncSearch):
  • kjs/identifier.cpp: (JSC::Identifier::checkSameIdentifierTable):
  • kjs/interpreter.cpp: (JSC::Interpreter::checkSyntax): (JSC::Interpreter::evaluate):
  • kjs/nodes.cpp: (JSC::ThrowableExpressionData::emitThrowError): (JSC::RegExpNode::emitCode): (JSC::ArrayNode::emitCode): (JSC::InstanceOfNode::emitCode):
  • kjs/nodes.h:
  • kjs/regexp.cpp: (JSC::RegExp::RegExp): (JSC::RegExp::create):
  • kjs/regexp.h:
  • profiler/HeavyProfile.h:
  • profiler/Profile.h:
  • wrec/WREC.cpp:
  • wrec/WREC.h:

WebKit/mac:

2008-10-08 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

  • WebView/WebScriptDebugger.mm: (WebScriptDebugger::WebScriptDebugger): Update since DebuggerCallFrame is simpler now.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ExecState.h

    r37428 r37433  
    2424#define ExecState_h
    2525
     26// FIXME: Rename this file to CallFrame.h.
     27
    2628#include "JSGlobalData.h"
    2729#include "Machine.h"
     
    3032namespace JSC  {
    3133
    32     class ExecState;
    33     class JSValue;
    34     class Register;
    35 
    36     typedef ExecState CallFrame;
     34    class Arguments;
     35    class JSActivation;
    3736
    3837    // Represents the current state of script execution.
    3938    // Passed as the first argument to most functions.
    40     class ExecState : private Register, Noncopyable {
     39    class ExecState : private Register {
    4140    public:
    42         static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); }
    43         Register* registers() { return this; }
     41        JSFunction* callee() const { return this[RegisterFile::Callee].function(); }
     42        CodeBlock* codeBlock() const { return this[RegisterFile::CodeBlock].Register::codeBlock(); }
     43        ScopeChainNode* scopeChain() const { return this[RegisterFile::ScopeChain].Register::scopeChain(); }
     44
     45        JSValue* thisValue();
    4446
    4547        // Global object in which execution began.
     
    4850        // Global object in which the currently executing code was defined.
    4951        // Differs from dynamicGlobalObject() during function calls across web browser frames.
    50         JSGlobalObject* lexicalGlobalObject()
     52        JSGlobalObject* lexicalGlobalObject() const
    5153        {
    52             return Machine::scopeChain(this)->globalObject();
     54            return scopeChain()->globalObject();
    5355        }
    5456
    5557        // Differs from lexicalGlobalObject because this will have DOM window shell rather than
    56         // the actual DOM window.
    57         JSObject* globalThisValue()
     58        // the actual DOM window, which can't be "this" for security reasons.
     59        JSObject* globalThisValue() const
    5860        {
    59             return Machine::scopeChain(this)->globalThisObject();
     61            return scopeChain()->globalThisObject();
    6062        }
    6163
    62         JSGlobalData& globalData()
     64        // FIXME: Elsewhere, we use JSGlobalData* rather than JSGlobalData&.
     65        // We should make this more uniform and either use a reference everywhere
     66        // or a pointer everywhere.
     67        JSGlobalData& globalData() const
    6368        {
    64             return *Machine::scopeChain(this)->globalData;
     69            return *scopeChain()->globalData;
    6570        }
    6671
    6772        // Convenience functions for access to global data.
     73        // It takes a few memory references to get from a call frame to the global data
     74        // pointer, so these are inefficient, and should be used sparingly in new code.
     75        // But they're used in many places in legacy code, so they're not going away any time soon.
    6876
    6977        void setException(JSValue* exception) { globalData().exception = exception; }
    7078        void clearException() { globalData().exception = 0; }
    71         JSValue* exception() { return globalData().exception; }
     79        JSValue* exception() const { return globalData().exception; }
    7280        JSValue** exceptionSlot() { return &globalData().exception; }
    73         bool hadException() { return !!globalData().exception; }
     81        bool hadException() const { return !!globalData().exception; }
    7482
    75         IdentifierTable* identifierTable() { return globalData().identifierTable; }
    76         const CommonIdentifiers& propertyNames() { return *globalData().propertyNames; }
    77         const ArgList& emptyList() { return *globalData().emptyList; }
    78         Lexer* lexer() { return globalData().lexer; }
    79         Parser* parser() { return globalData().parser; }
     83        const CommonIdentifiers& propertyNames() const { return *globalData().propertyNames; }
     84        const ArgList& emptyList() const { return *globalData().emptyList; }
    8085        Machine* machine() { return globalData().machine; }
    8186        Heap* heap() { return &globalData().heap; }
     
    9095
    9196    private:
     97        friend class Arguments;
     98        friend class JSActivation;
     99        friend class JSGlobalObject;
     100        friend class Machine;
     101
     102        static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); }
     103        Register* registers() { return this; }
     104
     105        CallFrame& operator=(const Register& r) { *static_cast<Register*>(this) = r; return *this; }
     106
     107        int argumentCount() const { return this[RegisterFile::ArgumentCount].i(); }
     108        CallFrame* callerFrame() const { return this[RegisterFile::CallerFrame].callFrame(); }
     109        Arguments* optionalCalleeArguments() const { return this[RegisterFile::OptionalCalleeArguments].arguments(); }
     110        Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); }
     111        int returnValueRegister() const { return this[RegisterFile::ReturnValueRegister].i(); }
     112
     113        void setArgumentCount(int count) { this[RegisterFile::ArgumentCount] = count; }
     114        void setCallee(JSFunction* callee) { this[RegisterFile::Callee] = callee; }
     115        void setCalleeArguments(Arguments* arguments) { this[RegisterFile::OptionalCalleeArguments] = arguments; }
     116        void setCallerFrame(CallFrame* callerFrame) { this[RegisterFile::CallerFrame] = callerFrame; }
     117        void setCodeBlock(CodeBlock* codeBlock) { this[RegisterFile::CodeBlock] = codeBlock; }
     118        void setScopeChain(ScopeChainNode* scopeChain) { this[RegisterFile::ScopeChain] = scopeChain; }
     119
     120        ALWAYS_INLINE void init(CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain,
     121            CallFrame* callerFrame, int returnValueRegister, int argc, JSFunction* function)
     122        {
     123            ASSERT(callerFrame); // Use noCaller() rather than 0 for the outer host call frame caller.
     124
     125            setCodeBlock(codeBlock);
     126            setScopeChain(scopeChain);
     127            setCallerFrame(callerFrame);
     128            this[RegisterFile::ReturnPC] = vPC;
     129            this[RegisterFile::ReturnValueRegister] = returnValueRegister;
     130            setArgumentCount(argc); // original argument count (for the sake of the "arguments" object)
     131            setCallee(function);
     132            setCalleeArguments(0);
     133        }
     134
     135        static const intptr_t HostCallFrameFlag = 1;
     136
     137        static CallFrame* noCaller() { return reinterpret_cast<CallFrame*>(HostCallFrameFlag); }
     138        bool hasHostCallFrameFlag() const { return reinterpret_cast<intptr_t>(this) & HostCallFrameFlag; }
     139        CallFrame* addHostCallFrameFlag() const { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) | HostCallFrameFlag); }
     140        CallFrame* removeHostCallFrameFlag() { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) & ~HostCallFrameFlag); }
     141
    92142        ExecState();
    93143        ~ExecState();
Note: See TracChangeset for help on using the changeset viewer.