Bug 1462544 - Use <algorithm> functions to fill and copy data in Bitmap.* rather than PodOperations.h functions. r=jandem
authorJeff Walden <jwalden@mit.edu>
Fri, 18 May 2018 11:44:44 -0700
changeset 418924 562e5ddb5332
parent 418923 63d37d73f5ae
child 418925 441f59473bfa
push id103419
push userjwalden@mit.edu
push dateFri, 18 May 2018 19:33:51 +0000
treeherdermozilla-inbound@7658d2d1e0d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1462544
milestone62.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 1462544 - Use <algorithm> functions to fill and copy data in Bitmap.* rather than PodOperations.h functions. r=jandem
js/src/ds/Bitmap.cpp
js/src/ds/Bitmap.h
--- a/js/src/ds/Bitmap.cpp
+++ b/js/src/ds/Bitmap.cpp
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ds/Bitmap.h"
 
+#include <algorithm>
+
 using namespace js;
 
 SparseBitmap::~SparseBitmap()
 {
     if (data.initialized()) {
         for (Data::Range r(data.all()); !r.empty(); r.popFront())
             js_delete(r.front().value());
     }
@@ -28,17 +30,17 @@ SparseBitmap::sizeOfExcludingThis(mozill
 SparseBitmap::BitBlock&
 SparseBitmap::createBlock(Data::AddPtr p, size_t blockId)
 {
     MOZ_ASSERT(!p);
     AutoEnterOOMUnsafeRegion oomUnsafe;
     BitBlock* block = js_new<BitBlock>();
     if (!block || !data.add(p, blockId, block))
         oomUnsafe.crash("Bitmap OOM");
-    PodZero(block);
+    std::fill(block->begin(), block->end(), 0);
     return *block;
 }
 
 bool
 SparseBitmap::getBit(size_t bit) const
 {
     size_t word = bit / JS_BITS_PER_WORD;
     size_t blockWord = blockStartWord(word);
--- a/js/src/ds/Bitmap.h
+++ b/js/src/ds/Bitmap.h
@@ -6,17 +6,16 @@
 
 #ifndef ds_Bitmap_h
 #define ds_Bitmap_h
 
 #include "mozilla/Array.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryChecking.h"
-#include "mozilla/PodOperations.h"
 
 #include <algorithm>
 #include <stddef.h>
 #include <stdint.h>
 
 #include "js/AllocPolicy.h"
 #include "js/HashTable.h"
 #include "js/Vector.h"
@@ -49,17 +48,19 @@ class DenseBitmap
     }
 
     size_t numWords() const { return data.length(); }
     uintptr_t word(size_t i) const { return data[i]; }
     uintptr_t& word(size_t i) { return data[i]; }
 
     void copyBitsFrom(size_t wordStart, size_t numWords, uintptr_t* source) {
         MOZ_ASSERT(wordStart + numWords <= data.length());
-        mozilla::PodCopy(&data[wordStart], source, numWords);
+        // Use std::copy and not std::copy_n because the former requires no
+        // overlap and so provides extra opportunity to optimize.
+        std::copy(source, source + numWords, &data[wordStart]);
     }
 
     void bitwiseOrRangeInto(size_t wordStart, size_t numWords, uintptr_t* target) const {
         for (size_t i = 0; i < numWords; i++)
             target[i] |= data[wordStart + i];
     }
 };