Bug 1535994 - Part 10: Move JIT information to BytecodeSection class. r=jorendorff
authorTooru Fujisawa <arai_a@mac.com>
Tue, 02 Apr 2019 18:21:07 +0900
changeset 468821 ab95e8d9d3002ef0ffd3b24a8c94db13094196f9
parent 468820 c05f903f3bfdd0d7a5c9c0350d0a0a7690cb0302
child 468822 ced956a624de1e59f318bb124c79417068fecd10
push id35851
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 21:56:12 +0000
treeherdermozilla-central@30ca3c3abfe6 [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());