Commit b11e7874 authored by ggaren@apple.com's avatar ggaren@apple.com

Use one object instead of two for closures, eliminating ScopeChainNode

https://bugs.webkit.org/show_bug.cgi?id=95501

Reviewed by Filip Pizlo.

../JavaScriptCore: 

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

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

* runtime/Completion.cpp:
(JSC::evaluate):
* runtime/Completion.h: Don't require an explicit scope chain argument
when evaluating code. Clients never wanted anything other than the
global scope, and other arbitrary scopes probably wouldn't work
correctly, anyway.

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

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

../WebCore: 

Mechanical changes to update for JSC interface changes.

../WebKit/mac: 

Mechanical change to update for JSC interface change.

../WebKit/qt: 

Mechanical change to update for JSC interface change.

* Api/qwebelement.cpp:
(QWebElement::evaluateJavaScript):

../WebKit2: 

Mechanical changes to update for JSC interface change.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127202 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7bc2b442
......@@ -53,7 +53,7 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
JSValue evaluationException;
JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject, &evaluationException);
JSValue returnValue = evaluate(globalObject->globalExec(), source, jsThisObject, &evaluationException);
if (evaluationException) {
if (exception)
......
......@@ -244,7 +244,6 @@ SET(JavaScriptCore_SOURCES
runtime/RegExpMatchesArray.cpp
runtime/RegExpObject.cpp
runtime/RegExpPrototype.cpp
runtime/ScopeChain.cpp
runtime/SmallStrings.cpp
runtime/StrictEvalActivation.cpp
runtime/StringConstructor.cpp
......
2012-08-30 Geoffrey Garen <ggaren@apple.com>
Use one object instead of two for closures, eliminating ScopeChainNode
https://bugs.webkit.org/show_bug.cgi?id=95501
Reviewed by Filip Pizlo.
This patch removes ScopeChainNode, and moves all the data and related
functions that used to be in ScopeChainNode into JSScope.
Most of this patch is mechanical changes to use a JSScope* where we used
to use a ScopeChainNode*. I've only specifically commented about items
that were non-mechanical.
* runtime/Completion.cpp:
(JSC::evaluate):
* runtime/Completion.h: Don't require an explicit scope chain argument
when evaluating code. Clients never wanted anything other than the
global scope, and other arbitrary scopes probably wouldn't work
correctly, anyway.
* runtime/JSScope.cpp:
* runtime/JSScope.h:
(JSC::JSScope::JSScope): JSScope now requires the data we used to pass to
ScopeChainNode, so it can link itself into the scope chain correctly.
* runtime/JSWithScope.h:
(JSC::JSWithScope::create):
(JSC::JSWithScope::JSWithScope): JSWithScope gets an extra constructor
for specifically supplying your own scope chain. The DOM needs this
interface for setting up the scope chain for certain event handlers.
Other clients always just push the JSWithScope to the head of the current
scope chain.
2012-08-30 Mark Lam <mark.lam@apple.com>
Render unto #ifdef's that which belong to them.
......
......@@ -630,9 +630,6 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/RegExpPrototype.h \
Source/JavaScriptCore/runtime/SamplingCounter.cpp \
Source/JavaScriptCore/runtime/SamplingCounter.h \
Source/JavaScriptCore/runtime/ScopeChain.cpp \
Source/JavaScriptCore/runtime/ScopeChain.h \
Source/JavaScriptCore/runtime/ScopeChainMark.h \
Source/JavaScriptCore/runtime/SmallStrings.cpp \
Source/JavaScriptCore/runtime/SmallStrings.h \
Source/JavaScriptCore/runtime/StorageBarrier.h \
......
......@@ -166,7 +166,7 @@ EXPORTS
?enumerable@PropertyDescriptor@JSC@@QBE_NXZ
?equalUTF16WithUTF8@Unicode@WTF@@YA_NPB_W0PBD1@Z
?evaluate@DebuggerCallFrame@JSC@@QBE?AVJSValue@2@ABVString@WTF@@AAV32@@Z
?evaluate@JSC@@YA?AVJSValue@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@V21@PAV21@@Z
?evaluate@JSC@@YA?AVJSValue@1@PAVExecState@1@PAVJSScope@1@ABVSourceCode@1@V21@PAV21@@Z
?exclude@Profile@JSC@@QAEXPBVProfileNode@2@@Z
?execute@ParallelEnvironment@WTF@@QAEXPAX@Z
?expand@MarkStackArray@JSC@@AAEXXZ
......@@ -263,7 +263,7 @@ EXPORTS
?numberToStringImpl@WTF@@YA?AV?$PassRefPtr@VStringImpl@WTF@@@1@I@Z
?numberToStringImpl@WTF@@YA?AV?$PassRefPtr@VStringImpl@WTF@@@1@J@Z
?numberToStringImpl@WTF@@YA?AV?$PassRefPtr@VStringImpl@WTF@@@1@K@Z
?objectAtScope@JSScope@JSC@@SAPAVJSObject@2@PAVScopeChainNode@2@@Z
?objectAtScope@JSScope@JSC@@SAPAVJSObject@2@PAVJSScope@2@@Z
?objectCount@Heap@JSC@@QAEIXZ
?objectProtoFuncToString@JSC@@YI_JPAVExecState@1@@Z
?objectTypeCounts@Heap@JSC@@QAE?AV?$PassOwnPtr@V?$HashCountedSet@PBDU?$PtrHash@PBD@WTF@@U?$HashTraits@PBD@2@@WTF@@@WTF@@XZ
......
......@@ -1193,18 +1193,6 @@
RelativePath="..\..\runtime\SamplingCounter.h"
>
</File>
<File
RelativePath="..\..\runtime\ScopeChain.cpp"
>
</File>
<File
RelativePath="..\..\runtime\ScopeChain.h"
>
</File>
<File
RelativePath="..\..\runtime\ScopeChainMark.h"
>
</File>
<File
RelativePath="..\..\runtime\SmallStrings.cpp"
>
......
......@@ -326,7 +326,6 @@
14469DE6107EC7E700650446 /* ObjectPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2680C80E16D4E900A06E92 /* ObjectPrototype.cpp */; };
14469DE7107EC7E700650446 /* PropertyNameArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */; };
14469DE8107EC7E700650446 /* PropertySlot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* PropertySlot.cpp */; };
14469DEA107EC7E700650446 /* ScopeChain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9374D3A8038D9D74008635CE /* ScopeChain.cpp */; };
14469DEB107EC7E700650446 /* StringConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC18C3C00E16EE3300B34460 /* StringConstructor.cpp */; };
14469DEC107EC7E700650446 /* StringObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC18C3C20E16EE3300B34460 /* StringObject.cpp */; };
14469DED107EC7E700650446 /* StringPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC18C3C50E16EE3300B34460 /* StringPrototype.cpp */; };
......@@ -654,7 +653,6 @@
BC18C45B0E16F5CD00B34460 /* RegExpObject.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A87C0255597D01FF60F7 /* RegExpObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC18C45D0E16F5CD00B34460 /* Register.h in Headers */ = {isa = PBXBuildFile; fileRef = 149B24FF0D8AF6D1009CB8C7 /* Register.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC18C45E0E16F5CD00B34460 /* RegisterFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D792640DAA03FB001A9F05 /* RegisterFile.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC18C4610E16F5CD00B34460 /* ScopeChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 9374D3A7038D9D74008635CE /* ScopeChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC18C4630E16F5CD00B34460 /* SourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E866ED0DD59AFA00A2B2A1 /* SourceProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC18C4640E16F5CD00B34460 /* SourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 65E866EE0DD59AFA00A2B2A1 /* SourceCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC18C3C10E16EE3300B34460 /* StringConstructor.h */; };
......@@ -1165,7 +1163,6 @@
65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CommonIdentifiers.cpp; sourceTree = "<group>"; };
65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CommonIdentifiers.h; sourceTree = "<group>"; };
704FD35305697E6D003DBED9 /* BooleanObject.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = BooleanObject.h; sourceTree = "<group>"; tabWidth = 8; };
7E2C6C980D31C6B6002D44E2 /* ScopeChainMark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopeChainMark.h; sourceTree = "<group>"; };
7E4EE7080EBB7963005934AA /* StructureChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureChain.h; sourceTree = "<group>"; };
7E4EE70E0EBB7A5B005934AA /* StructureChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StructureChain.cpp; sourceTree = "<group>"; };
7EFF00630EC05A9A00AA7C93 /* NodeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeInfo.h; sourceTree = "<group>"; };
......@@ -1278,8 +1275,6 @@
93345A8812D838C400302BE3 /* StringRecursionChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringRecursionChecker.h; sourceTree = "<group>"; };
933A349A038AE7C6008635CE /* Identifier.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Identifier.h; sourceTree = "<group>"; tabWidth = 8; };
933A349D038AE80F008635CE /* Identifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Identifier.cpp; sourceTree = "<group>"; tabWidth = 8; };
9374D3A7038D9D74008635CE /* ScopeChain.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ScopeChain.h; sourceTree = "<group>"; tabWidth = 8; };
9374D3A8038D9D74008635CE /* ScopeChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopeChain.cpp; sourceTree = "<group>"; tabWidth = 8; };
937B63CC09E766D200A671DD /* DerivedSources.make */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = DerivedSources.make; sourceTree = "<group>"; usesTabs = 1; };
938772E5038BFE19008635CE /* JSArray.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = JSArray.h; sourceTree = "<group>"; tabWidth = 8; };
93ADFCE60CCBD7AC00D30B08 /* JSArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArray.cpp; sourceTree = "<group>"; };
......@@ -2199,9 +2194,6 @@
BCD202C00E1706A7002C7E82 /* RegExpPrototype.h */,
0F7700911402FF280078EB39 /* SamplingCounter.cpp */,
0F77008E1402FDD60078EB39 /* SamplingCounter.h */,
9374D3A8038D9D74008635CE /* ScopeChain.cpp */,
9374D3A7038D9D74008635CE /* ScopeChain.h */,
7E2C6C980D31C6B6002D44E2 /* ScopeChainMark.h */,
93303FE80E6A72B500786E6A /* SmallStrings.cpp */,
93303FEA0E6A72C000786E6A /* SmallStrings.h */,
A781E358141970C700094D90 /* StorageBarrier.h */,
......@@ -2745,7 +2737,6 @@
869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */,
C22B31B9140577D700DB475A /* SamplingCounter.h in Headers */,
1429D8860ED21C3D00B89619 /* SamplingTool.h in Headers */,
BC18C4610E16F5CD00B34460 /* ScopeChain.h in Headers */,
86AE64AA135E5E1C00963012 /* SH4Assembler.h in Headers */,
14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */,
933040040E6A749400786E6A /* SmallStrings.h in Headers */,
......@@ -3407,7 +3398,6 @@
1428083A107EC0750013E7B2 /* RegisterFile.cpp in Sources */,
0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */,
1429D8850ED21C3D00B89619 /* SamplingTool.cpp in Sources */,
14469DEA107EC7E700650446 /* ScopeChain.cpp in Sources */,
9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */,
E49DC16B12EF293E00184A1F /* SourceProviderCache.cpp in Sources */,
A730B6131250068F009D25B1 /* StrictEvalActivation.cpp in Sources */,
......
......@@ -244,7 +244,6 @@ SOURCES += \
runtime/RegExpPrototype.cpp \
runtime/RegExpCache.cpp \
runtime/SamplingCounter.cpp \
runtime/ScopeChain.cpp \
runtime/SmallStrings.cpp \
runtime/StrictEvalActivation.cpp \
runtime/StringConstructor.cpp \
......
......@@ -2529,7 +2529,7 @@ void CodeBlock::createActivation(CallFrame* callFrame)
ASSERT(!callFrame->uncheckedR(activationRegister()).jsValue());
JSActivation* activation = JSActivation::create(callFrame->globalData(), callFrame, static_cast<FunctionExecutable*>(ownerExecutable()));
callFrame->uncheckedR(activationRegister()) = JSValue(activation);
callFrame->setScopeChain(callFrame->scopeChain()->push(activation));
callFrame->setScope(activation);
}
unsigned CodeBlock::addOrFindConstant(JSValue v)
......@@ -2725,27 +2725,27 @@ CodeBlock* FunctionCodeBlock::replacement()
return &static_cast<FunctionExecutable*>(ownerExecutable())->generatedBytecodeFor(m_isConstructor ? CodeForConstruct : CodeForCall);
}
JSObject* ProgramCodeBlock::compileOptimized(ExecState* exec, ScopeChainNode* scopeChainNode, unsigned bytecodeIndex)
JSObject* ProgramCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, unsigned bytecodeIndex)
{
if (replacement()->getJITType() == JITCode::nextTierJIT(getJITType()))
return 0;
JSObject* error = static_cast<ProgramExecutable*>(ownerExecutable())->compileOptimized(exec, scopeChainNode, bytecodeIndex);
JSObject* error = static_cast<ProgramExecutable*>(ownerExecutable())->compileOptimized(exec, scope, bytecodeIndex);
return error;
}
JSObject* EvalCodeBlock::compileOptimized(ExecState* exec, ScopeChainNode* scopeChainNode, unsigned bytecodeIndex)
JSObject* EvalCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, unsigned bytecodeIndex)
{
if (replacement()->getJITType() == JITCode::nextTierJIT(getJITType()))
return 0;
JSObject* error = static_cast<EvalExecutable*>(ownerExecutable())->compileOptimized(exec, scopeChainNode, bytecodeIndex);
JSObject* error = static_cast<EvalExecutable*>(ownerExecutable())->compileOptimized(exec, scope, bytecodeIndex);
return error;
}
JSObject* FunctionCodeBlock::compileOptimized(ExecState* exec, ScopeChainNode* scopeChainNode, unsigned bytecodeIndex)
JSObject* FunctionCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, unsigned bytecodeIndex)
{
if (replacement()->getJITType() == JITCode::nextTierJIT(getJITType()))
return 0;
JSObject* error = static_cast<FunctionExecutable*>(ownerExecutable())->compileOptimizedFor(exec, scopeChainNode, bytecodeIndex, m_isConstructor ? CodeForConstruct : CodeForCall);
JSObject* error = static_cast<FunctionExecutable*>(ownerExecutable())->compileOptimizedFor(exec, scope, bytecodeIndex, m_isConstructor ? CodeForConstruct : CodeForCall);
return error;
}
......
......@@ -448,7 +448,7 @@ namespace JSC {
MacroAssemblerCodePtr getJITCodeWithArityCheck() { return m_jitCodeWithArityCheck; }
JITCode::JITType getJITType() { return m_jitCode.jitType(); }
ExecutableMemoryHandle* executableMemory() { return getJITCode().getExecutableMemory(); }
virtual JSObject* compileOptimized(ExecState*, ScopeChainNode*, unsigned bytecodeIndex) = 0;
virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex) = 0;
virtual void jettison() = 0;
enum JITCompilationResult { AlreadyCompiled, CouldNotCompile, CompiledSuccessfully };
JITCompilationResult jitCompile(ExecState* exec)
......@@ -934,7 +934,7 @@ namespace JSC {
if (!codeOrigin.inlineCallFrame)
return globalObject();
// FIXME: if we ever inline based on executable not function, this code will need to change.
return codeOrigin.inlineCallFrame->callee->scope()->globalObject.get();
return codeOrigin.inlineCallFrame->callee->scope()->globalObject();
}
// Jump Tables
......@@ -1449,7 +1449,7 @@ namespace JSC {
#if ENABLE(JIT)
protected:
virtual JSObject* compileOptimized(ExecState*, ScopeChainNode*, unsigned bytecodeIndex);
virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex);
virtual void jettison();
virtual bool jitCompileImpl(ExecState*);
virtual CodeBlock* replacement();
......@@ -1484,7 +1484,7 @@ namespace JSC {
#if ENABLE(JIT)
protected:
virtual JSObject* compileOptimized(ExecState*, ScopeChainNode*, unsigned bytecodeIndex);
virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex);
virtual void jettison();
virtual bool jitCompileImpl(ExecState*);
virtual CodeBlock* replacement();
......@@ -1510,7 +1510,7 @@ namespace JSC {
#if ENABLE(JIT)
protected:
virtual JSObject* compileOptimized(ExecState*, ScopeChainNode*, unsigned bytecodeIndex);
virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex);
virtual void jettison();
virtual bool jitCompileImpl(ExecState*);
virtual CodeBlock* replacement();
......
......@@ -44,32 +44,32 @@ namespace JSC {
class EvalCodeCache {
public:
EvalExecutable* tryGet(bool inStrictContext, const String& evalSource, ScopeChainNode* scopeChain)
EvalExecutable* tryGet(bool inStrictContext, const String& evalSource, JSScope* scope)
{
if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && scopeChain->begin()->isVariableObject())
if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && scope->begin()->isVariableObject())
return m_cacheMap.get(evalSource.impl()).get();
return 0;
}
EvalExecutable* getSlow(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const String& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue)
EvalExecutable* getSlow(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const String& evalSource, JSScope* scope, JSValue& exceptionValue)
{
EvalExecutable* evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext);
exceptionValue = evalExecutable->compile(exec, scopeChain);
exceptionValue = evalExecutable->compile(exec, scope);
if (exceptionValue)
return 0;
if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && scopeChain->begin()->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
if (!inStrictContext && evalSource.length() < maxCacheableSourceLength && scope->begin()->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
m_cacheMap.set(evalSource.impl(), WriteBarrier<EvalExecutable>(exec->globalData(), owner, evalExecutable));
return evalExecutable;
}
EvalExecutable* get(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const String& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue)
EvalExecutable* get(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, const String& evalSource, JSScope* scope, JSValue& exceptionValue)
{
EvalExecutable* evalExecutable = tryGet(inStrictContext, evalSource, scopeChain);
EvalExecutable* evalExecutable = tryGet(inStrictContext, evalSource, scope);
if (!evalExecutable)
evalExecutable = getSlow(exec, owner, inStrictContext, evalSource, scopeChain, exceptionValue);
evalExecutable = getSlow(exec, owner, inStrictContext, evalSource, scope, exceptionValue);
return evalExecutable;
}
......
......@@ -28,7 +28,7 @@
#include "CallFrame.h"
#include "JSObject.h"
#include "ScopeChain.h"
#include <wtf/Vector.h>
namespace JSC {
......
......@@ -28,7 +28,7 @@
#include "JSObject.h"
#include "PolymorphicPutByIdList.h"
#include "ScopeChain.h"
namespace JSC {
......
......@@ -37,7 +37,7 @@
#include "JSFunction.h"
#include "Interpreter.h"
#include "LowLevelInterpreter.h"
#include "ScopeChain.h"
#include "StrongInlines.h"
#include <wtf/text/WTFString.h>
......@@ -209,7 +209,7 @@ JSObject* BytecodeGenerator::generate()
m_codeBlock->instructions() = RefCountedArray<Instruction>(m_instructions);
if (s_dumpsGeneratedCode)
m_codeBlock->dump(m_scopeChain->globalObject->globalExec());
m_codeBlock->dump(m_scope->globalObject()->globalExec());
#ifdef NDEBUG
if ((m_codeType == FunctionCode && !m_codeBlock->needsFullScopeChain() && !m_codeBlock->usesArguments()) || m_codeType == EvalCode)
......@@ -219,7 +219,7 @@ JSObject* BytecodeGenerator::generate()
m_codeBlock->shrinkToFit(CodeBlock::EarlyShrink);
if (m_expressionTooDeep)
return createOutOfMemoryError(m_scopeChain->globalObject.get());
return createOutOfMemoryError(m_scope->globalObject());
return 0;
}
......@@ -260,11 +260,11 @@ void BytecodeGenerator::preserveLastVar()
m_lastVar = &m_calleeRegisters.last();
}
BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock, CompilationKind compilationKind)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
, m_shouldEmitProfileHooks(scopeChain->globalObject->globalObjectMethodTable()->supportsProfiling(scopeChain->globalObject.get()))
, m_shouldEmitRichSourceInfo(scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()))
, m_scopeChain(*scopeChain->globalData, scopeChain)
BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, JSScope* scope, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock, CompilationKind compilationKind)
: m_shouldEmitDebugHooks(scope->globalObject()->debugger())
, m_shouldEmitProfileHooks(scope->globalObject()->globalObjectMethodTable()->supportsProfiling(scope->globalObject()))
, m_shouldEmitRichSourceInfo(scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject()))
, m_scope(*scope->globalData(), scope)
, m_symbolTable(symbolTable)
#if ENABLE(BYTECODE_COMMENTS)
, m_currentCommentString(0)
......@@ -281,7 +281,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* s
, m_hasCreatedActivation(true)
, m_firstLazyFunction(0)
, m_lastLazyFunction(0)
, m_globalData(scopeChain->globalData)
, m_globalData(scope->globalData())
, m_lastOpcodeID(op_end)
#ifndef NDEBUG
, m_lastOpcodePosition(0)
......@@ -306,7 +306,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* s
if (compilationKind == OptimizingCompilation)
return;
JSGlobalObject* globalObject = scopeChain->globalObject.get();
JSGlobalObject* globalObject = scope->globalObject();
ExecState* exec = globalObject->globalExec();
BatchedTransitionOptimizer optimizer(*m_globalData, globalObject);
......@@ -324,7 +324,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* s
bool propertyDidExist =
globalObject->removeDirect(*m_globalData, function->ident()); // Newly declared functions overwrite existing properties.
JSValue value = JSFunction::create(exec, makeFunction(exec, function), scopeChain);
JSValue value = JSFunction::create(exec, makeFunction(exec, function), scope);
int index = addGlobalVar(
function->ident(), IsVariable,
!propertyDidExist ? IsFunctionToSpecialize : NotFunctionOrNotSpecializable);
......@@ -341,11 +341,11 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, ScopeChainNode* s
}
}
BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, ScopeChainNode* scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock, CompilationKind)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
, m_shouldEmitProfileHooks(scopeChain->globalObject->globalObjectMethodTable()->supportsProfiling(scopeChain->globalObject.get()))
, m_shouldEmitRichSourceInfo(scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()))
, m_scopeChain(*scopeChain->globalData, scopeChain)
BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, JSScope* scope, SymbolTable* symbolTable, CodeBlock* codeBlock, CompilationKind)
: m_shouldEmitDebugHooks(scope->globalObject()->debugger())
, m_shouldEmitProfileHooks(scope->globalObject()->globalObjectMethodTable()->supportsProfiling(scope->globalObject()))
, m_shouldEmitRichSourceInfo(scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject()))
, m_scope(*scope->globalData(), scope)
, m_symbolTable(symbolTable)
#if ENABLE(BYTECODE_COMMENTS)
, m_currentCommentString(0)
......@@ -362,7 +362,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, ScopeChainN
, m_hasCreatedActivation(false)
, m_firstLazyFunction(0)
, m_lastLazyFunction(0)
, m_globalData(scopeChain->globalData)
, m_globalData(scope->globalData())
, m_lastOpcodeID(op_end)
#ifndef NDEBUG
, m_lastOpcodePosition(0)
......@@ -508,11 +508,11 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, ScopeChainN
}
}
BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, ScopeChainNode* scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock, CompilationKind)
: m_shouldEmitDebugHooks(scopeChain->globalObject->debugger())
, m_shouldEmitProfileHooks(scopeChain->globalObject->globalObjectMethodTable()->supportsProfiling(scopeChain->globalObject.get()))
, m_shouldEmitRichSourceInfo(scopeChain->globalObject->globalObjectMethodTable()->supportsRichSourceInfo(scopeChain->globalObject.get()))
, m_scopeChain(*scopeChain->globalData, scopeChain)
BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, JSScope* scope, SymbolTable* symbolTable, EvalCodeBlock* codeBlock, CompilationKind)
: m_shouldEmitDebugHooks(scope->globalObject()->debugger())
, m_shouldEmitProfileHooks(scope->globalObject()->globalObjectMethodTable()->supportsProfiling(scope->globalObject()))
, m_shouldEmitRichSourceInfo(scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject()))
, m_scope(*scope->globalData(), scope)
, m_symbolTable(symbolTable)
#if ENABLE(BYTECODE_COMMENTS)
, m_currentCommentString(0)
......@@ -529,7 +529,7 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, ScopeChainNode* scopeCh
, m_hasCreatedActivation(true)
, m_firstLazyFunction(0)
, m_lastLazyFunction(0)
, m_globalData(scopeChain->globalData)
, m_globalData(scope->globalData())
, m_lastOpcodeID(op_end)
#ifndef NDEBUG
, m_lastOpcodePosition(0)
......@@ -1040,7 +1040,7 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionCall(RegisterID* cond,
emitOpcode(op_jneq_ptr);
instructions().append(cond->index());
instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scopeChain->globalObject->callFunction()));
instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scope->globalObject()->callFunction()));
instructions().append(target->bind(begin, instructions().size()));
return target;
}
......@@ -1051,7 +1051,7 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionApply(RegisterID* cond
emitOpcode(op_jneq_ptr);
instructions().append(cond->index());
instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scopeChain->globalObject->applyFunction()));
instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scope->globalObject()->applyFunction()));
instructions().append(target->bind(begin, instructions().size()));
return target;
}
......@@ -1266,8 +1266,8 @@ ResolveResult BytecodeGenerator::resolve(const Identifier& property)
if (property == propertyNames().arguments || !canOptimizeNonLocals())
return ResolveResult::dynamicResolve(0);
ScopeChainIterator iter = m_scopeChain->begin();
ScopeChainIterator end = m_scopeChain->end();
ScopeChainIterator iter = m_scope->begin();
ScopeChainIterator end = m_scope->end();
size_t depth = 0;
size_t depthOfFirstScopeWithDynamicChecks = 0;
unsigned flags = 0;
......@@ -1337,8 +1337,8 @@ ResolveResult BytecodeGenerator::resolveConstDecl(const Identifier& property)
}
// Const declarations in eval code or global code.
ScopeChainIterator iter = scopeChain()->begin();
ScopeChainIterator end = scopeChain()->end();
ScopeChainIterator iter = scope()->begin();
ScopeChainIterator end = scope()->end();
size_t depth = 0;
for (; iter != end; ++iter, ++depth) {
JSObject* currentScope = iter.get();
......
......@@ -49,7 +49,7 @@ namespace JSC {
class Identifier;
class Label;
class ScopeChainNode;
class JSScope;
class CallArguments {
public:
......@@ -261,9 +261,9 @@ namespace JSC {
JS_EXPORT_PRIVATE static void setDumpsGeneratedCode(bool dumpsGeneratedCode);
static bool dumpsGeneratedCode();
BytecodeGenerator(ProgramNode*, ScopeChainNode*, SymbolTable*, ProgramCodeBlock*, CompilationKind);
BytecodeGenerator(FunctionBodyNode*, ScopeChainNode*, SymbolTable*, CodeBlock*, CompilationKind);
BytecodeGenerator(EvalNode*, ScopeChainNode*, SymbolTable*, EvalCodeBlock*, CompilationKind);
BytecodeGenerator(ProgramNode*, JSScope*, SymbolTable*, ProgramCodeBlock*, CompilationKind);
BytecodeGenerator(FunctionBodyNode*, JSScope*, SymbolTable*, CodeBlock*, CompilationKind);
BytecodeGenerator(EvalNode*, JSScope*, SymbolTable*, EvalCodeBlock*, CompilationKind);
~BytecodeGenerator();
......@@ -558,7 +558,7 @@ namespace JSC {
bool isStrictMode() const { return m_codeBlock->isStrictMode(); }
ScopeChainNode* scopeChain() const { return m_scopeChain.get(); }
JSScope* scope() const { return m_scope.get(); }
private:
friend class Label;
......@@ -700,7 +700,7 @@ namespace JSC {
bool m_shouldEmitProfileHooks;
bool m_shouldEmitRichSourceInfo;
Strong<ScopeChainNode> m_scopeChain;
Strong<JSScope> m_scope;
SymbolTable* m_symbolTable;
#if ENABLE(BYTECODE_COMMENTS)
......
......@@ -78,9 +78,9 @@ inline void Recompiler::operator()(JSCell* cell)
if (!m_functionExecutables.add(executable).isNewEntry)
return;
ExecState* exec = function->scope()->globalObject->JSGlobalObject::globalExec();
ExecState* exec = function->scope()->globalObject()->JSGlobalObject::globalExec();
executable->clearCodeIfNotCompiling();
if (m_debugger == function->scope()->globalObject->debugger())
if (m_debugger == function->scope()->globalObject()->debugger())
m_sourceProviders.add(executable->source().provider(), exec);
}
......@@ -133,7 +133,7 @@ JSValue evaluateInGlobalCallFrame(const String& script, JSValue& exception, JSGl
return exception;
}
JSValue result = globalData.interpreter->execute(eval, globalCallFrame, globalObject, globalCallFrame->scopeChain());
JSValue result = globalData.interpreter->execute(eval, globalCallFrame, globalObject, globalCallFrame->scope());
if (globalData.exception) {
exception = globalData.exception;
globalData.exception = JSValue();
......
......@@ -96,7 +96,7 @@ JSValue DebuggerCallFrame::evaluate(const String& script, JSValue& exception) co
globalData.exception = JSValue();
}
JSValue result = globalData.interpreter->execute(eval, m_callFrame, thisObject(), m_callFrame->scopeChain());
JSValue result = globalData.interpreter->execute(eval, m_callFrame, thisObject(), m_callFrame->scope());
if (globalData.exception) {
exception = globalData.exception;
globalData.exception = JSValue();
......
......@@ -50,7 +50,7 @@ namespace JSC {
CallFrame* callFrame() const { return m_callFrame; }
JSGlobalObject* dynamicGlobalObject() const { return m_callFrame->dynamicGlobalObject(); }
ScopeChainNode* scopeChain() const { return m_callFrame->scopeChain(); }
JSScope* scope() const { return m_callFrame->scope(); }
JS_EXPORT_PRIVATE const String* functionName() const;
JS_EXPORT_PRIVATE String calculatedFunctionName() const;
JS_EXPORT_PRIVATE Type type() const;
......
......@@ -141,7 +141,7 @@ public:
}
}
CodeBlock* get(const CodeBlockKey& key, ScopeChainNode* scope)
CodeBlock* get(const CodeBlockKey& key, JSScope* scope)
{
Map::iterator iter = m_map.find(key);
if (iter != m_map.end())
......
......@@ -28,7 +28,7 @@
#include "JSObject.h"
#include "JSString.h"
#include "ScopeChain.h"
#if ENABLE(DFG_JIT)
......
......@@ -901,7 +901,7 @@ static void* handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializ
ExecState* exec = execCallee->callerFrame();
JSGlobalData* globalData = &exec->globalData();
execCallee->setScopeChain(exec->scopeChain());
execCallee->setScope(exec->scope());
execCallee->setCodeBlock(0);
if (kind == CodeForCall) {
......@@ -959,7 +959,7 @@ inline char* linkFor(ExecState* execCallee, CodeSpecializationKind kind)
return reinterpret_cast<char*>(handleHostCall(execCallee, calleeAsValue, kind));
JSFunction* callee = jsCast<JSFunction*>(calleeAsFunctionCell);
execCallee->setScopeChain(callee->scopeUnchecked());
execCallee->setScope(callee->scopeUnchecked());
ExecutableBase* executable = callee->executable();
MacroAssemblerCodePtr codePtr;
......@@ -1009,7 +1009,7 @@ inline char* virtualFor(ExecState* execCallee, CodeSpecializationKind kind)
return reinterpret_cast<char*>(handleHostCall(execCallee, calleeAsValue, kind