Bug 1910674 - Part 3: Replace "typedef" with "using" in rest of js/src. r=spidermonkey-reviewers,jonco

Differential Revision: https://phabricator.services.mozilla.com/D218111
This commit is contained in:
André Bargull
2024-07-31 12:52:59 +00:00
parent 1fb02f6730
commit 86ed1f803b
13 changed files with 57 additions and 65 deletions

View File

@@ -2190,7 +2190,7 @@ int js::StringFindPattern(const JSLinearString* text, const JSLinearString* pat,
return StringMatch(text, pat, start); return StringMatch(text, pat, start);
} }
typedef Vector<JSLinearString*, 16, SystemAllocPolicy> LinearStringVector; using LinearStringVector = Vector<JSLinearString*, 16, SystemAllocPolicy>;
template <typename TextChar, typename PatChar> template <typename TextChar, typename PatChar>
static int RopeMatchImpl(const AutoCheckCannotGC& nogc, static int RopeMatchImpl(const AutoCheckCannotGC& nogc,

View File

@@ -285,9 +285,9 @@ class Completion {
Variant variant; Variant variant;
}; };
typedef HashSet<WeakHeapPtr<GlobalObject*>, using WeakGlobalObjectSet =
StableCellHasher<WeakHeapPtr<GlobalObject*>>, ZoneAllocPolicy> HashSet<WeakHeapPtr<GlobalObject*>,
WeakGlobalObjectSet; StableCellHasher<WeakHeapPtr<GlobalObject*>>, ZoneAllocPolicy>;
#ifdef DEBUG #ifdef DEBUG
extern void CheckDebuggeeThing(BaseScript* script, bool invisibleOk); extern void CheckDebuggeeThing(BaseScript* script, bool invisibleOk);
@@ -344,7 +344,7 @@ class DebuggerWeakMap : private WeakMap<HeapPtr<Referent*>, HeapPtr<Wrapper*>> {
JS::Compartment* compartment; JS::Compartment* compartment;
public: public:
typedef WeakMap<Key, Value> Base; using Base = WeakMap<Key, Value>;
using ReferentType = Referent; using ReferentType = Referent;
using WrapperType = Wrapper; using WrapperType = Wrapper;
@@ -466,8 +466,8 @@ using Env = JSObject;
// does point to something okay. Instead, we immediately build an instance of // does point to something okay. Instead, we immediately build an instance of
// this type from the Cell* and use that instead, so we can benefit from // this type from the Cell* and use that instead, so we can benefit from
// Variant's static checks. // Variant's static checks.
typedef mozilla::Variant<BaseScript*, WasmInstanceObject*> using DebuggerScriptReferent =
DebuggerScriptReferent; mozilla::Variant<BaseScript*, WasmInstanceObject*>;
// The referent of a Debugger.Source. // The referent of a Debugger.Source.
// //
@@ -479,8 +479,8 @@ typedef mozilla::Variant<BaseScript*, WasmInstanceObject*>
// The DebuggerSource object actually simply stores a Cell* in its private // The DebuggerSource object actually simply stores a Cell* in its private
// pointer. See the comments for DebuggerScriptReferent for the rationale for // pointer. See the comments for DebuggerScriptReferent for the rationale for
// this type. // this type.
typedef mozilla::Variant<ScriptSourceObject*, WasmInstanceObject*> using DebuggerSourceReferent =
DebuggerSourceReferent; mozilla::Variant<ScriptSourceObject*, WasmInstanceObject*>;
template <typename HookIsEnabledFun /* bool (Debugger*) */> template <typename HookIsEnabledFun /* bool (Debugger*) */>
class MOZ_RAII DebuggerList { class MOZ_RAII DebuggerList {
@@ -749,9 +749,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
* that way, but since stack frames are not gc-things, the implementation * that way, but since stack frames are not gc-things, the implementation
* has to be different. * has to be different.
*/ */
typedef HashMap<AbstractFramePtr, HeapPtr<DebuggerFrame*>, using FrameMap = HashMap<AbstractFramePtr, HeapPtr<DebuggerFrame*>,
DefaultHasher<AbstractFramePtr>, ZoneAllocPolicy> DefaultHasher<AbstractFramePtr>, ZoneAllocPolicy>;
FrameMap;
FrameMap frames; FrameMap frames;
/* /*
@@ -778,8 +777,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
* An entry in this table exists if and only if the Debugger.Frame's * An entry in this table exists if and only if the Debugger.Frame's
* GENERATOR_INFO_SLOT is set. * GENERATOR_INFO_SLOT is set.
*/ */
typedef DebuggerWeakMap<AbstractGeneratorObject, DebuggerFrame> using GeneratorWeakMap =
GeneratorWeakMap; DebuggerWeakMap<AbstractGeneratorObject, DebuggerFrame>;
GeneratorWeakMap generatorFrames; GeneratorWeakMap generatorFrames;
// An ephemeral map from BaseScript* to Debugger.Script instances. // An ephemeral map from BaseScript* to Debugger.Script instances.
@@ -790,28 +789,28 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
// The map from debuggee source script objects to their Debugger.Source // The map from debuggee source script objects to their Debugger.Source
// instances. // instances.
typedef DebuggerWeakMap<ScriptSourceObject, DebuggerSource, true> using SourceWeakMap =
SourceWeakMap; DebuggerWeakMap<ScriptSourceObject, DebuggerSource, true>;
SourceWeakMap sources; SourceWeakMap sources;
// The map from debuggee objects to their Debugger.Object instances. // The map from debuggee objects to their Debugger.Object instances.
typedef DebuggerWeakMap<JSObject, DebuggerObject> ObjectWeakMap; using ObjectWeakMap = DebuggerWeakMap<JSObject, DebuggerObject>;
ObjectWeakMap objects; ObjectWeakMap objects;
// The map from debuggee Envs to Debugger.Environment instances. // The map from debuggee Envs to Debugger.Environment instances.
typedef DebuggerWeakMap<JSObject, DebuggerEnvironment> EnvironmentWeakMap; using EnvironmentWeakMap = DebuggerWeakMap<JSObject, DebuggerEnvironment>;
EnvironmentWeakMap environments; EnvironmentWeakMap environments;
// The map from WasmInstanceObjects to synthesized Debugger.Script // The map from WasmInstanceObjects to synthesized Debugger.Script
// instances. // instances.
typedef DebuggerWeakMap<WasmInstanceObject, DebuggerScript> using WasmInstanceScriptWeakMap =
WasmInstanceScriptWeakMap; DebuggerWeakMap<WasmInstanceObject, DebuggerScript>;
WasmInstanceScriptWeakMap wasmInstanceScripts; WasmInstanceScriptWeakMap wasmInstanceScripts;
// The map from WasmInstanceObjects to synthesized Debugger.Source // The map from WasmInstanceObjects to synthesized Debugger.Source
// instances. // instances.
typedef DebuggerWeakMap<WasmInstanceObject, DebuggerSource> using WasmInstanceSourceWeakMap =
WasmInstanceSourceWeakMap; DebuggerWeakMap<WasmInstanceObject, DebuggerSource>;
WasmInstanceSourceWeakMap wasmInstanceSources; WasmInstanceSourceWeakMap wasmInstanceSources;
class QueryBase; class QueryBase;

View File

@@ -172,8 +172,8 @@ static constexpr size_t MaxSrcNotesLength = INT32_MAX;
// Have a few inline elements, so as to avoid heap allocation for tiny // Have a few inline elements, so as to avoid heap allocation for tiny
// sequences. See bug 1390526. // sequences. See bug 1390526.
typedef Vector<jsbytecode, 64> BytecodeVector; using BytecodeVector = Vector<jsbytecode, 64>;
typedef Vector<js::SrcNote, 64> SrcNotesVector; using SrcNotesVector = Vector<js::SrcNote, 64>;
// Bytecode and all data directly associated with specific opcode/index inside // Bytecode and all data directly associated with specific opcode/index inside
// bytecode is stored in this class. // bytecode is stored in this class.

View File

@@ -886,7 +886,7 @@ RegExpRunStatus ExecuteRaw(jit::JitCode* code, const CharT* chars,
static_assert(static_cast<int32_t>(RegExpRunStatus::Success_NotFound) == static_assert(static_cast<int32_t>(RegExpRunStatus::Success_NotFound) ==
v8::internal::RegExp::kInternalRegExpFailure); v8::internal::RegExp::kInternalRegExpFailure);
typedef int (*RegExpCodeSignature)(InputOutputData*); using RegExpCodeSignature = int (*)(InputOutputData*);
auto function = reinterpret_cast<RegExpCodeSignature>(code->raw()); auto function = reinterpret_cast<RegExpCodeSignature>(code->raw());
{ {
JS::AutoSuppressGCAnalysis nogc; JS::AutoSuppressGCAnalysis nogc;

View File

@@ -42,7 +42,7 @@ END_TEST(testAssemblerBuffer_BufferOffset)
BEGIN_TEST(testAssemblerBuffer_AssemblerBuffer) { BEGIN_TEST(testAssemblerBuffer_AssemblerBuffer) {
using js::jit::BufferOffset; using js::jit::BufferOffset;
typedef js::jit::AssemblerBuffer<5 * sizeof(uint32_t), uint32_t> AsmBuf; using AsmBuf = js::jit::AssemblerBuffer<5 * sizeof(uint32_t), uint32_t>;
AsmBuf ab; AsmBuf ab;
CHECK(ab.isAligned(16)); CHECK(ab.isAligned(16));
@@ -107,7 +107,7 @@ BEGIN_TEST(testAssemblerBuffer_AssemblerBuffer) {
END_TEST(testAssemblerBuffer_AssemblerBuffer) END_TEST(testAssemblerBuffer_AssemblerBuffer)
BEGIN_TEST(testAssemblerBuffer_BranchDeadlineSet) { BEGIN_TEST(testAssemblerBuffer_BranchDeadlineSet) {
typedef js::jit::BranchDeadlineSet<3> DLSet; using DLSet = js::jit::BranchDeadlineSet<3>;
using js::jit::BufferOffset; using js::jit::BufferOffset;
js::LifoAlloc alloc(1024); js::LifoAlloc alloc(1024);
@@ -217,13 +217,12 @@ namespace {
struct TestAssembler; struct TestAssembler;
typedef js::jit::AssemblerBufferWithConstantPools< using AsmBufWithPool = js::jit::AssemblerBufferWithConstantPools<
/* SliceSize */ 5 * sizeof(uint32_t), /* SliceSize */ 5 * sizeof(uint32_t),
/* InstSize */ 4, /* InstSize */ 4,
/* Inst */ uint32_t, /* Inst */ uint32_t,
/* Asm */ TestAssembler, /* Asm */ TestAssembler,
/* NumShortBranchRanges */ 3> /* NumShortBranchRanges */ 3>;
AsmBufWithPool;
struct TestAssembler { struct TestAssembler {
// Mock instruction set: // Mock instruction set:

View File

@@ -13,12 +13,10 @@
// #define FUZZ // #define FUZZ
typedef js::HashMap<uint32_t, uint32_t, js::DefaultHasher<uint32_t>, using IntMap = js::HashMap<uint32_t, uint32_t, js::DefaultHasher<uint32_t>,
js::SystemAllocPolicy> js::SystemAllocPolicy>;
IntMap; using IntSet =
typedef js::HashSet<uint32_t, js::DefaultHasher<uint32_t>, js::HashSet<uint32_t, js::DefaultHasher<uint32_t>, js::SystemAllocPolicy>;
js::SystemAllocPolicy>
IntSet;
/* /*
* The rekeying test as conducted by adding only keys masked with 0x0000FFFF * The rekeying test as conducted by adding only keys masked with 0x0000FFFF
@@ -314,7 +312,7 @@ struct MoveOnlyType {
} }
struct HashPolicy { struct HashPolicy {
typedef MoveOnlyType Lookup; using Lookup = MoveOnlyType;
static js::HashNumber hash(const Lookup& lookup) { return lookup.val; } static js::HashNumber hash(const Lookup& lookup) { return lookup.val; }
@@ -329,9 +327,8 @@ struct MoveOnlyType {
}; };
BEGIN_TEST(testHashSetOfMoveOnlyType) { BEGIN_TEST(testHashSetOfMoveOnlyType) {
typedef js::HashSet<MoveOnlyType, MoveOnlyType::HashPolicy, using Set = js::HashSet<MoveOnlyType, MoveOnlyType::HashPolicy,
js::SystemAllocPolicy> js::SystemAllocPolicy>;
Set;
Set set; Set set;

View File

@@ -9,7 +9,7 @@
#include "jit/MacroAssembler.h" #include "jit/MacroAssembler.h"
typedef void (*EnterTest)(); using EnterTest = void (*)();
// On entry to the JIT code, save every register. // On entry to the JIT code, save every register.
void PrepareJit(js::jit::MacroAssembler& masm); void PrepareJit(js::jit::MacroAssembler& masm);

View File

@@ -816,12 +816,12 @@ JS_PUBLIC_API bool JS_RefreshCrossCompartmentWrappers(JSContext* cx,
return RemapAllWrappersForObject(cx, obj, obj); return RemapAllWrappersForObject(cx, obj, obj);
} }
typedef struct JSStdName { struct JSStdName {
size_t atomOffset; /* offset of atom pointer in JSAtomState */ size_t atomOffset; /* offset of atom pointer in JSAtomState */
JSProtoKey key; JSProtoKey key;
bool isDummy() const { return key == JSProto_Null; } bool isDummy() const { return key == JSProto_Null; }
bool isSentinel() const { return key == JSProto_LIMIT; } bool isSentinel() const { return key == JSProto_LIMIT; }
} JSStdName; };
static const JSStdName* LookupStdName(const JSAtomState& names, JSAtom* name, static const JSStdName* LookupStdName(const JSAtomState& names, JSAtom* name,
const JSStdName* table) { const JSStdName* table) {

View File

@@ -506,15 +506,12 @@ extern JS_PUBLIC_API JSLinearString* GetErrorTypeName(JSContext* cx,
int16_t exnType); int16_t exnType);
/* Implemented in CrossCompartmentWrapper.cpp. */ /* Implemented in CrossCompartmentWrapper.cpp. */
typedef enum NukeReferencesToWindow { enum NukeReferencesToWindow { NukeWindowReferences, DontNukeWindowReferences };
NukeWindowReferences,
DontNukeWindowReferences
} NukeReferencesToWindow;
typedef enum NukeReferencesFromTarget { enum NukeReferencesFromTarget {
NukeAllReferences, NukeAllReferences,
NukeIncomingReferences, NukeIncomingReferences,
} NukeReferencesFromTarget; };
/* /*
* These filters are designed to be ephemeral stack classes, and thus don't * These filters are designed to be ephemeral stack classes, and thus don't
@@ -709,8 +706,8 @@ extern JS_PUBLIC_API bool IsSavedFrame(JSObject* obj);
#if defined(XP_WIN) #if defined(XP_WIN)
// Parameters use void* types to avoid #including windows.h. The return value of // Parameters use void* types to avoid #including windows.h. The return value of
// this function is returned from the exception handler. // this function is returned from the exception handler.
typedef long (*JitExceptionHandler)(void* exceptionRecord, // PEXECTION_RECORD using JitExceptionHandler = long (*)(void* exceptionRecord, // PEXECTION_RECORD
void* context); // PCONTEXT void* context); // PCONTEXT
/** /**
* Windows uses "structured exception handling" to handle faults. When a fault * Windows uses "structured exception handling" to handle faults. When a fault

View File

@@ -1724,7 +1724,7 @@ static bool AddIntlExtras(JSContext* cx, unsigned argc, Value* vp) {
* coincides with the end of a line. * coincides with the end of a line.
*/ */
int startline = lineno; int startline = lineno;
typedef Vector<char, 32> CharBuffer; using CharBuffer = Vector<char, 32>;
RootedObject globalLexical(cx, &cx->global()->lexicalEnvironment()); RootedObject globalLexical(cx, &cx->global()->lexicalEnvironment());
CharBuffer buffer(cx); CharBuffer buffer(cx);
do { do {
@@ -4127,12 +4127,12 @@ static bool CreateErrorReport(JSContext* cx, unsigned argc, Value* vp) {
#define LAZY_STANDARD_CLASSES #define LAZY_STANDARD_CLASSES
/* A class for easily testing the inner/outer object callbacks. */ /* A class for easily testing the inner/outer object callbacks. */
typedef struct ComplexObject { struct ComplexObject {
bool isInner; bool isInner;
bool frozen; bool frozen;
JSObject* inner; JSObject* inner;
JSObject* outer; JSObject* outer;
} ComplexObject; };
static bool sandbox_enumerate(JSContext* cx, JS::HandleObject obj, static bool sandbox_enumerate(JSContext* cx, JS::HandleObject obj,
JS::MutableHandleIdVector properties, JS::MutableHandleIdVector properties,
@@ -7545,7 +7545,7 @@ struct SharedObjectMailbox {
Value val; Value val;
}; };
typedef ExclusiveData<SharedObjectMailbox> SOMailbox; using SOMailbox = ExclusiveData<SharedObjectMailbox>;
// Never null after successful initialization. // Never null after successful initialization.
static SOMailbox* sharedObjectMailbox; static SOMailbox* sharedObjectMailbox;
@@ -7769,11 +7769,11 @@ static bool SetSharedObject(JSContext* cx, unsigned argc, Value* vp) {
return true; return true;
} }
typedef Vector<uint8_t, 0, SystemAllocPolicy> Uint8Vector; using Uint8Vector = Vector<uint8_t, 0, SystemAllocPolicy>;
class StreamCacheEntry : public AtomicRefCounted<StreamCacheEntry>, class StreamCacheEntry : public AtomicRefCounted<StreamCacheEntry>,
public JS::OptimizedEncodingListener { public JS::OptimizedEncodingListener {
typedef AtomicRefCounted<StreamCacheEntry> AtomicBase; using AtomicBase = AtomicRefCounted<StreamCacheEntry>;
Uint8Vector bytes_; Uint8Vector bytes_;
ExclusiveData<Uint8Vector> optimized_; ExclusiveData<Uint8Vector> optimized_;
@@ -7819,7 +7819,7 @@ class StreamCacheEntry : public AtomicRefCounted<StreamCacheEntry>,
} }
}; };
typedef RefPtr<StreamCacheEntry> StreamCacheEntryPtr; using StreamCacheEntryPtr = RefPtr<StreamCacheEntry>;
class StreamCacheEntryObject : public NativeObject { class StreamCacheEntryObject : public NativeObject {
static const unsigned CACHE_ENTRY_SLOT = 0; static const unsigned CACHE_ENTRY_SLOT = 0;

View File

@@ -187,7 +187,7 @@ struct MultiStringOption : public ValuedOption {
} /* namespace detail */ } /* namespace detail */
class MultiStringRange { class MultiStringRange {
typedef detail::StringArg StringArg; using StringArg = detail::StringArg;
const StringArg* cur; const StringArg* cur;
const StringArg* end; const StringArg* end;
@@ -233,9 +233,9 @@ class OptionParser {
}; };
private: private:
typedef Vector<detail::Option*, 0, detail::OptionAllocPolicy> Options; using Options = Vector<detail::Option*, 0, detail::OptionAllocPolicy>;
typedef detail::Option Option; using Option = detail::Option;
typedef detail::BoolOption BoolOption; using BoolOption = detail::BoolOption;
Options options; Options options;
Options arguments; Options arguments;

View File

@@ -75,7 +75,7 @@ class MOZ_RAII AutoNoteSingleThreadedRegion {
// occur when the data is both read from and written to. // occur when the data is both read from and written to.
template <typename Check, typename T> template <typename Check, typename T>
class ProtectedData { class ProtectedData {
typedef ProtectedData<Check, T> ThisType; using ThisType = ProtectedData<Check, T>;
public: public:
template <typename... Args> template <typename... Args>
@@ -302,7 +302,7 @@ using HelperThreadLockData = ProtectedDataNoCheckArgs<
// initialized, as such guarantees are not provided by this class. // initialized, as such guarantees are not provided by this class.
template <typename Check, typename T> template <typename Check, typename T>
class ProtectedDataWriteOnce { class ProtectedDataWriteOnce {
typedef ProtectedDataWriteOnce<Check, T> ThisType; using ThisType = ProtectedDataWriteOnce<Check, T>;
public: public:
template <typename... Args> template <typename... Args>

View File

@@ -28,7 +28,7 @@ static inline bool EqualContainers(const Container1& lhs,
"Must be trivially destructible"); \ "Must be trivially destructible"); \
namespace js { \ namespace js { \
namespace wasm { \ namespace wasm { \
typedef Vector<Type, 0, SystemAllocPolicy> VectorName; using VectorName = Vector<Type, 0, SystemAllocPolicy>;
using mozilla::MallocSizeOf; using mozilla::MallocSizeOf;