Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (289171 => 289172)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2022-02-06 19:00:10 UTC (rev 289171)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2022-02-06 19:17:26 UTC (rev 289172)
@@ -52,7 +52,7 @@
const ASCIILiteral RestrictedPropertyAccessError { "'arguments', 'callee', and 'caller' cannot be accessed in this context."_s };
template<unsigned charactersCount>
-static Bitmap<256> makeCharacterBitmap(const char (&characters)[charactersCount])
+static constexpr Bitmap<256> makeCharacterBitmap(const char (&characters)[charactersCount])
{
static_assert(charactersCount > 0, "Since string literal is null terminated, characterCount is always larger than 0");
Bitmap<256> bitmap;
@@ -544,7 +544,7 @@
JSC_DEFINE_HOST_FUNCTION(globalFuncDecodeURI, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
- static const Bitmap<256> doNotUnescapeWhenDecodingURI = makeCharacterBitmap(
+ static constexpr auto doNotUnescapeWhenDecodingURI = makeCharacterBitmap(
"#$&+,/:;=?@"
);
@@ -553,13 +553,13 @@
JSC_DEFINE_HOST_FUNCTION(globalFuncDecodeURIComponent, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
- static const Bitmap<256> emptyBitmap;
+ static constexpr auto emptyBitmap;
return JSValue::encode(decode(globalObject, callFrame->argument(0), emptyBitmap, true));
}
JSC_DEFINE_HOST_FUNCTION(globalFuncEncodeURI, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
- static const Bitmap<256> doNotEscapeWhenEncodingURI = makeCharacterBitmap(
+ static constexpr auto doNotEscapeWhenEncodingURI = makeCharacterBitmap(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
@@ -570,7 +570,7 @@
JSC_DEFINE_HOST_FUNCTION(globalFuncEncodeURIComponent, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
- static const Bitmap<256> doNotEscapeWhenEncodingURIComponent = makeCharacterBitmap(
+ static constexpr auto doNotEscapeWhenEncodingURIComponent = makeCharacterBitmap(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
@@ -582,7 +582,7 @@
JSC_DEFINE_HOST_FUNCTION(globalFuncEscape, (JSGlobalObject* globalObject, CallFrame* callFrame))
{
return JSValue::encode(toStringView(globalObject, callFrame->argument(0), [&] (StringView view) -> JSString* {
- static const Bitmap<256> doNotEscape = makeCharacterBitmap(
+ static constexpr auto doNotEscape = makeCharacterBitmap(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
Modified: trunk/Source/WTF/wtf/Bitmap.h (289171 => 289172)
--- trunk/Source/WTF/wtf/Bitmap.h 2022-02-06 19:00:10 UTC (rev 289171)
+++ trunk/Source/WTF/wtf/Bitmap.h 2022-02-06 19:17:26 UTC (rev 289172)
@@ -42,7 +42,7 @@
using WordType = PassedWordType;
static_assert(sizeof(WordType) <= sizeof(UCPURegister), "WordType must not be bigger than the CPU atomic word size");
- constexpr Bitmap();
+ constexpr Bitmap() = default;
static constexpr size_t size()
{
@@ -50,28 +50,28 @@
}
bool get(size_t, Dependency = Dependency()) const;
- void set(size_t);
- void set(size_t, bool);
- bool testAndSet(size_t);
- bool testAndClear(size_t);
+ constexpr void set(size_t);
+ constexpr void set(size_t, bool);
+ constexpr bool testAndSet(size_t);
+ constexpr bool testAndClear(size_t);
bool concurrentTestAndSet(size_t, Dependency = Dependency());
bool concurrentTestAndClear(size_t, Dependency = Dependency());
- size_t nextPossiblyUnset(size_t) const;
- void clear(size_t);
+ constexpr size_t nextPossiblyUnset(size_t) const;
+ constexpr void clear(size_t);
void clearAll();
- void invert();
+ constexpr void invert();
int64_t findRunOfZeros(size_t runLength) const;
size_t count(size_t start = 0) const;
- bool isEmpty() const;
- bool isFull() const;
+ constexpr bool isEmpty() const;
+ constexpr bool isFull() const;
- void merge(const Bitmap&);
- void filter(const Bitmap&);
- void exclude(const Bitmap&);
+ constexpr void merge(const Bitmap&);
+ constexpr void filter(const Bitmap&);
+ constexpr void exclude(const Bitmap&);
void concurrentFilter(const Bitmap&);
- bool subsumes(const Bitmap&) const;
+ constexpr bool subsumes(const Bitmap&) const;
// If the lambda returns an IterationStatus, we use it. The lambda can also return
// void, in which case, we'll iterate every set bit.
@@ -122,17 +122,17 @@
iterator begin() const { return iterator(*this, findBit(0, true)); }
iterator end() const { return iterator(*this, bitmapSize); }
- void mergeAndClear(Bitmap&);
- void setAndClear(Bitmap&);
+ constexpr void mergeAndClear(Bitmap&);
+ constexpr void setAndClear(Bitmap&);
void setEachNthBit(size_t n, size_t start = 0, size_t end = bitmapSize);
- bool operator==(const Bitmap&) const;
- bool operator!=(const Bitmap&) const;
+ constexpr bool operator==(const Bitmap&) const;
+ constexpr bool operator!=(const Bitmap&) const;
- void operator|=(const Bitmap&);
- void operator&=(const Bitmap&);
- void operator^=(const Bitmap&);
+ constexpr void operator|=(const Bitmap&);
+ constexpr void operator&=(const Bitmap&);
+ constexpr void operator^=(const Bitmap&);
unsigned hash() const;
@@ -152,16 +152,10 @@
// a 64 bit unsigned int would give 0xffff8000
static constexpr WordType _one_ = 1;
- std::array<WordType, words> bits;
+ std::array<WordType, words> bits { };
};
template<size_t bitmapSize, typename WordType>
-constexpr Bitmap<bitmapSize, WordType>::Bitmap()
-{
- clearAll();
-}
-
-template<size_t bitmapSize, typename WordType>
inline bool Bitmap<bitmapSize, WordType>::get(size_t n, Dependency dependency) const
{
return !!(dependency.consume(this)->bits[n / wordSize] & (one << (n % wordSize)));
@@ -168,13 +162,13 @@
}
template<size_t bitmapSize, typename WordType>
-ALWAYS_INLINE void Bitmap<bitmapSize, WordType>::set(size_t n)
+ALWAYS_INLINE constexpr void Bitmap<bitmapSize, WordType>::set(size_t n)
{
bits[n / wordSize] |= (one << (n % wordSize));
}
template<size_t bitmapSize, typename WordType>
-ALWAYS_INLINE void Bitmap<bitmapSize, WordType>::set(size_t n, bool value)
+ALWAYS_INLINE constexpr void Bitmap<bitmapSize, WordType>::set(size_t n, bool value)
{
if (value)
set(n);
@@ -183,7 +177,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline bool Bitmap<bitmapSize, WordType>::testAndSet(size_t n)
+inline constexpr bool Bitmap<bitmapSize, WordType>::testAndSet(size_t n)
{
WordType mask = one << (n % wordSize);
size_t index = n / wordSize;
@@ -193,7 +187,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline bool Bitmap<bitmapSize, WordType>::testAndClear(size_t n)
+inline constexpr bool Bitmap<bitmapSize, WordType>::testAndClear(size_t n)
{
WordType mask = one << (n % wordSize);
size_t index = n / wordSize;
@@ -235,7 +229,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::clear(size_t n)
+inline constexpr void Bitmap<bitmapSize, WordType>::clear(size_t n)
{
bits[n / wordSize] &= ~(one << (n % wordSize));
}
@@ -247,7 +241,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::invert()
+inline constexpr void Bitmap<bitmapSize, WordType>::invert()
{
for (size_t i = 0; i < words; ++i)
bits[i] = ~bits[i];
@@ -259,7 +253,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline size_t Bitmap<bitmapSize, WordType>::nextPossiblyUnset(size_t start) const
+inline constexpr size_t Bitmap<bitmapSize, WordType>::nextPossiblyUnset(size_t start) const
{
if (!~bits[start / wordSize])
return ((start / wordSize) + 1) * wordSize;
@@ -303,7 +297,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline bool Bitmap<bitmapSize, WordType>::isEmpty() const
+inline constexpr bool Bitmap<bitmapSize, WordType>::isEmpty() const
{
for (size_t i = 0; i < words; ++i)
if (bits[i])
@@ -312,7 +306,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline bool Bitmap<bitmapSize, WordType>::isFull() const
+inline constexpr bool Bitmap<bitmapSize, WordType>::isFull() const
{
for (size_t i = 0; i < words; ++i)
if (~bits[i]) {
@@ -330,7 +324,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::merge(const Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::merge(const Bitmap& other)
{
for (size_t i = 0; i < words; ++i)
bits[i] |= other.bits[i];
@@ -337,7 +331,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::filter(const Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::filter(const Bitmap& other)
{
for (size_t i = 0; i < words; ++i)
bits[i] &= other.bits[i];
@@ -344,7 +338,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::exclude(const Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::exclude(const Bitmap& other)
{
for (size_t i = 0; i < words; ++i)
bits[i] &= ~other.bits[i];
@@ -371,7 +365,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline bool Bitmap<bitmapSize, WordType>::subsumes(const Bitmap& other) const
+inline constexpr bool Bitmap<bitmapSize, WordType>::subsumes(const Bitmap& other) const
{
for (size_t i = 0; i < words; ++i) {
WordType myBits = bits[i];
@@ -427,7 +421,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::mergeAndClear(Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::mergeAndClear(Bitmap& other)
{
for (size_t i = 0; i < words; ++i) {
bits[i] |= other.bits[i];
@@ -436,7 +430,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::setAndClear(Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::setAndClear(Bitmap& other)
{
for (size_t i = 0; i < words; ++i) {
bits[i] = other.bits[i];
@@ -476,7 +470,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline bool Bitmap<bitmapSize, WordType>::operator==(const Bitmap& other) const
+inline constexpr bool Bitmap<bitmapSize, WordType>::operator==(const Bitmap& other) const
{
for (size_t i = 0; i < words; ++i) {
if (bits[i] != other.bits[i])
@@ -486,13 +480,13 @@
}
template<size_t bitmapSize, typename WordType>
-inline bool Bitmap<bitmapSize, WordType>::operator!=(const Bitmap& other) const
+inline constexpr bool Bitmap<bitmapSize, WordType>::operator!=(const Bitmap& other) const
{
return !(*this == other);
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::operator|=(const Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::operator|=(const Bitmap& other)
{
for (size_t i = 0; i < words; ++i)
bits[i] |= other.bits[i];
@@ -499,7 +493,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::operator&=(const Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::operator&=(const Bitmap& other)
{
for (size_t i = 0; i < words; ++i)
bits[i] &= other.bits[i];
@@ -506,7 +500,7 @@
}
template<size_t bitmapSize, typename WordType>
-inline void Bitmap<bitmapSize, WordType>::operator^=(const Bitmap& other)
+inline constexpr void Bitmap<bitmapSize, WordType>::operator^=(const Bitmap& other)
{
for (size_t i = 0; i < words; ++i)
bits[i] ^= other.bits[i];