Ignore:
Timestamp:
Dec 5, 2007, 6:31:41 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and
functions accessing data members from Interpreter to JSGlobalObject.
Changed Interpreter member functions to static functions.


This resolves a bug in global object bootstrapping, where the global
ExecState could be used when uninitialized.


This is a big change, but it's mostly code motion and renaming.


Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports
a .7% regression, but Shark sees no difference related to this patch,
and SunSpider reported a .7% speedup from an earlier step in this
refactoring, so I think it's fair to call that a wash.

JavaScriptGlue:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Replaced JSInterpreter
subclass with JSGlobalObject subclass.


  • JSRun.cpp: (JSRun::JSRun): (JSRun::Evaluate): (JSRun::CheckSyntax):
  • JSRun.h: (JSGlueGlobalObject::JSGlueGlobalObject):
  • JSUtils.cpp: (KJSValueToCFTypeInternal):
  • JSValueWrapper.cpp: (getThreadGlobalExecState):

WebCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Changed Interpreter
member functions to static functions. Same for the subclass,
ScriptInterpreter.


This is a big change, but it's mostly code motion and renaming.

WebKit/mac:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebView/WebFrame.mm: (-[WebFrame _attachScriptDebugger]):

WebKit/win:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebFrame.cpp: (WebFrame::globalContext): (WebFrame::attachScriptDebugger): (WebFrame::windowObjectCleared):
  • WebScriptDebugger.cpp: (WebScriptDebugger::WebScriptDebugger):
File:
1 edited

Legend:

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

    r28110 r28468  
    3232namespace KJS {
    3333
    34 
    3534// ECMA 10.2
    36 ExecState::ExecState(Interpreter* interpreter, JSGlobalObject* globalObject, JSObject* thisV,
    37                      FunctionBodyNode* currentBody, CodeType type, ExecState* callingExec,
     35ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisV,
     36                     FunctionBodyNode* currentBody, CodeType type, ExecState* callingExec, ExecState* currentExec,
    3837                     FunctionImp* func, const List* args)
    39     : m_interpreter(interpreter)
     38    : m_globalObject(globalObject)
    4039    , m_exception(0)
    4140    , m_propertyNames(CommonIdentifiers::shared())
    42     , m_savedExecState(interpreter->currentExec())
     41    , m_callingExec(callingExec)
     42    , m_savedExec(currentExec)
    4343    , m_currentBody(currentBody)
    4444    , m_function(func)
     
    4646    , m_iterationDepth(0)
    4747    , m_switchDepth(0)
     48    , m_codeType(type)
    4849{
    49     m_codeType = type;
    50     m_callingExecState = callingExec;
    51    
    5250    // create and initialize activation object (ECMA 10.1.6)
    5351    if (type == FunctionCode) {
     
    6260    switch(type) {
    6361    case EvalCode:
    64         if (m_callingExecState) {
    65             m_scopeChain = m_callingExecState->scopeChain();
    66             m_variable = m_callingExecState->variableObject();
    67             m_thisVal = m_callingExecState->thisValue();
     62        if (m_callingExec) {
     63            m_scopeChain = m_callingExec->scopeChain();
     64            m_variable = m_callingExec->variableObject();
     65            m_thisVal = m_callingExec->thisValue();
    6866            break;
    6967        } // else same as GlobalCode
    7068    case GlobalCode:
    71         if (globalObject)
    72             setGlobalObject(globalObject);
     69        m_scopeChain.push(globalObject);
     70        m_thisVal = globalObject;
    7371        break;
    7472    case FunctionCode:
     
    8179
    8280    if (currentBody)
    83         m_interpreter->setCurrentExec(this);
     81        m_globalObject->setCurrentExec(this);
    8482}
    8583
    8684ExecState::~ExecState()
    8785{
    88     m_interpreter->setCurrentExec(m_savedExecState);
     86    m_globalObject->setCurrentExec(m_savedExec);
    8987}
    9088
    9189void ExecState::mark()
    9290{
    93     for (ExecState* exec = this; exec; exec = exec->m_callingExecState)
     91    for (ExecState* exec = this; exec; exec = exec->m_callingExec)
    9492        exec->m_scopeChain.mark();
    9593}
    9694
    97 void ExecState::setGlobalObject(JSGlobalObject* globalObject)
    98 {
    99     m_scopeChain.clear();
    100     m_scopeChain.push(globalObject);
    101     m_thisVal = static_cast<JSObject*>(globalObject);
    102 }
    103 
    104 Interpreter* ExecState::lexicalInterpreter() const
     95JSGlobalObject* ExecState::lexicalGlobalObject() const
    10596{
    10697    if (scopeChain().isEmpty())
    107         return dynamicInterpreter();
     98        return dynamicGlobalObject();
    10899   
    109100    JSObject* object = scopeChain().bottom();
    110101    if (object && object->isGlobalObject())
    111         return static_cast<JSGlobalObject*>(object)->interpreter();
     102        return static_cast<JSGlobalObject*>(object);
    112103
    113     return dynamicInterpreter();
     104    return dynamicGlobalObject();
    114105}
    115106   
Note: See TracChangeset for help on using the changeset viewer.