Bug 1315943 - Part 1.1: Use class static const for bitfield size. r=shu
authorTooru Fujisawa <arai_a@mac.com>
Thu, 10 Nov 2016 18:22:12 +0900
changeset 348659 9afc1d0229c76f3876972638bbe398a91385e241
parent 348658 10205a882c3c11cb74065e86d6727a0920276b35
child 348660 87a690e25827b4ce1cd8149c9e87893f6772420a
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1315943
milestone52.0a1
Bug 1315943 - Part 1.1: Use class static const for bitfield size. r=shu
js/src/jsscript.h
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1898,27 +1898,28 @@ class LazyScript : public gc::TenuredCel
     // Add padding so LazyScript is gc::Cell aligned. Make padding protected
     // instead of private to suppress -Wunused-private-field compiler warnings.
   protected:
 #if JS_BITS_PER_WORD == 32
     uint32_t padding;
 #endif
 
   private:
+    static const uint32_t NumClosedOverBindingsBits = 21;
+    static const uint32_t NumInnerFunctionsBits = 20;
+
     struct PackedView {
         // Assorted bits that should really be in ScriptSourceObject.
         uint32_t version : 8;
 
         uint32_t shouldDeclareArguments : 1;
         uint32_t hasThisBinding : 1;
         uint32_t isAsync : 1;
-        // The number of bits should match to NumClosedOverBindingsLimit.
-        uint32_t numClosedOverBindings : 21;
-        // The number of bits should match to NumInnerFunctionsLimit.
-        uint32_t numInnerFunctions : 20;
+        uint32_t numClosedOverBindings : NumClosedOverBindingsBits;
+        uint32_t numInnerFunctions : NumInnerFunctionsBits;
 
         uint32_t generatorKindBits : 2;
 
         // N.B. These are booleans but need to be uint32_t to pack correctly on MSVC.
         // If you add another boolean here, make sure to initialze it in
         // LazyScript::CreateRaw().
         uint32_t strict : 1;
         uint32_t bindingsAccessedDynamically : 1;
@@ -1948,18 +1949,18 @@ class LazyScript : public gc::TenuredCel
     // Create a LazyScript without initializing the closedOverBindings and the
     // innerFunctions. To be GC-safe, the caller must initialize both vectors
     // with valid atoms and functions.
     static LazyScript* CreateRaw(ExclusiveContext* cx, HandleFunction fun,
                                  uint64_t packedData, uint32_t begin, uint32_t end,
                                  uint32_t lineno, uint32_t column);
 
   public:
-    static const uint32_t NumClosedOverBindingsLimit = 1 << 21;
-    static const uint32_t NumInnerFunctionsLimit = 1 << 20;
+    static const uint32_t NumClosedOverBindingsLimit = 1 << NumClosedOverBindingsBits;
+    static const uint32_t NumInnerFunctionsLimit = 1 << NumInnerFunctionsBits;
 
     // Create a LazyScript and initialize closedOverBindings and innerFunctions
     // with the provided vectors.
     static LazyScript* Create(ExclusiveContext* cx, HandleFunction fun,
                               const frontend::AtomVector& closedOverBindings,
                               Handle<GCVector<JSFunction*, 8>> innerFunctions,
                               JSVersion version, uint32_t begin, uint32_t end,
                               uint32_t lineno, uint32_t column);