mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
Bug 1623957 - Part 1: Replace mozilla::IsSame with std::is_same. r=jwalden
Differential Revision: https://phabricator.services.mozilla.com/D67648 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c781dd8809
commit
d3e5d8544e
@ -65,7 +65,8 @@
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "jstypes.h"
|
||||
|
||||
@ -112,8 +113,8 @@ class MOZ_STACK_CLASS NoUsedRval {
|
||||
|
||||
template <class WantUsedRval>
|
||||
class MOZ_STACK_CLASS CallArgsBase {
|
||||
static_assert(mozilla::IsSame<WantUsedRval, IncludeUsedRval>::value ||
|
||||
mozilla::IsSame<WantUsedRval, NoUsedRval>::value,
|
||||
static_assert(std::is_same_v<WantUsedRval, IncludeUsedRval> ||
|
||||
std::is_same_v<WantUsedRval, NoUsedRval>,
|
||||
"WantUsedRval can only be IncludeUsedRval or NoUsedRval");
|
||||
|
||||
protected:
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <type_traits>
|
||||
|
||||
#include "jspubtd.h"
|
||||
|
||||
@ -157,8 +157,8 @@ struct InefficientNonFlatteningStringHashPolicy {
|
||||
#define ADD_SIZE_TO_N(tabKind, servoKind, mSize) n += mSize;
|
||||
#define ADD_SIZE_TO_N_IF_LIVE_GC_THING(tabKind, servoKind, mSize) \
|
||||
/* Avoid self-comparison warnings by comparing enums indirectly. */ \
|
||||
n += (mozilla::IsSame<int[ServoSizes::servoKind], \
|
||||
int[ServoSizes::GCHeapUsed]>::value) \
|
||||
n += (std::is_same_v<int[ServoSizes::servoKind], \
|
||||
int[ServoSizes::GCHeapUsed]>) \
|
||||
? mSize \
|
||||
: 0;
|
||||
#define ADD_TO_TAB_SIZES(tabKind, servoKind, mSize) \
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/Range.h"
|
||||
#include "mozilla/TextUtils.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -75,7 +74,6 @@ using mozilla::AsciiAlphanumericToNumber;
|
||||
using mozilla::CheckedInt;
|
||||
using mozilla::IsAsciiHexDigit;
|
||||
using mozilla::IsNaN;
|
||||
using mozilla::IsSame;
|
||||
using mozilla::PodCopy;
|
||||
using mozilla::RangedPtr;
|
||||
|
||||
@ -706,12 +704,14 @@ static size_t ToLowerCaseImpl(CharT* destChars, const CharT* srcChars,
|
||||
size_t destLength) {
|
||||
MOZ_ASSERT(startIndex < srcLength);
|
||||
MOZ_ASSERT(srcLength <= destLength);
|
||||
MOZ_ASSERT_IF((IsSame<CharT, Latin1Char>::value), srcLength == destLength);
|
||||
if constexpr (std::is_same_v<CharT, Latin1Char>) {
|
||||
MOZ_ASSERT(srcLength == destLength);
|
||||
}
|
||||
|
||||
size_t j = startIndex;
|
||||
for (size_t i = startIndex; i < srcLength; i++) {
|
||||
CharT c = srcChars[i];
|
||||
if constexpr (!IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (!std::is_same_v<CharT, Latin1Char>) {
|
||||
if (unicode::IsLeadSurrogate(c) && i + 1 < srcLength) {
|
||||
char16_t trail = srcChars[i + 1];
|
||||
if (unicode::IsTrailSurrogate(trail)) {
|
||||
@ -791,7 +791,7 @@ static JSString* ToLowerCase(JSContext* cx, JSLinearString* str) {
|
||||
|
||||
// One element Latin-1 strings can be directly retrieved from the
|
||||
// static strings cache.
|
||||
if constexpr (IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (std::is_same_v<CharT, Latin1Char>) {
|
||||
if (length == 1) {
|
||||
CharT lower = unicode::ToLowerCase(chars[0]);
|
||||
MOZ_ASSERT(StaticStrings::hasUnit(lower));
|
||||
@ -804,7 +804,7 @@ static JSString* ToLowerCase(JSContext* cx, JSLinearString* str) {
|
||||
size_t i = 0;
|
||||
for (; i < length; i++) {
|
||||
CharT c = chars[i];
|
||||
if constexpr (!IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (!std::is_same_v<CharT, Latin1Char>) {
|
||||
if (unicode::IsLeadSurrogate(c) && i + 1 < length) {
|
||||
CharT trail = chars[i + 1];
|
||||
if (unicode::IsTrailSurrogate(trail)) {
|
||||
@ -836,7 +836,7 @@ static JSString* ToLowerCase(JSContext* cx, JSLinearString* str) {
|
||||
|
||||
size_t readChars =
|
||||
ToLowerCaseImpl(newChars.get(), chars, i, length, resultLength);
|
||||
if constexpr (!IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (!std::is_same_v<CharT, Latin1Char>) {
|
||||
if (readChars < length) {
|
||||
resultLength = ToLowerCaseLength(chars, readChars, length);
|
||||
|
||||
@ -1071,8 +1071,8 @@ template <typename DestChar, typename SrcChar>
|
||||
static size_t ToUpperCaseImpl(DestChar* destChars, const SrcChar* srcChars,
|
||||
size_t startIndex, size_t srcLength,
|
||||
size_t destLength) {
|
||||
static_assert(IsSame<SrcChar, Latin1Char>::value ||
|
||||
!IsSame<DestChar, Latin1Char>::value,
|
||||
static_assert(std::is_same_v<SrcChar, Latin1Char> ||
|
||||
!std::is_same_v<DestChar, Latin1Char>,
|
||||
"cannot write non-Latin-1 characters into Latin-1 string");
|
||||
MOZ_ASSERT(startIndex < srcLength);
|
||||
MOZ_ASSERT(srcLength <= destLength);
|
||||
@ -1080,7 +1080,7 @@ static size_t ToUpperCaseImpl(DestChar* destChars, const SrcChar* srcChars,
|
||||
size_t j = startIndex;
|
||||
for (size_t i = startIndex; i < srcLength; i++) {
|
||||
char16_t c = srcChars[i];
|
||||
if constexpr (!IsSame<DestChar, Latin1Char>::value) {
|
||||
if constexpr (!std::is_same_v<DestChar, Latin1Char>) {
|
||||
if (unicode::IsLeadSurrogate(c) && i + 1 < srcLength) {
|
||||
char16_t trail = srcChars[i + 1];
|
||||
if (unicode::IsTrailSurrogate(trail)) {
|
||||
@ -1105,8 +1105,9 @@ static size_t ToUpperCaseImpl(DestChar* destChars, const SrcChar* srcChars,
|
||||
}
|
||||
|
||||
c = unicode::ToUpperCase(c);
|
||||
MOZ_ASSERT_IF((IsSame<DestChar, Latin1Char>::value),
|
||||
c <= JSString::MAX_LATIN1_CHAR);
|
||||
if constexpr (std::is_same_v<DestChar, Latin1Char>) {
|
||||
MOZ_ASSERT(c <= JSString::MAX_LATIN1_CHAR);
|
||||
}
|
||||
destChars[j++] = c;
|
||||
}
|
||||
|
||||
@ -1131,7 +1132,7 @@ static size_t ToUpperCaseLength(const CharT* chars, size_t startIndex,
|
||||
template <typename DestChar, typename SrcChar>
|
||||
static inline void CopyChars(DestChar* destChars, const SrcChar* srcChars,
|
||||
size_t length) {
|
||||
static_assert(!IsSame<DestChar, SrcChar>::value,
|
||||
static_assert(!std::is_same_v<DestChar, SrcChar>,
|
||||
"PodCopy is used for the same type case");
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
destChars[i] = srcChars[i];
|
||||
@ -1189,7 +1190,7 @@ static JSString* ToUpperCase(JSContext* cx, JSLinearString* str) {
|
||||
|
||||
// Most one element Latin-1 strings can be directly retrieved from the
|
||||
// static strings cache.
|
||||
if constexpr (IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (std::is_same_v<CharT, Latin1Char>) {
|
||||
if (length == 1) {
|
||||
Latin1Char c = chars[0];
|
||||
if (c != unicode::MICRO_SIGN &&
|
||||
@ -1211,7 +1212,7 @@ static JSString* ToUpperCase(JSContext* cx, JSLinearString* str) {
|
||||
size_t i = 0;
|
||||
for (; i < length; i++) {
|
||||
CharT c = chars[i];
|
||||
if constexpr (!IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (!std::is_same_v<CharT, Latin1Char>) {
|
||||
if (unicode::IsLeadSurrogate(c) && i + 1 < length) {
|
||||
CharT trail = chars[i + 1];
|
||||
if (unicode::IsTrailSurrogate(trail)) {
|
||||
@ -1248,7 +1249,7 @@ static JSString* ToUpperCase(JSContext* cx, JSLinearString* str) {
|
||||
// If the original string is a two-byte string, its uppercase form is
|
||||
// so rarely Latin-1 that we don't even consider creating a new
|
||||
// Latin-1 string.
|
||||
if constexpr (IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (std::is_same_v<CharT, Latin1Char>) {
|
||||
bool resultIsLatin1 = true;
|
||||
for (size_t j = i; j < length; j++) {
|
||||
Latin1Char c = chars[j];
|
||||
@ -1925,7 +1926,7 @@ static MOZ_ALWAYS_INLINE int StringMatch(const TextChar* text, uint32_t textLen,
|
||||
* speed of memcmp. For small patterns, a simple loop is faster. We also can't
|
||||
* use memcmp if one of the strings is TwoByte and the other is Latin-1.
|
||||
*/
|
||||
return (patLen > 128 && IsSame<TextChar, PatChar>::value)
|
||||
return (patLen > 128 && std::is_same_v<TextChar, PatChar>)
|
||||
? Matcher<MemCmp<TextChar, PatChar>, TextChar, PatChar>(
|
||||
text, textLen, pat, patLen)
|
||||
: Matcher<ManualCmp<TextChar, PatChar>, TextChar, PatChar>(
|
||||
@ -3077,8 +3078,8 @@ static JSString* ReplaceAll(JSContext* cx, JSLinearString* string,
|
||||
|
||||
// Step 13.
|
||||
JSStringBuilder result(cx);
|
||||
if (std::is_same<StrChar, char16_t>::value ||
|
||||
std::is_same<RepChar, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<StrChar, char16_t> ||
|
||||
std::is_same_v<RepChar, char16_t>) {
|
||||
if (!result.ensureTwoByteChars()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -3160,8 +3161,8 @@ static JSString* ReplaceAllInterleave(JSContext* cx, JSLinearString* string,
|
||||
|
||||
// Step 13.
|
||||
JSStringBuilder result(cx);
|
||||
if (std::is_same<StrChar, char16_t>::value ||
|
||||
std::is_same<RepChar, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<StrChar, char16_t> ||
|
||||
std::is_same_v<RepChar, char16_t>) {
|
||||
if (!result.ensureTwoByteChars()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -4124,7 +4125,7 @@ static MOZ_NEVER_INLINE EncodeResult Encode(StringBuffer& sb,
|
||||
return Encode_Failure;
|
||||
}
|
||||
|
||||
if (mozilla::IsSame<CharT, Latin1Char>::value) {
|
||||
if constexpr (std::is_same_v<CharT, Latin1Char>) {
|
||||
if (c < 0x80) {
|
||||
if (!appendEncoded(c)) {
|
||||
return Encode_Failure;
|
||||
|
@ -8,11 +8,11 @@
|
||||
#define builtin_intl_CommonFunctions_h
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <type_traits>
|
||||
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/Vector.h"
|
||||
@ -99,7 +99,7 @@ extern UniqueChars EncodeLocale(JSContext* cx, JSString* locale);
|
||||
|
||||
// Starting with ICU 59, UChar defaults to char16_t.
|
||||
static_assert(
|
||||
mozilla::IsSame<UChar, char16_t>::value,
|
||||
std::is_same_v<UChar, char16_t>,
|
||||
"SpiderMonkey doesn't support redefining UChar to a different type");
|
||||
|
||||
// The inline capacity we use for a Vector<char16_t>. Use this to ensure that
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/Vector.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "frontend/BinAST-macros.h"
|
||||
@ -3544,7 +3545,7 @@ JS::Result<ParseNode*> BinASTParser<Tok>::parseInterfaceLiteralRegExpExpression(
|
||||
RegExpFlags reflags = JS::RegExpFlag::NoFlags;
|
||||
auto flagsContext =
|
||||
FieldContext(BinASTInterfaceAndField::LiteralRegExpExpression__Flags);
|
||||
if (mozilla::IsSame<Tok, BinASTTokenReaderContext>::value) {
|
||||
if constexpr (std::is_same_v<Tok, BinASTTokenReaderContext>) {
|
||||
// Hack: optimized `readChars` is not implemented for
|
||||
// `BinASTTokenReaderContext`.
|
||||
RootedAtom flags(cx_);
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "frontend/BCEParserHandle.h"
|
||||
#include "frontend/BinASTEnum.h"
|
||||
#include "frontend/BinASTParserBase.h"
|
||||
@ -202,10 +204,10 @@ class BinASTParserPerTokenizer : public BinASTParserBase,
|
||||
// This is used to avoid generating unnecessary branches for more
|
||||
// optimized format.
|
||||
static constexpr bool isInvalidKindPossible() {
|
||||
return mozilla::IsSame<Tok, BinASTTokenReaderMultipart>::value;
|
||||
return std::is_same_v<Tok, BinASTTokenReaderMultipart>;
|
||||
}
|
||||
static constexpr bool isInvalidVariantPossible() {
|
||||
return mozilla::IsSame<Tok, BinASTTokenReaderMultipart>::value;
|
||||
return std::is_same_v<Tok, BinASTTokenReaderMultipart>;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -24,13 +24,13 @@
|
||||
#include "mozilla/Range.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/Utf8.h"
|
||||
#include "mozilla/Variant.h"
|
||||
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
|
||||
#include "jsnum.h"
|
||||
#include "jstypes.h"
|
||||
@ -815,8 +815,8 @@ bool PerHandlerParser<ParseHandler>::
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isSyntaxParser =
|
||||
mozilla::IsSame<ParseHandler, SyntaxParseHandler>::value;
|
||||
constexpr bool isSyntaxParser =
|
||||
std::is_same_v<ParseHandler, SyntaxParseHandler>;
|
||||
uint32_t scriptId = pc_->scriptId();
|
||||
uint32_t scopeId = scope.id();
|
||||
|
||||
@ -827,19 +827,22 @@ bool PerHandlerParser<ParseHandler>::
|
||||
if (closedOver) {
|
||||
bi.setClosedOver();
|
||||
|
||||
if (isSyntaxParser &&
|
||||
!pc_->closedOverBindingsForLazy().append(bi.name())) {
|
||||
ReportOutOfMemory(cx_);
|
||||
return false;
|
||||
if constexpr (isSyntaxParser) {
|
||||
if (!pc_->closedOverBindingsForLazy().append(bi.name())) {
|
||||
ReportOutOfMemory(cx_);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append a nullptr to denote end-of-scope.
|
||||
if (isSyntaxParser && !pc_->closedOverBindingsForLazy().append(nullptr)) {
|
||||
ReportOutOfMemory(cx_);
|
||||
return false;
|
||||
if constexpr (isSyntaxParser) {
|
||||
if (!pc_->closedOverBindingsForLazy().append(nullptr)) {
|
||||
ReportOutOfMemory(cx_);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -173,7 +173,9 @@
|
||||
|
||||
#include "mozilla/Array.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "jspubtd.h"
|
||||
|
||||
@ -208,7 +210,7 @@ class SourceParseContext : public ParseContext {
|
||||
Directives* newDirectives)
|
||||
: ParseContext(prs->cx_, prs->pc_, sc, prs->tokenStream,
|
||||
prs->getCompilationInfo(), newDirectives,
|
||||
mozilla::IsSame<ParseHandler, FullParseHandler>::value) {}
|
||||
std::is_same_v<ParseHandler, FullParseHandler>) {}
|
||||
};
|
||||
|
||||
enum VarContext { HoistVars, DontHoistVars };
|
||||
@ -1789,11 +1791,9 @@ ParserAnyCharsAccess<Parser>::anyChars(const GeneralTokenStreamChars* ts) {
|
||||
|
||||
auto tssAddr = reinterpret_cast<uintptr_t>(tss);
|
||||
|
||||
using ActualTokenStreamType =
|
||||
decltype(static_cast<Parser*>(nullptr)->tokenStream);
|
||||
static_assert(
|
||||
mozilla::IsSame<ActualTokenStreamType, TokenStreamSpecific>::value,
|
||||
"Parser::tokenStream must have type TokenStreamSpecific");
|
||||
using ActualTokenStreamType = decltype(std::declval<Parser>().tokenStream);
|
||||
static_assert(std::is_same_v<ActualTokenStreamType, TokenStreamSpecific>,
|
||||
"Parser::tokenStream must have type TokenStreamSpecific");
|
||||
|
||||
uintptr_t parserAddr = tssAddr - offsetof(Parser, tokenStream);
|
||||
|
||||
|
@ -410,8 +410,8 @@ MOZ_ALWAYS_INLINE bool SourceCoords::add(uint32_t lineNum,
|
||||
// Otherwise return false to tell TokenStream about OOM.
|
||||
uint32_t maxPtr = MAX_PTR;
|
||||
if (!lineStartOffsets_.append(maxPtr)) {
|
||||
static_assert(mozilla::IsSame<decltype(lineStartOffsets_.allocPolicy()),
|
||||
TempAllocPolicy&>::value,
|
||||
static_assert(std::is_same_v<decltype(lineStartOffsets_.allocPolicy()),
|
||||
TempAllocPolicy&>,
|
||||
"this function's caller depends on it reporting an "
|
||||
"error on failure, as TempAllocPolicy ensures");
|
||||
return false;
|
||||
|
@ -7,6 +7,9 @@
|
||||
#include "gc/AtomMarking.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "vm/Realm.h"
|
||||
|
||||
#include "gc/Heap-inl.h"
|
||||
@ -31,8 +34,7 @@ inline bool ThingIsPermanent(JS::Symbol* symbol) {
|
||||
template <typename T, bool Fallible>
|
||||
MOZ_ALWAYS_INLINE bool AtomMarkingRuntime::inlinedMarkAtomInternal(
|
||||
JSContext* cx, T* thing) {
|
||||
static_assert(mozilla::IsSame<T, JSAtom>::value ||
|
||||
mozilla::IsSame<T, JS::Symbol>::value,
|
||||
static_assert(std::is_same_v<T, JSAtom> || std::is_same_v<T, JS::Symbol>,
|
||||
"Should only be called with JSAtom* or JS::Symbol* argument");
|
||||
|
||||
MOZ_ASSERT(thing);
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include "gc/AtomMarking-inl.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "gc/PublicIterators.h"
|
||||
#include "vm/Realm.h"
|
||||
|
||||
@ -198,8 +200,7 @@ void AtomMarkingRuntime::adoptMarkedAtoms(Zone* target, Zone* source) {
|
||||
#ifdef DEBUG
|
||||
template <typename T>
|
||||
bool AtomMarkingRuntime::atomIsMarked(Zone* zone, T* thing) {
|
||||
static_assert(mozilla::IsSame<T, JSAtom>::value ||
|
||||
mozilla::IsSame<T, JS::Symbol>::value,
|
||||
static_assert(std::is_same_v<T, JSAtom> || std::is_same_v<T, JS::Symbol>,
|
||||
"Should only be called with JSAtom* or JS::Symbol* argument");
|
||||
|
||||
MOZ_ASSERT(thing);
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "gc/RelocationOverlay.h"
|
||||
#include "vm/BigIntType.h"
|
||||
#include "vm/RegExpShared.h"
|
||||
@ -58,8 +60,7 @@ struct TaggedPtr<TaggedProto> {
|
||||
template <typename T>
|
||||
struct MightBeForwarded {
|
||||
static_assert(std::is_base_of<Cell, T>::value, "T must derive from Cell");
|
||||
static_assert(!mozilla::IsSame<Cell, T>::value &&
|
||||
!mozilla::IsSame<TenuredCell, T>::value,
|
||||
static_assert(!std::is_same_v<Cell, T> && !std::is_same_v<TenuredCell, T>,
|
||||
"T must not be Cell or TenuredCell");
|
||||
|
||||
static const bool value = std::is_base_of<JSObject, T>::value ||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
@ -57,7 +58,6 @@ using JS::MapTypeToTraceKind;
|
||||
|
||||
using mozilla::DebugOnly;
|
||||
using mozilla::IntegerRange;
|
||||
using mozilla::IsSame;
|
||||
using mozilla::PodCopy;
|
||||
|
||||
// [SMDOC] GC Tracing
|
||||
@ -698,11 +698,10 @@ void js::TraceGCCellPtrRoot(JSTracer* trc, JS::GCCellPtr* thingp,
|
||||
// a sufficiently smart C++ compiler may be able to devirtualize some paths.
|
||||
template <typename T>
|
||||
bool js::gc::TraceEdgeInternal(JSTracer* trc, T* thingp, const char* name) {
|
||||
#define IS_SAME_TYPE_OR(name, type, _, _1) mozilla::IsSame<type*, T>::value ||
|
||||
#define IS_SAME_TYPE_OR(name, type, _, _1) std::is_same_v<type*, T> ||
|
||||
static_assert(JS_FOR_EACH_TRACEKIND(IS_SAME_TYPE_OR)
|
||||
mozilla::IsSame<T, JS::Value>::value ||
|
||||
mozilla::IsSame<T, jsid>::value ||
|
||||
mozilla::IsSame<T, TaggedProto>::value,
|
||||
std::is_same_v<T, JS::Value> ||
|
||||
std::is_same_v<T, jsid> || std::is_same_v<T, TaggedProto>,
|
||||
"Only the base cell layout types are allowed into "
|
||||
"marking/tracing internals");
|
||||
#undef IS_SAME_TYPE_OR
|
||||
@ -3516,7 +3515,7 @@ size_t js::TenuringTracer::moveBigIntToTenured(JS::BigInt* dst, JS::BigInt* src,
|
||||
|
||||
template <typename T>
|
||||
static inline void CheckIsMarkedThing(T* thingp) {
|
||||
#define IS_SAME_TYPE_OR(name, type, _, _1) mozilla::IsSame<type*, T>::value ||
|
||||
#define IS_SAME_TYPE_OR(name, type, _, _1) std::is_same_v<type*, T> ||
|
||||
static_assert(JS_FOR_EACH_TRACEKIND(IS_SAME_TYPE_OR) false,
|
||||
"Only the base cell layout types are allowed into "
|
||||
"marking/tracing internals");
|
||||
|
@ -528,7 +528,7 @@ OutOfLineCode* CodeGenerator::oolCallVM(LInstruction* lir, const ArgSeq& args,
|
||||
const VMFunctionData& fun = GetVMFunction(id);
|
||||
MOZ_ASSERT(fun.explicitArgs == args.numArgs);
|
||||
MOZ_ASSERT(fun.returnsData() !=
|
||||
(mozilla::IsSame<StoreOutputTo, StoreNothing>::value));
|
||||
(std::is_same_v<StoreOutputTo, StoreNothing>));
|
||||
#endif
|
||||
|
||||
OutOfLineCode* ool = new (alloc())
|
||||
|
@ -5,9 +5,9 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "jit/JitOptions.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <type_traits>
|
||||
|
||||
#include "vm/JSFunction.h"
|
||||
|
||||
@ -25,11 +25,6 @@ static void Warn(const char* env, const char* value) {
|
||||
fprintf(stderr, "Warning: I didn't understand %s=\"%s\"\n", env, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct IsBool : mozilla::FalseType {};
|
||||
template <>
|
||||
struct IsBool<bool> : mozilla::TrueType {};
|
||||
|
||||
static Maybe<int> ParseInt(const char* str) {
|
||||
char* endp;
|
||||
int retval = strtol(str, &endp, 0);
|
||||
@ -45,7 +40,7 @@ T overrideDefault(const char* param, T dflt) {
|
||||
if (!str) {
|
||||
return dflt;
|
||||
}
|
||||
if (IsBool<T>::value) {
|
||||
if constexpr (std::is_same_v<T, bool>) {
|
||||
if (strcmp(str, "true") == 0 || strcmp(str, "yes") == 0) {
|
||||
return true;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/Tuple.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "js/Initialization.h"
|
||||
@ -63,8 +64,8 @@ class Thread {
|
||||
// constructor as an Options and vice versa.
|
||||
typename NonConstO = typename mozilla::RemoveConst<O>::Type,
|
||||
typename DerefO = typename mozilla::RemoveReference<NonConstO>::Type,
|
||||
typename = typename mozilla::EnableIf<
|
||||
mozilla::IsSame<DerefO, Options>::value, void*>::Type>
|
||||
typename = typename mozilla::EnableIf<std::is_same_v<DerefO, Options>,
|
||||
void*>::Type>
|
||||
explicit Thread(O&& options = Options())
|
||||
: id_(ThreadId()), options_(std::forward<O>(options)) {
|
||||
MOZ_ASSERT(isInitialized());
|
||||
|
@ -7,6 +7,8 @@
|
||||
#ifndef vm_EnvironmentObject_h
|
||||
#define vm_EnvironmentObject_h
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "builtin/ModuleObject.h"
|
||||
#include "frontend/NameAnalysisTypes.h"
|
||||
#include "gc/Barrier.h"
|
||||
@ -1118,27 +1120,29 @@ inline bool IsFrameInitialEnvironment(AbstractFramePtr frame,
|
||||
|
||||
// A function frame's CallObject, if present, is always the initial
|
||||
// environment.
|
||||
if (mozilla::IsSame<SpecificEnvironment, CallObject>::value) {
|
||||
if constexpr (std::is_same_v<SpecificEnvironment, CallObject>) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// For an eval frame, the VarEnvironmentObject, if present, is always the
|
||||
// initial environment.
|
||||
if (mozilla::IsSame<SpecificEnvironment, VarEnvironmentObject>::value &&
|
||||
frame.isEvalFrame()) {
|
||||
return true;
|
||||
if constexpr (std::is_same_v<SpecificEnvironment, VarEnvironmentObject>) {
|
||||
if (frame.isEvalFrame()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// For named lambda frames without CallObjects (i.e., no binding in the
|
||||
// body of the function was closed over), the LexicalEnvironmentObject
|
||||
// corresponding to the named lambda scope is the initial environment.
|
||||
if (mozilla::IsSame<SpecificEnvironment, NamedLambdaObject>::value &&
|
||||
frame.isFunctionFrame() &&
|
||||
frame.callee()->needsNamedLambdaEnvironment() &&
|
||||
!frame.callee()->needsCallObject()) {
|
||||
LexicalScope* namedLambdaScope = frame.script()->maybeNamedLambdaScope();
|
||||
return &env.template as<LexicalEnvironmentObject>().scope() ==
|
||||
namedLambdaScope;
|
||||
if constexpr (std::is_same_v<SpecificEnvironment, NamedLambdaObject>) {
|
||||
if (frame.isFunctionFrame() &&
|
||||
frame.callee()->needsNamedLambdaEnvironment() &&
|
||||
!frame.callee()->needsCallObject()) {
|
||||
LexicalScope* namedLambdaScope = frame.script()->maybeNamedLambdaScope();
|
||||
return &env.template as<LexicalEnvironmentObject>().scope() ==
|
||||
namedLambdaScope;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "vm/JSContext.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "builtin/Object.h"
|
||||
#include "gc/Zone.h"
|
||||
#include "jit/JitFrames.h"
|
||||
@ -94,8 +96,7 @@ class ContextChecks {
|
||||
|
||||
template <typename T>
|
||||
void checkAtom(T* thing, int argIndex) {
|
||||
static_assert(mozilla::IsSame<T, JSAtom>::value ||
|
||||
mozilla::IsSame<T, JS::Symbol>::value,
|
||||
static_assert(std::is_same_v<T, JSAtom> || std::is_same_v<T, JS::Symbol>,
|
||||
"Should only be called with JSAtom* or JS::Symbol* argument");
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -139,8 +140,8 @@ class ContextChecks {
|
||||
// iteration protocol, eg GCVector<jsid>.
|
||||
template <typename Container>
|
||||
typename mozilla::EnableIf<
|
||||
mozilla::IsSame<decltype(((Container*)nullptr)->begin()),
|
||||
decltype(((Container*)nullptr)->end())>::value>::Type
|
||||
std::is_same_v<decltype(((Container*)nullptr)->begin()),
|
||||
decltype(((Container*)nullptr)->end())>>::Type
|
||||
check(const Container& container, int argIndex) {
|
||||
for (auto i : container) {
|
||||
check(i, argIndex);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/PodOperations.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include "builtin/RegExp.h"
|
||||
#include "builtin/SelfHostingDefines.h" // REGEXP_*_FLAG
|
||||
@ -202,7 +203,7 @@ RegExpObject* RegExpObject::create(JSContext* cx, const CharT* chars,
|
||||
size_t length, RegExpFlags flags,
|
||||
frontend::TokenStreamAnyChars& tokenStream,
|
||||
NewObjectKind newKind) {
|
||||
static_assert(mozilla::IsSame<CharT, char16_t>::value,
|
||||
static_assert(std::is_same_v<CharT, char16_t>,
|
||||
"this code may need updating if/when CharT encodes UTF-8");
|
||||
|
||||
RootedAtom source(cx, AtomizeChars(cx, chars, length));
|
||||
@ -221,7 +222,7 @@ template <typename CharT>
|
||||
RegExpObject* RegExpObject::create(JSContext* cx, const CharT* chars,
|
||||
size_t length, RegExpFlags flags,
|
||||
NewObjectKind newKind) {
|
||||
static_assert(mozilla::IsSame<CharT, char16_t>::value,
|
||||
static_assert(std::is_same_v<CharT, char16_t>,
|
||||
"this code may need updating if/when CharT encodes UTF-8");
|
||||
|
||||
RootedAtom source(cx, AtomizeChars(cx, chars, length));
|
||||
@ -400,8 +401,10 @@ template <typename CharT>
|
||||
static MOZ_ALWAYS_INLINE bool SetupBuffer(StringBuffer& sb,
|
||||
const CharT* oldChars, size_t oldLen,
|
||||
const CharT* it) {
|
||||
if (mozilla::IsSame<CharT, char16_t>::value && !sb.ensureTwoByteChars()) {
|
||||
return false;
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
if (!sb.ensureTwoByteChars()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sb.reserve(oldLen + 1)) {
|
||||
|
@ -16,13 +16,12 @@
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/RangedPtr.h"
|
||||
#include "mozilla/TextUtils.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/Utf8.h"
|
||||
#include "mozilla/Vector.h"
|
||||
|
||||
#include <algorithm> // std::{all_of,copy_n,enable_if,is_const,move}
|
||||
#include <type_traits> // std::is_unsigned
|
||||
#include <type_traits> // std::is_same, std::is_unsigned
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
@ -51,7 +50,6 @@ using mozilla::AssertedCast;
|
||||
using mozilla::AsWritableChars;
|
||||
using mozilla::ConvertLatin1toUtf16;
|
||||
using mozilla::IsAsciiDigit;
|
||||
using mozilla::IsSame;
|
||||
using mozilla::IsUtf16Latin1;
|
||||
using mozilla::LossyConvertUtf16toLatin1;
|
||||
using mozilla::MakeSpan;
|
||||
@ -643,7 +641,7 @@ JSLinearString* JSRope::flattenInternal(JSContext* maybecx) {
|
||||
JSExtensibleString& left = leftMostRope->leftChild()->asExtensible();
|
||||
size_t capacity = left.capacity();
|
||||
if (capacity >= wholeLength &&
|
||||
left.hasTwoByteChars() == IsSame<CharT, char16_t>::value) {
|
||||
left.hasTwoByteChars() == std::is_same_v<CharT, char16_t>) {
|
||||
wholeChars = const_cast<CharT*>(left.nonInlineChars<CharT>(nogc));
|
||||
wholeCapacity = capacity;
|
||||
|
||||
@ -699,7 +697,7 @@ JSLinearString* JSRope::flattenInternal(JSContext* maybecx) {
|
||||
RemoveCellMemory(&left, left.allocSize(), MemoryUse::StringContents);
|
||||
}
|
||||
|
||||
if (IsSame<CharT, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
left.setLengthAndFlags(left_len, INIT_DEPENDENT_FLAGS);
|
||||
} else {
|
||||
left.setLengthAndFlags(left_len,
|
||||
@ -761,7 +759,7 @@ visit_right_child : {
|
||||
finish_node : {
|
||||
if (str == this) {
|
||||
MOZ_ASSERT(pos == wholeChars + wholeLength);
|
||||
if (IsSame<CharT, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
str->setLengthAndFlags(wholeLength, EXTENSIBLE_FLAGS);
|
||||
} else {
|
||||
str->setLengthAndFlags(wholeLength, EXTENSIBLE_FLAGS | LATIN1_CHARS_BIT);
|
||||
@ -778,7 +776,7 @@ finish_node : {
|
||||
}
|
||||
uintptr_t flattenData;
|
||||
uint32_t len = pos - str->nonInlineCharsRaw<CharT>();
|
||||
if (IsSame<CharT, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
flattenData = str->unsetFlattenData(len, INIT_DEPENDENT_FLAGS);
|
||||
} else {
|
||||
flattenData =
|
||||
@ -1607,7 +1605,7 @@ template <typename CharT>
|
||||
JSLinearString* js::NewString(JSContext* cx,
|
||||
UniquePtr<CharT[], JS::FreePolicy> chars,
|
||||
size_t length) {
|
||||
if constexpr (IsSame<CharT, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
if (CanStoreCharsAsLatin1(chars.get(), length)) {
|
||||
// Deflating copies from |chars.get()| and lets |chars| be freed on
|
||||
// return.
|
||||
@ -1656,7 +1654,7 @@ template <AllowGC allowGC, typename CharT>
|
||||
JSLinearString* js::NewString(JSContext* cx,
|
||||
UniquePtr<CharT[], JS::FreePolicy> chars,
|
||||
size_t length) {
|
||||
if constexpr (IsSame<CharT, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
if (CanStoreCharsAsLatin1(chars.get(), length)) {
|
||||
return NewStringDeflated<allowGC>(cx, chars.get(), length);
|
||||
}
|
||||
@ -1755,7 +1753,7 @@ JSLinearString* NewLatin1StringZ(JSContext* cx, UniqueChars chars) {
|
||||
|
||||
template <AllowGC allowGC, typename CharT>
|
||||
JSLinearString* NewStringCopyN(JSContext* cx, const CharT* s, size_t n) {
|
||||
if constexpr (IsSame<CharT, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
if (CanStoreCharsAsLatin1(s, n)) {
|
||||
return NewStringDeflated<allowGC>(cx, s, n);
|
||||
}
|
||||
@ -2029,7 +2027,7 @@ static bool FillWithRepresentatives(JSContext* cx, HandleArrayObject array,
|
||||
|
||||
// External. Note that we currently only support TwoByte external strings.
|
||||
RootedString external1(cx), external2(cx);
|
||||
if (IsSame<CharT, char16_t>::value) {
|
||||
if constexpr (std::is_same_v<CharT, char16_t>) {
|
||||
external1 = JS_NewExternalString(cx, (const char16_t*)chars, len,
|
||||
&RepresentativeExternalStringCallbacks);
|
||||
if (!external1 || !AppendString(cx, array, index, external1)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user