Source/JavaScriptCore/ChangeLog

 12015-02-04 Filip Pizlo <fpizlo@apple.com>
 2
 3 Remove BytecodeGenerator::preserveLastVar() and replace it with a more robust mechanism for preserving non-temporary registers
 4 https://bugs.webkit.org/show_bug.cgi?id=141211
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Previously, the way non-temporary registers were preserved (i.e. not reclaimed anytime
 9 we did newTemporary()) by calling preserveLastVar() after all non-temps are created. It
 10 would raise the refcount on the last (highest-numbered) variable created, and rely on
 11 the fact that register reclamation started at higher-numbered registers and worked its
 12 way down. So any retained register would block any lower-numbered registers from being
 13 reclaimed.
 14
 15 Also, preserveLastVar() sets a thing called m_firstConstantIndex. It's unused.
 16
 17 This removes preserveLastVar() and makes addVar() retain each register it creates. This
 18 is more explicit, since addVar() is the mechanism for creating non-temporary registers.
 19
 20 To make this work I had to remove an assertion that Register::setIndex() can only be
 21 called when the refcount is zero. This method might be called after a var is created to
 22 change its index. This previously worked because preserveLastVar() would be called after
 23 we had already made all index changes, so the vars would still have refcount zero. Now
 24 they have refcount 1. I think it's OK to lose this assertion; I can't remember this
 25 assertion ever firing in a way that alerted me to a serious issue.
 26
 27 * bytecompiler/BytecodeGenerator.cpp:
 28 (JSC::BytecodeGenerator::BytecodeGenerator):
 29 (JSC::BytecodeGenerator::preserveLastVar): Deleted.
 30 * bytecompiler/BytecodeGenerator.h:
 31 (JSC::BytecodeGenerator::addVar):
 32 * bytecompiler/RegisterID.h:
 33 (JSC::RegisterID::setIndex):
 34
 352015-02-03 Filip Pizlo <fpizlo@apple.com>
 36
 37 Reviewed by NOBODY (OOPS!).
 38
 39 Also removes the localArgumentsRegister local variable in BytecodeGenerator's
 40 constructor. It's not used.
 41
 42 * bytecompiler/BytecodeGenerator.cpp:
 43 (JSC::BytecodeGenerator::BytecodeGenerator):
 44 (JSC::BytecodeGenerator::preserveLastVar): Deleted.
 45 * bytecompiler/BytecodeGenerator.h:
 46 (JSC::BytecodeGenerator::addVar):
 47
1482015-02-04 Chris Dumez <cdumez@apple.com>
249
350 Add removeFirst(value) / removeAll(value) methods to WTF::Vector
179602

Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

@@bool BytecodeGenerator::addVar(
151151 return true;
152152}
153153
154 void BytecodeGenerator::preserveLastVar()
155 {
156  if ((m_firstConstantIndex = m_calleeRegisters.size()) != 0)
157  m_lastVar = &m_calleeRegisters.last();
158 }
159 
160154BytecodeGenerator::BytecodeGenerator(VM& vm, ProgramNode* programNode, UnlinkedProgramCodeBlock* codeBlock, DebuggerMode debuggerMode, ProfilerMode profilerMode)
161155 : m_shouldEmitDebugHooks(Options::forceDebuggerBytecodeGeneration() || debuggerMode == DebuggerOn)
162156 , m_shouldEmitProfileHooks(Options::forceProfilerBytecodeGeneration() || profilerMode == ProfilerOn)

@@BytecodeGenerator::BytecodeGenerator(VM&
428422 }
429423 addParameter(simpleParameter->boundProperty(), index);
430424 }
431  preserveLastVar();
432425
433426 // We declare the callee's name last because it should lose to a var, function, and/or parameter declaration.
434427 addCallee(functionNode, calleeRegister);

@@BytecodeGenerator::BytecodeGenerator(VM&
493486 variables.append(varStack[i].first);
494487 }
495488 codeBlock->adoptVariables(variables);
496  preserveLastVar();
497489}
498490
499491BytecodeGenerator::~BytecodeGenerator()
179533

Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

@@namespace JSC {
630630 RegisterID* addVar()
631631 {
632632 ++m_codeBlock->m_numVars;
633  return newRegister();
 633 RegisterID* result = newRegister();
 634 ASSERT(VirtualRegister(result->index()).toLocal() == m_codeBlock->m_numVars - 1);
 635 result->ref(); // We should never free this slot.
 636 return result;
634637 }
635638
636639 // Returns the index of the added var.

@@namespace JSC {
777780 SegmentedVector<RegisterID, 32> m_parameters;
778781 SegmentedVector<Label, 32> m_labels;
779782 LabelScopeStore m_labelScopes;
780  RefPtr<RegisterID> m_lastVar;
781783 int m_finallyDepth;
782784 int m_localScopeDepth;
783785 CodeType m_codeType;

@@namespace JSC {
791793 Vector<TryRange> m_tryRanges;
792794 SegmentedVector<TryData, 8> m_tryData;
793795
794  int m_firstConstantIndex;
795796 int m_nextConstantOffset;
796797
797798 int m_firstLazyFunction;
179533

Source/JavaScriptCore/bytecompiler/RegisterID.h

@@namespace JSC {
7070
7171 void setIndex(int index)
7272 {
73  ASSERT(!m_refCount);
7473#ifndef NDEBUG
7574 m_didSetIndex = true;
7675#endif
179533