Title: [179746] trunk/Source/_javascript_Core
- Revision
- 179746
- Author
- [email protected]
- Date
- 2015-02-06 08:04:39 -0800 (Fri, 06 Feb 2015)
Log Message
Remove BytecodeGenerator::preserveLastVar() and replace it with a more robust mechanism for preserving non-temporary registers
https://bugs.webkit.org/show_bug.cgi?id=141211
Reviewed by Mark Lam.
Previously, the way non-temporary registers were preserved (i.e. not reclaimed anytime
we did newTemporary()) by calling preserveLastVar() after all non-temps are created. It
would raise the refcount on the last (highest-numbered) variable created, and rely on
the fact that register reclamation started at higher-numbered registers and worked its
way down. So any retained register would block any lower-numbered registers from being
reclaimed.
Also, preserveLastVar() sets a thing called m_firstConstantIndex. It's unused.
This removes preserveLastVar() and makes addVar() retain each register it creates. This
is more explicit, since addVar() is the mechanism for creating non-temporary registers.
To make this work I had to remove an assertion that Register::setIndex() can only be
called when the refcount is zero. This method might be called after a var is created to
change its index. This previously worked because preserveLastVar() would be called after
we had already made all index changes, so the vars would still have refcount zero. Now
they have refcount 1. I think it's OK to lose this assertion; I can't remember this
assertion ever firing in a way that alerted me to a serious issue.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::preserveLastVar): Deleted.
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::addVar):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::setIndex):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (179745 => 179746)
--- trunk/Source/_javascript_Core/ChangeLog 2015-02-06 14:50:20 UTC (rev 179745)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-02-06 16:04:39 UTC (rev 179746)
@@ -1,3 +1,37 @@
+2015-02-04 Filip Pizlo <[email protected]>
+
+ Remove BytecodeGenerator::preserveLastVar() and replace it with a more robust mechanism for preserving non-temporary registers
+ https://bugs.webkit.org/show_bug.cgi?id=141211
+
+ Reviewed by Mark Lam.
+
+ Previously, the way non-temporary registers were preserved (i.e. not reclaimed anytime
+ we did newTemporary()) by calling preserveLastVar() after all non-temps are created. It
+ would raise the refcount on the last (highest-numbered) variable created, and rely on
+ the fact that register reclamation started at higher-numbered registers and worked its
+ way down. So any retained register would block any lower-numbered registers from being
+ reclaimed.
+
+ Also, preserveLastVar() sets a thing called m_firstConstantIndex. It's unused.
+
+ This removes preserveLastVar() and makes addVar() retain each register it creates. This
+ is more explicit, since addVar() is the mechanism for creating non-temporary registers.
+
+ To make this work I had to remove an assertion that Register::setIndex() can only be
+ called when the refcount is zero. This method might be called after a var is created to
+ change its index. This previously worked because preserveLastVar() would be called after
+ we had already made all index changes, so the vars would still have refcount zero. Now
+ they have refcount 1. I think it's OK to lose this assertion; I can't remember this
+ assertion ever firing in a way that alerted me to a serious issue.
+
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::BytecodeGenerator):
+ (JSC::BytecodeGenerator::preserveLastVar): Deleted.
+ * bytecompiler/BytecodeGenerator.h:
+ (JSC::BytecodeGenerator::addVar):
+ * bytecompiler/RegisterID.h:
+ (JSC::RegisterID::setIndex):
+
2015-02-06 Andreas Kling <[email protected]>
Remove WTF::fastMallocGoodSize().
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (179745 => 179746)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2015-02-06 14:50:20 UTC (rev 179745)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2015-02-06 16:04:39 UTC (rev 179746)
@@ -151,12 +151,6 @@
return true;
}
-void BytecodeGenerator::preserveLastVar()
-{
- if ((m_firstConstantIndex = m_calleeRegisters.size()) != 0)
- m_lastVar = &m_calleeRegisters.last();
-}
-
BytecodeGenerator::BytecodeGenerator(VM& vm, ProgramNode* programNode, UnlinkedProgramCodeBlock* codeBlock, DebuggerMode debuggerMode, ProfilerMode profilerMode)
: m_shouldEmitDebugHooks(Options::forceDebuggerBytecodeGeneration() || debuggerMode == DebuggerOn)
, m_shouldEmitProfileHooks(Options::forceProfilerBytecodeGeneration() || profilerMode == ProfilerOn)
@@ -428,7 +422,6 @@
}
addParameter(simpleParameter->boundProperty(), index);
}
- preserveLastVar();
// We declare the callee's name last because it should lose to a var, function, and/or parameter declaration.
addCallee(functionNode, calleeRegister);
@@ -493,7 +486,6 @@
variables.append(varStack[i].first);
}
codeBlock->adoptVariables(variables);
- preserveLastVar();
}
BytecodeGenerator::~BytecodeGenerator()
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (179745 => 179746)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2015-02-06 14:50:20 UTC (rev 179745)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2015-02-06 16:04:39 UTC (rev 179746)
@@ -630,7 +630,10 @@
RegisterID* addVar()
{
++m_codeBlock->m_numVars;
- return newRegister();
+ RegisterID* result = newRegister();
+ ASSERT(VirtualRegister(result->index()).toLocal() == m_codeBlock->m_numVars - 1);
+ result->ref(); // We should never free this slot.
+ return result;
}
// Returns the index of the added var.
@@ -777,7 +780,6 @@
SegmentedVector<RegisterID, 32> m_parameters;
SegmentedVector<Label, 32> m_labels;
LabelScopeStore m_labelScopes;
- RefPtr<RegisterID> m_lastVar;
int m_finallyDepth;
int m_localScopeDepth;
CodeType m_codeType;
@@ -791,7 +793,6 @@
Vector<TryRange> m_tryRanges;
SegmentedVector<TryData, 8> m_tryData;
- int m_firstConstantIndex;
int m_nextConstantOffset;
int m_firstLazyFunction;
Modified: trunk/Source/_javascript_Core/bytecompiler/RegisterID.h (179745 => 179746)
--- trunk/Source/_javascript_Core/bytecompiler/RegisterID.h 2015-02-06 14:50:20 UTC (rev 179745)
+++ trunk/Source/_javascript_Core/bytecompiler/RegisterID.h 2015-02-06 16:04:39 UTC (rev 179746)
@@ -70,7 +70,6 @@
void setIndex(int index)
{
- ASSERT(!m_refCount);
#ifndef NDEBUG
m_didSetIndex = true;
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes