Commit 6962a520 authored by barraclough@apple.com's avatar barraclough@apple.com

Don't leak registers for redeclared variables

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

Reviewed by Geoff Garen.

We currently always allocate registers for new global variables, but these are wasted when the variable is being redeclared.
Only allocate new registers when necessary.

No performance impact.

* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
* runtime/Executable.cpp:
(JSC::ProgramExecutable::initializeGlobalProperties):
    - Don't allocate the register here.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::addGlobalVar):
    - Allocate the register here instead.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3e8b8d11
2013-08-22 Gavin Barraclough <barraclough@apple.com>
Don't leak registers for redeclared variables
https://bugs.webkit.org/show_bug.cgi?id=120174
Reviewed by Geoff Garen.
We currently always allocate registers for new global variables, but these are wasted when the variable is being redeclared.
Only allocate new registers when necessary.
No performance impact.
* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
* runtime/Executable.cpp:
(JSC::ProgramExecutable::initializeGlobalProperties):
- Don't allocate the register here.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::addGlobalVar):
- Allocate the register here instead.
2013-08-22 Gavin Barraclough <barraclough@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=120128
......
......@@ -735,7 +735,6 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, J
JSONPPath.swap(JSONPData[entry].m_path);
JSValue JSONPValue = JSONPData[entry].m_value.get();
if (JSONPPath.size() == 1 && JSONPPath[0].m_type == JSONPPathEntryTypeDeclare) {
globalObject->addRegisters(1);
globalObject->addVar(callFrame, JSONPPath[0].m_pathEntryName);
PutPropertySlot slot;
globalObject->methodTable()->put(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, slot);
......
......@@ -390,10 +390,6 @@ JSObject* ProgramExecutable::initializeGlobalProperties(VM& vm, CallFrame* callF
const UnlinkedProgramCodeBlock::VariableDeclations& variableDeclarations = unlinkedCode->variableDeclarations();
const UnlinkedProgramCodeBlock::FunctionDeclations& functionDeclarations = unlinkedCode->functionDeclarations();
size_t newGlobals = variableDeclarations.size() + functionDeclarations.size();
if (!newGlobals)
return 0;
globalObject->addRegisters(newGlobals);
CallFrame* globalExec = globalObject->globalExec();
for (size_t i = 0; i < functionDeclarations.size(); ++i) {
......
......@@ -186,7 +186,9 @@ int JSGlobalObject::addGlobalVar(const Identifier& ident, ConstantMode constantM
if (functionMode == IsFunctionToSpecialize)
newEntry.attemptToWatch();
SymbolTable::Map::AddResult result = symbolTable()->add(locker, ident.impl(), newEntry);
if (!result.isNewEntry) {
if (result.isNewEntry)
addRegisters(1);
else {
result.iterator->value.notifyWrite();
index = result.iterator->value.getIndex();
}
......
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