Bug 1537908 part 1 - Clean up BytecodeEmitter's TypeSet count a bit. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 26 Apr 2019 09:16:32 +0000
changeset 530281 f35cf62b01a185a3cf8120ac340a347bb23dccf0
parent 530280 658653e0290cb28bb431e0947f629d39d4f9a34c
child 530282 39133aa95fce7f894c55ace40c778983c8ca26bf
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1537908
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 1537908 part 1 - Clean up BytecodeEmitter's TypeSet count a bit. r=tcampbell This makes the naming more consistent. Also, instead of checking against JSScript::MaxBytecodeTypeSets at every JOF_TYPESET op, we can move this condition to SharedScriptData creation if we use uint32_t instead of uint16_t. This is more efficient and also nicer because MaxBytecodeTypeSets seems to be more of a JSScript implementation detail the bytecode emitter doesn't need to worry about. Differential Revision: https://phabricator.services.mozilla.com/D28449
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
@@ -235,23 +235,21 @@ 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 (bytecodeSection().typesetCount() < JSScript::MaxBytecodeTypeSets) {
-      bytecodeSection().addTypesetCount();
-    }
+    bytecodeSection().incrementNumTypeSets();
   }
 
   if (BytecodeOpHasIC(op)) {
-    bytecodeSection().addNumICEntries();
+    bytecodeSection().incrementNumICEntries();
   }
 
   return true;
 }
 
 void BytecodeEmitter::BytecodeSection::updateDepth(ptrdiff_t target) {
   jsbytecode* pc = code(target);
 
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -219,21 +219,21 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
     bool isDuplicateLocation() const {
       return lastSeparatorLine_ == currentLine_ &&
              lastSeparatorColumn_ == lastColumn_;
     }
 
     // ---- JIT ----
 
     size_t numICEntries() const { return numICEntries_; }
-    void addNumICEntries() { numICEntries_++; }
+    void incrementNumICEntries() { numICEntries_++; }
     void setNumICEntries(size_t entries) { numICEntries_ = entries; }
 
-    uint16_t typesetCount() const { return typesetCount_; }
-    void addTypesetCount() { typesetCount_++; }
+    uint32_t numTypeSets() const { return numTypeSets_; }
+    void incrementNumTypeSets() { numTypeSets_++; }
 
    private:
     // ---- Bytecode ----
 
     // Bytecode.
     BytecodeVector code_;
 
     // ---- Source notes ----
@@ -301,17 +301,17 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
     uint32_t lastSeparatorColumn_ = 0;
 
     // ---- JIT ----
 
     // Number of JOF_IC opcodes emitted.
     size_t numICEntries_ = 0;
 
     // Number of JOF_TYPESET opcodes generated.
-    uint16_t typesetCount_ = 0;
+    uint32_t numTypeSets_ = 0;
   };
 
   BytecodeSection bytecodeSection_;
 
  public:
   BytecodeSection& bytecodeSection() { return bytecodeSection_; }
   const BytecodeSection& bytecodeSection() const { return bytecodeSection_; }
 
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -4520,17 +4520,19 @@ bool JSScript::hasBreakpointsAt(jsbyteco
 
   js::SharedScriptData* data = script->scriptData_;
 
   // Initialize POD fields
   data->mainOffset = bce->mainOffset();
   data->nfixed = bce->maxFixedSlots;
   data->nslots = nslots;
   data->bodyScopeIndex = bce->bodyScopeIndex;
-  data->numBytecodeTypeSets = bce->bytecodeSection().typesetCount();
+  data->numBytecodeTypeSets =
+      std::min<uint32_t>(uint32_t(JSScript::MaxBytecodeTypeSets),
+                         bce->bytecodeSection().numTypeSets());
 
   if (bce->sc->isFunctionBox()) {
     data->funLength = bce->sc->asFunctionBox()->length;
   }
 
   // Initialize trailing arrays
   std::copy_n(bce->bytecodeSection().code().begin(), codeLength, data->code());
   bce->copySrcNotes(data->notes(), noteLength);