Ignore:
Timestamp:
Aug 30, 2012, 3:50:00 PM (13 years ago)
Author:
[email protected]
Message:

Use one object instead of two for closures, eliminating ScopeChainNode
https://bugs.webkit.org/show_bug.cgi?id=95501

Reviewed by Filip Pizlo.

../JavaScriptCore:

This patch removes ScopeChainNode, and moves all the data and related
functions that used to be in ScopeChainNode into JSScope.

Most of this patch is mechanical changes to use a JSScope* where we used
to use a ScopeChainNode*. I've only specifically commented about items
that were non-mechanical.

  • runtime/Completion.cpp:

(JSC::evaluate):

  • runtime/Completion.h: Don't require an explicit scope chain argument

when evaluating code. Clients never wanted anything other than the
global scope, and other arbitrary scopes probably wouldn't work
correctly, anyway.

  • runtime/JSScope.cpp:
  • runtime/JSScope.h:

(JSC::JSScope::JSScope): JSScope now requires the data we used to pass to
ScopeChainNode, so it can link itself into the scope chain correctly.

  • runtime/JSWithScope.h:

(JSC::JSWithScope::create):
(JSC::JSWithScope::JSWithScope): JSWithScope gets an extra constructor
for specifically supplying your own scope chain. The DOM needs this
interface for setting up the scope chain for certain event handlers.
Other clients always just push the JSWithScope to the head of the current
scope chain.

../WebCore:

Mechanical changes to update for JSC interface changes.

../WebKit/mac:

Mechanical change to update for JSC interface change.

../WebKit/qt:

Mechanical change to update for JSC interface change.

  • Api/qwebelement.cpp:

(QWebElement::evaluateJavaScript):

../WebKit2:

Mechanical changes to update for JSC interface change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r126721 r127202  
    7171#include "RegExpObject.h"
    7272#include "RegExpPrototype.h"
    73 #include "ScopeChainMark.h"
    7473#include "StringConstructor.h"
    7574#include "StringPrototype.h"
     
    8079namespace JSC {
    8180
    82 const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &JSSegmentedVariableObject::s_info, 0, ExecState::globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) };
     81const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, 0, ExecState::globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) };
    8382
    8483const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptExperimentsEnabled };
     
    108107
    109108JSGlobalObject::JSGlobalObject(JSGlobalData& globalData, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable)
    110     : JSSegmentedVariableObject(globalData, structure)
    111     , m_globalScopeChain()
     109    : Base(globalData, structure, this, this, 0)
    112110    , m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(InitializedWatching)))
    113111    , m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
     
    134132{
    135133    ASSERT(globalData().apiLock().currentThreadIsHoldingLock());
    136    
    137     m_globalScopeChain.set(globalData(), this, ScopeChainNode::create(0, this, &globalData(), this, thisValue));
    138 
    139     JSGlobalObject::globalExec()->init(0, 0, m_globalScopeChain.get(), CallFrame::noCaller(), 0, 0);
     134
     135    setGlobalThis(globalData(), thisValue);
     136    JSGlobalObject::globalExec()->init(0, 0, this, CallFrame::noCaller(), 0, 0);
    140137
    141138    m_debugger = 0;
     
    151148    if (symbolTablePut(thisObject, exec, propertyName, value, slot.isStrictMode()))
    152149        return;
    153     JSSegmentedVariableObject::put(thisObject, exec, propertyName, value, slot);
     150    Base::put(thisObject, exec, propertyName, value, slot);
    154151}
    155152
     
    164161    JSValue valueBefore = thisObject->getDirect(exec->globalData(), propertyName);
    165162    PutPropertySlot slot;
    166     JSSegmentedVariableObject::put(thisObject, exec, propertyName, value, slot);
     163    Base::put(thisObject, exec, propertyName, value, slot);
    167164    if (!valueBefore) {
    168165        JSValue valueAfter = thisObject->getDirect(exec->globalData(), propertyName);
     
    346343    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
    347344    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
    348     JSSegmentedVariableObject::visitChildren(thisObject, visitor);
    349 
    350     visitor.append(&thisObject->m_globalScopeChain);
     345    Base::visitChildren(thisObject, visitor);
     346
    351347    visitor.append(&thisObject->m_methodCallDummy);
    352348
     
    419415{
    420416    JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
    421     if (getStaticFunctionSlot<JSSegmentedVariableObject>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, slot))
     417    if (getStaticFunctionSlot<Base>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, slot))
    422418        return true;
    423419    return symbolTableGet(thisObject, propertyName, slot);
     
    427423{
    428424    JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
    429     if (getStaticFunctionDescriptor<JSSegmentedVariableObject>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, descriptor))
     425    if (getStaticFunctionDescriptor<Base>(exec, ExecState::globalObjectTable(exec), thisObject, propertyName, descriptor))
    430426        return true;
    431427    return symbolTableGet(thisObject, propertyName, descriptor);
Note: See TracChangeset for help on using the changeset viewer.