summaryrefslogtreecommitdiff
path: root/js/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/wasm')
-rw-r--r--js/src/wasm/AsmJS.cpp14
-rw-r--r--js/src/wasm/AsmJS.h2
-rw-r--r--js/src/wasm/WasmBaselineCompile.cpp123
-rw-r--r--js/src/wasm/WasmBinaryFormat.h108
-rw-r--r--js/src/wasm/WasmBinaryIterator.h158
-rw-r--r--js/src/wasm/WasmBinaryToAST.cpp3
-rw-r--r--js/src/wasm/WasmBinaryToExperimentalText.h2
-rw-r--r--js/src/wasm/WasmBinaryToText.h3
-rw-r--r--js/src/wasm/WasmCode.h3
-rw-r--r--js/src/wasm/WasmGenerator.h51
-rw-r--r--js/src/wasm/WasmInstance.h5
-rw-r--r--js/src/wasm/WasmIonCompile.h3
-rw-r--r--js/src/wasm/WasmJS.h2
-rw-r--r--js/src/wasm/WasmSignalHandlers.h2
-rw-r--r--js/src/wasm/WasmTextToBinary.h3
-rw-r--r--js/src/wasm/WasmTextUtils.cpp8
-rw-r--r--js/src/wasm/WasmTextUtils.h5
-rw-r--r--js/src/wasm/WasmTypes.h2
18 files changed, 253 insertions, 244 deletions
diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp
index 9bb3f08e79..1c42ceca59 100644
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -1595,7 +1595,7 @@ class MOZ_STACK_CLASS ModuleValidator
MOZ_ASSERT(!moduleFunctionName_);
moduleFunctionName_ = name;
}
- MOZ_MUST_USE bool initGlobalArgumentName(PropertyName* n) {
+ [[nodiscard]] bool initGlobalArgumentName(PropertyName* n) {
MOZ_ASSERT(n->isTenured());
globalArgumentName_ = n;
if (n) {
@@ -1605,7 +1605,7 @@ class MOZ_STACK_CLASS ModuleValidator
}
return true;
}
- MOZ_MUST_USE bool initImportArgumentName(PropertyName* n) {
+ [[nodiscard]] bool initImportArgumentName(PropertyName* n) {
MOZ_ASSERT(n->isTenured());
importArgumentName_ = n;
if (n) {
@@ -1615,7 +1615,7 @@ class MOZ_STACK_CLASS ModuleValidator
}
return true;
}
- MOZ_MUST_USE bool initBufferArgumentName(PropertyName* n) {
+ [[nodiscard]] bool initBufferArgumentName(PropertyName* n) {
MOZ_ASSERT(n->isTenured());
bufferArgumentName_ = n;
if (n) {
@@ -2500,11 +2500,11 @@ class MOZ_STACK_CLASS FunctionValidator
Encoder& encoder() { return *encoder_; }
- MOZ_MUST_USE bool writeInt32Lit(int32_t i32) {
+ [[nodiscard]] bool writeInt32Lit(int32_t i32) {
return encoder().writeOp(Op::I32Const) &&
encoder().writeVarS32(i32);
}
- MOZ_MUST_USE bool writeConstExpr(const NumLit& lit) {
+ [[nodiscard]] bool writeConstExpr(const NumLit& lit) {
switch (lit.which()) {
case NumLit::Fixnum:
case NumLit::NegativeInt:
@@ -2521,11 +2521,11 @@ class MOZ_STACK_CLASS FunctionValidator
}
MOZ_CRASH("unexpected literal type");
}
- MOZ_MUST_USE bool writeCall(ParseNode* pn, Op op) {
+ [[nodiscard]] bool writeCall(ParseNode* pn, Op op) {
return encoder().writeOp(op) &&
fg_.addCallSiteLineNum(m().tokenStream().srcCoords.lineNum(pn->pn_pos.begin));
}
- MOZ_MUST_USE bool prepareCall(ParseNode* pn) {
+ [[nodiscard]] bool prepareCall(ParseNode* pn) {
return fg_.addCallSiteLineNum(m().tokenStream().srcCoords.lineNum(pn->pn_pos.begin));
}
};
diff --git a/js/src/wasm/AsmJS.h b/js/src/wasm/AsmJS.h
index 2bad4b3e4e..abdbf5111d 100644
--- a/js/src/wasm/AsmJS.h
+++ b/js/src/wasm/AsmJS.h
@@ -39,7 +39,7 @@ typedef frontend::Parser<frontend::FullParseHandler> AsmJSParser;
// indeterminate amount and the entire function should be reparsed from the
// beginning.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
CompileAsmJS(ExclusiveContext* cx, AsmJSParser& parser, frontend::ParseNode* stmtList,
bool* validated);
diff --git a/js/src/wasm/WasmBaselineCompile.cpp b/js/src/wasm/WasmBaselineCompile.cpp
index 152d15cf24..38d8d5b99b 100644
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -583,11 +584,11 @@ class BaseCompiler
const ValTypeVector& locals,
FuncCompileResults& compileResults);
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
void finish();
- MOZ_MUST_USE bool emitFunction();
+ [[nodiscard]] bool emitFunction();
// Used by some of the ScratchRegister implementations.
operator MacroAssembler&() const { return masm; }
@@ -607,14 +608,14 @@ class BaseCompiler
//
// Out of line code management.
- MOZ_MUST_USE OutOfLineCode* addOutOfLineCode(OutOfLineCode* ool) {
+ [[nodiscard]] OutOfLineCode* addOutOfLineCode(OutOfLineCode* ool) {
if (!ool || !outOfLine_.append(ool))
return nullptr;
ool->setFramePushed(masm.framePushed());
return ool;
}
- MOZ_MUST_USE bool generateOutOfLineCode() {
+ [[nodiscard]] bool generateOutOfLineCode() {
for (uint32_t i = 0; i < outOfLine_.length(); i++) {
OutOfLineCode* ool = outOfLine_[i];
ool->bind(masm);
@@ -1010,7 +1011,7 @@ class BaseCompiler
freeFPU(r.reg);
}
- MOZ_MUST_USE RegI32 needI32() {
+ [[nodiscard]] RegI32 needI32() {
if (!hasGPR())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegI32(allocGPR());
@@ -1030,7 +1031,7 @@ class BaseCompiler
needI32(r1);
}
- MOZ_MUST_USE RegI64 needI64() {
+ [[nodiscard]] RegI64 needI64() {
if (!hasInt64())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegI64(allocInt64());
@@ -1047,7 +1048,7 @@ class BaseCompiler
needI64(r1);
}
- MOZ_MUST_USE RegF32 needF32() {
+ [[nodiscard]] RegF32 needF32() {
if (!hasFPU<MIRType::Float32>())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegF32(allocFPU<MIRType::Float32>());
@@ -1059,7 +1060,7 @@ class BaseCompiler
allocFPU(specific.reg);
}
- MOZ_MUST_USE RegF64 needF64() {
+ [[nodiscard]] RegF64 needF64() {
if (!hasFPU<MIRType::Double>())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegF64(allocFPU<MIRType::Double>());
@@ -1491,7 +1492,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegI32 popI32() {
+ [[nodiscard]] RegI32 popI32() {
Stk& v = stk_.back();
RegI32 r;
if (v.kind() == Stk::RegisterI32)
@@ -1545,7 +1546,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegI64 popI64() {
+ [[nodiscard]] RegI64 popI64() {
Stk& v = stk_.back();
RegI64 r;
if (v.kind() == Stk::RegisterI64)
@@ -1599,7 +1600,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegF64 popF64() {
+ [[nodiscard]] RegF64 popF64() {
Stk& v = stk_.back();
RegF64 r;
if (v.kind() == Stk::RegisterF64)
@@ -1648,7 +1649,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegF32 popF32() {
+ [[nodiscard]] RegF32 popF32() {
Stk& v = stk_.back();
RegF32 r;
if (v.kind() == Stk::RegisterF32)
@@ -1673,7 +1674,7 @@ class BaseCompiler
return specific;
}
- MOZ_MUST_USE bool popConstI32(int32_t& c) {
+ [[nodiscard]] bool popConstI32(int32_t& c) {
Stk& v = stk_.back();
if (v.kind() != Stk::ConstI32)
return false;
@@ -1701,7 +1702,7 @@ class BaseCompiler
// popping of the stack we can just use the JoinReg as it will
// become available in that process.
- MOZ_MUST_USE AnyReg popJoinReg() {
+ [[nodiscard]] AnyReg popJoinReg() {
switch (stk_.back().kind()) {
case Stk::RegisterI32:
case Stk::ConstI32:
@@ -1731,7 +1732,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE AnyReg allocJoinReg(ExprType type) {
+ [[nodiscard]] AnyReg allocJoinReg(ExprType type) {
switch (type) {
case ExprType::I32:
allocGPR(joinRegI32.reg);
@@ -1926,7 +1927,7 @@ class BaseCompiler
Vector<Control, 8, SystemAllocPolicy> ctl_;
- MOZ_MUST_USE bool pushControl(UniquePooledLabel* label, UniquePooledLabel* otherLabel = nullptr)
+ [[nodiscard]] bool pushControl(UniquePooledLabel* label, UniquePooledLabel* otherLabel = nullptr)
{
uint32_t framePushed = masm.framePushed();
uint32_t stackSize = stk_.length();
@@ -1956,7 +1957,7 @@ class BaseCompiler
return ctl_[ctl_.length() - 1 - relativeDepth];
}
- MOZ_MUST_USE PooledLabel* newLabel() {
+ [[nodiscard]] PooledLabel* newLabel() {
// TODO / INVESTIGATE (Bug 1316819): allocate() is fallible, but we can
// probably rely on an infallible allocator here. That would simplify
// code later.
@@ -2825,7 +2826,7 @@ class BaseCompiler
}
};
- MOZ_MUST_USE bool truncateF32ToI32(RegF32 src, RegI32 dest, bool isUnsigned) {
+ [[nodiscard]] bool truncateF32ToI32(RegF32 src, RegI32 dest, bool isUnsigned) {
TrapOffset off = trapOffset();
OutOfLineCode* ool;
if (isCompilingAsmJS()) {
@@ -2853,7 +2854,7 @@ class BaseCompiler
return true;
}
- MOZ_MUST_USE bool truncateF64ToI32(RegF64 src, RegI32 dest, bool isUnsigned) {
+ [[nodiscard]] bool truncateF64ToI32(RegF64 src, RegI32 dest, bool isUnsigned) {
TrapOffset off = trapOffset();
OutOfLineCode* ool;
if (isCompilingAsmJS()) {
@@ -2923,7 +2924,7 @@ class BaseCompiler
};
#ifndef FLOAT_TO_I64_CALLOUT
- MOZ_MUST_USE bool truncateF32ToI64(RegF32 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
+ [[nodiscard]] bool truncateF32ToI64(RegF32 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
# if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86)
OutOfLineCode* ool =
addOutOfLineCode(new (alloc_) OutOfLineTruncateCheckF32OrF64ToI64(AnyReg(src),
@@ -2943,7 +2944,7 @@ class BaseCompiler
return true;
}
- MOZ_MUST_USE bool truncateF64ToI64(RegF64 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
+ [[nodiscard]] bool truncateF64ToI64(RegF64 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
# if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86)
OutOfLineCode* ool =
addOutOfLineCode(new (alloc_) OutOfLineTruncateCheckF32OrF64ToI64(AnyReg(src),
@@ -3231,7 +3232,7 @@ class BaseCompiler
}
// This is the temp register passed as the last argument to load()
- MOZ_MUST_USE size_t loadStoreTemps(MemoryAccessDesc& access) {
+ [[nodiscard]] size_t loadStoreTemps(MemoryAccessDesc& access) {
#if defined(JS_CODEGEN_ARM)
if (IsUnaligned(access)) {
switch (access.type()) {
@@ -3251,7 +3252,7 @@ class BaseCompiler
// ptr and dest may be the same iff dest is I32.
// This may destroy ptr even if ptr and dest are not the same.
- MOZ_MUST_USE bool load(MemoryAccessDesc& access, RegI32 ptr, AnyReg dest, RegI32 tmp1,
+ [[nodiscard]] bool load(MemoryAccessDesc& access, RegI32 ptr, AnyReg dest, RegI32 tmp1,
RegI32 tmp2)
{
checkOffset(&access, ptr);
@@ -3337,7 +3338,7 @@ class BaseCompiler
// ptr and src must not be the same register.
// This may destroy ptr.
- MOZ_MUST_USE bool store(MemoryAccessDesc access, RegI32 ptr, AnyReg src, RegI32 tmp1,
+ [[nodiscard]] bool store(MemoryAccessDesc access, RegI32 ptr, AnyReg src, RegI32 tmp1,
RegI32 tmp2)
{
checkOffset(&access, ptr);
@@ -3613,38 +3614,38 @@ class BaseCompiler
//////////////////////////////////////////////////////////////////////
- MOZ_MUST_USE bool emitBody();
- MOZ_MUST_USE bool emitBlock();
- MOZ_MUST_USE bool emitLoop();
- MOZ_MUST_USE bool emitIf();
- MOZ_MUST_USE bool emitElse();
- MOZ_MUST_USE bool emitEnd();
- MOZ_MUST_USE bool emitBr();
- MOZ_MUST_USE bool emitBrIf();
- MOZ_MUST_USE bool emitBrTable();
- MOZ_MUST_USE bool emitDrop();
- MOZ_MUST_USE bool emitReturn();
- MOZ_MUST_USE bool emitCallArgs(const ValTypeVector& args, FunctionCall& baselineCall);
- MOZ_MUST_USE bool emitCall();
- MOZ_MUST_USE bool emitCallIndirect(bool oldStyle);
- MOZ_MUST_USE bool emitCommonMathCall(uint32_t lineOrBytecode, SymbolicAddress callee,
+ [[nodiscard]] bool emitBody();
+ [[nodiscard]] bool emitBlock();
+ [[nodiscard]] bool emitLoop();
+ [[nodiscard]] bool emitIf();
+ [[nodiscard]] bool emitElse();
+ [[nodiscard]] bool emitEnd();
+ [[nodiscard]] bool emitBr();
+ [[nodiscard]] bool emitBrIf();
+ [[nodiscard]] bool emitBrTable();
+ [[nodiscard]] bool emitDrop();
+ [[nodiscard]] bool emitReturn();
+ [[nodiscard]] bool emitCallArgs(const ValTypeVector& args, FunctionCall& baselineCall);
+ [[nodiscard]] bool emitCall();
+ [[nodiscard]] bool emitCallIndirect(bool oldStyle);
+ [[nodiscard]] bool emitCommonMathCall(uint32_t lineOrBytecode, SymbolicAddress callee,
ValTypeVector& signature, ExprType retType);
- MOZ_MUST_USE bool emitUnaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
- MOZ_MUST_USE bool emitBinaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
+ [[nodiscard]] bool emitUnaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
+ [[nodiscard]] bool emitBinaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
#ifdef INT_DIV_I64_CALLOUT
- MOZ_MUST_USE bool emitDivOrModI64BuiltinCall(SymbolicAddress callee, ValType operandType);
+ [[nodiscard]] bool emitDivOrModI64BuiltinCall(SymbolicAddress callee, ValType operandType);
#endif
- MOZ_MUST_USE bool emitGetLocal();
- MOZ_MUST_USE bool emitSetLocal();
- MOZ_MUST_USE bool emitTeeLocal();
- MOZ_MUST_USE bool emitGetGlobal();
- MOZ_MUST_USE bool emitSetGlobal();
- MOZ_MUST_USE bool emitTeeGlobal();
- MOZ_MUST_USE bool emitLoad(ValType type, Scalar::Type viewType);
- MOZ_MUST_USE bool emitStore(ValType resultType, Scalar::Type viewType);
- MOZ_MUST_USE bool emitTeeStore(ValType resultType, Scalar::Type viewType);
- MOZ_MUST_USE bool emitTeeStoreWithCoercion(ValType resultType, Scalar::Type viewType);
- MOZ_MUST_USE bool emitSelect();
+ [[nodiscard]] bool emitGetLocal();
+ [[nodiscard]] bool emitSetLocal();
+ [[nodiscard]] bool emitTeeLocal();
+ [[nodiscard]] bool emitGetGlobal();
+ [[nodiscard]] bool emitSetGlobal();
+ [[nodiscard]] bool emitTeeGlobal();
+ [[nodiscard]] bool emitLoad(ValType type, Scalar::Type viewType);
+ [[nodiscard]] bool emitStore(ValType resultType, Scalar::Type viewType);
+ [[nodiscard]] bool emitTeeStore(ValType resultType, Scalar::Type viewType);
+ [[nodiscard]] bool emitTeeStoreWithCoercion(ValType resultType, Scalar::Type viewType);
+ [[nodiscard]] bool emitSelect();
void endBlock(ExprType type, bool isFunctionBody);
void endLoop(ExprType type);
@@ -3725,14 +3726,14 @@ class BaseCompiler
void emitNegateF64();
void emitSqrtF32();
void emitSqrtF64();
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF32ToI32();
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF64ToI32();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF32ToI32();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF64ToI32();
#ifdef FLOAT_TO_I64_CALLOUT
- MOZ_MUST_USE bool emitConvertFloatingToInt64Callout(SymbolicAddress callee, ValType operandType,
+ [[nodiscard]] bool emitConvertFloatingToInt64Callout(SymbolicAddress callee, ValType operandType,
ValType resultType);
#else
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF32ToI64();
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF64ToI64();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF32ToI64();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF64ToI64();
#endif
void emitWrapI64ToI32();
void emitExtendI32_8();
@@ -3751,7 +3752,7 @@ class BaseCompiler
void emitConvertI32ToF64();
void emitConvertU32ToF64();
#ifdef I64_TO_FLOAT_CALLOUT
- MOZ_MUST_USE bool emitConvertInt64ToFloatingCallout(SymbolicAddress callee, ValType operandType,
+ [[nodiscard]] bool emitConvertInt64ToFloatingCallout(SymbolicAddress callee, ValType operandType,
ValType resultType);
#else
void emitConvertI64ToF32();
@@ -3761,8 +3762,8 @@ class BaseCompiler
#endif
void emitReinterpretI32AsF32();
void emitReinterpretI64AsF64();
- MOZ_MUST_USE bool emitGrowMemory();
- MOZ_MUST_USE bool emitCurrentMemory();
+ [[nodiscard]] bool emitGrowMemory();
+ [[nodiscard]] bool emitCurrentMemory();
};
void
diff --git a/js/src/wasm/WasmBinaryFormat.h b/js/src/wasm/WasmBinaryFormat.h
index 0279597cb8..d7fda3aa8a 100644
--- a/js/src/wasm/WasmBinaryFormat.h
+++ b/js/src/wasm/WasmBinaryFormat.h
@@ -33,12 +33,12 @@ class Encoder
Bytes& bytes_;
template <class T>
- MOZ_MUST_USE bool write(const T& v) {
+ [[nodiscard]] bool write(const T& v) {
return bytes_.append(reinterpret_cast<const uint8_t*>(&v), sizeof(T));
}
template <typename UInt>
- MOZ_MUST_USE bool writeVarU(UInt i) {
+ [[nodiscard]] bool writeVarU(UInt i) {
do {
uint8_t byte = i & 0x7f;
i >>= 7;
@@ -51,7 +51,7 @@ class Encoder
}
template <typename SInt>
- MOZ_MUST_USE bool writeVarS(SInt i) {
+ [[nodiscard]] bool writeVarS(SInt i) {
bool done;
do {
uint8_t byte = i & 0x7f;
@@ -111,48 +111,48 @@ class Encoder
// Fixed-size encoding operations simply copy the literal bytes (without
// attempting to align).
- MOZ_MUST_USE bool writeFixedU7(uint8_t i) {
+ [[nodiscard]] bool writeFixedU7(uint8_t i) {
MOZ_ASSERT(i <= uint8_t(INT8_MAX));
return writeFixedU8(i);
}
- MOZ_MUST_USE bool writeFixedU8(uint8_t i) {
+ [[nodiscard]] bool writeFixedU8(uint8_t i) {
return write<uint8_t>(i);
}
- MOZ_MUST_USE bool writeFixedU32(uint32_t i) {
+ [[nodiscard]] bool writeFixedU32(uint32_t i) {
return write<uint32_t>(i);
}
- MOZ_MUST_USE bool writeFixedF32(RawF32 f) {
+ [[nodiscard]] bool writeFixedF32(RawF32 f) {
return write<uint32_t>(f.bits());
}
- MOZ_MUST_USE bool writeFixedF64(RawF64 d) {
+ [[nodiscard]] bool writeFixedF64(RawF64 d) {
return write<uint64_t>(d.bits());
}
// Variable-length encodings that all use LEB128.
- MOZ_MUST_USE bool writeVarU32(uint32_t i) {
+ [[nodiscard]] bool writeVarU32(uint32_t i) {
return writeVarU<uint32_t>(i);
}
- MOZ_MUST_USE bool writeVarS32(int32_t i) {
+ [[nodiscard]] bool writeVarS32(int32_t i) {
return writeVarS<int32_t>(i);
}
- MOZ_MUST_USE bool writeVarU64(uint64_t i) {
+ [[nodiscard]] bool writeVarU64(uint64_t i) {
return writeVarU<uint64_t>(i);
}
- MOZ_MUST_USE bool writeVarS64(int64_t i) {
+ [[nodiscard]] bool writeVarS64(int64_t i) {
return writeVarS<int64_t>(i);
}
- MOZ_MUST_USE bool writeValType(ValType type) {
+ [[nodiscard]] bool writeValType(ValType type) {
static_assert(size_t(TypeCode::Limit) <= UINT8_MAX, "fits");
MOZ_ASSERT(size_t(type) < size_t(TypeCode::Limit));
return writeFixedU8(uint8_t(type));
}
- MOZ_MUST_USE bool writeBlockType(ExprType type) {
+ [[nodiscard]] bool writeBlockType(ExprType type) {
static_assert(size_t(TypeCode::Limit) <= UINT8_MAX, "fits");
MOZ_ASSERT(size_t(type) < size_t(TypeCode::Limit));
return writeFixedU8(uint8_t(type));
}
- MOZ_MUST_USE bool writeOp(Op op) {
+ [[nodiscard]] bool writeOp(Op op) {
static_assert(size_t(Op::Limit) <= 2 * UINT8_MAX, "fits");
MOZ_ASSERT(size_t(op) < size_t(Op::Limit));
if (size_t(op) < UINT8_MAX)
@@ -163,7 +163,7 @@ class Encoder
// Fixed-length encodings that allow back-patching.
- MOZ_MUST_USE bool writePatchableFixedU7(size_t* offset) {
+ [[nodiscard]] bool writePatchableFixedU7(size_t* offset) {
*offset = bytes_.length();
return writeFixedU8(UINT8_MAX);
}
@@ -173,7 +173,7 @@ class Encoder
// Variable-length encodings that allow back-patching.
- MOZ_MUST_USE bool writePatchableVarU32(size_t* offset) {
+ [[nodiscard]] bool writePatchableVarU32(size_t* offset) {
*offset = bytes_.length();
return writeVarU32(UINT32_MAX);
}
@@ -184,7 +184,7 @@ class Encoder
// Byte ranges start with an LEB128 length followed by an arbitrary sequence
// of bytes. When used for strings, bytes are to be interpreted as utf8.
- MOZ_MUST_USE bool writeBytes(const void* bytes, uint32_t numBytes) {
+ [[nodiscard]] bool writeBytes(const void* bytes, uint32_t numBytes) {
return writeVarU32(numBytes) &&
bytes_.append(reinterpret_cast<const uint8_t*>(bytes), numBytes);
}
@@ -195,7 +195,7 @@ class Encoder
// end while the size's varU32 must be stored at the beginning. Immediately
// after the section length is the string id of the section.
- MOZ_MUST_USE bool startSection(SectionId id, size_t* offset) {
+ [[nodiscard]] bool startSection(SectionId id, size_t* offset) {
MOZ_ASSERT(id != SectionId::UserDefined); // not supported yet
return writeVarU32(uint32_t(id)) &&
@@ -218,7 +218,7 @@ class Decoder
UniqueChars* error_;
template <class T>
- MOZ_MUST_USE bool read(T* out) {
+ [[nodiscard]] bool read(T* out) {
if (bytesRemain() < sizeof(T))
return false;
memcpy((void*)out, cur_, sizeof(T));
@@ -243,7 +243,7 @@ class Decoder
}
template <typename UInt>
- MOZ_MUST_USE bool readVarU(UInt* out) {
+ [[nodiscard]] bool readVarU(UInt* out) {
const unsigned numBits = sizeof(UInt) * CHAR_BIT;
const unsigned remainderBits = numBits % 7;
const unsigned numBitsInSevens = numBits - remainderBits;
@@ -267,7 +267,7 @@ class Decoder
}
template <typename SInt>
- MOZ_MUST_USE bool readVarS(SInt* out) {
+ [[nodiscard]] bool readVarS(SInt* out) {
const unsigned numBits = sizeof(SInt) * CHAR_BIT;
const unsigned remainderBits = numBits % 7;
const unsigned numBitsInSevens = numBits - remainderBits;
@@ -344,20 +344,20 @@ class Decoder
// Fixed-size encoding operations simply copy the literal bytes (without
// attempting to align).
- MOZ_MUST_USE bool readFixedU8(uint8_t* i) {
+ [[nodiscard]] bool readFixedU8(uint8_t* i) {
return read<uint8_t>(i);
}
- MOZ_MUST_USE bool readFixedU32(uint32_t* u) {
+ [[nodiscard]] bool readFixedU32(uint32_t* u) {
return read<uint32_t>(u);
}
- MOZ_MUST_USE bool readFixedF32(RawF32* f) {
+ [[nodiscard]] bool readFixedF32(RawF32* f) {
uint32_t u;
if (!read<uint32_t>(&u))
return false;
*f = RawF32::fromBits(u);
return true;
}
- MOZ_MUST_USE bool readFixedF64(RawF64* d) {
+ [[nodiscard]] bool readFixedF64(RawF64* d) {
uint64_t u;
if (!read<uint64_t>(&u))
return false;
@@ -367,27 +367,27 @@ class Decoder
// Variable-length encodings that all use LEB128.
- MOZ_MUST_USE bool readVarU32(uint32_t* out) {
+ [[nodiscard]] bool readVarU32(uint32_t* out) {
return readVarU<uint32_t>(out);
}
- MOZ_MUST_USE bool readVarS32(int32_t* out) {
+ [[nodiscard]] bool readVarS32(int32_t* out) {
return readVarS<int32_t>(out);
}
- MOZ_MUST_USE bool readVarU64(uint64_t* out) {
+ [[nodiscard]] bool readVarU64(uint64_t* out) {
return readVarU<uint64_t>(out);
}
- MOZ_MUST_USE bool readVarS64(int64_t* out) {
+ [[nodiscard]] bool readVarS64(int64_t* out) {
return readVarS<int64_t>(out);
}
- MOZ_MUST_USE bool readValType(uint8_t* type) {
+ [[nodiscard]] bool readValType(uint8_t* type) {
static_assert(uint8_t(TypeCode::Limit) <= UINT8_MAX, "fits");
return readFixedU8(type);
}
- MOZ_MUST_USE bool readBlockType(uint8_t* type) {
+ [[nodiscard]] bool readBlockType(uint8_t* type) {
static_assert(size_t(TypeCode::Limit) <= UINT8_MAX, "fits");
return readFixedU8(type);
}
- MOZ_MUST_USE bool readOp(uint16_t* op) {
+ [[nodiscard]] bool readOp(uint16_t* op) {
static_assert(size_t(Op::Limit) <= 2 * UINT8_MAX, "fits");
uint8_t u8;
if (!readFixedU8(&u8))
@@ -404,7 +404,7 @@ class Decoder
// See writeBytes comment.
- MOZ_MUST_USE bool readBytes(uint32_t numBytes, const uint8_t** bytes = nullptr) {
+ [[nodiscard]] bool readBytes(uint32_t numBytes, const uint8_t** bytes = nullptr) {
if (bytes)
*bytes = cur_;
if (bytesRemain() < numBytes)
@@ -417,7 +417,7 @@ class Decoder
static const uint32_t NotStarted = UINT32_MAX;
- MOZ_MUST_USE bool startSection(SectionId id,
+ [[nodiscard]] bool startSection(SectionId id,
uint32_t* startOffset,
uint32_t* size,
const char* sectionName)
@@ -451,7 +451,7 @@ class Decoder
fail:
return fail("failed to start %s section", sectionName);
}
- MOZ_MUST_USE bool finishSection(uint32_t startOffset, uint32_t size,
+ [[nodiscard]] bool finishSection(uint32_t startOffset, uint32_t size,
const char* sectionName)
{
if (size != (cur_ - beg_) - startOffset)
@@ -462,7 +462,7 @@ class Decoder
// "User sections" do not cause validation errors unless the error is in
// the user-defined section header itself.
- MOZ_MUST_USE bool startUserDefinedSection(const char* expectedId,
+ [[nodiscard]] bool startUserDefinedSection(const char* expectedId,
size_t expectedIdSize,
uint32_t* sectionStart,
uint32_t* sectionSize)
@@ -492,7 +492,7 @@ class Decoder
return fail("failed to start user-defined section");
}
template <size_t IdSizeWith0>
- MOZ_MUST_USE bool startUserDefinedSection(const char (&id)[IdSizeWith0],
+ [[nodiscard]] bool startUserDefinedSection(const char (&id)[IdSizeWith0],
uint32_t* sectionStart,
uint32_t* sectionSize)
{
@@ -506,7 +506,7 @@ class Decoder
MOZ_ASSERT(cur_ <= end_);
clearError();
}
- MOZ_MUST_USE bool skipUserDefinedSection() {
+ [[nodiscard]] bool skipUserDefinedSection() {
uint32_t sectionStart, sectionSize;
if (!startUserDefinedSection(nullptr, 0, &sectionStart, &sectionSize))
return false;
@@ -587,56 +587,56 @@ class Decoder
UniqueChars
DecodeName(Decoder& d);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeTableLimits(Decoder& d, TableDescVector* tables);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
GlobalIsJSCompatible(Decoder& d, ValType type, bool isMutable);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EncodeLocalEntries(Encoder& d, const ValTypeVector& locals);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeLocalEntries(Decoder& d, ModuleKind kind, ValTypeVector* locals);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeGlobalType(Decoder& d, ValType* type, bool* isMutable);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeInitializerExpression(Decoder& d, const GlobalDescVector& globals, ValType expected,
InitExpr* init);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeLimits(Decoder& d, Limits* limits);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeMemoryLimits(Decoder& d, bool hasMemory, Limits* memory);
// Section macros.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodePreamble(Decoder& d);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeTypeSection(Decoder& d, SigWithIdVector* sigs);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeImportSection(Decoder& d, const SigWithIdVector& sigs, Uint32Vector* funcSigIndices,
GlobalDescVector* globals, TableDescVector* tables, Maybe<Limits>* memory,
ImportVector* imports);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeFunctionSection(Decoder& d, const SigWithIdVector& sigs, size_t numImportedFunc,
Uint32Vector* funcSigIndexes);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeUnknownSections(Decoder& d);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeDataSection(Decoder& d, bool usesMemory, uint32_t minMemoryByteLength,
const GlobalDescVector& globals, DataSegmentVector* segments);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeMemorySection(Decoder& d, bool hasMemory, Limits* memory, bool* present);
} // namespace wasm
diff --git a/js/src/wasm/WasmBinaryIterator.h b/js/src/wasm/WasmBinaryIterator.h
index ccad80f9dd..c5473ef42f 100644
--- a/js/src/wasm/WasmBinaryIterator.h
+++ b/js/src/wasm/WasmBinaryIterator.h
@@ -260,56 +260,56 @@ class MOZ_STACK_CLASS OpIter : private Policy
DebugOnly<Op> op_;
size_t offsetOfExpr_;
- MOZ_MUST_USE bool readFixedU8(uint8_t* out) {
+ [[nodiscard]] bool readFixedU8(uint8_t* out) {
if (Validate)
return d_.readFixedU8(out);
*out = d_.uncheckedReadFixedU8();
return true;
}
- MOZ_MUST_USE bool readFixedU32(uint32_t* out) {
+ [[nodiscard]] bool readFixedU32(uint32_t* out) {
if (Validate)
return d_.readFixedU32(out);
*out = d_.uncheckedReadFixedU32();
return true;
}
- MOZ_MUST_USE bool readVarS32(int32_t* out) {
+ [[nodiscard]] bool readVarS32(int32_t* out) {
if (Validate)
return d_.readVarS32(out);
*out = d_.uncheckedReadVarS32();
return true;
}
- MOZ_MUST_USE bool readVarU32(uint32_t* out) {
+ [[nodiscard]] bool readVarU32(uint32_t* out) {
if (Validate)
return d_.readVarU32(out);
*out = d_.uncheckedReadVarU32();
return true;
}
- MOZ_MUST_USE bool readVarS64(int64_t* out) {
+ [[nodiscard]] bool readVarS64(int64_t* out) {
if (Validate)
return d_.readVarS64(out);
*out = d_.uncheckedReadVarS64();
return true;
}
- MOZ_MUST_USE bool readVarU64(uint64_t* out) {
+ [[nodiscard]] bool readVarU64(uint64_t* out) {
if (Validate)
return d_.readVarU64(out);
*out = d_.uncheckedReadVarU64();
return true;
}
- MOZ_MUST_USE bool readFixedF32(RawF32* out) {
+ [[nodiscard]] bool readFixedF32(RawF32* out) {
if (Validate)
return d_.readFixedF32(out);
*out = d_.uncheckedReadFixedF32();
return true;
}
- MOZ_MUST_USE bool readFixedF64(RawF64* out) {
+ [[nodiscard]] bool readFixedF64(RawF64* out) {
if (Validate)
return d_.readFixedF64(out);
*out = d_.uncheckedReadFixedF64();
return true;
}
- MOZ_MUST_USE bool readAtomicViewType(Scalar::Type* viewType) {
+ [[nodiscard]] bool readAtomicViewType(Scalar::Type* viewType) {
uint8_t x;
if (!readFixedU8(&x))
return fail("unable to read atomic view");
@@ -319,7 +319,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
return true;
}
- MOZ_MUST_USE bool readAtomicBinOpOp(jit::AtomicOp* op) {
+ [[nodiscard]] bool readAtomicBinOpOp(jit::AtomicOp* op) {
uint8_t x;
if (!readFixedU8(&x))
return fail("unable to read atomic opcode");
@@ -339,23 +339,23 @@ class MOZ_STACK_CLASS OpIter : private Policy
return true;
}
- MOZ_MUST_USE bool readLinearMemoryAddress(uint32_t byteSize, LinearMemoryAddress<Value>* addr);
- MOZ_MUST_USE bool readBlockType(ExprType* expr);
+ [[nodiscard]] bool readLinearMemoryAddress(uint32_t byteSize, LinearMemoryAddress<Value>* addr);
+ [[nodiscard]] bool readBlockType(ExprType* expr);
- MOZ_MUST_USE bool typeMismatch(ExprType actual, ExprType expected) MOZ_COLD;
- MOZ_MUST_USE bool checkType(ValType actual, ValType expected);
- MOZ_MUST_USE bool checkType(ExprType actual, ExprType expected);
+ [[nodiscard]] bool typeMismatch(ExprType actual, ExprType expected) MOZ_COLD;
+ [[nodiscard]] bool checkType(ValType actual, ValType expected);
+ [[nodiscard]] bool checkType(ExprType actual, ExprType expected);
- MOZ_MUST_USE bool pushControl(LabelKind kind, ExprType type, bool reachable);
- MOZ_MUST_USE bool mergeControl(LabelKind* kind, ExprType* type, Value* value);
- MOZ_MUST_USE bool popControl(LabelKind* kind, ExprType* type, Value* value);
+ [[nodiscard]] bool pushControl(LabelKind kind, ExprType type, bool reachable);
+ [[nodiscard]] bool mergeControl(LabelKind* kind, ExprType* type, Value* value);
+ [[nodiscard]] bool popControl(LabelKind* kind, ExprType* type, Value* value);
- MOZ_MUST_USE bool push(ValType t) {
+ [[nodiscard]] bool push(ValType t) {
if (MOZ_UNLIKELY(!reachable_))
return true;
return valueStack_.emplaceBack(t);
}
- MOZ_MUST_USE bool push(TypeAndValue<Value> tv) {
+ [[nodiscard]] bool push(TypeAndValue<Value> tv) {
if (MOZ_UNLIKELY(!reachable_))
return true;
return valueStack_.append(tv);
@@ -372,7 +372,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Test whether reading the top of the value stack is currently valid.
- MOZ_MUST_USE bool checkTop() {
+ [[nodiscard]] bool checkTop() {
MOZ_ASSERT(reachable_);
if (Validate && valueStack_.length() <= controlStack_.back().valueStackStart()) {
if (valueStack_.empty())
@@ -383,7 +383,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Pop the top of the value stack.
- MOZ_MUST_USE bool pop(TypeAndValue<Value>* tv) {
+ [[nodiscard]] bool pop(TypeAndValue<Value>* tv) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -393,7 +393,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Pop the top of the value stack and check that it has the given type.
- MOZ_MUST_USE bool popWithType(ValType expectedType, Value* value) {
+ [[nodiscard]] bool popWithType(ValType expectedType, Value* value) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -407,7 +407,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Pop the top of the value stack and discard the result.
- MOZ_MUST_USE bool pop() {
+ [[nodiscard]] bool pop() {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -417,7 +417,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Read the top of the value stack (without popping it).
- MOZ_MUST_USE bool top(TypeAndValue<Value>* tv) {
+ [[nodiscard]] bool top(TypeAndValue<Value>* tv) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -428,7 +428,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
// Read the top of the value stack (without popping it) and check that it
// has the given type.
- MOZ_MUST_USE bool topWithType(ValType expectedType, Value* value) {
+ [[nodiscard]] bool topWithType(ValType expectedType, Value* value) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -442,7 +442,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Read the value stack entry at depth |index|.
- MOZ_MUST_USE bool peek(uint32_t index, TypeAndValue<Value>* tv) {
+ [[nodiscard]] bool peek(uint32_t index, TypeAndValue<Value>* tv) {
MOZ_ASSERT(reachable_);
if (Validate && valueStack_.length() - controlStack_.back().valueStackStart() < index)
return fail("peeking at value from outside block");
@@ -484,13 +484,13 @@ class MOZ_STACK_CLASS OpIter : private Policy
bool done() const { return d_.done(); }
// Report a general failure.
- MOZ_MUST_USE bool fail(const char* msg) MOZ_COLD;
+ [[nodiscard]] bool fail(const char* msg) MOZ_COLD;
// Report an unimplemented feature.
- MOZ_MUST_USE bool notYetImplemented(const char* what) MOZ_COLD;
+ [[nodiscard]] bool notYetImplemented(const char* what) MOZ_COLD;
// Report an unrecognized opcode.
- MOZ_MUST_USE bool unrecognizedOpcode(uint32_t expr) MOZ_COLD;
+ [[nodiscard]] bool unrecognizedOpcode(uint32_t expr) MOZ_COLD;
// Test whether the iterator is currently in "reachable" code.
bool inReachableCode() const { return reachable_; }
@@ -498,70 +498,70 @@ class MOZ_STACK_CLASS OpIter : private Policy
// ------------------------------------------------------------------------
// Decoding and validation interface.
- MOZ_MUST_USE bool readOp(uint16_t* op);
- MOZ_MUST_USE bool readFunctionStart(ExprType ret);
- MOZ_MUST_USE bool readFunctionEnd();
- MOZ_MUST_USE bool readReturn(Value* value);
- MOZ_MUST_USE bool readBlock();
- MOZ_MUST_USE bool readLoop();
- MOZ_MUST_USE bool readIf(Value* condition);
- MOZ_MUST_USE bool readElse(ExprType* thenType, Value* thenValue);
- MOZ_MUST_USE bool readEnd(LabelKind* kind, ExprType* type, Value* value);
- MOZ_MUST_USE bool readBr(uint32_t* relativeDepth, ExprType* type, Value* value);
- MOZ_MUST_USE bool readBrIf(uint32_t* relativeDepth, ExprType* type,
+ [[nodiscard]] bool readOp(uint16_t* op);
+ [[nodiscard]] bool readFunctionStart(ExprType ret);
+ [[nodiscard]] bool readFunctionEnd();
+ [[nodiscard]] bool readReturn(Value* value);
+ [[nodiscard]] bool readBlock();
+ [[nodiscard]] bool readLoop();
+ [[nodiscard]] bool readIf(Value* condition);
+ [[nodiscard]] bool readElse(ExprType* thenType, Value* thenValue);
+ [[nodiscard]] bool readEnd(LabelKind* kind, ExprType* type, Value* value);
+ [[nodiscard]] bool readBr(uint32_t* relativeDepth, ExprType* type, Value* value);
+ [[nodiscard]] bool readBrIf(uint32_t* relativeDepth, ExprType* type,
Value* value, Value* condition);
- MOZ_MUST_USE bool readBrTable(uint32_t* tableLength, ExprType* type,
+ [[nodiscard]] bool readBrTable(uint32_t* tableLength, ExprType* type,
Value* value, Value* index);
- MOZ_MUST_USE bool readBrTableEntry(ExprType* type, Value* value, uint32_t* depth);
- MOZ_MUST_USE bool readBrTableDefault(ExprType* type, Value* value, uint32_t* depth);
- MOZ_MUST_USE bool readUnreachable();
- MOZ_MUST_USE bool readDrop();
- MOZ_MUST_USE bool readUnary(ValType operandType, Value* input);
- MOZ_MUST_USE bool readConversion(ValType operandType, ValType resultType, Value* input);
- MOZ_MUST_USE bool readBinary(ValType operandType, Value* lhs, Value* rhs);
- MOZ_MUST_USE bool readComparison(ValType operandType, Value* lhs, Value* rhs);
- MOZ_MUST_USE bool readLoad(ValType resultType, uint32_t byteSize,
+ [[nodiscard]] bool readBrTableEntry(ExprType* type, Value* value, uint32_t* depth);
+ [[nodiscard]] bool readBrTableDefault(ExprType* type, Value* value, uint32_t* depth);
+ [[nodiscard]] bool readUnreachable();
+ [[nodiscard]] bool readDrop();
+ [[nodiscard]] bool readUnary(ValType operandType, Value* input);
+ [[nodiscard]] bool readConversion(ValType operandType, ValType resultType, Value* input);
+ [[nodiscard]] bool readBinary(ValType operandType, Value* lhs, Value* rhs);
+ [[nodiscard]] bool readComparison(ValType operandType, Value* lhs, Value* rhs);
+ [[nodiscard]] bool readLoad(ValType resultType, uint32_t byteSize,
LinearMemoryAddress<Value>* addr);
- MOZ_MUST_USE bool readStore(ValType resultType, uint32_t byteSize,
+ [[nodiscard]] bool readStore(ValType resultType, uint32_t byteSize,
LinearMemoryAddress<Value>* addr, Value* value);
- MOZ_MUST_USE bool readTeeStore(ValType resultType, uint32_t byteSize,
+ [[nodiscard]] bool readTeeStore(ValType resultType, uint32_t byteSize,
LinearMemoryAddress<Value>* addr, Value* value);
- MOZ_MUST_USE bool readNop();
- MOZ_MUST_USE bool readCurrentMemory();
- MOZ_MUST_USE bool readGrowMemory(Value* input);
- MOZ_MUST_USE bool readSelect(ValType* type,
+ [[nodiscard]] bool readNop();
+ [[nodiscard]] bool readCurrentMemory();
+ [[nodiscard]] bool readGrowMemory(Value* input);
+ [[nodiscard]] bool readSelect(ValType* type,
Value* trueValue, Value* falseValue, Value* condition);
- MOZ_MUST_USE bool readGetLocal(const ValTypeVector& locals, uint32_t* id);
- MOZ_MUST_USE bool readSetLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readTeeLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readGetGlobal(const GlobalDescVector& globals, uint32_t* id);
- MOZ_MUST_USE bool readSetGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readTeeGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readI32Const(int32_t* i32);
- MOZ_MUST_USE bool readI64Const(int64_t* i64);
- MOZ_MUST_USE bool readF32Const(RawF32* f32);
- MOZ_MUST_USE bool readF64Const(RawF64* f64);
- MOZ_MUST_USE bool readCall(uint32_t* calleeIndex);
- MOZ_MUST_USE bool readCallIndirect(uint32_t* sigIndex, Value* callee);
- MOZ_MUST_USE bool readOldCallIndirect(uint32_t* sigIndex);
- MOZ_MUST_USE bool readCallArg(ValType type, uint32_t numArgs, uint32_t argIndex, Value* arg);
- MOZ_MUST_USE bool readCallArgsEnd(uint32_t numArgs);
- MOZ_MUST_USE bool readOldCallIndirectCallee(Value* callee);
- MOZ_MUST_USE bool readCallReturn(ExprType ret);
- MOZ_MUST_USE bool readAtomicLoad(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readGetLocal(const ValTypeVector& locals, uint32_t* id);
+ [[nodiscard]] bool readSetLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readTeeLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readGetGlobal(const GlobalDescVector& globals, uint32_t* id);
+ [[nodiscard]] bool readSetGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readTeeGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readI32Const(int32_t* i32);
+ [[nodiscard]] bool readI64Const(int64_t* i64);
+ [[nodiscard]] bool readF32Const(RawF32* f32);
+ [[nodiscard]] bool readF64Const(RawF64* f64);
+ [[nodiscard]] bool readCall(uint32_t* calleeIndex);
+ [[nodiscard]] bool readCallIndirect(uint32_t* sigIndex, Value* callee);
+ [[nodiscard]] bool readOldCallIndirect(uint32_t* sigIndex);
+ [[nodiscard]] bool readCallArg(ValType type, uint32_t numArgs, uint32_t argIndex, Value* arg);
+ [[nodiscard]] bool readCallArgsEnd(uint32_t numArgs);
+ [[nodiscard]] bool readOldCallIndirectCallee(Value* callee);
+ [[nodiscard]] bool readCallReturn(ExprType ret);
+ [[nodiscard]] bool readAtomicLoad(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType);
- MOZ_MUST_USE bool readAtomicStore(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicStore(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
Value* value);
- MOZ_MUST_USE bool readAtomicBinOp(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicBinOp(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
jit::AtomicOp* op,
Value* value);
- MOZ_MUST_USE bool readAtomicCompareExchange(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicCompareExchange(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
Value* oldValue,
Value* newValue);
- MOZ_MUST_USE bool readAtomicExchange(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicExchange(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
Value* newValue);
diff --git a/js/src/wasm/WasmBinaryToAST.cpp b/js/src/wasm/WasmBinaryToAST.cpp
index 8d6db7b357..80bec9df46 100644
--- a/js/src/wasm/WasmBinaryToAST.cpp
+++ b/js/src/wasm/WasmBinaryToAST.cpp
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -150,7 +151,7 @@ class AstDecodeContext
void popBack() { return exprs().popBack(); }
AstDecodeStackItem popCopy() { return exprs().popCopy(); }
AstDecodeStackItem& top() { return exprs().back(); }
- MOZ_MUST_USE bool push(AstDecodeStackItem item) { return exprs().append(item); }
+ [[nodiscard]] bool push(AstDecodeStackItem item) { return exprs().append(item); }
bool needFirst() {
for (size_t i = depths().back(); i < exprs().length(); ++i) {
diff --git a/js/src/wasm/WasmBinaryToExperimentalText.h b/js/src/wasm/WasmBinaryToExperimentalText.h
index 6c77c583cb..a93a05eda0 100644
--- a/js/src/wasm/WasmBinaryToExperimentalText.h
+++ b/js/src/wasm/WasmBinaryToExperimentalText.h
@@ -46,7 +46,7 @@ struct ExperimentalTextFormatting
// Translate the given binary representation of a wasm module into the module's textual
// representation.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BinaryToExperimentalText(JSContext* cx, const uint8_t* bytes, size_t length, StringBuffer& buffer,
const ExperimentalTextFormatting& formatting = ExperimentalTextFormatting(),
GeneratedSourceMap* sourceMap = nullptr);
diff --git a/js/src/wasm/WasmBinaryToText.h b/js/src/wasm/WasmBinaryToText.h
index 1674bdcd48..e2c4e530c3 100644
--- a/js/src/wasm/WasmBinaryToText.h
+++ b/js/src/wasm/WasmBinaryToText.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +34,7 @@ namespace wasm {
// Translate the given binary representation of a wasm module into the module's textual
// representation.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BinaryToText(JSContext* cx, const uint8_t* bytes, size_t length, StringBuffer& buffer,
GeneratedSourceMap* sourceMap = nullptr);
diff --git a/js/src/wasm/WasmCode.h b/js/src/wasm/WasmCode.h
index c6f1ace02e..1254fd9d7c 100644
--- a/js/src/wasm/WasmCode.h
+++ b/js/src/wasm/WasmCode.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -530,7 +531,7 @@ class Code
// asynchronously walk the stack. Otherwise, the ProfilingFrameIterator will
// skip any activations of this code.
- MOZ_MUST_USE bool ensureProfilingState(JSContext* cx, bool enabled);
+ [[nodiscard]] bool ensureProfilingState(JSContext* cx, bool enabled);
bool profilingEnabled() const { return profilingEnabled_; }
const char* profilingLabel(uint32_t funcIndex) const { return funcLabels_[funcIndex].get(); }
diff --git a/js/src/wasm/WasmGenerator.h b/js/src/wasm/WasmGenerator.h
index 85b23664a2..377898d6c7 100644
--- a/js/src/wasm/WasmGenerator.h
+++ b/js/src/wasm/WasmGenerator.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -116,22 +117,22 @@ class MOZ_STACK_CLASS ModuleGenerator
bool funcIsCompiled(uint32_t funcIndex) const;
const CodeRange& funcCodeRange(uint32_t funcIndex) const;
- MOZ_MUST_USE bool patchCallSites(TrapExitOffsetArray* maybeTrapExits = nullptr);
- MOZ_MUST_USE bool patchFarJumps(const TrapExitOffsetArray& trapExits);
- MOZ_MUST_USE bool finishTask(IonCompileTask* task);
- MOZ_MUST_USE bool finishOutstandingTask();
- MOZ_MUST_USE bool finishFuncExports();
- MOZ_MUST_USE bool finishCodegen();
- MOZ_MUST_USE bool finishLinkData(Bytes& code);
- MOZ_MUST_USE bool addFuncImport(const Sig& sig, uint32_t globalDataOffset);
- MOZ_MUST_USE bool allocateGlobalBytes(uint32_t bytes, uint32_t align, uint32_t* globalDataOff);
- MOZ_MUST_USE bool allocateGlobal(GlobalDesc* global);
+ [[nodiscard]] bool patchCallSites(TrapExitOffsetArray* maybeTrapExits = nullptr);
+ [[nodiscard]] bool patchFarJumps(const TrapExitOffsetArray& trapExits);
+ [[nodiscard]] bool finishTask(IonCompileTask* task);
+ [[nodiscard]] bool finishOutstandingTask();
+ [[nodiscard]] bool finishFuncExports();
+ [[nodiscard]] bool finishCodegen();
+ [[nodiscard]] bool finishLinkData(Bytes& code);
+ [[nodiscard]] bool addFuncImport(const Sig& sig, uint32_t globalDataOffset);
+ [[nodiscard]] bool allocateGlobalBytes(uint32_t bytes, uint32_t align, uint32_t* globalDataOff);
+ [[nodiscard]] bool allocateGlobal(GlobalDesc* global);
public:
explicit ModuleGenerator(ImportVector&& imports);
~ModuleGenerator();
- MOZ_MUST_USE bool init(UniqueModuleGeneratorData shared, const CompileArgs& args,
+ [[nodiscard]] bool init(UniqueModuleGeneratorData shared, const CompileArgs& args,
Metadata* maybeAsmJSMetadata = nullptr);
bool isAsmJS() const { return metadata_->kind == ModuleKind::AsmJS; }
@@ -159,23 +160,23 @@ class MOZ_STACK_CLASS ModuleGenerator
uint32_t numFuncs() const;
// Exports:
- MOZ_MUST_USE bool addFuncExport(UniqueChars fieldName, uint32_t funcIndex);
- MOZ_MUST_USE bool addTableExport(UniqueChars fieldName);
- MOZ_MUST_USE bool addMemoryExport(UniqueChars fieldName);
- MOZ_MUST_USE bool addGlobalExport(UniqueChars fieldName, uint32_t globalIndex);
+ [[nodiscard]] bool addFuncExport(UniqueChars fieldName, uint32_t funcIndex);
+ [[nodiscard]] bool addTableExport(UniqueChars fieldName);
+ [[nodiscard]] bool addMemoryExport(UniqueChars fieldName);
+ [[nodiscard]] bool addGlobalExport(UniqueChars fieldName, uint32_t globalIndex);
// Function definitions:
- MOZ_MUST_USE bool startFuncDefs();
- MOZ_MUST_USE bool startFuncDef(uint32_t lineOrBytecode, FunctionGenerator* fg);
- MOZ_MUST_USE bool finishFuncDef(uint32_t funcIndex, FunctionGenerator* fg);
- MOZ_MUST_USE bool finishFuncDefs();
+ [[nodiscard]] bool startFuncDefs();
+ [[nodiscard]] bool startFuncDef(uint32_t lineOrBytecode, FunctionGenerator* fg);
+ [[nodiscard]] bool finishFuncDef(uint32_t funcIndex, FunctionGenerator* fg);
+ [[nodiscard]] bool finishFuncDefs();
// Start function:
bool setStartFunction(uint32_t funcIndex);
// Segments:
void setDataSegments(DataSegmentVector&& segments);
- MOZ_MUST_USE bool addElemSegment(InitExpr offset, Uint32Vector&& elemFuncIndices);
+ [[nodiscard]] bool addElemSegment(InitExpr offset, Uint32Vector&& elemFuncIndices);
// Function names:
void setFuncNames(NameInBytecodeVector&& funcNames);
@@ -183,12 +184,12 @@ class MOZ_STACK_CLASS ModuleGenerator
// asm.js lazy initialization:
void initSig(uint32_t sigIndex, Sig&& sig);
void initFuncSig(uint32_t funcIndex, uint32_t sigIndex);
- MOZ_MUST_USE bool initImport(uint32_t funcIndex, uint32_t sigIndex);
- MOZ_MUST_USE bool initSigTableLength(uint32_t sigIndex, uint32_t length);
- MOZ_MUST_USE bool initSigTableElems(uint32_t sigIndex, Uint32Vector&& elemFuncIndices);
+ [[nodiscard]] bool initImport(uint32_t funcIndex, uint32_t sigIndex);
+ [[nodiscard]] bool initSigTableLength(uint32_t sigIndex, uint32_t length);
+ [[nodiscard]] bool initSigTableElems(uint32_t sigIndex, Uint32Vector&& elemFuncIndices);
void initMemoryUsage(MemoryUsage memoryUsage);
void bumpMinMemoryLength(uint32_t newMinMemoryLength);
- MOZ_MUST_USE bool addGlobal(ValType type, bool isConst, uint32_t* index);
+ [[nodiscard]] bool addGlobal(ValType type, bool isConst, uint32_t* index);
// Finish compilation, provided the list of imports and source bytecode.
// Both these Vectors may be empty (viz., b/c asm.js does different things
@@ -240,7 +241,7 @@ class MOZ_STACK_CLASS FunctionGenerator
Bytes& bytes() {
return bytes_;
}
- MOZ_MUST_USE bool addCallSiteLineNum(uint32_t lineno) {
+ [[nodiscard]] bool addCallSiteLineNum(uint32_t lineno) {
return callSiteLineNums_.append(lineno);
}
};
diff --git a/js/src/wasm/WasmInstance.h b/js/src/wasm/WasmInstance.h
index 5c2871259c..523a08c31d 100644
--- a/js/src/wasm/WasmInstance.h
+++ b/js/src/wasm/WasmInstance.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,7 +100,7 @@ class Instance
// Execute the given export given the JS call arguments, storing the return
// value in args.rval.
- MOZ_MUST_USE bool callExport(JSContext* cx, uint32_t funcIndex, CallArgs args);
+ [[nodiscard]] bool callExport(JSContext* cx, uint32_t funcIndex, CallArgs args);
// Initially, calls to imports in wasm code call out through the generic
// callImport method. If the imported callee gets JIT compiled and the types
@@ -121,7 +122,7 @@ class Instance
// See Code::ensureProfilingState comment.
- MOZ_MUST_USE bool ensureProfilingState(JSContext* cx, bool enabled);
+ [[nodiscard]] bool ensureProfilingState(JSContext* cx, bool enabled);
// about:memory reporting:
diff --git a/js/src/wasm/WasmIonCompile.h b/js/src/wasm/WasmIonCompile.h
index dcd5c3c633..90f81643ec 100644
--- a/js/src/wasm/WasmIonCompile.h
+++ b/js/src/wasm/WasmIonCompile.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -146,7 +147,7 @@ class IonCompileTask
}
};
-MOZ_MUST_USE bool
+[[nodiscard]] bool
IonCompileFunction(IonCompileTask* task);
bool
diff --git a/js/src/wasm/WasmJS.h b/js/src/wasm/WasmJS.h
index ee1332102f..1ae4714f06 100644
--- a/js/src/wasm/WasmJS.h
+++ b/js/src/wasm/WasmJS.h
@@ -74,7 +74,7 @@ HasSupport(ExclusiveContext* cx);
// Compiles the given binary wasm module given the ArrayBufferObject
// and links the module's imports with the given import object.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
Eval(JSContext* cx, Handle<TypedArrayObject*> code, HandleObject importObj,
MutableHandleWasmInstanceObject instanceObj);
diff --git a/js/src/wasm/WasmSignalHandlers.h b/js/src/wasm/WasmSignalHandlers.h
index 87faa15025..40ebfeb2e2 100644
--- a/js/src/wasm/WasmSignalHandlers.h
+++ b/js/src/wasm/WasmSignalHandlers.h
@@ -38,7 +38,7 @@ namespace wasm {
// Ensure the given JSRuntime is set up to use signals. Failure to enable signal
// handlers indicates some catastrophic failure and creation of the runtime must
// fail.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EnsureSignalHandlers(JSRuntime* rt);
// Return whether signals can be used in this process for interrupts or
diff --git a/js/src/wasm/WasmTextToBinary.h b/js/src/wasm/WasmTextToBinary.h
index 1d16517586..7e5dce6db9 100644
--- a/js/src/wasm/WasmTextToBinary.h
+++ b/js/src/wasm/WasmTextToBinary.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +28,7 @@ namespace wasm {
// null-terminated char16_t array) into serialized bytes. If there is an error
// other than out-of-memory an error message string will be stored in 'error'.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
TextToBinary(const char16_t* text, Bytes* bytes, UniqueChars* error);
} // namespace wasm
diff --git a/js/src/wasm/WasmTextUtils.cpp b/js/src/wasm/WasmTextUtils.cpp
index 197a211f19..5cff1c9ce1 100644
--- a/js/src/wasm/WasmTextUtils.cpp
+++ b/js/src/wasm/WasmTextUtils.cpp
@@ -27,7 +27,7 @@ using namespace js::jit;
using mozilla::IsNaN;
template<size_t base>
-bool
+[[nodiscard]] bool
js::wasm::RenderInBase(StringBuffer& sb, uint64_t num)
{
uint64_t n = num;
@@ -52,7 +52,7 @@ js::wasm::RenderInBase(StringBuffer& sb, uint64_t num)
template bool js::wasm::RenderInBase<10>(StringBuffer& sb, uint64_t num);
template<class T>
-bool
+[[nodiscard]] bool
js::wasm::RenderNaN(StringBuffer& sb, Raw<T> num)
{
typedef typename mozilla::FloatingPoint<T> Traits;
@@ -73,5 +73,5 @@ js::wasm::RenderNaN(StringBuffer& sb, Raw<T> num)
RenderInBase<16>(sb, payload);
}
-template MOZ_MUST_USE bool js::wasm::RenderNaN(StringBuffer& b, Raw<float> num);
-template MOZ_MUST_USE bool js::wasm::RenderNaN(StringBuffer& b, Raw<double> num);
+template bool js::wasm::RenderNaN(StringBuffer& b, Raw<float> num);
+template bool js::wasm::RenderNaN(StringBuffer& b, Raw<double> num);
diff --git a/js/src/wasm/WasmTextUtils.h b/js/src/wasm/WasmTextUtils.h
index d772e621cd..a154681da9 100644
--- a/js/src/wasm/WasmTextUtils.h
+++ b/js/src/wasm/WasmTextUtils.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +28,14 @@ class StringBuffer;
namespace wasm {
template<size_t base>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RenderInBase(StringBuffer& sb, uint64_t num);
template<class T>
class Raw;
template<class T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RenderNaN(StringBuffer& sb, Raw<T> num);
} // namespace wasm
diff --git a/js/src/wasm/WasmTypes.h b/js/src/wasm/WasmTypes.h
index 57c737e454..26112ed137 100644
--- a/js/src/wasm/WasmTypes.h
+++ b/js/src/wasm/WasmTypes.h
@@ -316,7 +316,7 @@ class Sig
Sig() : args_(), ret_(ExprType::Void) {}
Sig(ValTypeVector&& args, ExprType ret) : args_(Move(args)), ret_(ret) {}
- MOZ_MUST_USE bool clone(const Sig& rhs) {
+ [[nodiscard]] bool clone(const Sig& rhs) {
ret_ = rhs.ret_;
MOZ_ASSERT(args_.empty());
return args_.appendAll(rhs.args_);