Commit 022f368a authored by fpizlo@apple.com's avatar fpizlo@apple.com

Create a new SymbolTable every time code is loaded so that the watchpoints don't get reused

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

Reviewed by Oliver Hunt.
        
This helps with one shot closure inference as well as closure variable constant
inference, since without this, if code was reloaded from the cache then we would
think that the first run was actually an Nth run. This would cause us to think that
the watchpoint(s) should all be invalidated.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::stronglyVisitStrongReferences):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::symbolTable):
* runtime/Executable.cpp:
(JSC::FunctionExecutable::symbolTable):
* runtime/Executable.h:
* runtime/SymbolTable.cpp:
(JSC::SymbolTable::clone):
* runtime/SymbolTable.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159795 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7397414f
2013-11-24 Filip Pizlo <fpizlo@apple.com>
Create a new SymbolTable every time code is loaded so that the watchpoints don't get reused
https://bugs.webkit.org/show_bug.cgi?id=124824
Reviewed by Oliver Hunt.
This helps with one shot closure inference as well as closure variable constant
inference, since without this, if code was reloaded from the cache then we would
think that the first run was actually an Nth run. This would cause us to think that
the watchpoint(s) should all be invalidated.
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::stronglyVisitStrongReferences):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::symbolTable):
* runtime/Executable.cpp:
(JSC::FunctionExecutable::symbolTable):
* runtime/Executable.h:
* runtime/SymbolTable.cpp:
(JSC::SymbolTable::clone):
* runtime/SymbolTable.h:
2013-11-26 Oliver Hunt <oliver@apple.com>
Crash in JSC::ASTBuilder::Expression JSC::Parser<JSC::Lexer<unsigned char> >::parseUnaryExpression<JSC::ASTBuilder>(JSC::ASTBuilder&)
......
......@@ -1481,6 +1481,10 @@ CodeBlock::CodeBlock(CopyParsedBlockTag, CodeBlock& other)
#endif
{
ASSERT(m_heap->isDeferred());
if (SymbolTable* symbolTable = other.symbolTable())
m_symbolTable.set(*m_vm, m_ownerExecutable.get(), symbolTable);
setNumParameters(other.numParameters());
optimizeAfterWarmUp();
jitAfterWarmUp();
......@@ -1527,6 +1531,13 @@ CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlin
{
ASSERT(m_heap->isDeferred());
if (SymbolTable* symbolTable = unlinkedCodeBlock->symbolTable()) {
if (codeType() == FunctionCode && symbolTable->captureCount())
m_symbolTable.set(*m_vm, m_ownerExecutable.get(), symbolTable->clone(*m_vm));
else
m_symbolTable.set(*m_vm, m_ownerExecutable.get(), symbolTable);
}
ASSERT(m_source);
setNumParameters(unlinkedCodeBlock->numParameters());
......@@ -2338,6 +2349,7 @@ void CodeBlock::stronglyVisitStrongReferences(SlotVisitor& visitor)
{
visitor.append(&m_globalObject);
visitor.append(&m_ownerExecutable);
visitor.append(&m_symbolTable);
visitor.append(&m_unlinkedCode);
if (m_rareData)
m_rareData->m_evalCodeCache.visitAggregate(visitor);
......
......@@ -722,7 +722,7 @@ public:
StringJumpTable& stringSwitchJumpTable(int tableIndex) { RELEASE_ASSERT(m_rareData); return m_rareData->m_stringSwitchJumpTables[tableIndex]; }
SymbolTable* symbolTable() const { return m_unlinkedCode->symbolTable(); }
SymbolTable* symbolTable() const { return m_symbolTable.get(); }
EvalCodeCache& evalCodeCache() { createRareDataIfNecessary(); return m_rareData->m_evalCodeCache; }
......@@ -1039,6 +1039,7 @@ private:
VM* m_vm;
RefCountedArray<Instruction> m_instructions;
WriteBarrier<SymbolTable> m_symbolTable;
VirtualRegister m_thisRegister;
VirtualRegister m_argumentsRegister;
VirtualRegister m_activationRegister;
......
......@@ -533,6 +533,11 @@ void FunctionExecutable::visitChildren(JSCell* cell, SlotVisitor& visitor)
visitor.append(&thisObject->m_unlinkedExecutable);
}
SymbolTable* FunctionExecutable::symbolTable(CodeSpecializationKind kind)
{
return codeBlockFor(kind)->symbolTable();
}
void FunctionExecutable::clearCodeIfNotCompiling()
{
if (isCompiling())
......
......@@ -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;
SymbolTable* symbolTable(CodeSpecializationKind kind) const { return m_unlinkedExecutable->symbolTable(kind); }
SymbolTable* symbolTable(CodeSpecializationKind);
void clearCodeIfNotCompiling();
void clearUnlinkedCodeForRecompilationIfNotCompiling();
......
......@@ -49,6 +49,7 @@ public:
static JSActivation* create(VM& vm, CallFrame* callFrame, Register* registers, CodeBlock* codeBlock)
{
SymbolTable* symbolTable = codeBlock->symbolTable();
ASSERT(codeBlock->codeType() == FunctionCode);
JSActivation* activation = new (
NotNull,
allocateCell<JSActivation>(
......
......@@ -109,5 +109,31 @@ SymbolTable::SymbolTable(VM& vm)
SymbolTable::~SymbolTable() { }
SymbolTable* SymbolTable::clone(VM& vm)
{
SymbolTable* result = SymbolTable::create(vm);
result->m_parameterCountIncludingThis = m_parameterCountIncludingThis;
result->m_usesNonStrictEval = m_usesNonStrictEval;
result->m_captureStart = m_captureStart;
result->m_captureEnd = m_captureEnd;
Map::iterator iter = m_map.begin();
Map::iterator end = m_map.end();
for (; iter != end; ++iter) {
result->m_map.add(
iter->key,
SymbolTableEntry(iter->value.getIndex(), iter->value.getAttributes()));
}
if (m_slowArguments) {
result->m_slowArguments = std::make_unique<SlowArgument[]>(parameterCount());
for (unsigned i = parameterCount(); i--;)
result->m_slowArguments[i] = m_slowArguments[i];
}
return result;
}
} // namespace JSC
......@@ -465,6 +465,8 @@ public:
// 0 if we don't capture any arguments; parameterCount() in length if we do.
const SlowArgument* slowArguments() { return m_slowArguments.get(); }
void setSlowArguments(std::unique_ptr<SlowArgument[]> slowArguments) { m_slowArguments = std::move(slowArguments); }
SymbolTable* clone(VM&);
DECLARE_EXPORT_INFO;
......
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