Bug 1442599 - Part 2: Replace bitmap macros with BitArrayElement functions. r=jorendorff
authorAndré Bargull <andre.bargull@gmail.com>
Thu, 15 Mar 2018 03:41:28 -0700
changeset 408310 593825fbb67430a901d6bdf0f6ec3e8f1264fe43
parent 408309 61ecd1a2547c53210a1bbeaef6c11fe866db909e
child 408311 12150eddce352b3cdc6473114e52035025cfa3ce
push id33634
push usercbrindusan@mozilla.com
push dateThu, 15 Mar 2018 23:37:18 +0000
treeherdermozilla-central@16e69d4df5dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1442599
milestone61.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 1442599 - Part 2: Replace bitmap macros with BitArrayElement functions. r=jorendorff
js/src/frontend/BytecodeEmitter.cpp
js/src/jsutil.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -4482,17 +4482,17 @@ BytecodeEmitter::emitSwitch(ParseNode* p
     CaseClause* firstCase = cases->pn_head ? &cases->pn_head->as<CaseClause>() : nullptr;
     if (caseCount == 0 ||
         (caseCount == 1 && (hasDefault = firstCase->isDefault())))
     {
         caseCount = 0;
         low = 0;
         high = -1;
     } else {
-        Vector<jsbitmap, 128, SystemAllocPolicy> intmap;
+        Vector<size_t, 128, SystemAllocPolicy> intmap;
         int32_t intmapBitLength = 0;
 
         low  = JSVAL_INT_MAX;
         high = JSVAL_INT_MIN;
 
         for (CaseClause* caseNode = firstCase; caseNode; caseNode = caseNode->next()) {
             if (caseNode->isDefault()) {
                 hasDefault = true;
@@ -4528,26 +4528,26 @@ BytecodeEmitter::emitSwitch(ParseNode* p
                 high = i;
 
             // Check for duplicates, which require a JSOP_CONDSWITCH.
             // We bias i by 65536 if it's negative, and hope that's a rare
             // case (because it requires a malloc'd bitmap).
             if (i < 0)
                 i += JS_BIT(16);
             if (i >= intmapBitLength) {
-                size_t newLength = (i / JS_BITMAP_NBITS) + 1;
+                size_t newLength = NumWordsForBitArrayOfLength(i + 1);
                 if (!intmap.resize(newLength))
                     return false;
-                intmapBitLength = newLength * JS_BITMAP_NBITS;
+                intmapBitLength = newLength * BitArrayElementBits;
             }
-            if (JS_TEST_BIT(intmap, i)) {
+            if (IsBitArrayElementSet(intmap.begin(), intmap.length(), i)) {
                 switchOp = JSOP_CONDSWITCH;
                 continue;
             }
-            JS_SET_BIT(intmap, i);
+            SetBitArrayElement(intmap.begin(), intmap.length(), i);
         }
 
         // Compute table length and select condswitch instead if overlarge or
         // more than half-sparse.
         if (switchOp == JSOP_TABLESWITCH) {
             tableLength = uint32_t(high - low + 1);
             if (tableLength >= JS_BIT(16) || tableLength > 2 * caseCount)
                 switchOp = JSOP_CONDSWITCH;
--- a/js/src/jsutil.h
+++ b/js/src/jsutil.h
@@ -367,26 +367,16 @@ JS_MeanAndStdDev(uint32_t num, double su
 extern void
 JS_DumpBasicStats(JSBasicStats* bs, const char* title, FILE* fp);
 extern void
 JS_DumpHistogram(JSBasicStats* bs, FILE* fp);
 #else
 # define JS_BASIC_STATS_ACCUM(bs,val)
 #endif
 
-/* A jsbitmap_t is a long integer that can be used for bitmaps. */
-typedef size_t jsbitmap;
-#define JS_BITMAP_NBITS (sizeof(jsbitmap) * CHAR_BIT)
-#define JS_TEST_BIT(_map,_bit)  ((_map)[(_bit)/JS_BITMAP_NBITS] &             \
-                                 (jsbitmap(1)<<((_bit)%JS_BITMAP_NBITS)))
-#define JS_SET_BIT(_map,_bit)   ((_map)[(_bit)/JS_BITMAP_NBITS] |=            \
-                                 (jsbitmap(1)<<((_bit)%JS_BITMAP_NBITS)))
-#define JS_CLEAR_BIT(_map,_bit) ((_map)[(_bit)/JS_BITMAP_NBITS] &=            \
-                                 ~(jsbitmap(1)<<((_bit)%JS_BITMAP_NBITS)))
-
 /* Wrapper for various macros to stop warnings coming from their expansions. */
 #if defined(__clang__)
 # define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr)                                \
     JS_BEGIN_MACRO                                                            \
         _Pragma("clang diagnostic push")                                      \
         /* If these _Pragmas cause warnings for you, try disabling ccache. */ \
         _Pragma("clang diagnostic ignored \"-Wunused-value\"")                \
         { expr; }                                                             \