Commit 0b44fca6 authored by ggaren@apple.com's avatar ggaren@apple.com

Shrink activation objects by half

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

Reviewed by Sam Weinig.

Removed the global object, global data, and global this pointers from
JSScope, and changed an int to a bitfield. This gets the JSActivation
class down to 64 bytes, which in practice cuts it in half by getting it
out of the 128 byte size class.

Now, it's one extra indirection to get these pointers. These pointers
aren't accessed by JIT code, so I thought there would be no cost to the
extra indirection. However, some C++-heavy SunSpider tests regressed a
bit in an early version of the patch, which added even more indirection.
This suggests that calls to exec->globalData() and/or exec->lexicalGlobalObject()
are common and probably duplicated in lots of places, and could stand
further optimization in C++.

* dfg/DFGAbstractState.cpp:
(JSC::DFG::AbstractState::execute): Test against the specific activation
for our global object, since there's no VM-shared activation structure
anymore. This is guaranteed to have the same success rate as the old test
because activation scope is fixed at compile time.

* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::MarkedBlock):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::globalData):
* heap/WeakSet.cpp:
(JSC::WeakSet::addAllocator):
* heap/WeakSet.h:
(WeakSet):
(JSC::WeakSet::WeakSet):
(JSC::WeakSet::globalData): Store a JSGlobalData* instead of a Heap*
because JSGlobalData->Heap is just a constant fold in the addressing
mode, while Heap->JSGlobalData is an extra pointer dereference. (These
objects should eventually just merge.)

* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_resolve_global_dynamic): See DFGAbstractState.cpp.

* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm: Load the activation structure from
the code block instead of the global data because the structure is not
VM-shared anymore. (See DFGAbstractState.cpp.)

* runtime/JSActivation.cpp:
(JSC::JSActivation::JSActivation):
* runtime/JSActivation.h:
(JSActivation): This is the point of the patch: Remove the data.

* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSGlobalData.h:
(JSGlobalData): No longer VM-shared. (See DFGAbstractState.cpp.)

(JSC::WeakSet::heap): (See WeakSet.h.)

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::JSGlobalObject):
(JSC::JSGlobalObject::setGlobalThis):
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSGlobalObject):
(JSC::JSGlobalObject::withScopeStructure):
(JSC::JSGlobalObject::strictEvalActivationStructure):
(JSC::JSGlobalObject::activationStructure):
(JSC::JSGlobalObject::nameScopeStructure):
(JSC::JSScope::globalThis):
(JSC::JSGlobalObject::globalThis): Data that used to be in the JSScope
class goes here now, so it's not duplicated across all activations.

* runtime/JSNameScope.h:
(JSC::JSNameScope::JSNameScope):
* runtime/JSScope.cpp:
(JSC::JSScope::visitChildren): This is the point of the patch: Remove the data.

* runtime/JSScope.h:
(JSScope):
(JSC::JSScope::JSScope):
(JSC::JSScope::globalObject):
(JSC::JSScope::globalData):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::JSSegmentedVariableObject):
* runtime/JSSymbolTableObject.h:
(JSC::JSSymbolTableObject::JSSymbolTableObject):
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::JSVariableObject):
* runtime/JSWithScope.h:
(JSC::JSWithScope::JSWithScope):
* runtime/StrictEvalActivation.cpp:
(JSC::StrictEvalActivation::StrictEvalActivation): Simplified now that
we don't need to pass so much data to JSScope.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127293 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c77901c5
2012-08-31 Geoffrey Garen <ggaren@apple.com>
Shrink activation objects by half
https://bugs.webkit.org/show_bug.cgi?id=95591
Reviewed by Sam Weinig.
Removed the global object, global data, and global this pointers from
JSScope, and changed an int to a bitfield. This gets the JSActivation
class down to 64 bytes, which in practice cuts it in half by getting it
out of the 128 byte size class.
Now, it's one extra indirection to get these pointers. These pointers
aren't accessed by JIT code, so I thought there would be no cost to the
extra indirection. However, some C++-heavy SunSpider tests regressed a
bit in an early version of the patch, which added even more indirection.
This suggests that calls to exec->globalData() and/or exec->lexicalGlobalObject()
are common and probably duplicated in lots of places, and could stand
further optimization in C++.
* dfg/DFGAbstractState.cpp:
(JSC::DFG::AbstractState::execute): Test against the specific activation
for our global object, since there's no VM-shared activation structure
anymore. This is guaranteed to have the same success rate as the old test
because activation scope is fixed at compile time.
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::MarkedBlock):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::globalData):
* heap/WeakSet.cpp:
(JSC::WeakSet::addAllocator):
* heap/WeakSet.h:
(WeakSet):
(JSC::WeakSet::WeakSet):
(JSC::WeakSet::globalData): Store a JSGlobalData* instead of a Heap*
because JSGlobalData->Heap is just a constant fold in the addressing
mode, while Heap->JSGlobalData is an extra pointer dereference. (These
objects should eventually just merge.)
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_resolve_global_dynamic): See DFGAbstractState.cpp.
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm: Load the activation structure from
the code block instead of the global data because the structure is not
VM-shared anymore. (See DFGAbstractState.cpp.)
* runtime/JSActivation.cpp:
(JSC::JSActivation::JSActivation):
* runtime/JSActivation.h:
(JSActivation): This is the point of the patch: Remove the data.
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSGlobalData.h:
(JSGlobalData): No longer VM-shared. (See DFGAbstractState.cpp.)
(JSC::WeakSet::heap): (See WeakSet.h.)
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::JSGlobalObject):
(JSC::JSGlobalObject::setGlobalThis):
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSGlobalObject):
(JSC::JSGlobalObject::withScopeStructure):
(JSC::JSGlobalObject::strictEvalActivationStructure):
(JSC::JSGlobalObject::activationStructure):
(JSC::JSGlobalObject::nameScopeStructure):
(JSC::JSScope::globalThis):
(JSC::JSGlobalObject::globalThis): Data that used to be in the JSScope
class goes here now, so it's not duplicated across all activations.
* runtime/JSNameScope.h:
(JSC::JSNameScope::JSNameScope):
* runtime/JSScope.cpp:
(JSC::JSScope::visitChildren): This is the point of the patch: Remove the data.
* runtime/JSScope.h:
(JSScope):
(JSC::JSScope::JSScope):
(JSC::JSScope::globalObject):
(JSC::JSScope::globalData):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::JSSegmentedVariableObject):
* runtime/JSSymbolTableObject.h:
(JSC::JSSymbolTableObject::JSSymbolTableObject):
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::JSVariableObject):
* runtime/JSWithScope.h:
(JSC::JSWithScope::JSWithScope):
* runtime/StrictEvalActivation.cpp:
(JSC::StrictEvalActivation::StrictEvalActivation): Simplified now that
we don't need to pass so much data to JSScope.
2012-08-31 Patrick Gansterer <paroga@webkit.org>
Build fix for WinCE after r127191.
......
......@@ -1171,7 +1171,7 @@ bool AbstractState::execute(unsigned indexInBlock)
case CreateActivation:
node.setCanExit(false);
forNode(nodeIndex).set(m_graph.m_globalData.activationStructure.get());
forNode(nodeIndex).set(m_codeBlock->globalObjectFor(node.codeOrigin)->activationStructure());
m_haveStructures = true;
break;
......
......@@ -45,7 +45,7 @@ MarkedBlock::MarkedBlock(const PageAllocationAligned& allocation, Heap* heap, si
, m_cellsNeedDestruction(cellsNeedDestruction)
, m_onlyContainsStructures(onlyContainsStructures)
, m_state(New) // All cells start out unmarked.
, m_weakSet(heap)
, m_weakSet(heap->globalData())
{
ASSERT(heap);
HEAP_LOG_BLOCK_STATE_TRANSITION(this);
......
......@@ -121,6 +121,7 @@ namespace JSC {
void lastChanceToFinalize();
Heap* heap() const;
JSGlobalData* globalData() const;
WeakSet& weakSet();
enum SweepMode { SweepOnly, SweepToFreeList };
......@@ -262,6 +263,11 @@ namespace JSC {
return m_weakSet.heap();
}
inline JSGlobalData* MarkedBlock::globalData() const
{
return m_weakSet.globalData();
}
inline WeakSet& MarkedBlock::weakSet()
{
return m_weakSet;
......
......@@ -27,6 +27,7 @@
#include "WeakSet.h"
#include "Heap.h"
#include "JSGlobalData.h"
namespace JSC {
......@@ -73,7 +74,7 @@ WeakBlock::FreeCell* WeakSet::tryFindAllocator()
WeakBlock::FreeCell* WeakSet::addAllocator()
{
WeakBlock* block = WeakBlock::create();
m_heap->didAllocate(WeakBlock::blockSize);
heap()->didAllocate(WeakBlock::blockSize);
m_blocks.append(block);
WeakBlock::SweepResult sweepResult = block->takeSweepResult();
ASSERT(!sweepResult.isNull() && sweepResult.freeList);
......
......@@ -38,11 +38,12 @@ public:
static WeakImpl* allocate(JSValue, WeakHandleOwner* = 0, void* context = 0);
static void deallocate(WeakImpl*);
WeakSet(Heap*);
WeakSet(JSGlobalData*);
~WeakSet();
void lastChanceToFinalize();
Heap* heap() const;
JSGlobalData* globalData() const;
bool isEmpty() const;
......@@ -61,19 +62,19 @@ private:
WeakBlock::FreeCell* m_allocator;
WeakBlock* m_nextAllocator;
DoublyLinkedList<WeakBlock> m_blocks;
Heap* m_heap;
JSGlobalData* m_globalData;
};
inline WeakSet::WeakSet(Heap* heap)
inline WeakSet::WeakSet(JSGlobalData* globalData)
: m_allocator(0)
, m_nextAllocator(0)
, m_heap(heap)
, m_globalData(globalData)
{
}
inline Heap* WeakSet::heap() const
inline JSGlobalData* WeakSet::globalData() const
{
return m_heap;
return m_globalData;
}
inline bool WeakSet::isEmpty() const
......
......@@ -1591,12 +1591,12 @@ void JIT::emit_op_resolve_global_dynamic(Instruction* currentInstruction)
Jump activationNotCreated;
if (checkTopLevel)
activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister()));
addSlowCase(checkStructure(regT0, m_globalData->activationStructure.get()));
addSlowCase(checkStructure(regT0, m_codeBlock->globalObject()->activationStructure()));
loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0);
activationNotCreated.link(this);
}
while (skip--) {
addSlowCase(checkStructure(regT0, m_globalData->activationStructure.get()));
addSlowCase(checkStructure(regT0, m_codeBlock->globalObject()->activationStructure()));
loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0);
}
emit_op_resolve_global(currentInstruction, true);
......
......@@ -1022,8 +1022,9 @@ end
_llint_op_resolve_global_dynamic:
traceExecution()
loadp JITStackFrame::globalData[sp], t3
loadp JSGlobalData::activationStructure[t3], t3
loadp CodeBlock[cfr], t3
loadp CodeBlock::m_globalObject[t3], t3
loadp JSGlobalObject::m_activationStructure[t3], t3
getScope(
20[PC],
macro (scope, scratch)
......
......@@ -873,8 +873,9 @@ end
_llint_op_resolve_global_dynamic:
traceExecution()
loadp JITStackFrame::globalData[sp], t3
loadp JSGlobalData::activationStructure[t3], t3
loadp CodeBlock[cfr], t3
loadp CodeBlock::m_globalObject[t3], t3
loadp JSGlobalObject::m_activationStructure[t3], t3
getScope(
40[PB, PC, 8],
macro (scope, scratch)
......
......@@ -44,10 +44,8 @@ const ClassInfo JSActivation::s_info = { "JSActivation", &Base::s_info, 0, 0, CR
JSActivation::JSActivation(CallFrame* callFrame, FunctionExecutable* functionExecutable)
: Base(
callFrame->globalData(),
callFrame->globalData().activationStructure.get(),
callFrame->lexicalGlobalObject()->activationStructure(),
callFrame->registers(),
callFrame->lexicalGlobalObject(),
callFrame->globalThisValue(),
callFrame->scope()
)
, m_registerArray(callFrame->globalData(), this, 0)
......
......@@ -96,11 +96,11 @@ namespace JSC {
size_t registerArraySizeInBytes();
StorageBarrier m_registerArray; // Independent copy of registers, used when a variable object copies its registers out of the register file.
int m_numCapturedArgs;
int m_numCapturedVars : 30;
unsigned m_numCapturedArgs;
unsigned m_numCapturedVars : 28;
bool m_isTornOff : 1;
bool m_requiresDynamicChecks : 1;
int m_argumentsRegister;
unsigned m_argumentsRegister : 2;
};
JSActivation* asActivation(JSValue);
......
......@@ -188,17 +188,13 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
IdentifierTable* existingEntryIdentifierTable = wtfThreadData().setCurrentIdentifierTable(identifierTable);
structureStructure.set(*this, Structure::createStructure(*this));
debuggerActivationStructure.set(*this, DebuggerActivation::createStructure(*this, 0, jsNull()));
activationStructure.set(*this, JSActivation::createStructure(*this, 0, jsNull()));
interruptedExecutionErrorStructure.set(*this, InterruptedExecutionError::createStructure(*this, 0, jsNull()));
terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull()));
nameScopeStructure.set(*this, JSNameScope::createStructure(*this, 0, jsNull()));
strictEvalActivationStructure.set(*this, StrictEvalActivation::createStructure(*this, 0, jsNull()));
stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull()));
notAnObjectStructure.set(*this, JSNotAnObject::createStructure(*this, 0, jsNull()));
propertyNameIteratorStructure.set(*this, JSPropertyNameIterator::createStructure(*this, 0, jsNull()));
getterSetterStructure.set(*this, GetterSetter::createStructure(*this, 0, jsNull()));
apiWrapperStructure.set(*this, JSAPIValueWrapper::createStructure(*this, 0, jsNull()));
JSScopeStructure.set(*this, JSScope::createStructure(*this, 0, jsNull()));
executableStructure.set(*this, ExecutableBase::createStructure(*this, 0, jsNull()));
nativeExecutableStructure.set(*this, NativeExecutable::createStructure(*this, 0, jsNull()));
evalExecutableStructure.set(*this, EvalExecutable::createStructure(*this, 0, jsNull()));
......@@ -207,7 +203,6 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull()));
sharedSymbolTableStructure.set(*this, SharedSymbolTable::createStructure(*this, 0, jsNull()));
structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull()));
withScopeStructure.set(*this, JSWithScope::createStructure(*this, 0, jsNull()));
wtfThreadData().setCurrentIdentifierTable(existingEntryIdentifierTable);
......
......@@ -228,17 +228,13 @@ namespace JSC {
Strong<Structure> structureStructure;
Strong<Structure> debuggerActivationStructure;
Strong<Structure> activationStructure;
Strong<Structure> interruptedExecutionErrorStructure;
Strong<Structure> terminatedExecutionErrorStructure;
Strong<Structure> nameScopeStructure;
Strong<Structure> strictEvalActivationStructure;
Strong<Structure> stringStructure;
Strong<Structure> notAnObjectStructure;
Strong<Structure> propertyNameIteratorStructure;
Strong<Structure> getterSetterStructure;
Strong<Structure> apiWrapperStructure;
Strong<Structure> JSScopeStructure;
Strong<Structure> executableStructure;
Strong<Structure> nativeExecutableStructure;
Strong<Structure> evalExecutableStructure;
......@@ -247,7 +243,6 @@ namespace JSC {
Strong<Structure> regExpStructure;
Strong<Structure> sharedSymbolTableStructure;
Strong<Structure> structureChainStructure;
Strong<Structure> withScopeStructure;
IdentifierTable* identifierTable;
CommonIdentifiers* propertyNames;
......@@ -474,6 +469,11 @@ namespace JSC {
}
#endif
inline Heap* WeakSet::heap() const
{
return &m_globalData->heap;
}
} // namespace JSC
#endif // JSGlobalData_h
......@@ -30,10 +30,6 @@
#include "config.h"
#include "JSGlobalObject.h"
#include "JSCallbackConstructor.h"
#include "JSCallbackFunction.h"
#include "JSCallbackObject.h"
#include "Arguments.h"
#include "ArrayConstructor.h"
#include "ArrayPrototype.h"
......@@ -42,18 +38,25 @@
#include "CodeBlock.h"
#include "DateConstructor.h"
#include "DatePrototype.h"
#include "Debugger.h"
#include "Error.h"
#include "ErrorConstructor.h"
#include "ErrorPrototype.h"
#include "FunctionConstructor.h"
#include "FunctionPrototype.h"
#include "GetterSetter.h"
#include "Interpreter.h"
#include "JSActivation.h"
#include "JSBoundFunction.h"
#include "JSCallbackConstructor.h"
#include "JSCallbackFunction.h"
#include "JSCallbackObject.h"
#include "JSFunction.h"
#include "JSGlobalObjectFunctions.h"
#include "JSLock.h"
#include "JSNameScope.h"
#include "JSONObject.h"
#include "Interpreter.h"
#include "JSWithScope.h"
#include "Lookup.h"
#include "MathObject.h"
#include "NameConstructor.h"
......@@ -70,9 +73,9 @@
#include "RegExpMatchesArray.h"
#include "RegExpObject.h"
#include "RegExpPrototype.h"
#include "StrictEvalActivation.h"
#include "StringConstructor.h"
#include "StringPrototype.h"
#include "Debugger.h"
#include "JSGlobalObject.lut.h"
......@@ -106,7 +109,7 @@ static const int initialTickCountThreshold = 255;
static const int preferredScriptCheckTimeInterval = 1000;
JSGlobalObject::JSGlobalObject(JSGlobalData& globalData, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable)
: Base(globalData, structure, this, this, 0)
: Base(globalData, structure, 0)
, m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(InitializedWatching)))
, m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
, m_evalEnabled(true)
......@@ -128,6 +131,11 @@ void JSGlobalObject::destroy(JSCell* cell)
static_cast<JSGlobalObject*>(cell)->JSGlobalObject::~JSGlobalObject();
}
void JSGlobalObject::setGlobalThis(JSGlobalData& globalData, JSObject* globalThis)
{
m_globalThis.set(globalData, this, globalThis);
}
void JSGlobalObject::init(JSObject* thisValue)
{
ASSERT(globalData().apiLock().currentThreadIsHoldingLock());
......@@ -208,6 +216,11 @@ void JSGlobalObject::reset(JSValue prototype)
m_objectPrototype->putDirectAccessor(exec->globalData(), exec->propertyNames().underscoreProto, protoAccessor, Accessor | DontEnum);
m_functionPrototype->structure()->setPrototypeWithoutTransition(exec->globalData(), m_objectPrototype.get());
m_nameScopeStructure.set(exec->globalData(), this, JSNameScope::createStructure(exec->globalData(), this, jsNull()));
m_activationStructure.set(exec->globalData(), this, JSActivation::createStructure(exec->globalData(), this, jsNull()));
m_strictEvalActivationStructure.set(exec->globalData(), this, StrictEvalActivation::createStructure(exec->globalData(), this, jsNull()));
m_withScopeStructure.set(exec->globalData(), this, JSWithScope::createStructure(exec->globalData(), this, jsNull()));
m_emptyObjectStructure.set(exec->globalData(), this, m_objectPrototype->inheritorID(exec->globalData()));
m_nullPrototypeObjectStructure.set(exec->globalData(), this, createEmptyObjectStructure(exec->globalData(), this, jsNull()));
......@@ -344,6 +357,7 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_globalThis);
visitor.append(&thisObject->m_methodCallDummy);
visitor.append(&thisObject->m_regExpConstructor);
......@@ -370,6 +384,10 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
visitor.append(&thisObject->m_regExpPrototype);
visitor.append(&thisObject->m_errorPrototype);
visitor.append(&thisObject->m_withScopeStructure);
visitor.append(&thisObject->m_strictEvalActivationStructure);
visitor.append(&thisObject->m_activationStructure);
visitor.append(&thisObject->m_nameScopeStructure);
visitor.append(&thisObject->m_argumentsStructure);
visitor.append(&thisObject->m_arrayStructure);
visitor.append(&thisObject->m_booleanObjectStructure);
......
......@@ -94,6 +94,7 @@ namespace JSC {
Register m_globalCallFrame[RegisterFile::CallFrameHeaderSize];
WriteBarrier<JSObject> m_globalThis;
WriteBarrier<JSObject> m_methodCallDummy;
WriteBarrier<RegExpConstructor> m_regExpConstructor;
......@@ -120,6 +121,10 @@ namespace JSC {
WriteBarrier<RegExpPrototype> m_regExpPrototype;
WriteBarrier<ErrorPrototype> m_errorPrototype;
WriteBarrier<Structure> m_withScopeStructure;
WriteBarrier<Structure> m_strictEvalActivationStructure;
WriteBarrier<Structure> m_activationStructure;
WriteBarrier<Structure> m_nameScopeStructure;
WriteBarrier<Structure> m_argumentsStructure;
WriteBarrier<Structure> m_arrayStructure;
WriteBarrier<Structure> m_booleanObjectStructure;
......@@ -248,6 +253,10 @@ namespace JSC {
JSObject* methodCallDummy() const { return m_methodCallDummy.get(); }
Structure* withScopeStructure() const { return m_withScopeStructure.get(); }
Structure* strictEvalActivationStructure() const { return m_strictEvalActivationStructure.get(); }
Structure* activationStructure() const { return m_activationStructure.get(); }
Structure* nameScopeStructure() const { return m_nameScopeStructure.get(); }
Structure* argumentsStructure() const { return m_argumentsStructure.get(); }
Structure* arrayStructure() const { return m_arrayStructure.get(); }
Structure* booleanObjectStructure() const { return m_booleanObjectStructure.get(); }
......@@ -301,6 +310,7 @@ namespace JSC {
void resetPrototype(JSGlobalData&, JSValue prototype);
JSGlobalData& globalData() const { return *Heap::heap(this)->globalData(); }
JSObject* globalThis() const;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
{
......@@ -345,6 +355,7 @@ namespace JSC {
// FIXME: Fold reset into init.
JS_EXPORT_PRIVATE void init(JSObject* thisValue);
void reset(JSValue prototype);
void setGlobalThis(JSGlobalData&, JSObject* globalThis);
void createThrowTypeError(ExecState*);
......@@ -485,6 +496,16 @@ namespace JSC {
return true;
}
inline JSObject* JSScope::globalThis()
{
return globalObject()->globalThis();
}
inline JSObject* JSGlobalObject::globalThis() const
{
return m_globalThis.get();
}
} // namespace JSC
#endif // JSGlobalObject_h
......@@ -26,6 +26,7 @@
#ifndef JSNameScope_h
#define JSNameScope_h
#include "JSGlobalObject.h"
#include "JSVariableObject.h"
namespace JSC {
......@@ -66,10 +67,8 @@ private:
JSNameScope(ExecState* exec)
: Base(
exec->globalData(),
exec->globalData().nameScopeStructure.get(),
exec->lexicalGlobalObject()->nameScopeStructure(),
reinterpret_cast<Register*>(&m_registerStore + 1),
exec->lexicalGlobalObject(),
exec->globalThisValue(),
exec->scope()
)
{
......
......@@ -44,8 +44,6 @@ void JSScope::visitChildren(JSCell* cell, SlotVisitor& visitor)
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_next);
visitor.append(&thisObject->m_globalObject);
visitor.append(&thisObject->m_globalThis);
}
bool JSScope::isDynamicScope(bool& requiresDynamicChecks) const
......
......@@ -73,25 +73,18 @@ public:
JSGlobalObject* globalObject();
JSGlobalData* globalData();
JSObject* globalThis();
void setGlobalThis(JSGlobalData&, JSObject*);
protected:
JSScope(JSGlobalData&, Structure*, JSGlobalObject*, JSObject* globalThis, JSScope* next);
JSScope(JSGlobalData&, Structure*, JSScope* next);
static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;
private:
JSGlobalData* m_globalData;
WriteBarrier<JSScope> m_next;
WriteBarrier<JSGlobalObject> m_globalObject;
WriteBarrier<JSObject> m_globalThis;
};
inline JSScope::JSScope(JSGlobalData& globalData, Structure* structure, JSGlobalObject* globalObject, JSObject* globalThis, JSScope* next)
inline JSScope::JSScope(JSGlobalData& globalData, Structure* structure, JSScope* next)
: Base(globalData, structure)
, m_globalData(&globalData)
, m_next(globalData, this, next, WriteBarrier<JSScope>::MayBeNull)
, m_globalObject(globalData, this, globalObject)
, m_globalThis(globalData, this, globalThis)
{
}
......@@ -133,22 +126,12 @@ inline JSScope* JSScope::next()
inline JSGlobalObject* JSScope::globalObject()
{
return m_globalObject.get();
return structure()->globalObject();
}
inline JSGlobalData* JSScope::globalData()
{
return m_globalData;
}
inline JSObject* JSScope::globalThis()
{
return m_globalThis.get();
}
inline void JSScope::setGlobalThis(JSGlobalData& globalData, JSObject* globalThis)
{
m_globalThis.set(globalData, this, globalThis);
return MarkedBlock::blockFor(this)->globalData();
}
inline Register& Register::operator=(JSScope* scope)
......
......@@ -82,8 +82,8 @@ public:
protected:
static const unsigned StructureFlags = OverridesVisitChildren | JSSymbolTableObject::StructureFlags;
JSSegmentedVariableObject(JSGlobalData& globalData, Structure* structure, JSGlobalObject* globalObject, JSObject* globalThis, JSScope* scope)
: JSSymbolTableObject(globalData, structure, globalObject, globalThis, scope)
JSSegmentedVariableObject(JSGlobalData& globalData, Structure* structure, JSScope* scope)
: JSSymbolTableObject(globalData, structure, scope)
{
}
......
......@@ -49,8 +49,8 @@ public:
protected:
static const unsigned StructureFlags = IsEnvironmentRecord | OverridesVisitChildren | OverridesGetPropertyNames | Base::StructureFlags;
JSSymbolTableObject(JSGlobalData& globalData, Structure* structure, JSGlobalObject* globalObject, JSObject* globalThis, JSScope* scope)
: Base(globalData, structure, globalObject, globalThis, scope)
JSSymbolTableObject(JSGlobalData& globalData, Structure* structure, JSScope* scope)
: Base(globalData, structure, scope)
{
}
......
......@@ -60,11 +60,9 @@ namespace JSC {
JSGlobalData& globalData,
Structure* structure,
Register* registers,
JSGlobalObject* globalObject,
JSObject* globalThis,
JSScope* scope
)
: Base(globalData, structure, globalObject, globalThis, scope)
: Base(globalData, structure, scope)
, m_registers(reinterpret_cast<WriteBarrierBase<Unknown>*>(registers))
{
}
......
......@@ -26,7 +26,7 @@
#ifndef JSWithScope_h
#define JSWithScope_h
#include "JSScope.h"
#include "JSGlobalObject.h"