Bug 1535994 - Part 10: Move JIT information to BytecodeSection class. r=jorendorff
☠☠ backed out by 7fb3acf38591 ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Wed, 10 Apr 2019 08:27:54 +0000
changeset 468767 e56d1810fb40cb7f3e312a55ebdfcd88bb4ef7b9
parent 468766 fdd1177e499a08b4cde3e80992e288e5ee8084d5
child 468768 d5975f907521e4a5fe727cd52e3799b60b97beb7
push id112755
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 22:06:41 +0000
treeherdermozilla-inbound@606f85641d0b [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 10: Move JIT information to BytecodeSection class. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D25740
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
@@ -121,17 +121,17 @@ BytecodeEmitter::BytecodeEmitter(
       currentLine_(lineNum),
       fieldInitializers_(fieldInitializers),
       firstLine(lineNum),
       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;
+    bytecodeSection().setNumICEntries(sc->asFunctionBox()->function()->nargs() + 1);
   }
 }
 
 BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent,
                                  BCEParserHandle* handle, SharedContext* sc,
                                  HandleScript script,
                                  Handle<LazyScript*> lazyScript,
                                  uint32_t lineNum, EmitterMode emitterMode,
@@ -238,23 +238,23 @@ bool BytecodeEmitter::emitCheck(JSOp op,
   if (!bytecodeSection().code().growByUninitialized(delta)) {
     ReportOutOfMemory(cx);
     return false;
   }
 
   // If op is JOF_TYPESET (see the type barriers comment in TypeInference.h),
   // reserve a type set to store its result.
   if (CodeSpec[op].format & JOF_TYPESET) {
-    if (typesetCount < JSScript::MaxBytecodeTypeSets) {
-      typesetCount++;
+    if (bytecodeSection().typesetCount() < JSScript::MaxBytecodeTypeSets) {
+      bytecodeSection().addTypesetCount();
     }
   }
 
   if (BytecodeOpHasIC(op)) {
-    numICEntries++;
+    bytecodeSection().addNumICEntries();
   }
 
   return true;
 }
 
 void BytecodeEmitter::BytecodeSection::updateDepth(ptrdiff_t target) {
   jsbytecode* pc = code(target);
 
@@ -356,17 +356,17 @@ bool BytecodeEmitter::emitN(JSOp op, siz
     *offset = off;
   }
   return true;
 }
 
 bool BytecodeEmitter::emitJumpTargetOp(JSOp op, ptrdiff_t* off) {
   MOZ_ASSERT(BytecodeIsJumpTarget(op));
 
-  size_t numEntries = numICEntries;
+  size_t numEntries = bytecodeSection().numICEntries();
   if (MOZ_UNLIKELY(numEntries > UINT32_MAX)) {
     reportError(nullptr, JSMSG_NEED_DIET, js_script_str);
     return false;
   }
 
   if (!emitN(op, CodeSpec[op].length - 1, off)) {
     return false;
   }
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -188,16 +188,25 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
     CGResumeOffsetList& resumeOffsetList() { return resumeOffsetList_; }
     const CGResumeOffsetList& resumeOffsetList() const {
       return resumeOffsetList_;
     }
 
     uint32_t numYields() const { return numYields_; }
     void addNumYields() { numYields_++; }
 
+    // ---- JIT ----
+
+    size_t numICEntries() const { return numICEntries_; }
+    void addNumICEntries() { numICEntries_++; }
+    void setNumICEntries(size_t entries) { numICEntries_ = entries; }
+
+    uint16_t typesetCount() const { return typesetCount_; }
+    void addTypesetCount() { typesetCount_++; }
+
    private:
     // ---- Bytecode ----
 
     // Bytecode.
     BytecodeVector code_;
 
     // ---- Source notes ----
 
@@ -236,16 +245,24 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
     // 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_ = 0;
+
+    // ---- JIT ----
+
+    // Number of JOF_IC opcodes emitted.
+    size_t numICEntries_ = 0;
+
+    // Number of JOF_TYPESET opcodes generated.
+    uint16_t typesetCount_ = 0;
   };
 
   BytecodeSection bytecodeSection_;
 
  public:
   BytecodeSection& bytecodeSection() { return bytecodeSection_; }
   const BytecodeSection& bytecodeSection() const { return bytecodeSection_; }
 
@@ -353,22 +370,16 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
   EmitterScope* innermostEmitterScope() const {
     MOZ_ASSERT(!unstableEmitterScope);
     return innermostEmitterScopeNoCheck();
   }
   EmitterScope* innermostEmitterScopeNoCheck() const {
     return innermostEmitterScope_;
   }
 
-  // Number of JOF_IC opcodes emitted.
-  size_t numICEntries = 0;
-
-  // Number of JOF_TYPESET opcodes generated.
-  uint16_t typesetCount = 0;
-
   // Script contains singleton initializer JSOP_OBJECT.
   bool hasSingletons = false;
 
   // Script contains finally block.
   bool hasTryFinally = false;
 
   // True while emitting a lambda which is only expected to run once.
   bool emittingRunOnceLambda = false;
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -3577,17 +3577,17 @@ bool JSScript::fullyInitFromEmitter(JSCo
   }
 
   // Initialize POD fields
   script->lineno_ = bce->firstLine;
   script->mainOffset_ = bce->mainOffset();
   script->nfixed_ = bce->maxFixedSlots;
   script->nslots_ = nslots;
   script->bodyScopeIndex_ = bce->bodyScopeIndex;
-  script->numBytecodeTypeSets_ = bce->typesetCount;
+  script->numBytecodeTypeSets_ = bce->bytecodeSection().typesetCount();
 
   // Initialize script flags from BytecodeEmitter
   script->setFlag(ImmutableFlags::Strict, bce->sc->strict());
   script->setFlag(ImmutableFlags::BindingsAccessedDynamically,
                   bce->sc->bindingsAccessedDynamically());
   script->setFlag(ImmutableFlags::HasSingletons, bce->hasSingletons);
   script->setFlag(ImmutableFlags::IsForEval, bce->sc->isEvalContext());
   script->setFlag(ImmutableFlags::IsModule, bce->sc->isModuleContext());