Changeset 79904 in webkit


Ignore:
Timestamp:
Feb 28, 2011 1:05:22 PM (13 years ago)
Author:
oliver@apple.com
Message:

2011-02-28 Oliver Hunt <oliver@apple.com>

Reviewed by Gavin Barraclough.

Make ScopeChainNode GC allocated
https://bugs.webkit.org/show_bug.cgi?id=55283

Simplify lifetime and other issues with the scopechain
by making it gc allocated. This allows us to simplify
function exit and unwinding, as well as making the
current iterative refcounting go away.

  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::createActivation):
  • bytecode/StructureStubInfo.cpp:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall): (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
  • bytecompiler/BytecodeGenerator.h:
  • debugger/Debugger.cpp: (JSC::Recompiler::operator()):
  • debugger/DebuggerCallFrame.h: (JSC::DebuggerCallFrame::scopeChain):
  • interpreter/CachedCall.h: (JSC::CachedCall::CachedCall):
  • interpreter/CallFrame.h:
  • interpreter/Interpreter.cpp: (JSC::depth): (JSC::Interpreter::unwindCallFrame): (JSC::Interpreter::throwException): (JSC::Interpreter::execute): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::privateExecute):
  • jit/JITCall.cpp: (JSC::JIT::compileOpCallInitializeCallFrame): (JSC::JIT::compileOpCall):
  • jit/JITCall32_64.cpp: (JSC::JIT::compileOpCallInitializeCallFrame): (JSC::JIT::emit_op_ret): (JSC::JIT::emit_op_ret_object_or_this): (JSC::JIT::compileOpCall):
  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_end): (JSC::JIT::emit_op_ret): (JSC::JIT::emit_op_ret_object_or_this):
  • jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_end):
  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
  • jit/JITStubs.h:
  • runtime/ArgList.cpp:
  • runtime/Completion.cpp: (JSC::evaluate):
  • runtime/Completion.h:
  • runtime/DateConversion.cpp:
  • runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::compileForCallInternal): (JSC::FunctionExecutable::compileForConstructInternal):
  • runtime/FunctionConstructor.cpp: (JSC::constructFunction):
  • runtime/GCActivityCallbackCF.cpp:
  • runtime/Identifier.cpp:
  • runtime/JSCell.h:
  • runtime/JSChunk.cpp: Added.
  • runtime/JSChunk.h: Added.
  • runtime/JSFunction.cpp: (JSC::JSFunction::JSFunction): (JSC::JSFunction::markChildren): (JSC::JSFunction::getCallData): (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getConstructData):
  • runtime/JSFunction.h: (JSC::JSFunction::scope): (JSC::JSFunction::setScope):
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSGlobalData.h:
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::markChildren):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): (JSC::JSGlobalObject::globalScopeChain):
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval):
  • runtime/JSLock.cpp:
  • runtime/JSNumberCell.cpp:
  • runtime/JSZombie.cpp:
  • runtime/MarkedBlock.cpp:
  • runtime/MarkedSpace.cpp:
  • runtime/PropertyNameArray.cpp:
  • runtime/ScopeChain.cpp: (JSC::ScopeChainNode::print): (JSC::ScopeChainNode::localDepth): (JSC::ScopeChainNode::markChildren):
  • runtime/ScopeChain.h: (JSC::ScopeChainNode::ScopeChainNode): (JSC::ScopeChainNode::createStructure): (JSC::ScopeChainNode::push): (JSC::ScopeChainNode::pop): (JSC::ScopeChainIterator::ScopeChainIterator): (JSC::ScopeChainIterator::operator*): (JSC::ScopeChainIterator::operator->): (JSC::ScopeChainIterator::operator++): (JSC::ScopeChainNode::begin): (JSC::ScopeChainNode::end): (JSC::ExecState::globalData): (JSC::ExecState::lexicalGlobalObject): (JSC::ExecState::globalThisValue):
  • runtime/ScopeChainMark.h:
  • wtf/DateMath.cpp:

2011-02-28 Oliver Hunt <oliver@apple.com>

Reviewed by Gavin Barraclough.

Make ScopeChainNode GC allocated
https://bugs.webkit.org/show_bug.cgi?id=55283

Update WebCore to deal with the absence of the ScopeChain
class.

  • ForwardingHeaders/runtime/ScopeChain.h: Added.
  • bindings/js/JSHTMLElementCustom.cpp: (WebCore::JSHTMLElement::pushEventHandlerScope):
  • bindings/js/JSJavaScriptCallFrameCustom.cpp: (WebCore::JSJavaScriptCallFrame::scopeChain): (WebCore::JSJavaScriptCallFrame::scopeType):
  • bindings/js/JSLazyEventListener.cpp: (WebCore::JSLazyEventListener::initializeJSFunction):
  • bindings/js/JSMainThreadExecState.h: (WebCore::JSMainThreadExecState::evaluate):
  • bindings/js/JSNodeCustom.cpp: (WebCore::JSNode::pushEventHandlerScope):
  • bindings/js/JavaScriptCallFrame.cpp: (WebCore::JavaScriptCallFrame::scopeChain):
  • bindings/js/JavaScriptCallFrame.h:
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/c/c_class.cpp:
  • bridge/c/c_runtime.cpp:
  • bridge/jni/JNIBridge.cpp:
  • bridge/qt/qt_runtime.cpp: (JSC::Bindings::QtConnectionObject::execute):
  • plugins/PluginViewNone.cpp:

2011-02-28 Oliver Hunt <oliver@apple.com>

Reviewed by Gavin Barraclough.

Make ScopeChainNode GC allocated
https://bugs.webkit.org/show_bug.cgi?id=55283

More updates for the absence of the ScopeChain class

  • WebView/WebScriptDebugDelegate.mm: (-[WebScriptCallFrame scopeChain]):
Location:
trunk/Source
Files:
3 added
60 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r79835 r79904  
     12011-02-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Make ScopeChainNode GC allocated
     6        https://bugs.webkit.org/show_bug.cgi?id=55283
     7
     8        Simplify lifetime and other issues with the scopechain
     9        by making it gc allocated.  This allows us to simplify
     10        function exit and unwinding, as well as making the
     11        current iterative refcounting go away.
     12
     13        * JavaScriptCore.exp:
     14        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     15        * bytecode/CodeBlock.cpp:
     16        (JSC::CodeBlock::createActivation):
     17        * bytecode/StructureStubInfo.cpp:
     18        * bytecompiler/BytecodeGenerator.cpp:
     19        (JSC::BytecodeGenerator::generate):
     20        (JSC::BytecodeGenerator::BytecodeGenerator):
     21        (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall):
     22        (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
     23        * bytecompiler/BytecodeGenerator.h:
     24        * debugger/Debugger.cpp:
     25        (JSC::Recompiler::operator()):
     26        * debugger/DebuggerCallFrame.h:
     27        (JSC::DebuggerCallFrame::scopeChain):
     28        * interpreter/CachedCall.h:
     29        (JSC::CachedCall::CachedCall):
     30        * interpreter/CallFrame.h:
     31        * interpreter/Interpreter.cpp:
     32        (JSC::depth):
     33        (JSC::Interpreter::unwindCallFrame):
     34        (JSC::Interpreter::throwException):
     35        (JSC::Interpreter::execute):
     36        (JSC::Interpreter::executeCall):
     37        (JSC::Interpreter::executeConstruct):
     38        (JSC::Interpreter::privateExecute):
     39        * jit/JITCall.cpp:
     40        (JSC::JIT::compileOpCallInitializeCallFrame):
     41        (JSC::JIT::compileOpCall):
     42        * jit/JITCall32_64.cpp:
     43        (JSC::JIT::compileOpCallInitializeCallFrame):
     44        (JSC::JIT::emit_op_ret):
     45        (JSC::JIT::emit_op_ret_object_or_this):
     46        (JSC::JIT::compileOpCall):
     47        * jit/JITOpcodes.cpp:
     48        (JSC::JIT::emit_op_end):
     49        (JSC::JIT::emit_op_ret):
     50        (JSC::JIT::emit_op_ret_object_or_this):
     51        * jit/JITOpcodes32_64.cpp:
     52        (JSC::JIT::emit_op_end):
     53        * jit/JITStubs.cpp:
     54        (JSC::DEFINE_STUB_FUNCTION):
     55        * jit/JITStubs.h:
     56        * runtime/ArgList.cpp:
     57        * runtime/Completion.cpp:
     58        (JSC::evaluate):
     59        * runtime/Completion.h:
     60        * runtime/DateConversion.cpp:
     61        * runtime/Executable.cpp:
     62        (JSC::EvalExecutable::compileInternal):
     63        (JSC::ProgramExecutable::compileInternal):
     64        (JSC::FunctionExecutable::compileForCallInternal):
     65        (JSC::FunctionExecutable::compileForConstructInternal):
     66        * runtime/FunctionConstructor.cpp:
     67        (JSC::constructFunction):
     68        * runtime/GCActivityCallbackCF.cpp:
     69        * runtime/Identifier.cpp:
     70        * runtime/JSCell.h:
     71        * runtime/JSChunk.cpp: Added.
     72        * runtime/JSChunk.h: Added.
     73        * runtime/JSFunction.cpp:
     74        (JSC::JSFunction::JSFunction):
     75        (JSC::JSFunction::markChildren):
     76        (JSC::JSFunction::getCallData):
     77        (JSC::JSFunction::getOwnPropertySlot):
     78        (JSC::JSFunction::getConstructData):
     79        * runtime/JSFunction.h:
     80        (JSC::JSFunction::scope):
     81        (JSC::JSFunction::setScope):
     82        * runtime/JSGlobalData.cpp:
     83        (JSC::JSGlobalData::JSGlobalData):
     84        * runtime/JSGlobalData.h:
     85        * runtime/JSGlobalObject.cpp:
     86        (JSC::JSGlobalObject::init):
     87        (JSC::JSGlobalObject::markChildren):
     88        * runtime/JSGlobalObject.h:
     89        (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
     90        (JSC::JSGlobalObject::globalScopeChain):
     91        * runtime/JSGlobalObjectFunctions.cpp:
     92        (JSC::globalFuncEval):
     93        * runtime/JSLock.cpp:
     94        * runtime/JSNumberCell.cpp:
     95        * runtime/JSZombie.cpp:
     96        * runtime/MarkedBlock.cpp:
     97        * runtime/MarkedSpace.cpp:
     98        * runtime/PropertyNameArray.cpp:
     99        * runtime/ScopeChain.cpp:
     100        (JSC::ScopeChainNode::print):
     101        (JSC::ScopeChainNode::localDepth):
     102        (JSC::ScopeChainNode::markChildren):
     103        * runtime/ScopeChain.h:
     104        (JSC::ScopeChainNode::ScopeChainNode):
     105        (JSC::ScopeChainNode::createStructure):
     106        (JSC::ScopeChainNode::push):
     107        (JSC::ScopeChainNode::pop):
     108        (JSC::ScopeChainIterator::ScopeChainIterator):
     109        (JSC::ScopeChainIterator::operator*):
     110        (JSC::ScopeChainIterator::operator->):
     111        (JSC::ScopeChainIterator::operator++):
     112        (JSC::ScopeChainNode::begin):
     113        (JSC::ScopeChainNode::end):
     114        (JSC::ExecState::globalData):
     115        (JSC::ExecState::lexicalGlobalObject):
     116        (JSC::ExecState::globalThisValue):
     117        * runtime/ScopeChainMark.h:
     118        * wtf/DateMath.cpp:
     119
    11202011-02-27  Adam Barth  <abarth@webkit.org>
    2121
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r79750 r79904  
    306306__ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE
    307307__ZN3JSC8Profiler8profilerEv
    308 __ZN3JSC8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_10SourceCodeENS_7JSValueE
     308__ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueE
    309309__ZN3JSC9CodeBlockD1Ev
    310310__ZN3JSC9CodeBlockD2Ev
     
    588588__ZTVN3JSC12StringObjectE
    589589__ZTVN3JSC14JSGlobalObjectE
     590__ZTVN3JSC14ScopeChainNodeE
    590591__ZTVN3JSC15JSWrapperObjectE
    591592__ZTVN3JSC16InternalFunctionE
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r79750 r79904  
    151151    ?equalUTF16WithUTF8@Unicode@WTF@@YA_NPB_W0PBD1@Z
    152152    ?evaluate@DebuggerCallFrame@JSC@@QBE?AVJSValue@2@ABVUString@2@AAV32@@Z
    153     ?evaluate@JSC@@YA?AVCompletion@1@PAVExecState@1@AAVScopeChain@1@ABVSourceCode@1@VJSValue@1@@Z
     153    ?evaluate@JSC@@YA?AVCompletion@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@VJSValue@1@@Z
    154154    ?exclude@Profile@JSC@@QAEXPBVProfileNode@2@@Z
    155155    ?fastCalloc@WTF@@YAPAXII@Z
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r77360 r79904  
    16981698    JSActivation* activation = new (callFrame) JSActivation(callFrame, static_cast<FunctionExecutable*>(ownerExecutable()));
    16991699    callFrame->uncheckedR(activationRegister()) = JSValue(activation);
    1700     callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
     1700    callFrame->setScopeChain(callFrame->scopeChain()->push(activation));
    17011701}
    17021702
  • trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp

    r64943 r79904  
    2626#include "config.h"
    2727#include "StructureStubInfo.h"
     28
     29#include "ScopeChain.h"
    2830
    2931namespace JSC {
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r79177 r79904  
    3434#include "JSFunction.h"
    3535#include "Interpreter.h"
     36#include "ScopeChain.h"
    3637#include "UString.h"
    3738
     
    147148
    148149    if (s_dumpsGeneratedCode)
    149         m_codeBlock->dump(m_scopeChain->globalObject()->globalExec());
     150        m_codeBlock->dump(m_scopeChain->globalObject->globalExec());
    150151#endif
    151152
     
    156157
    157158    if (m_expressionTooDeep)
    158         return createOutOfMemoryError(m_scopeChain->globalObject());
     159        return createOutOfMemoryError(m_scopeChain->globalObject.get());
    159160    return 0;
    160161}
     
    198199}
    199200
    200 BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock)
    201     : m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
    202     , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
    203     , m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
    204     , m_scopeChain(&scopeChain)
     201BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock)
     202    : m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
     203    , m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
     204    , m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
     205    , m_scopeChain(*scopeChain->globalData, scopeChain)
    205206    , m_symbolTable(symbolTable)
    206207    , m_scopeNode(programNode)
     
    217218    , m_firstLazyFunction(0)
    218219    , m_lastLazyFunction(0)
    219     , m_globalData(&scopeChain.globalObject()->globalData())
     220    , m_globalData(scopeChain->globalData)
    220221    , m_lastOpcodeID(op_end)
    221222#ifndef NDEBUG
     
    238239    m_codeBlock->m_numParameters = 1; // Allocate space for "this"
    239240
    240     JSGlobalObject* globalObject = scopeChain.globalObject();
     241    JSGlobalObject* globalObject = scopeChain->globalObject.get();
    241242    ExecState* exec = globalObject->globalExec();
    242243    RegisterFile* registerFile = &exec->globalData().interpreter->registerFile();
     
    283284        for (size_t i = 0; i < functionStack.size(); ++i) {
    284285            FunctionBodyNode* function = functionStack[i];
    285             globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction(exec, function), scopeChain.node()), DontDelete);
     286            globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction(exec, function), scopeChain), DontDelete);
    286287        }
    287288        for (size_t i = 0; i < varStack.size(); ++i) {
     
    299300}
    300301
    301 BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)
    302     : m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
    303     , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
    304     , m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
    305     , m_scopeChain(&scopeChain)
     302BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, ScopeChainNode* scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)
     303    : m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
     304    , m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
     305    , m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
     306    , m_scopeChain(*scopeChain->globalData, scopeChain)
    306307    , m_symbolTable(symbolTable)
    307308    , m_scopeNode(functionBody)
     
    317318    , m_firstLazyFunction(0)
    318319    , m_lastLazyFunction(0)
    319     , m_globalData(&scopeChain.globalObject()->globalData())
     320    , m_globalData(scopeChain->globalData)
    320321    , m_lastOpcodeID(op_end)
    321322#ifndef NDEBUG
     
    465466}
    466467
    467 BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
    468     : m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
    469     , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
    470     , m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
    471     , m_scopeChain(&scopeChain)
     468BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
     469    : m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
     470    , m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
     471    , m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
     472    , m_scopeChain(*scopeChain->globalData, scopeChain)
    472473    , m_symbolTable(symbolTable)
    473474    , m_scopeNode(evalNode)
     
    483484    , m_firstLazyFunction(0)
    484485    , m_lastLazyFunction(0)
    485     , m_globalData(&scopeChain.globalObject()->globalData())
     486    , m_globalData(scopeChain->globalData)
    486487    , m_lastOpcodeID(op_end)
    487488#ifndef NDEBUG
     
    908909    emitOpcode(op_jneq_ptr);
    909910    instructions().append(cond->index());
    910     instructions().append(m_scopeChain->globalObject()->d()->callFunction.get());
     911    instructions().append(m_scopeChain->globalObject->d()->callFunction.get());
    911912    instructions().append(target->bind(begin, instructions().size()));
    912913    return target;
     
    919920    emitOpcode(op_jneq_ptr);
    920921    instructions().append(cond->index());
    921     instructions().append(m_scopeChain->globalObject()->d()->applyFunction.get());
     922    instructions().append(m_scopeChain->globalObject->d()->applyFunction.get());
    922923    instructions().append(target->bind(begin, instructions().size()));
    923924    return target;
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r76248 r79904  
    4848
    4949    class Identifier;
    50     class ScopeChain;
    51     class ScopeNode;
     50    class ScopeChainNode;
    5251
    5352    class CallArguments {
     
    9493        static bool dumpsGeneratedCode();
    9594
    96         BytecodeGenerator(ProgramNode*, const ScopeChain&, SymbolTable*, ProgramCodeBlock*);
    97         BytecodeGenerator(FunctionBodyNode*, const ScopeChain&, SymbolTable*, CodeBlock*);
    98         BytecodeGenerator(EvalNode*, const ScopeChain&, SymbolTable*, EvalCodeBlock*);
     95        BytecodeGenerator(ProgramNode*, ScopeChainNode*, SymbolTable*, ProgramCodeBlock*);
     96        BytecodeGenerator(FunctionBodyNode*, ScopeChainNode*, SymbolTable*, CodeBlock*);
     97        BytecodeGenerator(EvalNode*, ScopeChainNode*, SymbolTable*, EvalCodeBlock*);
    9998
    10099        JSGlobalData* globalData() const { return m_globalData; }
     
    521520        bool m_shouldEmitRichSourceInfo;
    522521
    523         const ScopeChain* m_scopeChain;
     522        Global<ScopeChainNode> m_scopeChain;
    524523        SymbolTable* m_symbolTable;
    525524
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r79132 r79904  
    7777        return;
    7878
    79     ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec();
     79    ExecState* exec = function->scope()->globalObject->JSGlobalObject::globalExec();
    8080    executable->discardCode();
    81     if (m_debugger == function->scope().globalObject()->debugger())
     81    if (m_debugger == function->scope()->globalObject->debugger())
    8282        m_sourceProviders.add(executable->source().provider(), exec);
    8383}
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.h

    r44224 r79904  
    5050
    5151        JSGlobalObject* dynamicGlobalObject() const { return m_callFrame->dynamicGlobalObject(); }
    52         const ScopeChainNode* scopeChain() const { return m_callFrame->scopeChain(); }
     52        ScopeChainNode* scopeChain() const { return m_callFrame->scopeChain(); }
    5353        const UString* functionName() const;
    5454        UString calculatedFunctionName() const;
  • trunk/Source/JavaScriptCore/interpreter/CachedCall.h

    r76248 r79904  
    3939            : m_valid(false)
    4040            , m_interpreter(callFrame->interpreter())
    41             , m_globalObjectScope(callFrame, function->scope().globalObject())
     41            , m_globalObjectScope(callFrame, function->scope()->globalObject.get())
    4242        {
    4343            ASSERT(!function->isHostFunction());
    44             m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argCount, function->scope().node());
     44            m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argCount, function->scope());
    4545            m_valid = !callFrame->hadException();
    4646        }
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r77151 r79904  
    2727#include "MacroAssemblerCodeRef.h"
    2828#include "RegisterFile.h"
    29 #include "ScopeChain.h"
    3029
    3130namespace JSC  {
     
    3433    class JSActivation;
    3534    class Interpreter;
     35    class ScopeChainNode;
    3636
    3737    // Represents the current state of script execution.
     
    5252        // Global object in which the currently executing code was defined.
    5353        // Differs from dynamicGlobalObject() during function calls across web browser frames.
    54         JSGlobalObject* lexicalGlobalObject() const
    55         {
    56             return scopeChain()->globalObject;
    57         }
     54        inline JSGlobalObject* lexicalGlobalObject() const;
    5855
    5956        // Differs from lexicalGlobalObject because this will have DOM window shell rather than
    6057        // the actual DOM window, which can't be "this" for security reasons.
    61         JSObject* globalThisValue() const
    62         {
    63             return scopeChain()->globalThis;
    64         }
     58        inline JSObject* globalThisValue() const;
    6559
    66         JSGlobalData& globalData() const
    67         {
    68             ASSERT(scopeChain()->globalData);
    69             return *scopeChain()->globalData;
    70         }
     60        inline JSGlobalData& globalData() const;
    7161
    7262        // Convenience functions for access to global data.
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r79475 r79904  
    7777
    7878// Returns the depth of the scope chain within a given call frame.
    79 static int depth(CodeBlock* codeBlock, ScopeChain& sc)
     79static int depth(CodeBlock* codeBlock, ScopeChainNode* sc)
    8080{
    8181    if (!codeBlock->needsFullScopeChain())
    8282        return 0;
    83     return sc.localDepth();
     83    return sc->localDepth();
    8484}
    8585
     
    580580    }
    581581
    582     if (oldCodeBlock->needsFullScopeChain())
    583         scopeChain->deref();
    584 
    585582    CallFrame* callerFrame = callFrame->callerFrame();
    586583    if (callerFrame->hasHostCallFrameFlag())
     
    711708    // Unwind the scope chain within the exception handler's call frame.
    712709    ScopeChainNode* scopeChain = callFrame->scopeChain();
    713     ScopeChain sc(scopeChain);
    714710    int scopeDelta = 0;
    715711    if (!codeBlock->needsFullScopeChain() || codeBlock->codeType() != FunctionCode
    716712        || callFrame->uncheckedR(codeBlock->activationRegister()).jsValue())
    717         scopeDelta = depth(codeBlock, sc) - handler->scopeDepth;
     713        scopeDelta = depth(codeBlock, scopeChain) - handler->scopeDepth;
    718714    ASSERT(scopeDelta >= 0);
    719715    while (scopeDelta--)
     
    762758    newCallFrame->uncheckedR(newCallFrame->hostThisRegister()) = JSValue(thisObj);
    763759
    764     if (codeBlock->needsFullScopeChain())
    765         scopeChain->ref();
    766 
    767     DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
     760    DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject.get());
    768761
    769762    Profiler** profiler = Profiler::enabledProfilerReference();
     
    836829        newCallFrame->init(newCodeBlock, 0, callDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, function);
    837830
    838         DynamicGlobalObjectScope globalObjectScope(newCallFrame, callDataScopeChain->globalObject);
     831        DynamicGlobalObjectScope globalObjectScope(newCallFrame, callDataScopeChain->globalObject.get());
    839832
    840833        Profiler** profiler = Profiler::enabledProfilerReference();
     
    868861    newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, function);
    869862
    870     DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject);
     863    DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject.get());
    871864
    872865    Profiler** profiler = Profiler::enabledProfilerReference();
     
    925918        newCallFrame->init(newCodeBlock, 0, constructDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor);
    926919
    927         DynamicGlobalObjectScope globalObjectScope(newCallFrame, constructDataScopeChain->globalObject);
     920        DynamicGlobalObjectScope globalObjectScope(newCallFrame, constructDataScopeChain->globalObject.get());
    928921
    929922        Profiler** profiler = Profiler::enabledProfilerReference();
     
    960953    newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor);
    961954
    962     DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject);
     955    DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject.get());
    963956
    964957    Profiler** profiler = Profiler::enabledProfilerReference();
     
    10771070        return checkedReturn(throwStackOverflowError(callFrame));
    10781071
    1079     DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
     1072    DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject.get());
    10801073
    10811074    JSObject* compileError = eval->compile(callFrame, scopeChain);
     
    10851078
    10861079    JSObject* variableObject;
    1087     for (ScopeChainNode* node = scopeChain; ; node = node->next) {
     1080    for (ScopeChainNode* node = scopeChain; ; node = node->next.get()) {
    10881081        ASSERT(node);
    10891082        if (node->object->isVariableObject()) {
     
    11331126    newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), codeBlock->m_numParameters, 0);
    11341127    newCallFrame->uncheckedR(newCallFrame->hostThisRegister()) = JSValue(thisObj);
    1135 
    1136     if (codeBlock->needsFullScopeChain())
    1137         scopeChain->ref();
    11381128
    11391129    Profiler** profiler = Profiler::enabledProfilerReference();
     
    38063796        if (!function->name().isNull()) {
    38073797            JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
    3808             func->scope().push(functionScopeObject);
     3798            func->setScope(*globalData, func->scope()->push(functionScopeObject));
    38093799        }
    38103800
     
    38363826        Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
    38373827        JSValue thisValue = argv[0].jsValue();
    3838         JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject;
     3828        JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject.get();
    38393829
    38403830        if (thisValue == globalObject && funcVal == globalObject->evalFunction()) {
     
    41514141        int result = vPC[1].u.operand;
    41524142
    4153         if (callFrame->codeBlock()->needsFullScopeChain() && callFrame->r(codeBlock->activationRegister()).jsValue())
    4154             callFrame->scopeChain()->deref();
    4155 
    41564143        JSValue returnValue = callFrame->r(result).jsValue();
    41574144
     
    41924179        int result = vPC[1].u.operand;
    41934180
    4194         if (codeBlock->needsFullScopeChain() && callFrame->r(codeBlock->activationRegister()).jsValue())
    4195             callFrame->scopeChain()->deref();
    4196 
    41974181        JSValue returnValue = callFrame->r(result).jsValue();
    41984182
     
    42394223            JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionExecutable*>(codeBlock->ownerExecutable()));
    42404224            callFrame->r(activationReg) = JSValue(activation);
    4241             callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
     4225            callFrame->setScopeChain(callFrame->scopeChain()->push(activation));
    42424226        }
    42434227        vPC += OPCODE_LENGTH(op_create_activation);
     
    42784262            structure = asObject(proto)->inheritorID();
    42794263        else
    4280             structure = constructor->scope().node()->globalObject->emptyObjectStructure();
     4264            structure = constructor->scope()->globalObject->emptyObjectStructure();
    42814265        callFrame->uncheckedR(thisRegister) = constructEmptyObject(callFrame, structure);
    42824266
     
    46444628        */
    46454629
    4646         if (codeBlock->needsFullScopeChain()) {
    4647             ScopeChainNode* scopeChain = callFrame->scopeChain();
    4648             ASSERT(scopeChain->refCount > 1);
    4649             scopeChain->deref();
    4650         }
    46514630        int result = vPC[1].u.operand;
    46524631        return callFrame->r(result).jsValue();
  • trunk/Source/JavaScriptCore/jit/JITCall.cpp

    r70111 r79904  
    5050{
    5151    store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
    52     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT3); // newScopeChain
     52    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT3); // newScopeChain
    5353    storePtr(regT0, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register))));
    5454    storePtr(regT3, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register))));
     
    199199    // Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee
    200200
    201     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // newScopeChain
     201    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); // newScopeChain
    202202
    203203    store32(Imm32(argCount), Address(callFrameRegister, (registerOffset + RegisterFile::ArgumentCount) * static_cast<int>(sizeof(Register))));
  • trunk/Source/JavaScriptCore/jit/JITCall32_64.cpp

    r79247 r79904  
    5151    // regT0 holds callee, regT1 holds argCount
    5252    store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
    53     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT3); // scopeChain
     53    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT3); // scopeChain
    5454    storePtr(regT0, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register)))); // callee
    5555    storePtr(regT3, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)))); // scopeChain
     
    108108    unsigned dst = currentInstruction[1].u.operand;
    109109
    110     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    111     if (m_codeBlock->needsFullScopeChain()) {
    112         Jump activationNotCreated = branch32(Equal, tagFor(m_codeBlock->activationRegister()), Imm32(JSValue::EmptyValueTag));
    113         JITStubCall(this, cti_op_ret_scopeChain).call();
    114         activationNotCreated.link(this);
    115     }
    116110    emitLoad(dst, regT1, regT0);
    117111    emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT2);
     
    126120    unsigned result = currentInstruction[1].u.operand;
    127121    unsigned thisReg = currentInstruction[2].u.operand;
    128 
    129     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    130     if (m_codeBlock->needsFullScopeChain()) {
    131         Jump activationNotCreated = branch32(Equal, tagFor(m_codeBlock->activationRegister()), Imm32(JSValue::EmptyValueTag));
    132         JITStubCall(this, cti_op_ret_scopeChain).call();
    133         activationNotCreated.link(this);
    134     }
    135122
    136123    emitLoad(result, regT1, regT0);
     
    292279    // Fast version of stack frame initialization, directly relative to edi.
    293280    // Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee
    294     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT2);
     281    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT2);
    295282
    296283    store32(Imm32(argCount), Address(callFrameRegister, (registerOffset + RegisterFile::ArgumentCount) * static_cast<int>(sizeof(Register))));
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r78732 r79904  
    331331void JIT::emit_op_end(Instruction* currentInstruction)
    332332{
    333     if (m_codeBlock->needsFullScopeChain())
    334         JITStubCall(this, cti_op_end).call();
    335 
    336333    ASSERT(returnValueRegister != callFrameRegister);
    337334    emitGetVirtualRegister(currentInstruction[1].u.operand, returnValueRegister);
     
    544541void JIT::emit_op_ret(Instruction* currentInstruction)
    545542{
    546     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    547     if (m_codeBlock->needsFullScopeChain()) {
    548         Jump activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister()));
    549         JITStubCall(this, cti_op_ret_scopeChain).call();
    550         activationNotCreated.link(this);
    551     }
    552543    ASSERT(callFrameRegister != regT1);
    553544    ASSERT(regT1 != returnValueRegister);
     
    570561void JIT::emit_op_ret_object_or_this(Instruction* currentInstruction)
    571562{
    572     // We could JIT generate the deref, only calling out to C when the refcount hits zero.
    573     if (m_codeBlock->needsFullScopeChain()) {
    574         Jump activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister()));
    575         JITStubCall(this, cti_op_ret_scopeChain).call();
    576         activationNotCreated.link(this);
    577     }
    578 
    579563    ASSERT(callFrameRegister != regT1);
    580564    ASSERT(regT1 != returnValueRegister);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r78732 r79904  
    449449void JIT::emit_op_end(Instruction* currentInstruction)
    450450{
    451     if (m_codeBlock->needsFullScopeChain())
    452         JITStubCall(this, cti_op_end).call();
    453451    ASSERT(returnValueRegister != callFrameRegister);
    454452    emitLoad(currentInstruction[1].u.operand, regT1, regT0);
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r79551 r79904  
    11751175        structure = asObject(proto)->inheritorID();
    11761176    else
    1177         structure = constructor->scope().node()->globalObject->emptyObjectStructure();
     1177        structure = constructor->scope()->globalObject->emptyObjectStructure();
    11781178    JSValue result = constructEmptyObject(callFrame, structure);
    11791179
     
    12031203    CHECK_FOR_EXCEPTION_AT_END();
    12041204    return JSValue::encode(result);
    1205 }
    1206 
    1207 DEFINE_STUB_FUNCTION(void, op_end)
    1208 {
    1209     STUB_INIT_STACK_FRAME(stackFrame);
    1210 
    1211     ScopeChainNode* scopeChain = stackFrame.callFrame->scopeChain();
    1212     ASSERT(scopeChain->refCount > 1);
    1213     scopeChain->deref();
    12141205}
    12151206
     
    18481839    ASSERT(!function->isHostFunction());
    18491840    FunctionExecutable* executable = function->jsExecutable();
    1850     ScopeChainNode* callDataScopeChain = function->scope().node();
     1841    ScopeChainNode* callDataScopeChain = function->scope();
    18511842    JSObject* error = executable->compileForCall(stackFrame.callFrame, callDataScopeChain);
    18521843    if (error) {
     
    18691860    ASSERT(!function->isHostFunction());
    18701861    FunctionExecutable* executable = function->jsExecutable();
    1871     ScopeChainNode* callDataScopeChain = function->scope().node();
     1862    ScopeChainNode* callDataScopeChain = function->scope();
    18721863    JSObject* error = executable->compileForConstruct(stackFrame.callFrame, callDataScopeChain);
    18731864    if (error) {
     
    19301921    callFrame->setArgumentCountIncludingThis(argCount);
    19311922    callFrame->setCallee(callee);
    1932     callFrame->setScopeChain(callee->scope().node());
     1923    callFrame->setScopeChain(callee->scope());
    19331924    callFrame->setReturnPC(pc.value());
    19341925
     
    19891980    callFrame->setArgumentCountIncludingThis(argCount);
    19901981    callFrame->setCallee(callee);
    1991     callFrame->setScopeChain(callee->scope().node());
     1982    callFrame->setScopeChain(callee->scope());
    19921983    callFrame->setReturnPC(pc.value());
    19931984
     
    20102001    else {
    20112002        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    2012         JSObject* error = functionExecutable->compileForCall(callFrame, callee->scope().node());
     2003        JSObject* error = functionExecutable->compileForCall(callFrame, callee->scope());
    20132004        if (error) {
    20142005            callFrame->globalData().exception = createStackOverflowError(callFrame);
     
    20442035    else {
    20452036        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    2046         JSObject* error = functionExecutable->compileForConstruct(callFrame, callee->scope().node());
     2037        JSObject* error = functionExecutable->compileForConstruct(callFrame, callee->scope());
    20472038        if (error) {
    20482039            throwStackOverflowError(callFrame, stackFrame.globalData, ReturnAddressPtr(callFrame->returnPC()), STUB_RETURN_ADDRESS);
     
    20712062
    20722063    JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable()));
    2073     stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->copy()->push(activation));
     2064    stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(activation));
    20742065    return activation;
    20752066}
     
    21732164    ASSERT(*stackFrame.enabledProfilerReference);
    21742165    (*stackFrame.enabledProfilerReference)->didExecute(stackFrame.callFrame, stackFrame.args[0].jsValue());
    2175 }
    2176 
    2177 DEFINE_STUB_FUNCTION(void, op_ret_scopeChain)
    2178 {
    2179     STUB_INIT_STACK_FRAME(stackFrame);
    2180 
    2181     ASSERT(stackFrame.callFrame->codeBlock()->needsFullScopeChain());
    2182     stackFrame.callFrame->scopeChain()->deref();
    21832166}
    21842167
     
    30092992    if (!function->name().isNull()) {
    30102993        JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
    3011         func->scope().push(functionScopeObject);
     2994        func->setScope(callFrame->globalData(), func->scope()->push(functionScopeObject));
    30122995    }
    30132996
     
    31193102    Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
    31203103    JSValue baseValue = argv[0].jsValue();
    3121     JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject;
     3104    JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject.get();
    31223105
    31233106    if (baseValue == globalObject && funcVal == globalObject->evalFunction()) {
  • trunk/Source/JavaScriptCore/jit/JITStubs.h

    r75408 r79904  
    391391    void JIT_STUB cti_op_put_getter(STUB_ARGS_DECLARATION);
    392392    void JIT_STUB cti_op_put_setter(STUB_ARGS_DECLARATION);
    393     void JIT_STUB cti_op_ret_scopeChain(STUB_ARGS_DECLARATION);
    394393    void JIT_STUB cti_op_tear_off_activation(STUB_ARGS_DECLARATION);
    395394    void JIT_STUB cti_op_tear_off_arguments(STUB_ARGS_DECLARATION);
  • trunk/Source/JavaScriptCore/runtime/ArgList.cpp

    r77151 r79904  
    2424#include "JSValue.h"
    2525#include "JSCell.h"
     26#include "ScopeChain.h"
    2627
    2728using std::min;
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r70703 r79904  
    4848}
    4949
    50 Completion evaluate(ExecState* exec, ScopeChain& scopeChain, const SourceCode& source, JSValue thisValue)
     50Completion evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue)
    5151{
    5252    JSLock lock(exec);
     
    5454
    5555    RefPtr<ProgramExecutable> program = ProgramExecutable::create(exec, source);
    56     JSObject* error = program->compile(exec, scopeChain.node());
     56    JSObject* error = program->compile(exec, scopeChain);
    5757    if (error)
    5858        return Completion(Throw, error);
     
    6060    JSObject* thisObj = (!thisValue || thisValue.isUndefinedOrNull()) ? exec->dynamicGlobalObject() : thisValue.toObject(exec);
    6161
    62     JSValue result = exec->interpreter()->execute(program.get(), exec, scopeChain.node(), thisObj);
     62    JSValue result = exec->interpreter()->execute(program.get(), exec, scopeChain, thisObj);
    6363
    6464    if (exec->hadException()) {
  • trunk/Source/JavaScriptCore/runtime/Completion.h

    r57192 r79904  
    2929
    3030    class ExecState;
    31     class ScopeChain;
     31    class ScopeChainNode;
    3232    class SourceCode;
    3333
     
    5757
    5858    Completion checkSyntax(ExecState*, const SourceCode&);
    59     Completion evaluate(ExecState*, ScopeChain&, const SourceCode&, JSValue thisValue = JSValue());
     59    Completion evaluate(ExecState*, ScopeChainNode*, const SourceCode&, JSValue thisValue = JSValue());
    6060
    6161} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/DateConversion.cpp

    r69833 r79904  
    4545
    4646#include "CallFrame.h"
     47#include "ScopeChain.h"
    4748#include "UString.h"
    4849#include <wtf/DateMath.h>
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r79177 r79904  
    102102    recordParse(evalNode->features(), evalNode->hasCapturedVariables(), evalNode->lineNo(), evalNode->lastLine());
    103103
    104     ScopeChain scopeChain(scopeChainNode);
    105     JSGlobalObject* globalObject = scopeChain.globalObject();
     104    JSGlobalObject* globalObject = scopeChainNode->globalObject.get();
    106105
    107106    ASSERT(!m_evalCodeBlock);
    108     m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));
    109     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), scopeChain, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get())));
     107    m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scopeChainNode->localDepth()));
     108    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), scopeChainNode, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get())));
    110109    if ((exception = generator->generate())) {
    111110        m_evalCodeBlock.clear();
     
    155154    recordParse(programNode->features(), programNode->hasCapturedVariables(), programNode->lineNo(), programNode->lastLine());
    156155
    157     ScopeChain scopeChain(scopeChainNode);
    158     JSGlobalObject* globalObject = scopeChain.globalObject();
     156    JSGlobalObject* globalObject = scopeChainNode->globalObject.get();
    159157   
    160158    m_programCodeBlock = adoptPtr(new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider()));
    161     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), scopeChain, &globalObject->symbolTable(), m_programCodeBlock.get())));
     159    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), scopeChainNode, &globalObject->symbolTable(), m_programCodeBlock.get())));
    162160    if ((exception = generator->generate())) {
    163161        m_programCodeBlock.clear();
     
    195193    recordParse(body->features(), body->hasCapturedVariables(), body->lineNo(), body->lastLine());
    196194
    197     ScopeChain scopeChain(scopeChainNode);
    198     JSGlobalObject* globalObject = scopeChain.globalObject();
     195    JSGlobalObject* globalObject = scopeChainNode->globalObject.get();
    199196
    200197    ASSERT(!m_codeBlockForCall);
    201198    m_codeBlockForCall = adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), false));
    202     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall.get())));
     199    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChainNode, m_codeBlockForCall->symbolTable(), m_codeBlockForCall.get())));
    203200    if ((exception = generator->generate())) {
    204201        m_codeBlockForCall.clear();
     
    241238    recordParse(body->features(), body->hasCapturedVariables(), body->lineNo(), body->lastLine());
    242239
    243     ScopeChain scopeChain(scopeChainNode);
    244     JSGlobalObject* globalObject = scopeChain.globalObject();
     240    JSGlobalObject* globalObject = scopeChainNode->globalObject.get();
    245241
    246242    ASSERT(!m_codeBlockForConstruct);
    247243    m_codeBlockForConstruct = adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), true));
    248     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct.get())));
     244    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChainNode, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct.get())));
    249245    if ((exception = generator->generate())) {
    250246        m_codeBlockForConstruct.clear();
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r77151 r79904  
    107107    }
    108108
    109     ScopeChain scopeChain(globalObject, &globalData, globalObject, exec->globalThisValue());
    110     return new (exec) JSFunction(exec, function, scopeChain.node());
     109    ScopeChainNode* scopeChain = new (exec) ScopeChainNode(0, globalObject, &globalData, globalObject, exec->globalThisValue());
     110    return new (exec) JSFunction(exec, function, scopeChain);
    111111}
    112112
  • trunk/Source/JavaScriptCore/runtime/GCActivityCallbackCF.cpp

    r79434 r79904  
    3434#include "JSGlobalData.h"
    3535#include "JSLock.h"
     36#include "ScopeChain.h"
    3637#include <wtf/RetainPtr.h>
    3738#include <wtf/WTFThreadData.h>
  • trunk/Source/JavaScriptCore/runtime/Identifier.cpp

    r72592 r79904  
    2424#include "CallFrame.h"
    2525#include "NumericStrings.h"
     26#include "ScopeChain.h"
    2627#include <new> // for placement new
    2728#include <string.h> // for strlen
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r79750 r79904  
    6666        friend class MarkedSpace;
    6767        friend class MarkedBlock;
     68        friend class ScopeChainNode;
    6869
    6970    private:
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r79240 r79904  
    6060    : Base(structure)
    6161    , m_executable(adoptRef(new VPtrHackExecutable()))
    62     , m_scopeChain(NoScopeChain())
    6362{
    6463    ASSERT(inherits(&s_info));
     
    6867    : Base(globalObject, structure)
    6968    , m_executable(thunk)
    70     , m_scopeChain(globalObject->globalScopeChain())
     69    , m_scopeChain(exec->globalData(), this, globalObject->globalScopeChain())
    7170{
    7271    ASSERT(inherits(&s_info));
     
    7877    : Base(globalObject, structure)
    7978    , m_executable(exec->globalData().getHostFunction(func))
    80     , m_scopeChain(globalObject->globalScopeChain())
     79    , m_scopeChain(exec->globalData(), this, globalObject->globalScopeChain())
    8180{
    8281    ASSERT(inherits(&s_info));
     
    8685
    8786JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<FunctionExecutable> executable, ScopeChainNode* scopeChainNode)
    88     : Base(scopeChainNode->globalObject, scopeChainNode->globalObject->functionStructure())
     87    : Base(scopeChainNode->globalObject.get(), scopeChainNode->globalObject->functionStructure())
    8988    , m_executable(executable)
    90     , m_scopeChain(scopeChainNode)
     89    , m_scopeChain(exec->globalData(), this, scopeChainNode)
    9190{
    9291    ASSERT(inherits(&s_info));
     
    152151    if (!isHostFunction()) {
    153152        jsExecutable()->markAggregate(markStack);
    154         scope().markAggregate(markStack);
     153        markStack.append(&m_scopeChain);
    155154    }
    156155}
     
    163162    }
    164163    callData.js.functionExecutable = jsExecutable();
    165     callData.js.scopeChain = scope().node();
     164    callData.js.scopeChain = scope();
    166165    return CallTypeJS;
    167166}
     
    197196
    198197        if (!location) {
    199             JSObject* prototype = constructEmptyObject(exec, scope().globalObject()->emptyObjectStructure());
     198            JSObject* prototype = constructEmptyObject(exec, scope()->globalObject->emptyObjectStructure());
    200199            prototype->putDirect(exec->globalData(), exec->propertyNames().constructor, this, DontEnum);
    201200            putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | DontEnum);
     
    327326        return ConstructTypeNone;
    328327    constructData.js.functionExecutable = jsExecutable();
    329     constructData.js.scopeChain = scope().node();
     328    constructData.js.scopeChain = scope();
    330329    return ConstructTypeJS;
    331330}
  • trunk/Source/JavaScriptCore/runtime/JSFunction.h

    r79177 r79904  
    5454        const UString calculatedDisplayName(ExecState*);
    5555
    56         ScopeChain& scope()
     56        ScopeChainNode* scope()
    5757        {
    5858            ASSERT(!isHostFunctionNonInline());
    59             return m_scopeChain;
     59            return m_scopeChain.get();
    6060        }
    61         void setScope(const ScopeChain& scopeChain)
     61        void setScope(JSGlobalData& globalData, ScopeChainNode* scopeChain)
    6262        {
    6363            ASSERT(!isHostFunctionNonInline());
    64             m_scopeChain = scopeChain;
     64            m_scopeChain.set(globalData, this, scopeChain);
    6565        }
    6666
     
    104104
    105105        RefPtr<ExecutableBase> m_executable;
    106         ScopeChain m_scopeChain;
     106        WriteBarrier<ScopeChainNode> m_scopeChain;
    107107    };
    108108
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r79616 r79904  
    133133    , getterSetterStructure(GetterSetter::createStructure(jsNull()))
    134134    , apiWrapperStructure(JSAPIValueWrapper::createStructure(jsNull()))
     135    , scopeChainNodeStructure(ScopeChainNode::createStructure(jsNull()))
    135136    , dummyMarkableCellStructure(JSCell::createDummyStructure())
    136137    , identifierTable(globalDataType == Default ? wtfThreadData().currentIdentifierTable() : createIdentifierTable())
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r79616 r79904  
    154154        RefPtr<Structure> getterSetterStructure;
    155155        RefPtr<Structure> apiWrapperStructure;
     156        RefPtr<Structure> scopeChainNodeStructure;
    156157        RefPtr<Structure> dummyMarkableCellStructure;
    157158
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r79616 r79904  
    113113
    114114    d()->globalData = Heap::heap(this)->globalData();
    115     d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), this, thisValue);
    116 
    117     JSGlobalObject::globalExec()->init(0, 0, d()->globalScopeChain.node(), CallFrame::noCaller(), 0, 0);
     115    d()->globalScopeChain.set(*d()->globalData, this, new (d()->globalData.get()) ScopeChainNode(0, this, d()->globalData.get(), this, thisValue));
     116
     117    JSGlobalObject::globalExec()->init(0, 0, d()->globalScopeChain.get(), CallFrame::noCaller(), 0, 0);
    118118
    119119    d()->debugger = 0;
     
    320320    JSVariableObject::markChildren(markStack);
    321321   
     322    markIfNeeded(markStack, &d()->globalScopeChain);
     323
    322324    markIfNeeded(markStack, &d()->regExpConstructor);
    323325    markIfNeeded(markStack, &d()->errorConstructor);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r79177 r79904  
    7070                , destructor(destructor)
    7171                , registerArraySize(0)
    72                 , globalScopeChain(NoScopeChain())
     72                , globalScopeChain()
    7373                , weakRandom(static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
    7474            {
     
    8484            Debugger* debugger;
    8585           
    86             ScopeChain globalScopeChain;
     86            WriteBarrier<ScopeChainNode> globalScopeChain;
    8787            Register globalCallFrame[RegisterFile::CallFrameHeaderSize];
    8888
     
    229229        virtual bool supportsRichSourceInfo() const { return true; }
    230230
    231         ScopeChain& globalScopeChain() { return d()->globalScopeChain; }
     231        ScopeChainNode* globalScopeChain() { return d()->globalScopeChain.get(); }
    232232
    233233        virtual bool isGlobalObject() const { return true; }
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r79177 r79904  
    451451
    452452    RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s), false);
    453     JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node());
     453    JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain());
    454454    if (error)
    455455        return throwVMError(exec, error);
    456456
    457     return JSValue::encode(exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node()));
     457    return JSValue::encode(exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain()));
    458458}
    459459
  • trunk/Source/JavaScriptCore/runtime/JSLock.cpp

    r79564 r79904  
    2424#include "Heap.h"
    2525#include "CallFrame.h"
     26#include "ScopeChain.h"
    2627
    2728#if USE(PTHREADS)
  • trunk/Source/JavaScriptCore/runtime/JSNumberCell.cpp

    r70111 r79904  
    2323#include "config.h"
    2424#include "JSNumberCell.h"
     25#include "ScopeChain.h"
    2526
    2627// Keep our exported symbols lists happy.
  • trunk/Source/JavaScriptCore/runtime/JSZombie.cpp

    r79132 r79904  
    2727#include "JSZombie.h"
    2828#include "ClassInfo.h"
     29#include "ScopeChain.h"
    2930
    3031#if ENABLE(JSC_ZOMBIES)
  • trunk/Source/JavaScriptCore/runtime/MarkedBlock.cpp

    r79492 r79904  
    2828
    2929#include "JSCell.h"
     30#include "ScopeChain.h"
    3031
    3132namespace JSC {
  • trunk/Source/JavaScriptCore/runtime/MarkedSpace.cpp

    r79750 r79904  
    2525#include "JSGlobalData.h"
    2626#include "JSLock.h"
     27#include "ScopeChain.h"
    2728
    2829namespace JSC {
  • trunk/Source/JavaScriptCore/runtime/PropertyNameArray.cpp

    r65104 r79904  
    2222#include "PropertyNameArray.h"
    2323
     24#include "ScopeChain.h"
    2425#include "Structure.h"
    2526#include "StructureChain.h"
  • trunk/Source/JavaScriptCore/runtime/ScopeChain.cpp

    r79132 r79904  
    3232#ifndef NDEBUG
    3333
    34 void ScopeChainNode::print() const
     34void ScopeChainNode::print()
    3535{
    3636    ScopeChainIterator scopeEnd = end();
    3737    for (ScopeChainIterator scopeIter = begin(); scopeIter != scopeEnd; ++scopeIter) {
    38         DeprecatedPtr<JSObject> o = *scopeIter;
     38        JSObject* o = scopeIter->get();
    3939        PropertyNameArray propertyNames(globalObject->globalExec());
    4040        o->getPropertyNames(globalObject->globalExec(), propertyNames);
    4141        PropertyNameArray::const_iterator propEnd = propertyNames.end();
    4242
    43         fprintf(stderr, "----- [scope %p] -----\n", o.get());
     43        fprintf(stderr, "----- [scope %p] -----\n", o);
    4444        for (PropertyNameArray::const_iterator propIter = propertyNames.begin(); propIter != propEnd; propIter++) {
    4545            Identifier name = *propIter;
     
    5252#endif
    5353
    54 int ScopeChain::localDepth() const
     54int ScopeChainNode::localDepth()
    5555{
    5656    int scopeDepth = 0;
     
    6666}
    6767
     68void ScopeChainNode::markChildren(MarkStack& markStack)
     69{
     70    if (next)
     71        markStack.append(&next);
     72    markStack.append(&object);
     73    markStack.append(&globalObject);
     74    markStack.append(&globalThis);
     75}
     76
    6877} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/ScopeChain.h

    r77151 r79904  
    2222#define ScopeChain_h
    2323
    24 #include "WriteBarrier.h"
     24#include "JSCell.h"
    2525#include <wtf/FastAllocBase.h>
    2626
     
    3333    class ScopeChainIterator;
    3434   
    35     class ScopeChainNode {
    36         WTF_MAKE_FAST_ALLOCATED;
     35    class ScopeChainNode : public JSCell {
    3736    public:
    3837        ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
    39             : next(next)
    40             , object(object)
     38            : JSCell(globalData->scopeChainNodeStructure.get())
    4139            , globalData(globalData)
    42             , globalObject(globalObject)
    43             , globalThis(globalThis)
    44             , refCount(1)
     40            , next(*globalData, this, next)
     41            , object(*globalData, this, object)
     42            , globalObject(*globalData, this, globalObject)
     43            , globalThis(*globalData, this, globalThis)
    4544        {
    4645            ASSERT(globalData);
    4746            ASSERT(globalObject);
    4847        }
    49 #ifndef NDEBUG
    50         // Due to the number of subtle and timing dependent bugs that have occurred due
    51         // to deleted but still "valid" ScopeChainNodes we now deliberately clobber the
    52         // contents in debug builds.
    53         ~ScopeChainNode()
    54         {
    55             next = 0;
    56             globalData = 0;
    57             globalObject = 0;
    58             globalThis = 0;
    59         }
    60 #endif
    6148
    62         ScopeChainNode* next;
    63         DeprecatedPtr<JSObject> object;
    6449        JSGlobalData* globalData;
    65         JSGlobalObject* globalObject;
    66         JSObject* globalThis;
    67         int refCount;
    68 
    69         void deref() { ASSERT(refCount); if (--refCount == 0) { release();} }
    70         void ref() { ASSERT(refCount); ++refCount; }
    71         void release();
    72 
    73         // Before calling "push" on a bare ScopeChainNode, a client should
    74         // logically "copy" the node. Later, the client can "deref" the head
    75         // of its chain of ScopeChainNodes to reclaim all the nodes it added
    76         // after the logical copy, leaving nodes added before the logical copy
    77         // (nodes shared with other clients) untouched.
    78         ScopeChainNode* copy()
    79         {
    80             ref();
    81             return this;
    82         }
     50        WriteBarrier<ScopeChainNode> next;
     51        WriteBarrier<JSObject> object;
     52        WriteBarrier<JSGlobalObject> globalObject;
     53        WriteBarrier<JSObject> globalThis;
    8354
    8455        ScopeChainNode* push(JSObject*);
    8556        ScopeChainNode* pop();
    8657
    87         ScopeChainIterator begin() const;
    88         ScopeChainIterator end() const;
     58        ScopeChainIterator begin();
     59        ScopeChainIterator end();
     60
     61        int localDepth();
    8962
    9063#ifndef NDEBUG       
    91         void print() const;
     64        void print();
    9265#endif
     66       
     67        static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(CompoundType, StructureFlags), AnonymousSlotCount, 0); }
     68        virtual void markChildren(MarkStack&);
     69    private:
     70        static const unsigned StructureFlags = OverridesMarkChildren;
    9371    };
    9472
     
    9674    {
    9775        ASSERT(o);
    98         return new ScopeChainNode(this, o, globalData, globalObject, globalThis);
     76        return new (globalData) ScopeChainNode(this, o, globalData, globalObject.get(), globalThis.get());
    9977    }
    10078
     
    10280    {
    10381        ASSERT(next);
    104         ScopeChainNode* result = next;
    105 
    106         if (--refCount != 0)
    107             ++result->refCount;
    108         else
    109             delete this;
    110 
    111         return result;
    112     }
    113 
    114     inline void ScopeChainNode::release()
    115     {
    116         // This function is only called by deref(),
    117         // Deref ensures these conditions are true.
    118         ASSERT(refCount == 0);
    119         ScopeChainNode* n = this;
    120         do {
    121             ScopeChainNode* next = n->next;
    122             delete n;
    123             n = next;
    124         } while (n && --n->refCount == 0);
     82        return next.get();
    12583    }
    12684
    12785    class ScopeChainIterator {
    12886    public:
    129         ScopeChainIterator(const ScopeChainNode* node)
     87        ScopeChainIterator(ScopeChainNode* node)
    13088            : m_node(node)
    13189        {
    13290        }
    13391
    134         DeprecatedPtr<JSObject> const & operator*() const { return m_node->object; }
    135         DeprecatedPtr<JSObject> const * operator->() const { return &(operator*()); }
     92        WriteBarrier<JSObject> const & operator*() const { return m_node->object; }
     93        WriteBarrier<JSObject> const * operator->() const { return &(operator*()); }
    13694   
    137         ScopeChainIterator& operator++() { m_node = m_node->next; return *this; }
     95        ScopeChainIterator& operator++() { m_node = m_node->next.get(); return *this; }
    13896
    13997        // postfix ++ intentionally omitted
     
    143101
    144102    private:
    145         const ScopeChainNode* m_node;
     103        DeprecatedPtr<ScopeChainNode> m_node;
    146104    };
    147105
    148     inline ScopeChainIterator ScopeChainNode::begin() const
     106    inline ScopeChainIterator ScopeChainNode::begin()
    149107    {
    150108        return ScopeChainIterator(this);
    151109    }
    152110
    153     inline ScopeChainIterator ScopeChainNode::end() const
     111    inline ScopeChainIterator ScopeChainNode::end()
    154112    {
    155113        return ScopeChainIterator(0);
    156114    }
    157115
    158     class NoScopeChain {};
    159 
    160     class ScopeChain {
    161         friend class JIT;
    162     public:
    163         ScopeChain(NoScopeChain)
    164             : m_node(0)
    165         {
    166         }
    167 
    168         ScopeChain(JSObject* o, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
    169             : m_node(new ScopeChainNode(0, o, globalData, globalObject, globalThis))
    170         {
    171         }
    172 
    173         ScopeChain(const ScopeChain& c)
    174             : m_node(c.m_node->copy())
    175         {
    176         }
    177 
    178         ScopeChain& operator=(const ScopeChain& c);
    179 
    180         explicit ScopeChain(ScopeChainNode* node)
    181             : m_node(node->copy())
    182         {
    183         }
    184 
    185         ~ScopeChain()
    186         {
    187             if (m_node)
    188                 m_node->deref();
    189 #ifndef NDEBUG
    190             m_node = 0;
    191 #endif
    192         }
    193 
    194         void swap(ScopeChain&);
    195 
    196         ScopeChainNode* node() const { return m_node; }
    197 
    198         JSObject* top() const { return m_node->object.get(); }
    199 
    200         ScopeChainIterator begin() const { return m_node->begin(); }
    201         ScopeChainIterator end() const { return m_node->end(); }
    202 
    203         void push(JSObject* o) { m_node = m_node->push(o); }
    204 
    205         void pop() { m_node = m_node->pop(); }
    206         void clear() { m_node->deref(); m_node = 0; }
    207        
    208         JSGlobalObject* globalObject() const { return m_node->globalObject; }
    209 
    210         void markAggregate(MarkStack&) const;
    211 
    212         // Caution: this should only be used if the codeblock this is being used
    213         // with needs a full scope chain, otherwise this returns the depth of
    214         // the preceeding call frame
    215         //
    216         // Returns the depth of the current call frame's scope chain
    217         int localDepth() const;
    218 
    219 #ifndef NDEBUG       
    220         void print() const { m_node->print(); }
    221 #endif
    222 
    223     private:
    224         ScopeChainNode* m_node;
    225     };
    226 
    227     inline void ScopeChain::swap(ScopeChain& o)
     116    ALWAYS_INLINE JSGlobalData& ExecState::globalData() const
    228117    {
    229         ScopeChainNode* tmp = m_node;
    230         m_node = o.m_node;
    231         o.m_node = tmp;
     118        ASSERT(scopeChain()->globalData);
     119        return *scopeChain()->globalData;
    232120    }
    233121
    234     inline ScopeChain& ScopeChain::operator=(const ScopeChain& c)
     122    ALWAYS_INLINE JSGlobalObject* ExecState::lexicalGlobalObject() const
    235123    {
    236         ScopeChain tmp(c);
    237         swap(tmp);
    238         return *this;
     124        return scopeChain()->globalObject.get();
     125    }
     126   
     127    ALWAYS_INLINE JSObject* ExecState::globalThisValue() const
     128    {
     129        return scopeChain()->globalThis.get();
    239130    }
    240131
  • trunk/Source/JavaScriptCore/runtime/ScopeChainMark.h

    r77151 r79904  
    2626namespace JSC {
    2727
    28     inline void ScopeChain::markAggregate(MarkStack& markStack) const
    29     {
    30         for (ScopeChainNode* n = m_node; n; n = n->next)
    31             markStack.append(&n->object);
    32     }
    33 
    3428} // namespace JSC
    3529
  • trunk/Source/JavaScriptCore/wtf/DateMath.cpp

    r79060 r79904  
    7777#include "CurrentTime.h"
    7878#include "MathExtras.h"
     79#if USE(JSC)
     80#include "ScopeChain.h"
     81#endif
    7982#include "StdLibExtras.h"
    8083#include "StringExtras.h"
  • trunk/Source/WebCore/ChangeLog

    r79900 r79904  
     12011-02-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Make ScopeChainNode GC allocated
     6        https://bugs.webkit.org/show_bug.cgi?id=55283
     7
     8        Update WebCore to deal with the absence of the ScopeChain
     9        class.
     10
     11        * ForwardingHeaders/runtime/ScopeChain.h: Added.
     12        * bindings/js/JSHTMLElementCustom.cpp:
     13        (WebCore::JSHTMLElement::pushEventHandlerScope):
     14        * bindings/js/JSJavaScriptCallFrameCustom.cpp:
     15        (WebCore::JSJavaScriptCallFrame::scopeChain):
     16        (WebCore::JSJavaScriptCallFrame::scopeType):
     17        * bindings/js/JSLazyEventListener.cpp:
     18        (WebCore::JSLazyEventListener::initializeJSFunction):
     19        * bindings/js/JSMainThreadExecState.h:
     20        (WebCore::JSMainThreadExecState::evaluate):
     21        * bindings/js/JSNodeCustom.cpp:
     22        (WebCore::JSNode::pushEventHandlerScope):
     23        * bindings/js/JavaScriptCallFrame.cpp:
     24        (WebCore::JavaScriptCallFrame::scopeChain):
     25        * bindings/js/JavaScriptCallFrame.h:
     26        * bindings/scripts/CodeGeneratorJS.pm:
     27        * bridge/c/c_class.cpp:
     28        * bridge/c/c_runtime.cpp:
     29        * bridge/jni/JNIBridge.cpp:
     30        * bridge/qt/qt_runtime.cpp:
     31        (JSC::Bindings::QtConnectionObject::execute):
     32        * plugins/PluginViewNone.cpp:
     33
    1342011-02-28  Chang Shu  <cshu@webkit.org>
    235
  • trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp

    r46444 r79904  
    3434using namespace JSC;
    3535
    36 void JSHTMLElement::pushEventHandlerScope(ExecState* exec, ScopeChain& scope) const
     36ScopeChainNode* JSHTMLElement::pushEventHandlerScope(ExecState* exec, ScopeChainNode* scope) const
    3737{
    3838    HTMLElement* element = impl();
    3939
    4040    // The document is put on first, fall back to searching it only after the element and form.
    41     scope.push(asObject(toJS(exec, globalObject(), element->ownerDocument())));
     41    scope = scope->push(asObject(toJS(exec, globalObject(), element->ownerDocument())));
    4242
    4343    // The form is next, searched before the document, but after the element itself.
    4444    if (HTMLFormElement* form = element->form())
    45         scope.push(asObject(toJS(exec, globalObject(), form)));
     45        scope = scope->push(asObject(toJS(exec, globalObject(), form)));
    4646
    4747    // The element is on top, searched first.
    48     scope.push(asObject(toJS(exec, globalObject(), element)));
     48    return scope->push(asObject(toJS(exec, globalObject(), element)));
    4949}
    5050
  • trunk/Source/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp

    r77151 r79904  
    7171        return jsNull();
    7272
    73     const ScopeChainNode* scopeChain = impl()->scopeChain();
     73    ScopeChainNode* scopeChain = impl()->scopeChain();
    7474    ScopeChainIterator iter = scopeChain->begin();
    7575    ScopeChainIterator end = scopeChain->end();
     
    9696    int index = exec->argument(0).asInt32();
    9797
    98     const ScopeChainNode* scopeChain = impl()->scopeChain();
     98    ScopeChainNode* scopeChain = impl()->scopeChain();
    9999    ScopeChainIterator end = scopeChain->end();
    100100
    101101    bool foundLocalScope = false;
    102102    for (ScopeChainIterator iter = scopeChain->begin(); iter != end; ++iter) {
    103         JSC::DeprecatedPtr<JSObject> scope = *iter;
     103        JSObject* scope = iter->get();
    104104        if (scope->isActivationObject()) {
    105105            if (!foundLocalScope) {
  • trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp

    r78634 r79904  
    121121        // Add the event's home element to the scope
    122122        // (and the document, and the form - see JSHTMLElement::eventHandlerScope)
    123         ScopeChain scope = listenerAsFunction->scope();
    124         static_cast<JSNode*>(wrapper())->pushEventHandlerScope(exec, scope);
    125         listenerAsFunction->setScope(scope);
     123        listenerAsFunction->setScope(exec->globalData(), static_cast<JSNode*>(wrapper())->pushEventHandlerScope(exec, listenerAsFunction->scope()));
    126124    }
    127125
  • trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h

    r76248 r79904  
    4949    };
    5050
    51     static JSC::Completion evaluate(JSC::ExecState* exec, JSC::ScopeChain& chain, const JSC::SourceCode& source, JSC::JSValue thisValue)
     51    static JSC::Completion evaluate(JSC::ExecState* exec, JSC::ScopeChainNode* chain, const JSC::SourceCode& source, JSC::JSValue thisValue)
    5252    {
    5353        JSMainThreadExecState currentState(exec);
  • trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp

    r78150 r79904  
    113113}
    114114
    115 void JSNode::pushEventHandlerScope(ExecState*, ScopeChain&) const
    116 {
     115ScopeChainNode* JSNode::pushEventHandlerScope(ExecState*, ScopeChainNode* node) const
     116{
     117    return node;
    117118}
    118119
  • trunk/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp

    r78482 r79904  
    5757}
    5858
    59 const JSC::ScopeChainNode* JavaScriptCallFrame::scopeChain() const
     59JSC::ScopeChainNode* JavaScriptCallFrame::scopeChain() const
    6060{
    6161    ASSERT(m_isValid);
  • trunk/Source/WebCore/bindings/js/JavaScriptCallFrame.h

    r78482 r79904  
    7070    String functionName() const;
    7171    JSC::DebuggerCallFrame::Type type() const;
    72     const JSC::ScopeChainNode* scopeChain() const;
     72    JSC::ScopeChainNode* scopeChain() const;
    7373    JSC::JSGlobalObject* dynamicGlobalObject() const;
    7474
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r79675 r79904  
    759759
    760760    # Custom pushEventHandlerScope function
    761     push(@headerContent, "    virtual void pushEventHandlerScope(JSC::ExecState*, JSC::ScopeChain&) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
     761    push(@headerContent, "    virtual JSC::ScopeChainNode* pushEventHandlerScope(JSC::ExecState*, JSC::ScopeChainNode*) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
    762762
    763763    # Custom call functions
  • trunk/Source/WebCore/bridge/c/c_class.cpp

    r65344 r79904  
    3333#include "c_runtime.h"
    3434#include "npruntime_impl.h"
     35#include <runtime/ScopeChain.h>
    3536#include <runtime/Identifier.h>
    3637#include <runtime/JSLock.h>
  • trunk/Source/WebCore/bridge/c/c_runtime.cpp

    r54516 r79904  
    3333#include "c_utility.h"
    3434#include "npruntime_impl.h"
     35#include <runtime/ScopeChain.h>
    3536#include <runtime/JSLock.h>
    3637
  • trunk/Source/WebCore/bridge/jni/JNIBridge.cpp

    r69594 r79904  
    3030#if ENABLE(JAVA_BRIDGE)
    3131
     32#include <runtime/ScopeChain.h>
    3233#include <wtf/text/CString.h>
    3334#include <wtf/text/StringBuilder.h>
  • trunk/Source/WebCore/bridge/qt/qt_runtime.cpp

    r79132 r79904  
    18271827                    }
    18281828                    // Stuff in the __qt_sender property, if we can
    1829                     ScopeChain oldsc = ScopeChain(NoScopeChain());
     1829                    ScopeChainNode* oldsc = 0;
    18301830                    JSFunction* fimp = 0;
    18311831                    if (m_funcObject->inherits(&JSFunction::s_info)) {
     
    18371837                        wrapper->put(exec, Identifier(exec, "__qt_sender__"), qt_sender, slot);
    18381838                        oldsc = fimp->scope();
    1839                         ScopeChain sc = oldsc;
    1840                         sc.push(wrapper);
    1841                         fimp->setScope(sc);
     1839                        fimp->setScope(oldsc->push(wrapper));
    18421840                    }
    18431841
  • trunk/Source/WebCore/plugins/PluginViewNone.cpp

    r66569 r79904  
    2929#if USE(JSC)
    3030#include "Bridge.h"
     31#include <runtime/ScopeChain.h>
    3132#endif
    3233
  • trunk/Source/WebKit/mac/ChangeLog

    r79793 r79904  
     12011-02-28  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Make ScopeChainNode GC allocated
     6        https://bugs.webkit.org/show_bug.cgi?id=55283
     7
     8        More updates for the absence of the ScopeChain class
     9
     10        * WebView/WebScriptDebugDelegate.mm:
     11        (-[WebScriptCallFrame scopeChain]):
     12
    1132011-02-26  Vsevolod Vlasov  <vsevik@chromium.org>
    214
  • trunk/Source/WebKit/mac/WebView/WebScriptDebugDelegate.mm

    r77151 r79904  
    177177    JSLock lock(SilenceAssertionsOnly);
    178178
    179     const ScopeChainNode* scopeChain = _private->debuggerCallFrame->scopeChain();
     179    ScopeChainNode* scopeChain = _private->debuggerCallFrame->scopeChain();
    180180    if (!scopeChain->next)  // global frame
    181181        return [NSArray arrayWithObject:_private->globalObject];
Note: See TracChangeset for help on using the changeset viewer.