Commit 97cdbd4c authored by oliver@apple.com's avatar oliver@apple.com

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]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79904 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 049f16eb
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-27 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
......
......@@ -305,7 +305,7 @@ __ZN3JSC8JSObject6s_infoE
__ZN3JSC8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC8Profiler8profilerEv
__ZN3JSC8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_10SourceCodeENS_7JSValueE
__ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueE
__ZN3JSC9CodeBlockD1Ev
__ZN3JSC9CodeBlockD2Ev
__ZN3JSC9MarkStack10s_pageSizeE
......@@ -587,6 +587,7 @@ __ZNK3WTF6String9substringEjj
__ZNK3WTF8Collator7collateEPKtmS2_m
__ZTVN3JSC12StringObjectE
__ZTVN3JSC14JSGlobalObjectE
__ZTVN3JSC14ScopeChainNodeE
__ZTVN3JSC15JSWrapperObjectE
__ZTVN3JSC16InternalFunctionE
__ZTVN3JSC16JSVariableObjectE
......
......@@ -150,7 +150,7 @@ EXPORTS
?equal@Identifier@JSC@@SA_NPBVStringImpl@WTF@@PBD@Z
?equalUTF16WithUTF8@Unicode@WTF@@YA_NPB_W0PBD1@Z
?evaluate@DebuggerCallFrame@JSC@@QBE?AVJSValue@2@ABVUString@2@AAV32@@Z
?evaluate@JSC@@YA?AVCompletion@1@PAVExecState@1@AAVScopeChain@1@ABVSourceCode@1@VJSValue@1@@Z
?evaluate@JSC@@YA?AVCompletion@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@VJSValue@1@@Z
?exclude@Profile@JSC@@QAEXPBVProfileNode@2@@Z
?fastCalloc@WTF@@YAPAXII@Z
?fastFree@WTF@@YAXPAX@Z
......
......@@ -1697,7 +1697,7 @@ void CodeBlock::createActivation(CallFrame* callFrame)
ASSERT(!callFrame->uncheckedR(activationRegister()).jsValue());
JSActivation* activation = new (callFrame) JSActivation(callFrame, static_cast<FunctionExecutable*>(ownerExecutable()));
callFrame->uncheckedR(activationRegister()) = JSValue(activation);
callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
callFrame->setScopeChain(callFrame->scopeChain()->push(activation));
}
} // namespace JSC
......@@ -26,6 +26,8 @@
#include "config.h"
#include "StructureStubInfo.h"
#include "ScopeChain.h"
namespace JSC {
#if ENABLE(JIT)
......
......@@ -33,6 +33,7 @@
#include "BatchedTransitionOptimizer.h"
#include "JSFunction.h"
#include "Interpreter.h"
#include "ScopeChain.h"
#include "UString.h"
using namespace std;
......@@ -146,7 +147,7 @@ JSObject* BytecodeGenerator::generate()
m_codeBlock->setInstructionCount(m_codeBlock->instructions().size());
if (s_dumpsGeneratedCode)
m_codeBlock->dump(m_scopeChain->globalObject()->globalExec());
m_codeBlock->dump(m_scopeChain->globalObject->globalExec());
#endif
if ((m_codeType == FunctionCode && !m_codeBlock->needsFullScopeChain() && !m_codeBlock->usesArguments()) || m_codeType == EvalCode)
......@@ -155,7 +156,7 @@ JSObject* BytecodeGenerator::generate()
m_codeBlock->shrinkToFit();
if (m_expressionTooDeep)
return createOutOfMemoryError(m_scopeChain->globalObject());
return createOutOfMemoryError(m_scopeChain->globalObject.get());
return 0;
}
......@@ -197,11 +198,11 @@ void BytecodeGenerator::preserveLastVar()
m_lastVar = &m_calleeRegisters.last();
}
BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock)
: m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
, m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
, m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
, m_scopeChain(&scopeChain)
BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
, m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
, m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
, m_scopeChain(*scopeChain->globalData, scopeChain)
, m_symbolTable(symbolTable)
, m_scopeNode(programNode)
, m_codeBlock(codeBlock)
......@@ -216,7 +217,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain&
, m_hasCreatedActivation(true)
, m_firstLazyFunction(0)
, m_lastLazyFunction(0)
, m_globalData(&scopeChain.globalObject()->globalData())
, m_globalData(scopeChain->globalData)
, m_lastOpcodeID(op_end)
#ifndef NDEBUG
, m_lastOpcodePosition(0)
......@@ -237,7 +238,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain&
m_codeBlock->m_numParameters = 1; // Allocate space for "this"
JSGlobalObject* globalObject = scopeChain.globalObject();
JSGlobalObject* globalObject = scopeChain->globalObject.get();
ExecState* exec = globalObject->globalExec();
RegisterFile* registerFile = &exec->globalData().interpreter->registerFile();
......@@ -282,7 +283,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain&
} else {
for (size_t i = 0; i < functionStack.size(); ++i) {
FunctionBodyNode* function = functionStack[i];
globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction(exec, function), scopeChain.node()), DontDelete);
globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction(exec, function), scopeChain), DontDelete);
}
for (size_t i = 0; i < varStack.size(); ++i) {
if (globalObject->hasProperty(exec, *varStack[i].first))
......@@ -298,11 +299,11 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain&
codeBlock->m_numCapturedVars = codeBlock->m_numVars;
}
BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)
: m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
, m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
, m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
, m_scopeChain(&scopeChain)
BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, ScopeChainNode* scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
, m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
, m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
, m_scopeChain(*scopeChain->globalData, scopeChain)
, m_symbolTable(symbolTable)
, m_scopeNode(functionBody)
, m_codeBlock(codeBlock)
......@@ -316,7 +317,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Scope
, m_hasCreatedActivation(false)
, m_firstLazyFunction(0)
, m_lastLazyFunction(0)
, m_globalData(&scopeChain.globalObject()->globalData())
, m_globalData(scopeChain->globalData)
, m_lastOpcodeID(op_end)
#ifndef NDEBUG
, m_lastOpcodePosition(0)
......@@ -464,11 +465,11 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Scope
}
}
BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
: m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
, m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
, m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
, m_scopeChain(&scopeChain)
BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
, m_shouldEmitProfileHooks(scopeChain->globalObject->supportsProfiling())
, m_shouldEmitRichSourceInfo(scopeChain->globalObject->supportsRichSourceInfo())
, m_scopeChain(*scopeChain->globalData, scopeChain)
, m_symbolTable(symbolTable)
, m_scopeNode(evalNode)
, m_codeBlock(codeBlock)
......@@ -482,7 +483,7 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const ScopeChain& scope
, m_hasCreatedActivation(true)
, m_firstLazyFunction(0)
, m_lastLazyFunction(0)
, m_globalData(&scopeChain.globalObject()->globalData())
, m_globalData(scopeChain->globalData)
, m_lastOpcodeID(op_end)
#ifndef NDEBUG
, m_lastOpcodePosition(0)
......@@ -907,7 +908,7 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionCall(RegisterID* cond,
emitOpcode(op_jneq_ptr);
instructions().append(cond->index());
instructions().append(m_scopeChain->globalObject()->d()->callFunction.get());
instructions().append(m_scopeChain->globalObject->d()->callFunction.get());
instructions().append(target->bind(begin, instructions().size()));
return target;
}
......@@ -918,7 +919,7 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionApply(RegisterID* cond
emitOpcode(op_jneq_ptr);
instructions().append(cond->index());
instructions().append(m_scopeChain->globalObject()->d()->applyFunction.get());
instructions().append(m_scopeChain->globalObject->d()->applyFunction.get());
instructions().append(target->bind(begin, instructions().size()));
return target;
}
......
......@@ -47,8 +47,7 @@
namespace JSC {
class Identifier;
class ScopeChain;
class ScopeNode;
class ScopeChainNode;
class CallArguments {
public:
......@@ -93,9 +92,9 @@ namespace JSC {
static void setDumpsGeneratedCode(bool dumpsGeneratedCode);
static bool dumpsGeneratedCode();
BytecodeGenerator(ProgramNode*, const ScopeChain&, SymbolTable*, ProgramCodeBlock*);
BytecodeGenerator(FunctionBodyNode*, const ScopeChain&, SymbolTable*, CodeBlock*);
BytecodeGenerator(EvalNode*, const ScopeChain&, SymbolTable*, EvalCodeBlock*);
BytecodeGenerator(ProgramNode*, ScopeChainNode*, SymbolTable*, ProgramCodeBlock*);
BytecodeGenerator(FunctionBodyNode*, ScopeChainNode*, SymbolTable*, CodeBlock*);
BytecodeGenerator(EvalNode*, ScopeChainNode*, SymbolTable*, EvalCodeBlock*);
JSGlobalData* globalData() const { return m_globalData; }
const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; }
......@@ -520,7 +519,7 @@ namespace JSC {
bool m_shouldEmitProfileHooks;
bool m_shouldEmitRichSourceInfo;
const ScopeChain* m_scopeChain;
Global<ScopeChainNode> m_scopeChain;
SymbolTable* m_symbolTable;
ScopeNode* m_scopeNode;
......
......@@ -76,9 +76,9 @@ inline void Recompiler::operator()(JSCell* cell)
if (!m_functionExecutables.add(executable).second)
return;
ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec();
ExecState* exec = function->scope()->globalObject->JSGlobalObject::globalExec();
executable->discardCode();
if (m_debugger == function->scope().globalObject()->debugger())
if (m_debugger == function->scope()->globalObject->debugger())
m_sourceProviders.add(executable->source().provider(), exec);
}
......
......@@ -49,7 +49,7 @@ namespace JSC {
}
JSGlobalObject* dynamicGlobalObject() const { return m_callFrame->dynamicGlobalObject(); }
const ScopeChainNode* scopeChain() const { return m_callFrame->scopeChain(); }
ScopeChainNode* scopeChain() const { return m_callFrame->scopeChain(); }
const UString* functionName() const;
UString calculatedFunctionName() const;
Type type() const;
......
......@@ -38,10 +38,10 @@ namespace JSC {
CachedCall(CallFrame* callFrame, JSFunction* function, int argCount)
: m_valid(false)
, m_interpreter(callFrame->interpreter())
, m_globalObjectScope(callFrame, function->scope().globalObject())
, m_globalObjectScope(callFrame, function->scope()->globalObject.get())
{
ASSERT(!function->isHostFunction());
m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argCount, function->scope().node());
m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argCount, function->scope());
m_valid = !callFrame->hadException();
}
......
......@@ -26,13 +26,13 @@
#include "JSGlobalData.h"
#include "MacroAssemblerCodeRef.h"
#include "RegisterFile.h"
#include "ScopeChain.h"
namespace JSC {
class Arguments;
class JSActivation;
class Interpreter;
class ScopeChainNode;
// Represents the current state of script execution.
// Passed as the first argument to most functions.
......@@ -51,23 +51,13 @@ namespace JSC {
// Global object in which the currently executing code was defined.
// Differs from dynamicGlobalObject() during function calls across web browser frames.
JSGlobalObject* lexicalGlobalObject() const
{
return scopeChain()->globalObject;
}
inline JSGlobalObject* lexicalGlobalObject() const;
// Differs from lexicalGlobalObject because this will have DOM window shell rather than
// the actual DOM window, which can't be "this" for security reasons.
JSObject* globalThisValue() const
{
return scopeChain()->globalThis;
}
inline JSObject* globalThisValue() const;
JSGlobalData& globalData() const
{
ASSERT(scopeChain()->globalData);
return *scopeChain()->globalData;
}
inline JSGlobalData& globalData() const;
// Convenience functions for access to global data.
// It takes a few memory references to get from a call frame to the global data
......
......@@ -76,11 +76,11 @@ using namespace std;
namespace JSC {
// Returns the depth of the scope chain within a given call frame.
static int depth(CodeBlock* codeBlock, ScopeChain& sc)
static int depth(CodeBlock* codeBlock, ScopeChainNode* sc)
{
if (!codeBlock->needsFullScopeChain())
return 0;
return sc.localDepth();
return sc->localDepth();
}
#if ENABLE(INTERPRETER)
......@@ -579,9 +579,6 @@ NEVER_INLINE bool Interpreter::unwindCallFrame(CallFrame*& callFrame, JSValue ex
asArguments(arguments)->copyRegisters();
}
if (oldCodeBlock->needsFullScopeChain())
scopeChain->deref();
CallFrame* callerFrame = callFrame->callerFrame();
if (callerFrame->hasHostCallFrameFlag())
return false;
......@@ -710,11 +707,10 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV
// Unwind the scope chain within the exception handler's call frame.
ScopeChainNode* scopeChain = callFrame->scopeChain();
ScopeChain sc(scopeChain);
int scopeDelta = 0;
if (!codeBlock->needsFullScopeChain() || codeBlock->codeType() != FunctionCode
|| callFrame->uncheckedR(codeBlock->activationRegister()).jsValue())
scopeDelta = depth(codeBlock, sc) - handler->scopeDepth;
scopeDelta = depth(codeBlock, scopeChain) - handler->scopeDepth;
ASSERT(scopeDelta >= 0);
while (scopeDelta--)
scopeChain = scopeChain->pop();
......@@ -761,10 +757,7 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, S
newCallFrame->init(codeBlock, 0, scopeChain, CallFrame::noCaller(), codeBlock->m_numParameters, 0);
newCallFrame->uncheckedR(newCallFrame->hostThisRegister()) = JSValue(thisObj);
if (codeBlock->needsFullScopeChain())
scopeChain->ref();
DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject.get());
Profiler** profiler = Profiler::enabledProfilerReference();
if (*profiler)
......@@ -835,7 +828,7 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT
newCallFrame->init(newCodeBlock, 0, callDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, function);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, callDataScopeChain->globalObject);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, callDataScopeChain->globalObject.get());
Profiler** profiler = Profiler::enabledProfilerReference();
if (*profiler)
......@@ -867,7 +860,7 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT
newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset);
newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, function);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject.get());
Profiler** profiler = Profiler::enabledProfilerReference();
if (*profiler)
......@@ -924,7 +917,7 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc
newCallFrame->init(newCodeBlock, 0, constructDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, constructDataScopeChain->globalObject);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, constructDataScopeChain->globalObject.get());
Profiler** profiler = Profiler::enabledProfilerReference();
if (*profiler)
......@@ -959,7 +952,7 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc
newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset);
newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject);
DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject.get());
Profiler** profiler = Profiler::enabledProfilerReference();
if (*profiler)
......@@ -1076,7 +1069,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec
if (m_reentryDepth >= MaxSmallThreadReentryDepth && m_reentryDepth >= callFrame->globalData().maxReentryDepth)
return checkedReturn(throwStackOverflowError(callFrame));
DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject.get());
JSObject* compileError = eval->compile(callFrame, scopeChain);
if (UNLIKELY(!!compileError))
......@@ -1084,7 +1077,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec
EvalCodeBlock* codeBlock = &eval->generatedBytecode();
JSObject* variableObject;
for (ScopeChainNode* node = scopeChain; ; node = node->next) {
for (ScopeChainNode* node = scopeChain; ; node = node->next.get()) {
ASSERT(node);
if (node->object->isVariableObject()) {
variableObject = static_cast<JSVariableObject*>(node->object.get());
......@@ -1133,9 +1126,6 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec
newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), codeBlock->m_numParameters, 0);
newCallFrame->uncheckedR(newCallFrame->hostThisRegister()) = JSValue(thisObj);
if (codeBlock->needsFullScopeChain())
scopeChain->ref();
Profiler** profiler = Profiler::enabledProfilerReference();
if (*profiler)
(*profiler)->willExecute(callFrame, eval->sourceURL(), eval->lineNo());
......@@ -3805,7 +3795,7 @@ skip_id_custom_self:
*/
if (!function->name().isNull()) {
JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
func->scope().push(functionScopeObject);
func->setScope(*globalData, func->scope()->push(functionScopeObject));
}
callFrame->uncheckedR(dst) = JSValue(func);
......@@ -3835,7 +3825,7 @@ skip_id_custom_self:
Register* newCallFrame = callFrame->registers() + registerOffset;
Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
JSValue thisValue = argv[0].jsValue();
JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject;
JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject.get();
if (thisValue == globalObject && funcVal == globalObject->evalFunction()) {
JSValue result = callEval(callFrame, registerFile, argv, argCount, registerOffset);
......@@ -4150,9 +4140,6 @@ skip_id_custom_self:
int result = vPC[1].u.operand;
if (callFrame->codeBlock()->needsFullScopeChain() && callFrame->r(codeBlock->activationRegister()).jsValue())
callFrame->scopeChain()->deref();
JSValue returnValue = callFrame->r(result).jsValue();
vPC = callFrame->returnVPC();
......@@ -4191,9 +4178,6 @@ skip_id_custom_self:
int result = vPC[1].u.operand;
if (codeBlock->needsFullScopeChain() && callFrame->r(codeBlock->activationRegister()).jsValue())
callFrame->scopeChain()->deref();
JSValue returnValue = callFrame->r(result).jsValue();
if (UNLIKELY(!returnValue.isObject()))
......@@ -4238,7 +4222,7 @@ skip_id_custom_self:
if (!callFrame->r(activationReg).jsValue()) {
JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionExecutable*>(codeBlock->ownerExecutable()));
callFrame->r(activationReg) = JSValue(activation);
callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation));
callFrame->setScopeChain(callFrame->scopeChain()->push(activation));
}
vPC += OPCODE_LENGTH(op_create_activation);
NEXT_INSTRUCTION();
......@@ -4277,7 +4261,7 @@ skip_id_custom_self:
if (proto.isObject())
structure = asObject(proto)->inheritorID();
else
structure = constructor->scope().node()->globalObject->emptyObjectStructure();
structure = constructor->scope()->globalObject->emptyObjectStructure();
callFrame->uncheckedR(thisRegister) = constructEmptyObject(callFrame, structure);
vPC += OPCODE_LENGTH(op_create_this);
......@@ -4643,11 +4627,6 @@ skip_id_custom_self:
program. Return control to the calling native code.
*/
if (codeBlock->needsFullScopeChain()) {
ScopeChainNode* scopeChain = callFrame->scopeChain();
ASSERT(scopeChain->refCount > 1);
scopeChain->deref();
}
int result = vPC[1].u.operand;
return callFrame->r(result).jsValue();
}
......
......@@ -49,7 +49,7 @@ namespace JSC {
void JIT::compileOpCallInitializeCallFrame()
{
store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT3); // newScopeChain