Changeset 37427 in webkit for trunk/JavaScriptCore/VM/Machine.h


Ignore:
Timestamp:
Oct 8, 2008, 10:03:10 AM (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/VM/Machine.h

    r37406 r37427  
    4545    class CodeBlock;
    4646    class EvalNode;
    47     class ExecState;
    4847    class FunctionBodyNode;
    4948    class Instruction;
     
    9695        bool isOpcode(Opcode opcode);
    9796       
    98         JSValue* execute(ProgramNode*, ExecState*, ScopeChainNode*, JSObject* thisObj, JSValue** exception);
    99         JSValue* execute(FunctionBodyNode*, ExecState*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue** exception);
    100         JSValue* execute(EvalNode* evalNode, ExecState* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue** exception);
    101 
    102         JSValue* retrieveArguments(ExecState*, JSFunction*) const;
    103         JSValue* retrieveCaller(ExecState*, InternalFunction*) const;
    104         void retrieveLastCaller(ExecState* exec, int& lineNumber, intptr_t& sourceID, UString& sourceURL, JSValue*& function) const;
    105        
    106         static ScopeChainNode* scopeChain(const Register* r) { return r[RegisterFile::ScopeChain].scopeChain(); }
    107         static CodeBlock* codeBlock(const Register* r) { return r[RegisterFile::CodeBlock].codeBlock(); }
    108 
    109         void getArgumentsData(Register* callFrame, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
     97        JSValue* execute(ProgramNode*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue** exception);
     98        JSValue* execute(FunctionBodyNode*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue** exception);
     99        JSValue* execute(EvalNode* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue** exception);
     100
     101        JSValue* retrieveArguments(CallFrame*, JSFunction*) const;
     102        JSValue* retrieveCaller(CallFrame*, InternalFunction*) const;
     103        void retrieveLastCaller(CallFrame*, int& lineNumber, intptr_t& sourceID, UString& sourceURL, JSValue*& function) const;
     104       
     105        void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
    110106        void setTimeoutTime(unsigned timeoutTime) { m_timeoutTime = timeoutTime; }
    111107       
     
    240236        bool isJSArray(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsArrayVptr; }
    241237        bool isJSString(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsStringVptr; }
    242        
    243         ALWAYS_INLINE static void initializeCallFrame(Register* callFrame, CodeBlock*, Instruction*, ScopeChainNode*, Register* r, int returnValueRegister, int argc, JSValue* function);
    244238
    245239    private:
    246240        enum ExecutionFlag { Normal, InitializeAndReturn };
    247241
    248         NEVER_INLINE JSValue* callEval(ExecState* exec, JSObject* thisObj, ScopeChainNode* scopeChain, RegisterFile*, Register* r, int argv, int argc, JSValue*& exceptionValue);
    249         JSValue* execute(EvalNode*, ExecState*, JSObject* thisObj, int registerOffset, ScopeChainNode*, JSValue** exception);
    250 
    251         NEVER_INLINE void debug(ExecState*, Register*, DebugHookID, int firstLine, int lastLine);
    252 
    253         NEVER_INLINE bool resolve(ExecState* exec, Instruction* vPC, Register* r, JSValue*& exceptionValue);
    254         NEVER_INLINE bool resolveSkip(ExecState* exec, Instruction* vPC, Register* r, JSValue*& exceptionValue);
    255         NEVER_INLINE bool resolveGlobal(ExecState* exec, Instruction* vPC, Register* r, JSValue*& exceptionValue);
    256         NEVER_INLINE void resolveBase(ExecState* exec, Instruction* vPC, Register* r);
    257         NEVER_INLINE bool resolveBaseAndProperty(ExecState* exec, Instruction* vPC, Register* r, JSValue*& exceptionValue);
    258         NEVER_INLINE ScopeChainNode* createExceptionScope(ExecState* exec, const Instruction* vPC, Register* r);
    259 
    260         NEVER_INLINE bool unwindCallFrame(ExecState*&, JSValue*, const Instruction*&, CodeBlock*&, Register*&);
    261         NEVER_INLINE Instruction* throwException(ExecState*, JSValue*&, const Instruction*, Register*&, bool);
    262         NEVER_INLINE bool resolveBaseAndFunc(ExecState* exec, Instruction* vPC, Register* r, JSValue*& exceptionValue);
    263 
    264         Register* callFrame(ExecState*, InternalFunction*) const;
    265 
    266         JSValue* privateExecute(ExecutionFlag, RegisterFile*, Register*, JSValue** exception);
    267 
    268         void dumpCallFrame(const RegisterFile*, const Register*);
    269         void dumpRegisters(const RegisterFile*, const Register*);
     242        NEVER_INLINE JSValue* callEval(CallFrame*, JSObject* thisObject, ScopeChainNode*, RegisterFile*, int argv, int argc, JSValue*& exceptionValue);
     243        JSValue* execute(EvalNode*, CallFrame*, JSObject* thisObject, int registerOffset, ScopeChainNode*, JSValue** exception);
     244
     245        NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine);
     246
     247        NEVER_INLINE bool resolve(CallFrame*, Instruction*, JSValue*& exceptionValue);
     248        NEVER_INLINE bool resolveSkip(CallFrame*, Instruction*, JSValue*& exceptionValue);
     249        NEVER_INLINE bool resolveGlobal(CallFrame*, Instruction*, JSValue*& exceptionValue);
     250        NEVER_INLINE void resolveBase(CallFrame*, Instruction* vPC);
     251        NEVER_INLINE bool resolveBaseAndProperty(CallFrame*, Instruction*, JSValue*& exceptionValue);
     252        NEVER_INLINE ScopeChainNode* createExceptionScope(CallFrame*, const Instruction* vPC);
     253
     254        NEVER_INLINE bool unwindCallFrame(CallFrame*&, JSValue*, const Instruction*&, CodeBlock*&);
     255        NEVER_INLINE Instruction* throwException(CallFrame*&, JSValue*&, const Instruction*, bool);
     256        NEVER_INLINE bool resolveBaseAndFunc(CallFrame*, Instruction*, JSValue*& exceptionValue);
     257
     258        static ALWAYS_INLINE CallFrame* slideRegisterWindowForCall(CodeBlock*, RegisterFile*, CallFrame*, size_t registerOffset, int argc);
     259
     260        static CallFrame* findFunctionCallFrame(CallFrame*, InternalFunction*);
     261
     262        JSValue* privateExecute(ExecutionFlag, RegisterFile*, CallFrame*, JSValue** exception);
     263
     264        void dumpCallFrame(const RegisterFile*, CallFrame*);
     265        void dumpRegisters(const RegisterFile*, CallFrame*);
    270266
    271267        JSValue* checkTimeout(JSGlobalObject*);
    272268        void resetTimeoutCheck();
    273269
    274         void tryCacheGetByID(ExecState*, CodeBlock*, Instruction* vPC, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&);
     270        void tryCacheGetByID(CallFrame*, CodeBlock*, Instruction*, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&);
    275271        void uncacheGetByID(CodeBlock*, Instruction* vPC);
    276         void tryCachePutByID(ExecState* exec, CodeBlock*, Instruction* vPC, JSValue* baseValue, const PutPropertySlot&);
     272        void tryCachePutByID(CallFrame*, CodeBlock*, Instruction*, JSValue* baseValue, const PutPropertySlot&);
    277273        void uncachePutByID(CodeBlock*, Instruction* vPC);
    278274
    279275#if ENABLE(CTI)
    280         void tryCTICacheGetByID(ExecState*, CodeBlock*, void* returnAddress, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&);
    281         void tryCTICachePutByID(ExecState*, CodeBlock*, void* returnAddress, JSValue* baseValue, const PutPropertySlot&);
    282 
    283         void* getCTIArrayLengthTrampoline(ExecState*, CodeBlock*);
    284         void* getCTIStringLengthTrampoline(ExecState*, CodeBlock*);
     276        void tryCTICacheGetByID(CallFrame*, CodeBlock*, void* returnAddress, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&);
     277        void tryCTICachePutByID(CallFrame*, CodeBlock*, void* returnAddress, JSValue* baseValue, const PutPropertySlot&);
     278
     279        void* getCTIArrayLengthTrampoline(CallFrame*, CodeBlock*);
     280        void* getCTIStringLengthTrampoline(CallFrame*, CodeBlock*);
    285281
    286282        void* m_ctiArrayLengthTrampoline;
     
    310306    };
    311307
    312     ALWAYS_INLINE void Machine::initializeCallFrame(Register* callFrame, CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain, Register* r, int returnValueRegister, int argc, JSValue* function)
    313     {
    314         ASSERT(r); // use makeHostCallFramePointer(0) to create a host call frame sentinel.
    315         callFrame[RegisterFile::CodeBlock] = codeBlock;
    316         callFrame[RegisterFile::ScopeChain] = scopeChain;
    317         callFrame[RegisterFile::CallerRegisters] = r;
    318         callFrame[RegisterFile::ReturnPC] = vPC;
    319         callFrame[RegisterFile::ReturnValueRegister] = returnValueRegister;
    320         callFrame[RegisterFile::ArgumentCount] = argc; // original argument count (for the sake of the "arguments" object)
    321         callFrame[RegisterFile::Callee] = function;
    322         callFrame[RegisterFile::OptionalCalleeArguments] = nullJSValue;
    323     }
    324 
    325     const intptr_t HostCallFrameMask = 1;
    326 
    327     inline Register* makeHostCallFramePointer(Register* callFrame)
    328     {
    329         return reinterpret_cast<Register*>(reinterpret_cast<intptr_t>(callFrame) | HostCallFrameMask);
    330     }
    331 
    332     inline bool isHostCallFrame(Register* callFrame)
    333     {
    334         return reinterpret_cast<intptr_t>(callFrame) & HostCallFrameMask;
    335     }
    336 
    337     inline Register* stripHostCallFrameBit(Register* callFrame)
    338     {
    339         return reinterpret_cast<Register*>(reinterpret_cast<intptr_t>(callFrame) & ~HostCallFrameMask);
    340     }
    341 
    342308} // namespace JSC
    343309
Note: See TracChangeset for help on using the changeset viewer.