Bug 924393 - don't use JS_BITS_PER_WORD in BitArray.h; r=Waldo

This commit is contained in:
Nathan Froyd 2013-10-08 09:54:50 -04:00
parent 763ff26d42
commit 92d4df75b8

View File

@ -9,6 +9,8 @@
#include "mozilla/TemplateLib.h"
#include <limits.h>
#include "jstypes.h"
namespace js {
@ -16,8 +18,9 @@ namespace js {
template <size_t nbits>
class BitArray {
private:
static const size_t bitsPerElement = sizeof(uintptr_t) * CHAR_BIT;
static const size_t numSlots =
nbits / JS_BITS_PER_WORD + (nbits % JS_BITS_PER_WORD == 0 ? 0 : 1);
nbits / bitsPerElement + (nbits % bitsPerElement == 0 ? 0 : 1);
uintptr_t map[numSlots];
public:
@ -54,8 +57,10 @@ class BitArray {
private:
inline void getMarkWordAndMask(size_t offset,
uintptr_t *indexp, uintptr_t *maskp) const {
*indexp = offset >> mozilla::tl::FloorLog2<JS_BITS_PER_WORD>::value;
*maskp = uintptr_t(1) << (offset & (JS_BITS_PER_WORD - 1));
static_assert(bitsPerElement == 32 || bitsPerElement == 64,
"unexpected bitsPerElement value");
*indexp = offset / bitsPerElement;
*maskp = uintptr_t(1) << (offset % bitsPerElement);
}
};