Bug 1535994 - Part 5: Move tryNodeList to BytecodeSection class. r=jorendorff
☠☠ backed out by 7fb3acf38591 ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Wed, 10 Apr 2019 08:26:52 +0000
changeset 468740 7c763b9a2118ade0f7b0e372da562e415679c610
parent 468739 4f5084424c22603d3d6f87e9d283c6bf4421558f
child 468741 8a480b0bbd0565adc7dfac295f6cac482e4d3350
push id35850
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 21:52:56 +0000
treeherdermozilla-central@9d3dbe3fef26 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1535994
milestone68.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 1535994 - Part 5: Move tryNodeList to BytecodeSection class. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D25735
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/BytecodeEmitter.h
js/src/vm/JSScript.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -87,17 +87,17 @@ static bool ParseNodeRequiresSpecialLine
   // Functions usually shouldn't have location information (bug 1431202).
 
   ParseNodeKind kind = pn->getKind();
   return kind == ParseNodeKind::WhileStmt || kind == ParseNodeKind::ForStmt ||
          kind == ParseNodeKind::Function;
 }
 
 BytecodeEmitter::BytecodeSection::BytecodeSection(JSContext* cx)
-    : code_(cx), notes_(cx) {}
+    : code_(cx), notes_(cx), tryNoteList_(cx) {}
 
 BytecodeEmitter::BytecodeEmitter(
     BytecodeEmitter* parent, SharedContext* sc, HandleScript script,
     Handle<LazyScript*> lazyScript, uint32_t lineNum, EmitterMode emitterMode,
     FieldInitializers fieldInitializers /* = FieldInitializers::Invalid() */)
     : sc(sc),
       cx(sc->cx_),
       parent(parent),
@@ -105,17 +105,16 @@ BytecodeEmitter::BytecodeEmitter(
       lazyScript(cx, lazyScript),
       bytecodeSection_(cx),
       currentLine_(lineNum),
       fieldInitializers_(fieldInitializers),
       atomIndices(cx->frontendCollectionPool()),
       firstLine(lineNum),
       numberList(cx),
       scopeList(cx),
-      tryNoteList(cx),
       scopeNoteList(cx),
       resumeOffsetList(cx),
       emitterMode(emitterMode) {
   MOZ_ASSERT_IF(emitterMode == LazyFunction, lazyScript);
 
   if (sc->isFunctionBox()) {
     // Functions have IC entries for type monitoring |this| and arguments.
     numICEntries = sc->asFunctionBox()->function()->nargs() + 1;
@@ -9336,17 +9335,17 @@ static bool AllocSrcNote(JSContext* cx, 
 
   *index = notes.length() - 1;
   return true;
 }
 
 bool BytecodeEmitter::addTryNote(JSTryNoteKind kind, uint32_t stackDepth,
                                  size_t start, size_t end) {
   MOZ_ASSERT(!inPrologue());
-  return tryNoteList.append(kind, stackDepth, start, end);
+  return bytecodeSection().tryNoteList().append(kind, stackDepth, start, end);
 }
 
 bool BytecodeEmitter::newSrcNote(SrcNoteType type, unsigned* indexp) {
   // Prologue shouldn't have source notes.
   MOZ_ASSERT(!inPrologue());
   SrcNotesVector& notes = bytecodeSection().notes();
   unsigned index;
   if (!AllocSrcNote(cx, notes, &index)) {
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -168,16 +168,21 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
 
     int32_t stackDepth() const { return stackDepth_; }
     void setStackDepth(int32_t depth) { stackDepth_ = depth; }
 
     uint32_t maxStackDepth() const { return maxStackDepth_; }
 
     void updateDepth(ptrdiff_t target);
 
+    // ---- Try notes ----
+
+    CGTryNoteList& tryNoteList() { return tryNoteList_; };
+    const CGTryNoteList& tryNoteList() const { return tryNoteList_; };
+
    private:
     // ---- Bytecode ----
 
     // Bytecode.
     BytecodeVector code_;
 
     // ---- Source notes ----
 
@@ -194,16 +199,21 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
 
     // ---- Stack ----
 
     // Maximum number of expression stack slots so far.
     uint32_t maxStackDepth_ = 0;
 
     // Current stack depth in script frame.
     int32_t stackDepth_ = 0;
+
+    // ---- Try notes ----
+
+    // List of emitted try notes.
+    CGTryNoteList tryNoteList_;
   };
 
   BytecodeSection bytecodeSection_;
 
  public:
   BytecodeSection& bytecodeSection() { return bytecodeSection_; }
   const BytecodeSection& bytecodeSection() const { return bytecodeSection_; }
 
@@ -264,17 +274,16 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
   }
   EmitterScope* innermostEmitterScopeNoCheck() const {
     return innermostEmitterScope_;
   }
 
   CGNumberList numberList;       /* double and bigint values used by script */
   CGObjectList objectList;       /* list of emitted objects */
   CGScopeList scopeList;         /* list of emitted scopes */
-  CGTryNoteList tryNoteList;     /* list of emitted try notes */
   CGScopeNoteList scopeNoteList; /* list of emitted block scope notes */
 
   // 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;
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -3236,17 +3236,17 @@ PrivateScriptData* PrivateScriptData::ne
                                      nscopenotes, nresumeoffsets);
 }
 
 /* static */ bool PrivateScriptData::InitFromEmitter(
     JSContext* cx, js::HandleScript script, frontend::BytecodeEmitter* bce) {
   uint32_t nscopes = bce->scopeList.length();
   uint32_t nconsts = bce->numberList.length();
   uint32_t nobjects = bce->objectList.length;
-  uint32_t ntrynotes = bce->tryNoteList.length();
+  uint32_t ntrynotes = bce->bytecodeSection().tryNoteList().length();
   uint32_t nscopenotes = bce->scopeNoteList.length();
   uint32_t nresumeoffsets = bce->resumeOffsetList.length();
 
   // Create and initialize PrivateScriptData
   if (!JSScript::createPrivateScriptData(cx, script, nscopes, nconsts, nobjects,
                                          ntrynotes, nscopenotes,
                                          nresumeoffsets)) {
     return false;
@@ -3258,17 +3258,17 @@ PrivateScriptData* PrivateScriptData::ne
   }
   if (nconsts) {
     bce->numberList.finish(data->consts());
   }
   if (nobjects) {
     bce->objectList.finish(data->objects());
   }
   if (ntrynotes) {
-    bce->tryNoteList.finish(data->tryNotes());
+    bce->bytecodeSection().tryNoteList().finish(data->tryNotes());
   }
   if (nscopenotes) {
     bce->scopeNoteList.finish(data->scopeNotes());
   }
   if (nresumeoffsets) {
     bce->resumeOffsetList.finish(data->resumeOffsets());
   }