Commit bbddb5bf authored by fpizlo@apple.com's avatar fpizlo@apple.com

Combine SymbolTable and SharedSymbolTable

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

Reviewed by Geoffrey Garen.
        
SymbolTable was never used directly; we now always used SharedSymbolTable. So, this
gets rid of SymbolTable and renames SharedSymbolTable to SymbolTable.

* bytecode/CodeBlock.h:
(JSC::CodeBlock::symbolTable):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedFunctionExecutable::symbolTable):
(JSC::UnlinkedCodeBlock::symbolTable):
(JSC::UnlinkedCodeBlock::finishCreation):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::symbolTable):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGStackLayoutPhase.cpp:
(JSC::DFG::StackLayoutPhase::run):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::symbolTableFor):
* runtime/Arguments.h:
(JSC::Arguments::finishCreation):
* runtime/Executable.h:
(JSC::FunctionExecutable::symbolTable):
* runtime/JSActivation.h:
(JSC::JSActivation::create):
(JSC::JSActivation::JSActivation):
(JSC::JSActivation::registersOffset):
(JSC::JSActivation::allocationSize):
* runtime/JSSymbolTableObject.h:
(JSC::JSSymbolTableObject::symbolTable):
(JSC::JSSymbolTableObject::JSSymbolTableObject):
(JSC::JSSymbolTableObject::finishCreation):
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::JSVariableObject):
* runtime/SymbolTable.cpp:
(JSC::SymbolTable::destroy):
(JSC::SymbolTable::SymbolTable):
* runtime/SymbolTable.h:
(JSC::SymbolTable::create):
(JSC::SymbolTable::createStructure):
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159713 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 751589e5
2013-11-21 Filip Pizlo <fpizlo@apple.com>
Combine SymbolTable and SharedSymbolTable
https://bugs.webkit.org/show_bug.cgi?id=124761
Reviewed by Geoffrey Garen.
SymbolTable was never used directly; we now always used SharedSymbolTable. So, this
gets rid of SymbolTable and renames SharedSymbolTable to SymbolTable.
* bytecode/CodeBlock.h:
(JSC::CodeBlock::symbolTable):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedFunctionExecutable::symbolTable):
(JSC::UnlinkedCodeBlock::symbolTable):
(JSC::UnlinkedCodeBlock::finishCreation):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::symbolTable):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGStackLayoutPhase.cpp:
(JSC::DFG::StackLayoutPhase::run):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::symbolTableFor):
* runtime/Arguments.h:
(JSC::Arguments::finishCreation):
* runtime/Executable.h:
(JSC::FunctionExecutable::symbolTable):
* runtime/JSActivation.h:
(JSC::JSActivation::create):
(JSC::JSActivation::JSActivation):
(JSC::JSActivation::registersOffset):
(JSC::JSActivation::allocationSize):
* runtime/JSSymbolTableObject.h:
(JSC::JSSymbolTableObject::symbolTable):
(JSC::JSSymbolTableObject::JSSymbolTableObject):
(JSC::JSSymbolTableObject::finishCreation):
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::JSVariableObject):
* runtime/SymbolTable.cpp:
(JSC::SymbolTable::destroy):
(JSC::SymbolTable::SymbolTable):
* runtime/SymbolTable.h:
(JSC::SymbolTable::create):
(JSC::SymbolTable::createStructure):
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:
2013-11-22 Mark Lam <mark.lam@apple.com>
Remove residual references to "dynamicGlobalObject".
......
......@@ -722,7 +722,7 @@ public:
StringJumpTable& stringSwitchJumpTable(int tableIndex) { RELEASE_ASSERT(m_rareData); return m_rareData->m_stringSwitchJumpTables[tableIndex]; }
SharedSymbolTable* symbolTable() const { return m_unlinkedCode->symbolTable(); }
SymbolTable* symbolTable() const { return m_unlinkedCode->symbolTable(); }
EvalCodeCache& evalCodeCache() { createRareDataIfNecessary(); return m_rareData->m_evalCodeCache; }
......
......@@ -55,7 +55,7 @@ struct ParserError;
class ScriptExecutable;
class SourceCode;
class SourceProvider;
class SharedSymbolTable;
class SymbolTable;
class UnlinkedCodeBlock;
class UnlinkedFunctionCodeBlock;
......@@ -93,7 +93,7 @@ public:
const Identifier& name() const { return m_name; }
const Identifier& inferredName() const { return m_inferredName; }
JSString* nameValue() const { return m_nameValue.get(); }
SharedSymbolTable* symbolTable(CodeSpecializationKind kind)
SymbolTable* symbolTable(CodeSpecializationKind kind)
{
return (kind == CodeForCall) ? m_symbolTableForCall.get() : m_symbolTableForConstruct.get();
}
......@@ -156,8 +156,8 @@ private:
Identifier m_name;
Identifier m_inferredName;
WriteBarrier<JSString> m_nameValue;
WriteBarrier<SharedSymbolTable> m_symbolTableForCall;
WriteBarrier<SharedSymbolTable> m_symbolTableForConstruct;
WriteBarrier<SymbolTable> m_symbolTableForCall;
WriteBarrier<SymbolTable> m_symbolTableForConstruct;
RefPtr<FunctionParameters> m_parameters;
unsigned m_firstLineOffset;
unsigned m_lineCount;
......@@ -383,7 +383,7 @@ public:
void addExceptionHandler(const UnlinkedHandlerInfo& hanler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); }
UnlinkedHandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
SharedSymbolTable* symbolTable() const { return m_symbolTable.get(); }
SymbolTable* symbolTable() const { return m_symbolTable.get(); }
VM* vm() const { return m_vm; }
......@@ -469,7 +469,7 @@ protected:
Base::finishCreation(vm);
if (codeType() == GlobalCode)
return;
m_symbolTable.set(vm, this, SharedSymbolTable::create(vm));
m_symbolTable.set(vm, this, SymbolTable::create(vm));
}
private:
......@@ -512,7 +512,7 @@ private:
FunctionExpressionVector m_functionDecls;
FunctionExpressionVector m_functionExprs;
WriteBarrier<SharedSymbolTable> m_symbolTable;
WriteBarrier<SymbolTable> m_symbolTable;
Vector<unsigned> m_propertyAccessInstructions;
......
......@@ -534,7 +534,7 @@ namespace JSC {
Vector<UnlinkedInstruction, 0, UnsafeVectorOverflow>& instructions() { return m_instructions; }
SharedSymbolTable& symbolTable() { return *m_symbolTable; }
SymbolTable& symbolTable() { return *m_symbolTable; }
bool shouldOptimizeLocals()
{
......@@ -577,7 +577,7 @@ namespace JSC {
bool m_shouldEmitDebugHooks;
bool m_shouldEmitProfileHooks;
SharedSymbolTable* m_symbolTable;
SymbolTable* m_symbolTable;
ScopeNode* m_scopeNode;
Strong<UnlinkedCodeBlock> m_codeBlock;
......
......@@ -4350,7 +4350,7 @@ void SpeculativeJIT::compile(Node* node)
JITCompiler::Jump notCreated = m_jit.branch32(JITCompiler::Equal, activationValueTagGPR, TrustedImm32(JSValue::EmptyValueTag));
SharedSymbolTable* symbolTable = m_jit.symbolTableFor(node->codeOrigin);
SymbolTable* symbolTable = m_jit.symbolTableFor(node->codeOrigin);
int registersOffset = JSActivation::registersOffset(symbolTable);
int bytecodeCaptureStart = symbolTable->captureStart();
......
......@@ -4630,7 +4630,7 @@ void SpeculativeJIT::compile(Node* node)
JITCompiler::Jump notCreated = m_jit.branchTest64(JITCompiler::Zero, activationValueGPR);
SharedSymbolTable* symbolTable = m_jit.symbolTableFor(node->codeOrigin);
SymbolTable* symbolTable = m_jit.symbolTableFor(node->codeOrigin);
int registersOffset = JSActivation::registersOffset(symbolTable);
int bytecodeCaptureStart = symbolTable->captureStart();
......
......@@ -46,7 +46,7 @@ public:
bool run()
{
SharedSymbolTable* symbolTable = codeBlock()->symbolTable();
SymbolTable* symbolTable = codeBlock()->symbolTable();
// This enumerates the locals that we actually care about and packs them. So for example
// if we use local 1, 3, 4, 5, 7, then we remap them: 1->0, 3->1, 4->2, 5->3, 7->4. We
......
......@@ -435,7 +435,7 @@ public:
return baselineArgumentsRegisterFor(codeOrigin.inlineCallFrame);
}
SharedSymbolTable* symbolTableFor(const CodeOrigin& codeOrigin)
SymbolTable* symbolTableFor(const CodeOrigin& codeOrigin)
{
return baselineCodeBlockFor(codeOrigin)->symbolTable();
}
......
......@@ -251,7 +251,7 @@ inline void Arguments::finishCreation(CallFrame* callFrame)
CodeBlock* codeBlock = callFrame->codeBlock();
if (codeBlock->hasSlowArguments()) {
SharedSymbolTable* symbolTable = codeBlock->symbolTable();
SymbolTable* symbolTable = codeBlock->symbolTable();
const SlowArgument* slowArguments = codeBlock->machineSlowArguments();
allocateSlowArguments();
size_t count = std::min<unsigned>(m_numArguments, symbolTable->parameterCount());
......
......@@ -639,7 +639,7 @@ public:
JSString* nameValue() const { return m_unlinkedExecutable->nameValue(); }
size_t parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'!
String paramString() const;
SharedSymbolTable* symbolTable(CodeSpecializationKind kind) const { return m_unlinkedExecutable->symbolTable(kind); }
SymbolTable* symbolTable(CodeSpecializationKind kind) const { return m_unlinkedExecutable->symbolTable(kind); }
void clearCodeIfNotCompiling();
void clearUnlinkedCodeForRecompilationIfNotCompiling();
......
......@@ -41,14 +41,14 @@ class Register;
class JSActivation : public JSVariableObject {
private:
JSActivation(VM&, CallFrame*, Register*, SharedSymbolTable*);
JSActivation(VM&, CallFrame*, Register*, SymbolTable*);
public:
typedef JSVariableObject Base;
static JSActivation* create(VM& vm, CallFrame* callFrame, Register* registers, CodeBlock* codeBlock)
{
SharedSymbolTable* symbolTable = codeBlock->symbolTable();
SymbolTable* symbolTable = codeBlock->symbolTable();
JSActivation* activation = new (
NotNull,
allocateCell<JSActivation>(
......@@ -87,7 +87,7 @@ public:
bool isValid(const SymbolTableEntry&) const;
bool isTornOff();
int registersOffset();
static int registersOffset(SharedSymbolTable*);
static int registersOffset(SymbolTable*);
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | OverridesGetPropertyNames | Base::StructureFlags;
......@@ -101,7 +101,7 @@ private:
static JSValue argumentsGetter(ExecState*, JSValue, PropertyName);
static size_t allocationSize(SharedSymbolTable*);
static size_t allocationSize(SymbolTable*);
static size_t storageOffset();
WriteBarrier<Unknown>* storage(); // captureCount() number of registers.
......@@ -110,7 +110,7 @@ private:
extern int activationCount;
extern int allTheThingsCount;
inline JSActivation::JSActivation(VM& vm, CallFrame* callFrame, Register* registers, SharedSymbolTable* symbolTable)
inline JSActivation::JSActivation(VM& vm, CallFrame* callFrame, Register* registers, SymbolTable* symbolTable)
: Base(
vm,
callFrame->lexicalGlobalObject()->activationStructure(),
......@@ -137,7 +137,7 @@ ALWAYS_INLINE JSActivation* Register::activation() const
return asActivation(jsValue());
}
inline int JSActivation::registersOffset(SharedSymbolTable* symbolTable)
inline int JSActivation::registersOffset(SymbolTable* symbolTable)
{
return storageOffset() + ((symbolTable->captureCount() - symbolTable->captureStart() - 1) * sizeof(WriteBarrier<Unknown>));
}
......@@ -175,7 +175,7 @@ inline WriteBarrier<Unknown>* JSActivation::storage()
reinterpret_cast<char*>(this) + storageOffset());
}
inline size_t JSActivation::allocationSize(SharedSymbolTable* symbolTable)
inline size_t JSActivation::allocationSize(SymbolTable* symbolTable)
{
size_t objectSizeInBytes = WTF::roundUpToMultipleOf<sizeof(WriteBarrier<Unknown>)>(sizeof(JSActivation));
size_t storageSizeInBytes = symbolTable->captureCount() * sizeof(WriteBarrier<Unknown>);
......
......@@ -39,7 +39,7 @@ class JSSymbolTableObject : public JSScope {
public:
typedef JSScope Base;
SharedSymbolTable* symbolTable() const { return m_symbolTable.get(); }
SymbolTable* symbolTable() const { return m_symbolTable.get(); }
JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, ExecState*, PropertyName);
JS_EXPORT_PRIVATE static void getOwnNonIndexPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
......@@ -47,7 +47,7 @@ public:
protected:
static const unsigned StructureFlags = IsEnvironmentRecord | OverridesVisitChildren | OverridesGetPropertyNames | Base::StructureFlags;
JSSymbolTableObject(VM& vm, Structure* structure, JSScope* scope, SharedSymbolTable* symbolTable = 0)
JSSymbolTableObject(VM& vm, Structure* structure, JSScope* scope, SymbolTable* symbolTable = 0)
: Base(vm, structure, scope)
{
if (symbolTable)
......@@ -58,12 +58,12 @@ protected:
{
Base::finishCreation(vm);
if (!m_symbolTable)
m_symbolTable.set(vm, this, SharedSymbolTable::create(vm));
m_symbolTable.set(vm, this, SymbolTable::create(vm));
}
static void visitChildren(JSCell*, SlotVisitor&);
WriteBarrier<SharedSymbolTable> m_symbolTable;
WriteBarrier<SymbolTable> m_symbolTable;
};
template<typename SymbolTableObjectType>
......
......@@ -61,7 +61,7 @@ protected:
Structure* structure,
Register* registers,
JSScope* scope,
SharedSymbolTable* symbolTable = 0)
SymbolTable* symbolTable = 0)
: Base(vm, structure, scope, symbolTable)
, m_registers(reinterpret_cast<WriteBarrierBase<Unknown>*>(registers))
{
......
......@@ -29,13 +29,13 @@
#include "config.h"
#include "SymbolTable.h"
#include "JSCellInlines.h"
#include "JSDestructibleObject.h"
#include "Operations.h"
#include "SlotVisitorInlines.h"
namespace JSC {
const ClassInfo SharedSymbolTable::s_info = { "SharedSymbolTable", 0, 0, 0, CREATE_METHOD_TABLE(SharedSymbolTable) };
const ClassInfo SymbolTable::s_info = { "SymbolTable", 0, 0, 0, CREATE_METHOD_TABLE(SymbolTable) };
SymbolTableEntry& SymbolTableEntry::copySlow(const SymbolTableEntry& other)
{
......@@ -46,10 +46,10 @@ SymbolTableEntry& SymbolTableEntry::copySlow(const SymbolTableEntry& other)
return *this;
}
void SharedSymbolTable::destroy(JSCell* cell)
void SymbolTable::destroy(JSCell* cell)
{
SharedSymbolTable* thisObject = jsCast<SharedSymbolTable*>(cell);
thisObject->SharedSymbolTable::~SharedSymbolTable();
SymbolTable* thisObject = jsCast<SymbolTable*>(cell);
thisObject->SymbolTable::~SymbolTable();
}
void SymbolTableEntry::freeFatEntrySlow()
......@@ -98,7 +98,15 @@ SymbolTableEntry::FatEntry* SymbolTableEntry::inflateSlow()
return entry;
}
SymbolTable::SymbolTable() { }
SymbolTable::SymbolTable(VM& vm)
: JSCell(vm, vm.symbolTableStructure.get())
, m_parameterCountIncludingThis(0)
, m_usesNonStrictEval(false)
, m_captureStart(0)
, m_captureEnd(0)
{
}
SymbolTable::~SymbolTable() { }
} // namespace JSC
......
......@@ -334,13 +334,27 @@ struct SymbolTableIndexHashTraits : HashTraits<SymbolTableEntry> {
static const bool needsDestruction = true;
};
class SymbolTable {
class SymbolTable : public JSCell {
public:
typedef JSCell Base;
typedef HashMap<RefPtr<StringImpl>, SymbolTableEntry, IdentifierRepHash, HashTraits<RefPtr<StringImpl>>, SymbolTableIndexHashTraits> Map;
JS_EXPORT_PRIVATE SymbolTable();
JS_EXPORT_PRIVATE ~SymbolTable();
static SymbolTable* create(VM& vm)
{
SymbolTable* symbolTable = new (NotNull, allocateCell<SymbolTable>(vm.heap)) SymbolTable(vm);
symbolTable->finishCreation(vm);
return symbolTable;
}
static const bool needsDestruction = true;
static const bool hasImmortalStructure = true;
static void destroy(JSCell*);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(LeafType, StructureFlags), info());
}
// You must hold the lock until after you're done with the iterator.
Map::iterator find(const ConcurrentJITLocker&, StringImpl* key)
{
......@@ -433,32 +447,6 @@ public:
return contains(locker, key);
}
private:
Map m_map;
public:
mutable ConcurrentJITLock m_lock;
};
class SharedSymbolTable : public JSCell, public SymbolTable {
public:
typedef JSCell Base;
static SharedSymbolTable* create(VM& vm)
{
SharedSymbolTable* sharedSymbolTable = new (NotNull, allocateCell<SharedSymbolTable>(vm.heap)) SharedSymbolTable(vm);
sharedSymbolTable->finishCreation(vm);
return sharedSymbolTable;
}
static const bool needsDestruction = true;
static const bool hasImmortalStructure = true;
static void destroy(JSCell*);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(LeafType, StructureFlags), info());
}
bool usesNonStrictEval() { return m_usesNonStrictEval; }
void setUsesNonStrictEval(bool usesNonStrictEval) { m_usesNonStrictEval = usesNonStrictEval; }
......@@ -481,15 +469,11 @@ public:
DECLARE_EXPORT_INFO;
private:
SharedSymbolTable(VM& vm)
: JSCell(vm, vm.sharedSymbolTableStructure.get())
, m_parameterCountIncludingThis(0)
, m_usesNonStrictEval(false)
, m_captureStart(0)
, m_captureEnd(0)
{
}
JS_EXPORT_PRIVATE SymbolTable(VM&);
~SymbolTable();
Map m_map;
int m_parameterCountIncludingThis;
bool m_usesNonStrictEval;
......@@ -497,6 +481,9 @@ private:
int m_captureEnd;
std::unique_ptr<SlowArgument[]> m_slowArguments;
public:
mutable ConcurrentJITLock m_lock;
};
} // namespace JSC
......
......@@ -245,7 +245,7 @@ VM::VM(VMType vmType, HeapType heapType)
programExecutableStructure.set(*this, ProgramExecutable::createStructure(*this, 0, jsNull()));
functionExecutableStructure.set(*this, FunctionExecutable::createStructure(*this, 0, jsNull()));
regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull()));
sharedSymbolTableStructure.set(*this, SharedSymbolTable::createStructure(*this, 0, jsNull()));
symbolTableStructure.set(*this, SymbolTable::createStructure(*this, 0, jsNull()));
structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull()));
sparseArrayValueMapStructure.set(*this, SparseArrayValueMap::createStructure(*this, 0, jsNull()));
withScopeStructure.set(*this, JSWithScope::createStructure(*this, 0, jsNull()));
......
......@@ -264,7 +264,7 @@ namespace JSC {
Strong<Structure> programExecutableStructure;
Strong<Structure> functionExecutableStructure;
Strong<Structure> regExpStructure;
Strong<Structure> sharedSymbolTableStructure;
Strong<Structure> symbolTableStructure;
Strong<Structure> structureChainStructure;
Strong<Structure> sparseArrayValueMapStructure;
Strong<Structure> withScopeStructure;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment