Ignore:
Timestamp:
Nov 18, 2007, 1:09:27 AM (18 years ago)
Author:
[email protected]
Message:

Fix: <rdar://problem/5607032> (REGRESSION: testapi exits with assertion failure in debug build) and <rdar://problem/5440659> (JSGlobalContextCreate throws away globalObjectClass's prototype)

Split Interpreter's initialization into two distinct steps: the creation of the global prototypes
and constructors, and storing them on the global object. This allows JSClassRef's passed to
JSGlobalContextCreate to be instantiated with the correct prototype.

Reviewed by Darin Adler.

File:
1 edited

Legend:

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

    r27344 r27885  
    3434
    3535// ECMA 10.2
    36 ExecState::ExecState(Interpreter* interpreter, JSGlobalObject* glob, JSObject* thisV,
     36ExecState::ExecState(Interpreter* interpreter, JSGlobalObject* globalObject, JSObject* thisV,
    3737                     FunctionBodyNode* currentBody, CodeType type, ExecState* callingExec,
    3838                     FunctionImp* func, const List* args)
     
    5656    } else {
    5757        m_activation = 0;
    58         m_variable = glob;
     58        m_variable = globalObject;
    5959    }
    6060   
     
    6363    case EvalCode:
    6464        if (m_callingExecState) {
    65             scope = m_callingExecState->scopeChain();
     65            m_scopeChain = m_callingExecState->scopeChain();
    6666            m_variable = m_callingExecState->variableObject();
    6767            m_thisVal = m_callingExecState->thisValue();
     
    6969        } // else same as GlobalCode
    7070    case GlobalCode:
    71         scope.clear();
    72         scope.push(glob);
    73         m_thisVal = static_cast<JSObject*>(glob);
     71        if (globalObject)
     72            setGlobalObject(globalObject);
    7473        break;
    7574    case FunctionCode:
    76         scope = func->scope();
    77         scope.push(m_activation);
     75        m_scopeChain = func->scope();
     76        m_scopeChain.push(m_activation);
    7877        m_variable = m_activation; // TODO: DontDelete ? (ECMA 10.2.3)
    7978        m_thisVal = thisV;
     
    9392{
    9493    for (ExecState* exec = this; exec; exec = exec->m_callingExecState)
    95         exec->scope.mark();
     94        exec->m_scopeChain.mark();
     95}
     96
     97void ExecState::setGlobalObject(JSGlobalObject* globalObject)
     98{
     99    m_scopeChain.clear();
     100    m_scopeChain.push(globalObject);
     101    m_thisVal = static_cast<JSObject*>(globalObject);
    96102}
    97103
Note: See TracChangeset for help on using the changeset viewer.