Bug 1287006 - Adjust js/ code to not pass Maybe (or any class containing a Maybe member) by value, only by reference or pointer. r=luke

--HG--
extra : rebase_source : b26cb2a94fdc218ea7f40931060eecfc50353d48
This commit is contained in:
Jeff Walden 2017-02-13 09:07:26 -08:00
Родитель d7372e37d9
Коммит 096aac1e32
22 изменённых файлов: 138 добавлений и 130 удалений

Просмотреть файл

@ -78,7 +78,7 @@ struct DeserializedNode {
const char16_t* typeName,
uint64_t size,
EdgeVector&& edges,
Maybe<StackFrameId> allocationStack,
const Maybe<StackFrameId>& allocationStack,
const char* className,
const char* filename,
HeapSnapshot& owner)

Просмотреть файл

@ -301,7 +301,7 @@ struct ForEachTrackedOptimizationTypeInfoOp
// The location parameter is the only one that may need escaping if being
// quoted.
virtual void readType(const char* keyedBy, const char* name,
const char* location, mozilla::Maybe<unsigned> lineno) = 0;
const char* location, const mozilla::Maybe<unsigned>& lineno) = 0;
// Called once per entry.
virtual void operator()(TrackedTypeSite site, const char* mirType) = 0;

Просмотреть файл

@ -65,18 +65,18 @@ class MOZ_STACK_CLASS BytecodeCompiler
ModuleObject* compileModule();
bool compileStandaloneFunction(MutableHandleFunction fun, GeneratorKind generatorKind,
FunctionAsyncKind asyncKind,
Maybe<uint32_t> parameterListEnd);
const Maybe<uint32_t>& parameterListEnd);
ScriptSourceObject* sourceObjectPtr() const;
private:
JSScript* compileScript(HandleObject environment, SharedContext* sc);
bool checkLength();
bool createScriptSource(Maybe<uint32_t> parameterListEnd);
bool createScriptSource(const Maybe<uint32_t>& parameterListEnd);
bool maybeCompressSource();
bool canLazilyParse();
bool createParser();
bool createSourceAndParser(Maybe<uint32_t> parameterListEnd = Nothing());
bool createSourceAndParser(const Maybe<uint32_t>& parameterListEnd = Nothing());
bool createScript();
bool emplaceEmitter(Maybe<BytecodeEmitter>& emitter, SharedContext* sharedContext);
bool handleParseFailure(const Directives& newDirectives);
@ -162,7 +162,7 @@ BytecodeCompiler::checkLength()
}
bool
BytecodeCompiler::createScriptSource(Maybe<uint32_t> parameterListEnd)
BytecodeCompiler::createScriptSource(const Maybe<uint32_t>& parameterListEnd)
{
if (!checkLength())
return false;
@ -233,7 +233,7 @@ BytecodeCompiler::createParser()
}
bool
BytecodeCompiler::createSourceAndParser(Maybe<uint32_t> parameterListEnd /* = Nothing() */)
BytecodeCompiler::createSourceAndParser(const Maybe<uint32_t>& parameterListEnd /* = Nothing() */)
{
return createScriptSource(parameterListEnd) &&
maybeCompressSource() &&
@ -431,7 +431,7 @@ bool
BytecodeCompiler::compileStandaloneFunction(MutableHandleFunction fun,
GeneratorKind generatorKind,
FunctionAsyncKind asyncKind,
Maybe<uint32_t> parameterListEnd)
const Maybe<uint32_t>& parameterListEnd)
{
MOZ_ASSERT(fun);
MOZ_ASSERT(fun->isTenured());
@ -486,7 +486,7 @@ BytecodeCompiler::sourceObjectPtr() const
ScriptSourceObject*
frontend::CreateScriptSourceObject(JSContext* cx, const ReadOnlyCompileOptions& options,
Maybe<uint32_t> parameterListEnd /* = Nothing() */)
const Maybe<uint32_t>& parameterListEnd /* = Nothing() */)
{
ScriptSource* ss = cx->new_<ScriptSource>();
if (!ss)
@ -684,7 +684,7 @@ bool
frontend::CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
Maybe<uint32_t> parameterListEnd,
const Maybe<uint32_t>& parameterListEnd,
HandleScope enclosingScope /* = nullptr */)
{
RootedScope scope(cx, enclosingScope);
@ -700,7 +700,7 @@ bool
frontend::CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
Maybe<uint32_t> parameterListEnd)
const Maybe<uint32_t>& parameterListEnd)
{
RootedScope emptyGlobalScope(cx, &cx->global()->emptyGlobalScope());
@ -713,7 +713,7 @@ bool
frontend::CompileStandaloneAsyncFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
Maybe<uint32_t> parameterListEnd)
const Maybe<uint32_t>& parameterListEnd)
{
RootedScope emptyGlobalScope(cx, &cx->global()->emptyGlobalScope());

Просмотреть файл

@ -69,20 +69,20 @@ MOZ_MUST_USE bool
CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd,
const mozilla::Maybe<uint32_t>& parameterListEnd,
HandleScope enclosingScope = nullptr);
MOZ_MUST_USE bool
CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd);
const mozilla::Maybe<uint32_t>& parameterListEnd);
MOZ_MUST_USE bool
CompileStandaloneAsyncFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd);
const mozilla::Maybe<uint32_t>& parameterListEnd);
MOZ_MUST_USE bool
CompileAsyncFunctionBody(JSContext* cx, MutableHandleFunction fun,
@ -91,7 +91,7 @@ CompileAsyncFunctionBody(JSContext* cx, MutableHandleFunction fun,
ScriptSourceObject*
CreateScriptSourceObject(JSContext* cx, const ReadOnlyCompileOptions& options,
mozilla::Maybe<uint32_t> parameterListEnd = mozilla::Nothing());
const mozilla::Maybe<uint32_t>& parameterListEnd = mozilla::Nothing());
/*
* True if str consists of an IdentifierStart character, followed by one or

Просмотреть файл

@ -1771,7 +1771,7 @@ class MOZ_STACK_CLASS TryEmitter
}
public:
bool emitFinally(Maybe<uint32_t> finallyPos = Nothing()) {
bool emitFinally(const Maybe<uint32_t>& finallyPos = Nothing()) {
MOZ_ASSERT(hasFinally());
if (state_ == Try) {
@ -5149,7 +5149,8 @@ BytecodeEmitter::emitIteratorNext(ParseNode* pn, bool allowSelfHosted)
}
bool
BytecodeEmitter::emitIteratorClose(Maybe<JumpTarget> yieldStarTryStart, bool allowSelfHosted)
BytecodeEmitter::emitIteratorClose(const Maybe<JumpTarget>& yieldStarTryStart,
bool allowSelfHosted)
{
MOZ_ASSERT(allowSelfHosted || emitterMode != BytecodeEmitter::SelfHosting,
".close() on iterators is prohibited in self-hosted code because it "

Просмотреть файл

@ -680,7 +680,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// onto the stack.
MOZ_MUST_USE bool emitIteratorNext(ParseNode* pn, bool allowSelfHosted = false);
MOZ_MUST_USE bool emitIteratorClose(
mozilla::Maybe<JumpTarget> yieldStarTryStart = mozilla::Nothing(),
const mozilla::Maybe<JumpTarget>& yieldStarTryStart = mozilla::Nothing(),
bool allowSelfHosted = false);
template <typename InnerEmitter>

Просмотреть файл

@ -2294,7 +2294,7 @@ template <>
ParseNode*
Parser<FullParseHandler>::standaloneFunction(HandleFunction fun,
HandleScope enclosingScope,
Maybe<uint32_t> parameterListEnd,
const Maybe<uint32_t>& parameterListEnd,
GeneratorKind generatorKind,
FunctionAsyncKind asyncKind,
Directives inheritedDirectives,
@ -3398,7 +3398,7 @@ bool
Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
YieldHandling yieldHandling,
Node pn, FunctionSyntaxKind kind,
Maybe<uint32_t> parameterListEnd /* = Nothing() */,
const Maybe<uint32_t>& parameterListEnd /* = Nothing() */,
bool isStandaloneFunction /* = false */)
{
// Given a properly initialized parse context, try to parse an actual
@ -4037,7 +4037,8 @@ Parser<ParseHandler>::PossibleError::transferErrorsTo(PossibleError* other)
template <>
bool
Parser<FullParseHandler>::checkDestructuringName(ParseNode* expr, Maybe<DeclarationKind> maybeDecl)
Parser<FullParseHandler>::checkDestructuringName(ParseNode* expr,
const Maybe<DeclarationKind>& maybeDecl)
{
MOZ_ASSERT(!handler.isUnparenthesizedDestructuringPattern(expr));

Просмотреть файл

@ -1092,7 +1092,7 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
// Parse a function, used for the Function, GeneratorFunction, and
// AsyncFunction constructors.
Node standaloneFunction(HandleFunction fun, HandleScope enclosingScope,
mozilla::Maybe<uint32_t> parameterListEnd,
const mozilla::Maybe<uint32_t>& parameterListEnd,
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
Directives inheritedDirectives, Directives* newDirectives);
@ -1111,7 +1111,7 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
// ParseContext is already on the stack.
bool functionFormalParametersAndBody(InHandling inHandling, YieldHandling yieldHandling,
Node pn, FunctionSyntaxKind kind,
mozilla::Maybe<uint32_t> parameterListEnd = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& parameterListEnd = mozilla::Nothing(),
bool isStandaloneFunction = false);
// Match the current token against the BindingIdentifier production with
@ -1435,7 +1435,7 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
// error if not passed a name.
bool checkDestructuringArray(Node arrayPattern, const mozilla::Maybe<DeclarationKind>& maybeDecl);
bool checkDestructuringObject(Node objectPattern, const mozilla::Maybe<DeclarationKind>& maybeDecl);
bool checkDestructuringName(Node expr, mozilla::Maybe<DeclarationKind> maybeDecl);
bool checkDestructuringName(Node expr, const mozilla::Maybe<DeclarationKind>& maybeDecl);
Node newNumber(const Token& tok) {
return handler.newNumber(tok.number(), tok.decimalPoint(), tok.pos);

Просмотреть файл

@ -695,7 +695,7 @@ class MemoryAccessDesc
public:
explicit MemoryAccessDesc(Scalar::Type type, uint32_t align, uint32_t offset,
mozilla::Maybe<TrapOffset> trapOffset,
const mozilla::Maybe<TrapOffset>& trapOffset,
unsigned numSimdElems = 0,
jit::MemoryBarrierBits barrierBefore = jit::MembarNobits,
jit::MemoryBarrierBits barrierAfter = jit::MembarNobits)

Просмотреть файл

@ -2163,7 +2163,7 @@ FormatIntroducedFilename(JSContext* cx, const char* filename, unsigned lineno,
bool
ScriptSource::initFromOptions(JSContext* cx, const ReadOnlyCompileOptions& options,
Maybe<uint32_t> parameterListEnd)
const Maybe<uint32_t>& parameterListEnd)
{
MOZ_ASSERT(!filename_);
MOZ_ASSERT(!introducerFilename_);

Просмотреть файл

@ -476,7 +476,7 @@ class ScriptSource
}
MOZ_MUST_USE bool initFromOptions(JSContext* cx,
const ReadOnlyCompileOptions& options,
mozilla::Maybe<uint32_t> parameterListEnd = mozilla::Nothing());
const mozilla::Maybe<uint32_t>& parameterListEnd = mozilla::Nothing());
MOZ_MUST_USE bool setSourceCopy(JSContext* cx,
JS::SourceBufferHolder& srcBuf,
SourceCompressionTask* tok);

Просмотреть файл

@ -5305,7 +5305,7 @@ class SprintOptimizationTypeInfoOp : public JS::ForEachTrackedOptimizationTypeIn
{ }
void readType(const char* keyedBy, const char* name,
const char* location, Maybe<unsigned> lineno) override
const char* location, const Maybe<unsigned>& lineno) override
{
if (hadError_)
return;

Просмотреть файл

@ -513,14 +513,15 @@ class js::WasmArrayRawBuffer
size_t mappedSize_;
protected:
WasmArrayRawBuffer(uint8_t* buffer, uint32_t length, Maybe<uint32_t> maxSize, size_t mappedSize)
WasmArrayRawBuffer(uint8_t* buffer, uint32_t length, const Maybe<uint32_t>& maxSize,
size_t mappedSize)
: maxSize_(maxSize), mappedSize_(mappedSize)
{
MOZ_ASSERT(buffer == dataPointer());
}
public:
static WasmArrayRawBuffer* Allocate(uint32_t numBytes, Maybe<uint32_t> maxSize);
static WasmArrayRawBuffer* Allocate(uint32_t numBytes, const Maybe<uint32_t>& maxSize);
static void Release(void* mem);
uint8_t* dataPointer() {
@ -622,7 +623,7 @@ class js::WasmArrayRawBuffer
};
/* static */ WasmArrayRawBuffer*
WasmArrayRawBuffer::Allocate(uint32_t numBytes, Maybe<uint32_t> maxSize)
WasmArrayRawBuffer::Allocate(uint32_t numBytes, const Maybe<uint32_t>& maxSize)
{
size_t mappedSize;
#ifdef WASM_HUGE_MEMORY
@ -704,7 +705,8 @@ ArrayBufferObject::BufferContents::wasmBuffer() const
#define ROUND_UP(v, a) ((v) % (a) == 0 ? (v) : v + a - ((v) % (a)))
/* static */ ArrayBufferObject*
ArrayBufferObject::createForWasm(JSContext* cx, uint32_t initialSize, Maybe<uint32_t> maxSize)
ArrayBufferObject::createForWasm(JSContext* cx, uint32_t initialSize,
const Maybe<uint32_t>& maybeMaxSize)
{
MOZ_ASSERT(initialSize % wasm::PageSize == 0);
MOZ_RELEASE_ASSERT(wasm::HaveSignalHandlers());
@ -712,10 +714,11 @@ ArrayBufferObject::createForWasm(JSContext* cx, uint32_t initialSize, Maybe<uint
// Prevent applications specifying a large max (like UINT32_MAX) from
// unintentially OOMing the browser on 32-bit: they just want "a lot of
// memory". Maintain the invariant that initialSize <= maxSize.
if (sizeof(void*) == 4 && maxSize) {
Maybe<uint32_t> maxSize = maybeMaxSize;
if (sizeof(void*) == 4 && maybeMaxSize) {
static const uint32_t OneGiB = 1 << 30;
uint32_t clamp = Max(OneGiB, initialSize);
maxSize = Some(Min(clamp, maxSize.value()));
maxSize = Some(Min(clamp, maybeMaxSize.value()));
}
RootedArrayBufferObject buffer(cx, ArrayBufferObject::createEmpty(cx));

Просмотреть файл

@ -336,7 +336,7 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared
// WebAssembly support:
static ArrayBufferObject* createForWasm(JSContext* cx, uint32_t initialSize,
mozilla::Maybe<uint32_t> maxSize);
const mozilla::Maybe<uint32_t>& maxSize);
static MOZ_MUST_USE bool prepareForAsmJS(JSContext* cx, Handle<ArrayBufferObject*> buffer,
bool needGuard);
size_t wasmMappedSize() const;

Просмотреть файл

@ -627,7 +627,7 @@ class AstGlobal : public AstNode
{}
explicit AstGlobal(AstName name, ValType type, bool isMutable,
Maybe<AstExpr*> init = Maybe<AstExpr*>())
const Maybe<AstExpr*>& init = Maybe<AstExpr*>())
: name_(name), isMutable_(isMutable), type_(type), init_(init)
{}
@ -656,10 +656,11 @@ class AstImport : public AstNode
AstImport(AstName name, AstName module, AstName field, AstRef funcSig)
: name_(name), module_(module), field_(field), kind_(DefinitionKind::Function), funcSig_(funcSig)
{}
AstImport(AstName name, AstName module, AstName field, DefinitionKind kind, Limits limits)
AstImport(AstName name, AstName module, AstName field, DefinitionKind kind,
const Limits& limits)
: name_(name), module_(module), field_(field), kind_(kind), limits_(limits)
{}
AstImport(AstName name, AstName module, AstName field, AstGlobal global)
AstImport(AstName name, AstName module, AstName field, const AstGlobal& global)
: name_(name), module_(module), field_(field), kind_(DefinitionKind::Global), global_(global)
{}
@ -753,7 +754,7 @@ struct AstResizable
Limits limits;
bool imported;
AstResizable(Limits limits, bool imported, AstName name = AstName())
AstResizable(const Limits& limits, bool imported, AstName name = AstName())
: name(name),
limits(limits),
imported(imported)
@ -805,7 +806,7 @@ class AstModule : public AstNode
bool init() {
return sigMap_.init();
}
bool addMemory(AstName name, Limits memory) {
bool addMemory(AstName name, const Limits& memory) {
return memories_.append(AstResizable(memory, false, name));
}
bool hasMemory() const {
@ -814,7 +815,7 @@ class AstModule : public AstNode
const AstResizableVector& memories() const {
return memories_;
}
bool addTable(AstName name, Limits table) {
bool addTable(AstName name, const Limits& table) {
return tables_.append(AstResizable(table, false, name));
}
bool hasTable() const {

Просмотреть файл

@ -3302,10 +3302,10 @@ 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, bool omitBoundsCheck, AnyReg dest,
MOZ_MUST_USE bool load(MemoryAccessDesc* access, RegI32 ptr, bool omitBoundsCheck, AnyReg dest,
RegI32 tmp1, RegI32 tmp2, RegI32 tmp3)
{
checkOffset(&access, ptr);
checkOffset(access, ptr);
OutOfLineCode* ool = nullptr;
#ifndef WASM_HUGE_MEMORY
@ -3314,48 +3314,48 @@ class BaseCompiler
#endif
#if defined(JS_CODEGEN_X64)
Operand srcAddr(HeapReg, ptr, TimesOne, access.offset());
Operand srcAddr(HeapReg, ptr, TimesOne, access->offset());
if (dest.tag == AnyReg::I64)
masm.wasmLoadI64(access, srcAddr, dest.i64());
masm.wasmLoadI64(*access, srcAddr, dest.i64());
else
masm.wasmLoad(access, srcAddr, dest.any());
masm.wasmLoad(*access, srcAddr, dest.any());
#elif defined(JS_CODEGEN_X86)
Operand srcAddr(ptr, access.offset());
Operand srcAddr(ptr, access->offset());
if (dest.tag == AnyReg::I64) {
MOZ_ASSERT(dest.i64() == abiReturnRegI64);
masm.wasmLoadI64(access, srcAddr, dest.i64());
masm.wasmLoadI64(*access, srcAddr, dest.i64());
} else {
bool byteRegConflict = access.byteSize() == 1 && !singleByteRegs_.has(dest.i32());
bool byteRegConflict = access->byteSize() == 1 && !singleByteRegs_.has(dest.i32());
AnyRegister out = byteRegConflict ? AnyRegister(ScratchRegX86) : dest.any();
masm.wasmLoad(access, srcAddr, out);
masm.wasmLoad(*access, srcAddr, out);
if (byteRegConflict)
masm.mov(ScratchRegX86, dest.i32());
}
#elif defined(JS_CODEGEN_ARM)
if (IsUnaligned(access)) {
if (IsUnaligned(*access)) {
switch (dest.tag) {
case AnyReg::I64:
masm.wasmUnalignedLoadI64(access, ptr, ptr, dest.i64(), tmp1);
masm.wasmUnalignedLoadI64(*access, ptr, ptr, dest.i64(), tmp1);
break;
case AnyReg::F32:
masm.wasmUnalignedLoadFP(access, ptr, ptr, dest.f32(), tmp1, tmp2, Register::Invalid());
masm.wasmUnalignedLoadFP(*access, ptr, ptr, dest.f32(), tmp1, tmp2, Register::Invalid());
break;
case AnyReg::F64:
masm.wasmUnalignedLoadFP(access, ptr, ptr, dest.f64(), tmp1, tmp2, tmp3);
masm.wasmUnalignedLoadFP(*access, ptr, ptr, dest.f64(), tmp1, tmp2, tmp3);
break;
default:
masm.wasmUnalignedLoad(access, ptr, ptr, dest.i32(), tmp1);
masm.wasmUnalignedLoad(*access, ptr, ptr, dest.i32(), tmp1);
break;
}
} else {
if (dest.tag == AnyReg::I64)
masm.wasmLoadI64(access, ptr, ptr, dest.i64());
masm.wasmLoadI64(*access, ptr, ptr, dest.i64());
else
masm.wasmLoad(access, ptr, ptr, dest.any());
masm.wasmLoad(*access, ptr, ptr, dest.any());
}
#else
MOZ_CRASH("BaseCompiler platform hook: load");
@ -3366,7 +3366,7 @@ class BaseCompiler
return true;
}
MOZ_MUST_USE size_t storeTemps(MemoryAccessDesc& access, ValType srcType) {
MOZ_MUST_USE size_t storeTemps(const MemoryAccessDesc& access, ValType srcType) {
#if defined(JS_CODEGEN_ARM)
if (IsUnaligned(access) && srcType != ValType::I32)
return 1;
@ -3376,10 +3376,10 @@ class BaseCompiler
// ptr and src must not be the same register.
// This may destroy ptr and src.
MOZ_MUST_USE bool store(MemoryAccessDesc access, RegI32 ptr, bool omitBoundsCheck, AnyReg src,
MOZ_MUST_USE bool store(MemoryAccessDesc* access, RegI32 ptr, bool omitBoundsCheck, AnyReg src,
RegI32 tmp)
{
checkOffset(&access, ptr);
checkOffset(access, ptr);
Label rejoin;
#ifndef WASM_HUGE_MEMORY
@ -3390,58 +3390,58 @@ class BaseCompiler
// Emit the store
#if defined(JS_CODEGEN_X64)
MOZ_ASSERT(tmp == Register::Invalid());
Operand dstAddr(HeapReg, ptr, TimesOne, access.offset());
Operand dstAddr(HeapReg, ptr, TimesOne, access->offset());
masm.wasmStore(access, src.any(), dstAddr);
masm.wasmStore(*access, src.any(), dstAddr);
#elif defined(JS_CODEGEN_X86)
MOZ_ASSERT(tmp == Register::Invalid());
Operand dstAddr(ptr, access.offset());
Operand dstAddr(ptr, access->offset());
if (access.type() == Scalar::Int64) {
masm.wasmStoreI64(access, src.i64(), dstAddr);
if (access->type() == Scalar::Int64) {
masm.wasmStoreI64(*access, src.i64(), dstAddr);
} else {
AnyRegister value;
if (src.tag == AnyReg::I64) {
if (access.byteSize() == 1 && !singleByteRegs_.has(src.i64().low)) {
if (access->byteSize() == 1 && !singleByteRegs_.has(src.i64().low)) {
masm.mov(src.i64().low, ScratchRegX86);
value = AnyRegister(ScratchRegX86);
} else {
value = AnyRegister(src.i64().low);
}
} else if (access.byteSize() == 1 && !singleByteRegs_.has(src.i32())) {
} else if (access->byteSize() == 1 && !singleByteRegs_.has(src.i32())) {
masm.mov(src.i32(), ScratchRegX86);
value = AnyRegister(ScratchRegX86);
} else {
value = src.any();
}
masm.wasmStore(access, value, dstAddr);
masm.wasmStore(*access, value, dstAddr);
}
#elif defined(JS_CODEGEN_ARM)
if (IsUnaligned(access)) {
if (IsUnaligned(*access)) {
switch (src.tag) {
case AnyReg::I64:
masm.wasmUnalignedStoreI64(access, src.i64(), ptr, ptr, tmp);
masm.wasmUnalignedStoreI64(*access, src.i64(), ptr, ptr, tmp);
break;
case AnyReg::F32:
masm.wasmUnalignedStoreFP(access, src.f32(), ptr, ptr, tmp);
masm.wasmUnalignedStoreFP(*access, src.f32(), ptr, ptr, tmp);
break;
case AnyReg::F64:
masm.wasmUnalignedStoreFP(access, src.f64(), ptr, ptr, tmp);
masm.wasmUnalignedStoreFP(*access, src.f64(), ptr, ptr, tmp);
break;
default:
MOZ_ASSERT(tmp == Register::Invalid());
masm.wasmUnalignedStore(access, src.i32(), ptr, ptr);
masm.wasmUnalignedStore(*access, src.i32(), ptr, ptr);
break;
}
} else {
MOZ_ASSERT(tmp == Register::Invalid());
if (access.type() == Scalar::Int64)
masm.wasmStoreI64(access, src.i64(), ptr, ptr);
if (access->type() == Scalar::Int64)
masm.wasmStoreI64(*access, src.i64(), ptr, ptr);
else if (src.tag == AnyReg::I64)
masm.wasmStore(access, AnyRegister(src.i64().low), ptr, ptr);
masm.wasmStore(*access, AnyRegister(src.i64().low), ptr, ptr);
else
masm.wasmStore(access, src.any(), ptr, ptr);
masm.wasmStore(*access, src.any(), ptr, ptr);
}
#else
MOZ_CRASH("BaseCompiler platform hook: store");
@ -6299,7 +6299,7 @@ BaseCompiler::emitLoad(ValType type, Scalar::Type viewType)
#else
RegI32 rv = rp;
#endif
if (!load(access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
if (!load(&access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
return false;
pushI32(rv);
if (rp != rv)
@ -6317,7 +6317,7 @@ BaseCompiler::emitLoad(ValType type, Scalar::Type viewType)
rp = popMemoryAccess(&access, &omitBoundsCheck);
rv = needI64();
#endif
if (!load(access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
if (!load(&access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
return false;
pushI64(rv);
freeI32(rp);
@ -6326,7 +6326,7 @@ BaseCompiler::emitLoad(ValType type, Scalar::Type viewType)
case ValType::F32: {
RegI32 rp = popMemoryAccess(&access, &omitBoundsCheck);
RegF32 rv = needF32();
if (!load(access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
if (!load(&access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
return false;
pushF32(rv);
freeI32(rp);
@ -6335,7 +6335,7 @@ BaseCompiler::emitLoad(ValType type, Scalar::Type viewType)
case ValType::F64: {
RegI32 rp = popMemoryAccess(&access, &omitBoundsCheck);
RegF64 rv = needF64();
if (!load(access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
if (!load(&access, rp, omitBoundsCheck, AnyReg(rv), tmp1, tmp2, tmp3))
return false;
pushF64(rv);
freeI32(rp);
@ -6379,7 +6379,7 @@ BaseCompiler::emitStore(ValType resultType, Scalar::Type viewType)
case ValType::I32: {
RegI32 rv = popI32();
RegI32 rp = popMemoryAccess(&access, &omitBoundsCheck);
if (!store(access, rp, omitBoundsCheck, AnyReg(rv), tmp))
if (!store(&access, rp, omitBoundsCheck, AnyReg(rv), tmp))
return false;
freeI32(rp);
freeI32(rv);
@ -6388,7 +6388,7 @@ BaseCompiler::emitStore(ValType resultType, Scalar::Type viewType)
case ValType::I64: {
RegI64 rv = popI64();
RegI32 rp = popMemoryAccess(&access, &omitBoundsCheck);
if (!store(access, rp, omitBoundsCheck, AnyReg(rv), tmp))
if (!store(&access, rp, omitBoundsCheck, AnyReg(rv), tmp))
return false;
freeI32(rp);
freeI64(rv);
@ -6397,7 +6397,7 @@ BaseCompiler::emitStore(ValType resultType, Scalar::Type viewType)
case ValType::F32: {
RegF32 rv = popF32();
RegI32 rp = popMemoryAccess(&access, &omitBoundsCheck);
if (!store(access, rp, omitBoundsCheck, AnyReg(rv), tmp))
if (!store(&access, rp, omitBoundsCheck, AnyReg(rv), tmp))
return false;
freeI32(rp);
freeF32(rv);
@ -6406,7 +6406,7 @@ BaseCompiler::emitStore(ValType resultType, Scalar::Type viewType)
case ValType::F64: {
RegF64 rv = popF64();
RegI32 rp = popMemoryAccess(&access, &omitBoundsCheck);
if (!store(access, rp, omitBoundsCheck, AnyReg(rv), tmp))
if (!store(&access, rp, omitBoundsCheck, AnyReg(rv), tmp))
return false;
freeI32(rp);
freeF64(rv);

Просмотреть файл

@ -1377,20 +1377,22 @@ RenderGlobalSection(WasmRenderContext& c, const AstModule& module)
}
static bool
RenderResizableMemory(WasmRenderContext& c, Limits memory)
RenderResizableMemory(WasmRenderContext& c, const Limits& memory)
{
if (!c.buffer.append("(memory "))
return false;
MOZ_ASSERT(memory.initial % PageSize == 0);
memory.initial /= PageSize;
Limits resizedMemory = memory;
if (memory.maximum) {
MOZ_ASSERT(*memory.maximum % PageSize == 0);
*memory.maximum /= PageSize;
MOZ_ASSERT(resizedMemory.initial % PageSize == 0);
resizedMemory.initial /= PageSize;
if (resizedMemory.maximum) {
MOZ_ASSERT(*resizedMemory.maximum % PageSize == 0);
*resizedMemory.maximum /= PageSize;
}
if (!RenderLimits(c, memory))
if (!RenderLimits(c, resizedMemory))
return false;
return c.buffer.append(")");

Просмотреть файл

@ -719,74 +719,74 @@ class FunctionCompiler
}
public:
MDefinition* load(MDefinition* base, MemoryAccessDesc access, ValType result)
MDefinition* load(MDefinition* base, MemoryAccessDesc* access, ValType result)
{
if (inDeadCode())
return nullptr;
MInstruction* load = nullptr;
if (access.isPlainAsmJS()) {
MOZ_ASSERT(access.offset() == 0);
load = MAsmJSLoadHeap::New(alloc(), base, access.type());
if (access->isPlainAsmJS()) {
MOZ_ASSERT(access->offset() == 0);
load = MAsmJSLoadHeap::New(alloc(), base, access->type());
} else {
checkOffsetAndBounds(&access, &base);
load = MWasmLoad::New(alloc(), base, access, ToMIRType(result));
checkOffsetAndBounds(access, &base);
load = MWasmLoad::New(alloc(), base, *access, ToMIRType(result));
}
curBlock_->add(load);
return load;
}
void store(MDefinition* base, MemoryAccessDesc access, MDefinition* v)
void store(MDefinition* base, MemoryAccessDesc* access, MDefinition* v)
{
if (inDeadCode())
return;
MInstruction* store = nullptr;
if (access.isPlainAsmJS()) {
MOZ_ASSERT(access.offset() == 0);
store = MAsmJSStoreHeap::New(alloc(), base, access.type(), v);
if (access->isPlainAsmJS()) {
MOZ_ASSERT(access->offset() == 0);
store = MAsmJSStoreHeap::New(alloc(), base, access->type(), v);
} else {
checkOffsetAndBounds(&access, &base);
store = MWasmStore::New(alloc(), base, access, v);
checkOffsetAndBounds(access, &base);
store = MWasmStore::New(alloc(), base, *access, v);
}
curBlock_->add(store);
}
MDefinition* atomicCompareExchangeHeap(MDefinition* base, MemoryAccessDesc access,
MDefinition* atomicCompareExchangeHeap(MDefinition* base, MemoryAccessDesc* access,
MDefinition* oldv, MDefinition* newv)
{
if (inDeadCode())
return nullptr;
checkOffsetAndBounds(&access, &base);
auto* cas = MAsmJSCompareExchangeHeap::New(alloc(), base, access, oldv, newv, tlsPointer_);
checkOffsetAndBounds(access, &base);
auto* cas = MAsmJSCompareExchangeHeap::New(alloc(), base, *access, oldv, newv, tlsPointer_);
curBlock_->add(cas);
return cas;
}
MDefinition* atomicExchangeHeap(MDefinition* base, MemoryAccessDesc access,
MDefinition* atomicExchangeHeap(MDefinition* base, MemoryAccessDesc* access,
MDefinition* value)
{
if (inDeadCode())
return nullptr;
checkOffsetAndBounds(&access, &base);
auto* cas = MAsmJSAtomicExchangeHeap::New(alloc(), base, access, value, tlsPointer_);
checkOffsetAndBounds(access, &base);
auto* cas = MAsmJSAtomicExchangeHeap::New(alloc(), base, *access, value, tlsPointer_);
curBlock_->add(cas);
return cas;
}
MDefinition* atomicBinopHeap(js::jit::AtomicOp op,
MDefinition* base, MemoryAccessDesc access,
MDefinition* base, MemoryAccessDesc* access,
MDefinition* v)
{
if (inDeadCode())
return nullptr;
checkOffsetAndBounds(&access, &base);
auto* binop = MAsmJSAtomicBinopHeap::New(alloc(), op, base, access, v, tlsPointer_);
checkOffsetAndBounds(access, &base);
auto* binop = MAsmJSAtomicBinopHeap::New(alloc(), op, base, *access, v, tlsPointer_);
curBlock_->add(binop);
return binop;
}
@ -2319,7 +2319,7 @@ EmitLoad(FunctionCompiler& f, ValType type, Scalar::Type viewType)
return false;
MemoryAccessDesc access(viewType, addr.align, addr.offset, f.trapIfNotAsmJS());
f.iter().setResult(f.load(addr.base, access, type));
f.iter().setResult(f.load(addr.base, &access, type));
return true;
}
@ -2333,7 +2333,7 @@ EmitStore(FunctionCompiler& f, ValType resultType, Scalar::Type viewType)
MemoryAccessDesc access(viewType, addr.align, addr.offset, f.trapIfNotAsmJS());
f.store(addr.base, access, value);
f.store(addr.base, &access, value);
return true;
}
@ -2347,7 +2347,7 @@ EmitTeeStore(FunctionCompiler& f, ValType resultType, Scalar::Type viewType)
MemoryAccessDesc access(viewType, addr.align, addr.offset, f.trapIfNotAsmJS());
f.store(addr.base, access, value);
f.store(addr.base, &access, value);
return true;
}
@ -2368,7 +2368,7 @@ EmitTeeStoreWithCoercion(FunctionCompiler& f, ValType resultType, Scalar::Type v
MemoryAccessDesc access(viewType, addr.align, addr.offset, f.trapIfNotAsmJS());
f.store(addr.base, access, value);
f.store(addr.base, &access, value);
return true;
}
@ -2441,7 +2441,7 @@ EmitAtomicsLoad(FunctionCompiler& f)
MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(f.trapOffset()), 0,
MembarBeforeLoad, MembarAfterLoad);
f.iter().setResult(f.load(addr.base, access, ValType::I32));
f.iter().setResult(f.load(addr.base, &access, ValType::I32));
return true;
}
@ -2457,7 +2457,7 @@ EmitAtomicsStore(FunctionCompiler& f)
MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(f.trapOffset()), 0,
MembarBeforeStore, MembarAfterStore);
f.store(addr.base, access, value);
f.store(addr.base, &access, value);
f.iter().setResult(value);
return true;
}
@ -2474,7 +2474,7 @@ EmitAtomicsBinOp(FunctionCompiler& f)
MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(f.trapOffset()));
f.iter().setResult(f.atomicBinopHeap(op, addr.base, access, value));
f.iter().setResult(f.atomicBinopHeap(op, addr.base, &access, value));
return true;
}
@ -2490,7 +2490,7 @@ EmitAtomicsCompareExchange(FunctionCompiler& f)
MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(f.trapOffset()));
f.iter().setResult(f.atomicCompareExchangeHeap(addr.base, access, oldValue, newValue));
f.iter().setResult(f.atomicCompareExchangeHeap(addr.base, &access, oldValue, newValue));
return true;
}
@ -2505,7 +2505,7 @@ EmitAtomicsExchange(FunctionCompiler& f)
MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(f.trapOffset()));
f.iter().setResult(f.atomicExchangeHeap(addr.base, access, value));
f.iter().setResult(f.atomicExchangeHeap(addr.base, &access, value));
return true;
}
@ -2728,7 +2728,7 @@ EmitSimdLoad(FunctionCompiler& f, ValType resultType, unsigned numElems)
MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(f.trapOffset()), numElems);
f.iter().setResult(f.load(addr.base, access, resultType));
f.iter().setResult(f.load(addr.base, &access, resultType));
return true;
}
@ -2748,7 +2748,7 @@ EmitSimdStore(FunctionCompiler& f, ValType resultType, unsigned numElems)
MemoryAccessDesc access(viewType, addr.align, addr.offset, Some(f.trapOffset()), numElems);
f.store(addr.base, access, value);
f.store(addr.base, &access, value);
return true;
}

Просмотреть файл

@ -1491,7 +1491,7 @@ WasmTableObject::trace(JSTracer* trc, JSObject* obj)
}
/* static */ WasmTableObject*
WasmTableObject::create(JSContext* cx, Limits limits)
WasmTableObject::create(JSContext* cx, const Limits& limits)
{
RootedObject proto(cx, &cx->global()->getPrototype(JSProto_WasmTable).toObject());

Просмотреть файл

@ -276,7 +276,7 @@ class WasmTableObject : public NativeObject
// Note that, after creation, a WasmTableObject's table() is not initialized
// and must be initialized before use.
static WasmTableObject* create(JSContext* cx, wasm::Limits limits);
static WasmTableObject* create(JSContext* cx, const wasm::Limits& limits);
wasm::Table& table() const;
};

Просмотреть файл

@ -604,8 +604,8 @@ Module::instantiateFunctions(JSContext* cx, Handle<FunctionVector> funcImports)
}
static bool
CheckLimits(JSContext* cx, uint32_t declaredMin, Maybe<uint32_t> declaredMax, uint32_t actualLength,
Maybe<uint32_t> actualMax, bool isAsmJS, const char* kind)
CheckLimits(JSContext* cx, uint32_t declaredMin, const Maybe<uint32_t>& declaredMax, uint32_t actualLength,
const Maybe<uint32_t>& actualMax, bool isAsmJS, const char* kind)
{
if (isAsmJS) {
MOZ_ASSERT(actualLength >= declaredMin);

Просмотреть файл

@ -1106,7 +1106,7 @@ struct TableDesc
Limits limits;
TableDesc() = default;
TableDesc(TableKind kind, Limits limits)
TableDesc(TableKind kind, const Limits& limits)
: kind(kind),
external(false),
globalDataOffset(UINT32_MAX),