Bug 1503170 part 3 - Remove unused CGResumeOffsetList::numAwaits, move numYields to BytecodeEmitter. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 02 Nov 2018 13:38:32 +0000
changeset 444141 71bab79a1a0afe4fb3a56373d745dc701c17d789
parent 444140 5e76645a4e5c2fadf34a3db208dd58906ec58140
child 444142 801cdde1f5973e7729f139d69ba1f13ca93e759a
push id34983
push usercsabou@mozilla.com
push dateFri, 02 Nov 2018 21:46:41 +0000
treeherdermozilla-central@e05552012e19 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1503170
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1503170 part 3 - Remove unused CGResumeOffsetList::numAwaits, move numYields to BytecodeEmitter. r=tcampbell Differential Revision: https://phabricator.services.mozilla.com/D10686
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/BytecodeEmitter.h
js/src/frontend/ForOfLoopControl.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -111,16 +111,17 @@ BytecodeEmitter::BytecodeEmitter(Bytecod
 #ifdef DEBUG
     unstableEmitterScope(false),
 #endif
     numberList(cx),
     scopeList(cx),
     tryNoteList(cx),
     scopeNoteList(cx),
     resumeOffsetList(cx),
+    numYields(0),
     typesetCount(0),
     hasSingletons(false),
     hasTryFinally(false),
     emittingRunOnceLambda(false),
     emitterMode(emitterMode),
     scriptStartOffsetSet(false),
     functionBodyEndPosSet(false)
 {
@@ -2214,21 +2215,18 @@ BytecodeEmitter::emitYieldOp(JSOp op)
 
     MOZ_ASSERT(op == JSOP_INITIALYIELD || op == JSOP_YIELD || op == JSOP_AWAIT);
 
     ptrdiff_t off;
     if (!emitN(op, 3, &off)) {
         return false;
     }
 
-
-    if (op == JSOP_AWAIT) {
-        resumeOffsetList.numAwaits++;
-    } else {
-        resumeOffsetList.numYields++;
+    if (op == JSOP_INITIALYIELD || op == JSOP_YIELD) {
+        numYields++;
     }
 
     uint32_t resumeIndex;
     if (!allocateResumeIndexForCurrentOffset(&resumeIndex)) {
         return false;
     }
 
     SET_UINT24(code(off), resumeIndex);
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -95,19 +95,17 @@ struct CGScopeNoteList {
                              uint32_t parent);
     void recordEnd(uint32_t index, uint32_t offset, bool inPrologue);
     size_t length() const { return list.length(); }
     void finish(mozilla::Span<ScopeNote> array, uint32_t prologueLength);
 };
 
 struct CGResumeOffsetList {
     Vector<uint32_t> list;
-    uint32_t numYields;
-    uint32_t numAwaits;
-    explicit CGResumeOffsetList(JSContext* cx) : list(cx), numYields(0), numAwaits(0) {}
+    explicit CGResumeOffsetList(JSContext* cx) : list(cx) {}
 
     MOZ_MUST_USE bool append(uint32_t offset) { return list.append(offset); }
     size_t length() const { return list.length(); }
     void finish(mozilla::Span<uint32_t> array, uint32_t prologueLength);
 };
 
 // Have a few inline elements, so as to avoid heap allocation for tiny
 // sequences.  See bug 1390526.
@@ -204,16 +202,19 @@ struct MOZ_STACK_CLASS BytecodeEmitter
 
     // Certain ops (yield, await, gosub) have an entry in the script's
     // resumeOffsets list. This can be used to map from the op's resumeIndex to
     // the bytecode offset of the next pc. This indirection makes it easy to
     // resume in the JIT (because BaselineScript stores a resumeIndex => native
     // code array).
     CGResumeOffsetList resumeOffsetList;
 
+    // Number of yield instructions emitted. Does not include JSOP_AWAIT.
+    uint32_t        numYields;
+
     uint16_t        typesetCount;   /* Number of JOF_TYPESET opcodes generated */
 
     bool            hasSingletons:1;    /* script contains singleton initializer JSOP_OBJECT */
 
     bool            hasTryFinally:1;    /* script contains finally block */
 
     bool            emittingRunOnceLambda:1; /* true while emitting a lambda which is only
                                                 expected to run once. */
--- a/js/src/frontend/ForOfLoopControl.cpp
+++ b/js/src/frontend/ForOfLoopControl.cpp
@@ -27,17 +27,17 @@ ForOfLoopControl::emitBeginCodeNeedingIt
 {
     tryCatch_.emplace(bce, TryEmitter::Kind::TryCatch, TryEmitter::ControlKind::NonSyntactic);
 
     if (!tryCatch_->emitTry()) {
         return false;
     }
 
     MOZ_ASSERT(numYieldsAtBeginCodeNeedingIterClose_ == UINT32_MAX);
-    numYieldsAtBeginCodeNeedingIterClose_ = bce->resumeOffsetList.numYields;
+    numYieldsAtBeginCodeNeedingIterClose_ = bce->numYields;
 
     return true;
 }
 
 bool
 ForOfLoopControl::emitEndCodeNeedingIteratorClose(BytecodeEmitter* bce)
 {
     if (!tryCatch_->emitCatch()) {            // ITER ...
@@ -81,17 +81,17 @@ ForOfLoopControl::emitEndCodeNeedingIter
 
     if (!bce->emit1(JSOP_THROW)) {            // ITER ...
         return false;
     }
 
     // If any yields were emitted, then this for-of loop is inside a star
     // generator and must handle the case of Generator.return. Like in
     // yield*, it is handled with a finally block.
-    uint32_t numYieldsEmitted = bce->resumeOffsetList.numYields;
+    uint32_t numYieldsEmitted = bce->numYields;
     if (numYieldsEmitted > numYieldsAtBeginCodeNeedingIterClose_) {
         if (!tryCatch_->emitFinally()) {
             return false;
         }
 
         InternalIfEmitter ifGeneratorClosing(bce);
         if (!bce->emit1(JSOP_ISGENCLOSING)) { // ITER ... FTYPE FVALUE CLOSING
             return false;