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);
}
typedef Vector<JSLinearString*, 16, SystemAllocPolicy> LinearStringVector;
using LinearStringVector = Vector<JSLinearString*, 16, SystemAllocPolicy>;
template <typename TextChar, typename PatChar>
static int RopeMatchImpl(const AutoCheckCannotGC& nogc,

View File

@@ -285,9 +285,9 @@ class Completion {
Variant variant;
};
typedef HashSet<WeakHeapPtr<GlobalObject*>,
StableCellHasher<WeakHeapPtr<GlobalObject*>>, ZoneAllocPolicy>
WeakGlobalObjectSet;
using WeakGlobalObjectSet =
HashSet<WeakHeapPtr<GlobalObject*>,
StableCellHasher<WeakHeapPtr<GlobalObject*>>, ZoneAllocPolicy>;
#ifdef DEBUG
extern void CheckDebuggeeThing(BaseScript* script, bool invisibleOk);
@@ -344,7 +344,7 @@ class DebuggerWeakMap : private WeakMap<HeapPtr<Referent*>, HeapPtr<Wrapper*>> {
JS::Compartment* compartment;
public:
typedef WeakMap<Key, Value> Base;
using Base = WeakMap<Key, Value>;
using ReferentType = Referent;
using WrapperType = Wrapper;
@@ -466,8 +466,8 @@ using Env = JSObject;
// 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
// Variant's static checks.
typedef mozilla::Variant<BaseScript*, WasmInstanceObject*>
DebuggerScriptReferent;
using DebuggerScriptReferent =
mozilla::Variant<BaseScript*, WasmInstanceObject*>;
// 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
// pointer. See the comments for DebuggerScriptReferent for the rationale for
// this type.
typedef mozilla::Variant<ScriptSourceObject*, WasmInstanceObject*>
DebuggerSourceReferent;
using DebuggerSourceReferent =
mozilla::Variant<ScriptSourceObject*, WasmInstanceObject*>;
template <typename HookIsEnabledFun /* bool (Debugger*) */>
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
* has to be different.
*/
typedef HashMap<AbstractFramePtr, HeapPtr<DebuggerFrame*>,
DefaultHasher<AbstractFramePtr>, ZoneAllocPolicy>
FrameMap;
using FrameMap = HashMap<AbstractFramePtr, HeapPtr<DebuggerFrame*>,
DefaultHasher<AbstractFramePtr>, ZoneAllocPolicy>;
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
* GENERATOR_INFO_SLOT is set.
*/
typedef DebuggerWeakMap<AbstractGeneratorObject, DebuggerFrame>
GeneratorWeakMap;
using GeneratorWeakMap =
DebuggerWeakMap<AbstractGeneratorObject, DebuggerFrame>;
GeneratorWeakMap generatorFrames;
// 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
// instances.
typedef DebuggerWeakMap<ScriptSourceObject, DebuggerSource, true>
SourceWeakMap;
using SourceWeakMap =
DebuggerWeakMap<ScriptSourceObject, DebuggerSource, true>;
SourceWeakMap sources;
// The map from debuggee objects to their Debugger.Object instances.
typedef DebuggerWeakMap<JSObject, DebuggerObject> ObjectWeakMap;
using ObjectWeakMap = DebuggerWeakMap<JSObject, DebuggerObject>;
ObjectWeakMap objects;
// The map from debuggee Envs to Debugger.Environment instances.
typedef DebuggerWeakMap<JSObject, DebuggerEnvironment> EnvironmentWeakMap;
using EnvironmentWeakMap = DebuggerWeakMap<JSObject, DebuggerEnvironment>;
EnvironmentWeakMap environments;
// The map from WasmInstanceObjects to synthesized Debugger.Script
// instances.
typedef DebuggerWeakMap<WasmInstanceObject, DebuggerScript>
WasmInstanceScriptWeakMap;
using WasmInstanceScriptWeakMap =
DebuggerWeakMap<WasmInstanceObject, DebuggerScript>;
WasmInstanceScriptWeakMap wasmInstanceScripts;
// The map from WasmInstanceObjects to synthesized Debugger.Source
// instances.
typedef DebuggerWeakMap<WasmInstanceObject, DebuggerSource>
WasmInstanceSourceWeakMap;
using WasmInstanceSourceWeakMap =
DebuggerWeakMap<WasmInstanceObject, DebuggerSource>;
WasmInstanceSourceWeakMap wasmInstanceSources;
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
// sequences. See bug 1390526.
typedef Vector<jsbytecode, 64> BytecodeVector;
typedef Vector<js::SrcNote, 64> SrcNotesVector;
using BytecodeVector = Vector<jsbytecode, 64>;
using SrcNotesVector = Vector<js::SrcNote, 64>;
// Bytecode and all data directly associated with specific opcode/index inside
// 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) ==
v8::internal::RegExp::kInternalRegExpFailure);
typedef int (*RegExpCodeSignature)(InputOutputData*);
using RegExpCodeSignature = int (*)(InputOutputData*);
auto function = reinterpret_cast<RegExpCodeSignature>(code->raw());
{
JS::AutoSuppressGCAnalysis nogc;

View File

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

View File

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

View File

@@ -9,7 +9,7 @@
#include "jit/MacroAssembler.h"
typedef void (*EnterTest)();
using EnterTest = void (*)();
// On entry to the JIT code, save every register.
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);
}
typedef struct JSStdName {
struct JSStdName {
size_t atomOffset; /* offset of atom pointer in JSAtomState */
JSProtoKey key;
bool isDummy() const { return key == JSProto_Null; }
bool isSentinel() const { return key == JSProto_LIMIT; }
} JSStdName;
};
static const JSStdName* LookupStdName(const JSAtomState& names, JSAtom* name,
const JSStdName* table) {

View File

@@ -506,15 +506,12 @@ extern JS_PUBLIC_API JSLinearString* GetErrorTypeName(JSContext* cx,
int16_t exnType);
/* Implemented in CrossCompartmentWrapper.cpp. */
typedef enum NukeReferencesToWindow {
NukeWindowReferences,
DontNukeWindowReferences
} NukeReferencesToWindow;
enum NukeReferencesToWindow { NukeWindowReferences, DontNukeWindowReferences };
typedef enum NukeReferencesFromTarget {
enum NukeReferencesFromTarget {
NukeAllReferences,
NukeIncomingReferences,
} NukeReferencesFromTarget;
};
/*
* These filters are designed to be ephemeral stack classes, and thus don't
@@ -709,7 +706,7 @@ extern JS_PUBLIC_API bool IsSavedFrame(JSObject* obj);
#if defined(XP_WIN)
// Parameters use void* types to avoid #including windows.h. The return value of
// 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
/**

View File

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

View File

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

View File

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

View File

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