Bug 1668373 - wasm: Split CompilerEnvironment from ModuleEnvironment. r=lth

ModuleEnvironment contains a CompilerEnvironment pointer, which describes the compiler selection,
tiering, and whether debugging is enabled. None of this information is needed for validation,
so wasm::Validate() has to create a synthetic CompilerEnvironment which is never read. This
isn't a large issue, but indicates ModuleEnvironment is doing too many things.

This commit removes CompilerEnvironment from ModuleEnvironment and pipes it
through the compiler pipeline. This is fairly straightforward except for:
  * wasm::Validate() no longer needs to create a synthetic compiler env
  * DecodeModuleEnvironment() used to invoke moduleEnv.compilerEnv.computeParameters(d)
    after the preamble was decoded. I believe this was needed for handling the GC opt-in
    section, which is no longer used. I moved this call to computeParameters() to after
    all callers of DecodeModuleEnvironment().
  * I added an assertion in IonCompileFunctions/CraneliftCompileFunctions that they are
    not being invoked for debugged modules.

Differential Revision: https://phabricator.services.mozilla.com/D91995
This commit is contained in:
Ryan Hunt 2020-10-05 15:47:27 +00:00
Родитель ab7788915e
Коммит fb950b7f4d
12 изменённых файлов: 90 добавлений и 79 удалений

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

@ -1359,7 +1359,7 @@ class MOZ_STACK_CLASS ModuleValidatorShared {
arrayViews_(cx),
compilerEnv_(CompileMode::Once, Tier::Optimized, OptimizedBackend::Ion,
DebugEnabled::False),
moduleEnv_(&compilerEnv_, FeatureArgs(), ModuleKind::AsmJS) {
moduleEnv_(FeatureArgs(), ModuleKind::AsmJS) {
compilerEnv_.computeParameters();
moduleEnv_.minMemoryLength = RoundUpToNextValidAsmJSHeapLength(0);
}
@ -2123,7 +2123,7 @@ class MOZ_STACK_CLASS ModuleValidator : public ModuleValidatorShared {
return nullptr;
}
ModuleGenerator mg(*args, &moduleEnv_, nullptr, nullptr);
ModuleGenerator mg(*args, &moduleEnv_, &compilerEnv_, nullptr, nullptr);
if (!mg.init(asmJSMetadata_.get())) {
return nullptr;
}

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

@ -3221,6 +3221,7 @@ class BaseCompiler final : public BaseCompilerInterface {
};
const ModuleEnvironment& moduleEnv_;
const CompilerEnvironment& compilerEnv_;
BaseOpIter iter_;
const FuncCompileInput& func_;
size_t lastReadCallSite_;
@ -3259,6 +3260,7 @@ class BaseCompiler final : public BaseCompilerInterface {
public:
BaseCompiler(const ModuleEnvironment& moduleEnv,
const CompilerEnvironment& compilerEnv,
const FuncCompileInput& input, const ValTypeVector& locals,
const MachineState& trapExitLayout,
size_t trapExitLayoutNumWords, Decoder& decoder,
@ -4169,7 +4171,7 @@ class BaseCompiler final : public BaseCompilerInterface {
const ExitStubMapVector& extras,
uint32_t assemblerOffset) {
auto debugFrame =
moduleEnv_.debugEnabled() ? HasDebugFrame::Yes : HasDebugFrame::No;
compilerEnv_.debugEnabled() ? HasDebugFrame::Yes : HasDebugFrame::No;
return stackMapGenerator_.createStackMap(who, extras, assemblerOffset,
debugFrame, stk_);
}
@ -5277,10 +5279,11 @@ class BaseCompiler final : public BaseCompilerInterface {
}
}
GenerateFunctionPrologue(
masm, moduleEnv_.funcTypes[func_.index]->id,
moduleEnv_.mode() == CompileMode::Tier1 ? Some(func_.index) : Nothing(),
&offsets_);
GenerateFunctionPrologue(masm, moduleEnv_.funcTypes[func_.index]->id,
compilerEnv_.mode() == CompileMode::Tier1
? Some(func_.index)
: Nothing(),
&offsets_);
// GenerateFunctionPrologue pushes exactly one wasm::Frame's worth of
// stuff, and none of the values are GC pointers. Hence:
@ -5292,7 +5295,7 @@ class BaseCompiler final : public BaseCompilerInterface {
// Initialize DebugFrame fields before the stack overflow trap so that
// we have the invariant that all observable Frames in a debugEnabled
// Module have valid DebugFrames.
if (moduleEnv_.debugEnabled()) {
if (compilerEnv_.debugEnabled()) {
#ifdef JS_CODEGEN_ARM64
static_assert(DebugFrame::offsetOfFrame() % WasmStackAlignment == 0,
"aligned");
@ -5359,7 +5362,7 @@ class BaseCompiler final : public BaseCompilerInterface {
}
// If we're in a debug frame, copy the stack result pointer arg
// to a well-known place.
if (moduleEnv_.debugEnabled()) {
if (compilerEnv_.debugEnabled()) {
Register target = ABINonArgReturnReg0;
fr.loadIncomingStackResultAreaPtr(RegPtr(target));
size_t debugFrameOffset =
@ -5410,7 +5413,7 @@ class BaseCompiler final : public BaseCompilerInterface {
fr.zeroLocals(&ra);
fr.storeTlsPtr(WasmTlsReg);
if (moduleEnv_.debugEnabled()) {
if (compilerEnv_.debugEnabled()) {
insertBreakablePoint(CallSiteDesc::EnterFrame);
if (!createStackMap("debug: breakable point")) {
return false;
@ -5438,7 +5441,7 @@ class BaseCompiler final : public BaseCompilerInterface {
}
void saveRegisterReturnValues(const ResultType& resultType) {
MOZ_ASSERT(moduleEnv_.debugEnabled());
MOZ_ASSERT(compilerEnv_.debugEnabled());
size_t debugFrameOffset = masm.framePushed() - DebugFrame::offsetOfFrame();
size_t registerResultIdx = 0;
for (ABIResultIter i(resultType); !i.done(); i.next()) {
@ -5491,7 +5494,7 @@ class BaseCompiler final : public BaseCompilerInterface {
}
void restoreRegisterReturnValues(const ResultType& resultType) {
MOZ_ASSERT(moduleEnv_.debugEnabled());
MOZ_ASSERT(compilerEnv_.debugEnabled());
size_t debugFrameOffset = masm.framePushed() - DebugFrame::offsetOfFrame();
size_t registerResultIdx = 0;
for (ABIResultIter i(resultType); !i.done(); i.next()) {
@ -5557,7 +5560,7 @@ class BaseCompiler final : public BaseCompilerInterface {
popStackReturnValues(resultType);
if (moduleEnv_.debugEnabled()) {
if (compilerEnv_.debugEnabled()) {
// Store and reload the return value from DebugFrame::return so that
// it can be clobbered, and/or modified by the debug trap.
saveRegisterReturnValues(resultType);
@ -10944,7 +10947,7 @@ bool BaseCompiler::emitSetGlobal() {
//
// Finally, when the debugger allows locals to be mutated we must disable BCE
// for references via a local, by returning immediately from bceCheckLocal if
// moduleEnv_.debugEnabled() is true.
// compilerEnv_.debugEnabled() is true.
//
//
// Alignment check elimination.
@ -14043,12 +14046,12 @@ bool BaseCompiler::emitBody() {
OpBytes op;
CHECK(iter_.readOp(&op));
// When moduleEnv_.debugEnabled(), every operator has breakpoint site but
// When compilerEnv_.debugEnabled(), every operator has breakpoint site but
// Op::End.
if (moduleEnv_.debugEnabled() && op.b0 != (uint16_t)Op::End) {
if (compilerEnv_.debugEnabled() && op.b0 != (uint16_t)Op::End) {
// TODO sync only registers that can be clobbered by the exit
// prologue/epilogue or disable these registers for use in
// baseline compiler when moduleEnv_.debugEnabled() is set.
// baseline compiler when compilerEnv_.debugEnabled() is set.
sync();
insertBreakablePoint(CallSiteDesc::Breakpoint);
@ -15465,6 +15468,7 @@ bool BaseCompiler::emitFunction() {
}
BaseCompiler::BaseCompiler(const ModuleEnvironment& moduleEnv,
const CompilerEnvironment& compilerEnv,
const FuncCompileInput& func,
const ValTypeVector& locals,
const MachineState& trapExitLayout,
@ -15472,6 +15476,7 @@ BaseCompiler::BaseCompiler(const ModuleEnvironment& moduleEnv,
StkVector& stkSource, TempAllocator* alloc,
MacroAssembler* masm, StackMaps* stackMaps)
: moduleEnv_(moduleEnv),
compilerEnv_(compilerEnv),
iter_(moduleEnv, decoder),
func_(func),
lastReadCallSite_(0),
@ -15520,7 +15525,8 @@ bool BaseCompiler::init() {
}
ArgTypeVector args(funcType());
if (!fr.setupLocals(locals_, args, moduleEnv_.debugEnabled(), &localInfo_)) {
if (!fr.setupLocals(locals_, args, compilerEnv_.debugEnabled(),
&localInfo_)) {
return false;
}
@ -15564,11 +15570,12 @@ bool js::wasm::BaselinePlatformSupport() {
}
bool js::wasm::BaselineCompileFunctions(const ModuleEnvironment& moduleEnv,
const CompilerEnvironment& compilerEnv,
LifoAlloc& lifo,
const FuncCompileInputVector& inputs,
CompiledCode* code,
UniqueChars* error) {
MOZ_ASSERT(moduleEnv.tier() == Tier::Baseline);
MOZ_ASSERT(compilerEnv.tier() == Tier::Baseline);
MOZ_ASSERT(moduleEnv.kind == ModuleKind::Wasm);
// The MacroAssembler will sometimes access the jitContext.
@ -15612,7 +15619,7 @@ bool js::wasm::BaselineCompileFunctions(const ModuleEnvironment& moduleEnv,
// One-pass baseline compilation.
BaseCompiler f(moduleEnv, func, locals, trapExitLayout,
BaseCompiler f(moduleEnv, compilerEnv, func, locals, trapExitLayout,
trapExitLayoutNumWords, d, stk, &alloc, &masm,
&code->stackMaps);
if (!f.init()) {

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

@ -30,11 +30,10 @@ namespace wasm {
MOZ_MUST_USE bool BaselinePlatformSupport();
// Generate adequate code quickly.
MOZ_MUST_USE bool BaselineCompileFunctions(const ModuleEnvironment& moduleEnv,
LifoAlloc& lifo,
const FuncCompileInputVector& inputs,
CompiledCode* code,
UniqueChars* error);
MOZ_MUST_USE bool BaselineCompileFunctions(
const ModuleEnvironment& moduleEnv, const CompilerEnvironment& compilerEnv,
LifoAlloc& lifo, const FuncCompileInputVector& inputs, CompiledCode* code,
UniqueChars* error);
class BaseLocalIter {
private:

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

@ -576,13 +576,14 @@ SharedModule wasm::CompileBuffer(const CompileArgs& args,
JSTelemetrySender telemetrySender) {
Decoder d(bytecode.bytes, 0, error, warnings);
CompilerEnvironment compilerEnv(args);
ModuleEnvironment moduleEnv(&compilerEnv, args.features);
ModuleEnvironment moduleEnv(args.features);
if (!DecodeModuleEnvironment(d, &moduleEnv)) {
return nullptr;
}
CompilerEnvironment compilerEnv(args);
compilerEnv.computeParameters(d);
ModuleGenerator mg(args, &moduleEnv, nullptr, error);
ModuleGenerator mg(args, &moduleEnv, &compilerEnv, nullptr, error);
if (!mg.init(nullptr, telemetrySender)) {
return nullptr;
}
@ -608,15 +609,15 @@ void wasm::CompileTier2(const CompileArgs& args, const Bytes& bytecode,
? OptimizedBackend::Cranelift
: OptimizedBackend::Ion;
CompilerEnvironment compilerEnv(CompileMode::Tier2, Tier::Optimized,
optimizedBackend, DebugEnabled::False);
ModuleEnvironment moduleEnv(&compilerEnv, args.features);
ModuleEnvironment moduleEnv(args.features);
if (!DecodeModuleEnvironment(d, &moduleEnv)) {
return;
}
CompilerEnvironment compilerEnv(CompileMode::Tier2, Tier::Optimized,
optimizedBackend, DebugEnabled::False);
compilerEnv.computeParameters(d);
ModuleGenerator mg(args, &moduleEnv, cancelled, &error);
ModuleGenerator mg(args, &moduleEnv, &compilerEnv, cancelled, &error);
if (!mg.init(nullptr, telemetrySender)) {
return;
}
@ -719,7 +720,7 @@ SharedModule wasm::CompileStreaming(
const Atomic<bool>& cancelled, UniqueChars* error,
UniqueCharsVector* warnings, JSTelemetrySender telemetrySender) {
CompilerEnvironment compilerEnv(args);
ModuleEnvironment moduleEnv(&compilerEnv, args.features);
ModuleEnvironment moduleEnv(args.features);
{
Decoder d(envBytes, 0, error, warnings);
@ -727,6 +728,7 @@ SharedModule wasm::CompileStreaming(
if (!DecodeModuleEnvironment(d, &moduleEnv)) {
return nullptr;
}
compilerEnv.computeParameters(d);
if (!moduleEnv.codeSection) {
d.fail("unknown section before code section");
@ -737,7 +739,7 @@ SharedModule wasm::CompileStreaming(
MOZ_RELEASE_ASSERT(d.done());
}
ModuleGenerator mg(args, &moduleEnv, &cancelled, error);
ModuleGenerator mg(args, &moduleEnv, &compilerEnv, &cancelled, error);
if (!mg.init(nullptr, telemetrySender)) {
return nullptr;
}

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

@ -433,13 +433,15 @@ const GlobalDesc* env_global(const CraneliftModuleEnvironment* wrapper,
}
bool wasm::CraneliftCompileFunctions(const ModuleEnvironment& moduleEnv,
const CompilerEnvironment& compilerEnv,
LifoAlloc& lifo,
const FuncCompileInputVector& inputs,
CompiledCode* code, UniqueChars* error) {
MOZ_RELEASE_ASSERT(CraneliftPlatformSupport());
MOZ_ASSERT(moduleEnv.tier() == Tier::Optimized);
MOZ_ASSERT(moduleEnv.optimizedBackend() == OptimizedBackend::Cranelift);
MOZ_ASSERT(compilerEnv.tier() == Tier::Optimized);
MOZ_ASSERT(compilerEnv.debug() == DebugEnabled::False);
MOZ_ASSERT(compilerEnv.optimizedBackend() == OptimizedBackend::Cranelift);
MOZ_ASSERT(!moduleEnv.isAsmJS());
TempAllocator alloc(&lifo);

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

@ -33,8 +33,8 @@ MOZ_MUST_USE bool CraneliftPlatformSupport();
// Generates code with Cranelift.
MOZ_MUST_USE bool CraneliftCompileFunctions(
const ModuleEnvironment& moduleEnv, LifoAlloc& lifo,
const FuncCompileInputVector& inputs, CompiledCode* code,
const ModuleEnvironment& moduleEnv, const CompilerEnvironment& compilerEnv,
LifoAlloc& lifo, const FuncCompileInputVector& inputs, CompiledCode* code,
UniqueChars* error);
void CraneliftFreeReusableData(void* data);
@ -42,8 +42,8 @@ void CraneliftFreeReusableData(void* data);
MOZ_MUST_USE inline bool CraneliftPlatformSupport() { return false; }
MOZ_MUST_USE inline bool CraneliftCompileFunctions(
const ModuleEnvironment& moduleEnv, LifoAlloc& lifo,
const FuncCompileInputVector& inputs, CompiledCode* code,
const ModuleEnvironment& moduleEnv, const CompilerEnvironment& compilerEnv,
LifoAlloc& lifo, const FuncCompileInputVector& inputs, CompiledCode* code,
UniqueChars* error) {
MOZ_CRASH("Should not happen");
}

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

@ -78,12 +78,14 @@ static const uint32_t BAD_CODE_RANGE = UINT32_MAX;
ModuleGenerator::ModuleGenerator(const CompileArgs& args,
ModuleEnvironment* moduleEnv,
CompilerEnvironment* compilerEnv,
const Atomic<bool>* cancelled,
UniqueChars* error)
: compileArgs_(&args),
error_(error),
cancelled_(cancelled),
moduleEnv_(moduleEnv),
compilerEnv_(compilerEnv),
linkData_(nullptr),
metadataTier_(nullptr),
lifo_(GENERATOR_LIFO_DEFAULT_CHUNK_SIZE),
@ -435,7 +437,7 @@ bool ModuleGenerator::init(Metadata* maybeAsmJSMetadata,
return false;
}
for (size_t i = 0; i < numTasks; i++) {
tasks_.infallibleEmplaceBack(*moduleEnv_, taskState_,
tasks_.infallibleEmplaceBack(*moduleEnv_, *compilerEnv_, taskState_,
COMPILATION_LIFO_DEFAULT_CHUNK_SIZE,
telemetrySender);
}
@ -739,12 +741,13 @@ static bool ExecuteCompileTask(CompileTask* task, UniqueChars* error) {
int compileTimeTelemetryID;
#endif
switch (task->moduleEnv.tier()) {
switch (task->compilerEnv.tier()) {
case Tier::Optimized:
switch (task->moduleEnv.optimizedBackend()) {
switch (task->compilerEnv.optimizedBackend()) {
case OptimizedBackend::Cranelift:
if (!CraneliftCompileFunctions(task->moduleEnv, task->lifo,
task->inputs, &task->output, error)) {
if (!CraneliftCompileFunctions(task->moduleEnv, task->compilerEnv,
task->lifo, task->inputs,
&task->output, error)) {
return false;
}
#ifdef ENABLE_SPIDERMONKEY_TELEMETRY
@ -752,8 +755,9 @@ static bool ExecuteCompileTask(CompileTask* task, UniqueChars* error) {
#endif
break;
case OptimizedBackend::Ion:
if (!IonCompileFunctions(task->moduleEnv, task->lifo, task->inputs,
&task->output, error)) {
if (!IonCompileFunctions(task->moduleEnv, task->compilerEnv,
task->lifo, task->inputs, &task->output,
error)) {
return false;
}
#ifdef ENABLE_SPIDERMONKEY_TELEMETRY
@ -763,8 +767,9 @@ static bool ExecuteCompileTask(CompileTask* task, UniqueChars* error) {
}
break;
case Tier::Baseline:
if (!BaselineCompileFunctions(task->moduleEnv, task->lifo, task->inputs,
&task->output, error)) {
if (!BaselineCompileFunctions(task->moduleEnv, task->compilerEnv,
task->lifo, task->inputs, &task->output,
error)) {
return false;
}
#ifdef ENABLE_SPIDERMONKEY_TELEMETRY
@ -899,7 +904,7 @@ bool ModuleGenerator::compileFuncDef(uint32_t funcIndex,
threshold = JitOptions.wasmBatchBaselineThreshold;
break;
case Tier::Optimized:
switch (moduleEnv_->optimizedBackend()) {
switch (compilerEnv_->optimizedBackend()) {
case OptimizedBackend::Ion:
threshold = JitOptions.wasmBatchIonThreshold;
break;
@ -1099,7 +1104,7 @@ UniqueCodeTier ModuleGenerator::finishCodeTier() {
#ifdef DEBUG
// Check that each stack map is associated with a plausible instruction.
for (size_t i = 0; i < metadataTier_->stackMaps.length(); i++) {
MOZ_ASSERT(IsValidStackMapKey(moduleEnv_->debugEnabled(),
MOZ_ASSERT(IsValidStackMapKey(compilerEnv_->debugEnabled(),
metadataTier_->stackMaps.get(i).nextInsnAddr),
"wasm stack map does not reference a valid insn");
}
@ -1129,7 +1134,7 @@ SharedMetadata ModuleGenerator::finishMetadata(const Bytes& bytecode) {
// Copy over additional debug information.
if (moduleEnv_->debugEnabled()) {
if (compilerEnv_->debugEnabled()) {
metadata_->debugEnabled = true;
const size_t numFuncTypes = moduleEnv_->funcTypes.length();
@ -1254,7 +1259,7 @@ SharedModule ModuleGenerator::finishModule(
UniqueBytes debugUnlinkedCode;
UniqueLinkData debugLinkData;
const ShareableBytes* debugBytecode = nullptr;
if (moduleEnv_->debugEnabled()) {
if (compilerEnv_->debugEnabled()) {
MOZ_ASSERT(mode() == CompileMode::Once);
MOZ_ASSERT(tier() == Tier::Debug);
@ -1294,7 +1299,7 @@ SharedModule ModuleGenerator::finishModule(
bool ModuleGenerator::finishTier2(const Module& module) {
MOZ_ASSERT(mode() == CompileMode::Tier2);
MOZ_ASSERT(tier() == Tier::Optimized);
MOZ_ASSERT(!moduleEnv_->debugEnabled());
MOZ_ASSERT(!compilerEnv_->debugEnabled());
if (cancelled_ && *cancelled_) {
return false;

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

@ -132,15 +132,19 @@ struct CompileTaskState {
struct CompileTask : public HelperThreadTask {
const ModuleEnvironment& moduleEnv;
const CompilerEnvironment& compilerEnv;
CompileTaskState& state;
LifoAlloc lifo;
FuncCompileInputVector inputs;
CompiledCode output;
JSTelemetrySender telemetrySender;
CompileTask(const ModuleEnvironment& moduleEnv, CompileTaskState& state,
CompileTask(const ModuleEnvironment& moduleEnv,
const CompilerEnvironment& compilerEnv, CompileTaskState& state,
size_t defaultChunkSize, JSTelemetrySender telemetrySender)
: moduleEnv(moduleEnv),
compilerEnv(compilerEnv),
state(state),
lifo(defaultChunkSize),
telemetrySender(telemetrySender) {}
@ -174,6 +178,7 @@ class MOZ_STACK_CLASS ModuleGenerator {
UniqueChars* const error_;
const Atomic<bool>* const cancelled_;
ModuleEnvironment* const moduleEnv_;
CompilerEnvironment* const compilerEnv_;
JSTelemetrySender telemetrySender_;
// Data that is moved into the result of finish()
@ -224,12 +229,13 @@ class MOZ_STACK_CLASS ModuleGenerator {
SharedMetadata finishMetadata(const Bytes& bytecode);
bool isAsmJS() const { return moduleEnv_->isAsmJS(); }
Tier tier() const { return moduleEnv_->tier(); }
CompileMode mode() const { return moduleEnv_->mode(); }
bool debugEnabled() const { return moduleEnv_->debugEnabled(); }
Tier tier() const { return compilerEnv_->tier(); }
CompileMode mode() const { return compilerEnv_->mode(); }
bool debugEnabled() const { return compilerEnv_->debugEnabled(); }
public:
ModuleGenerator(const CompileArgs& args, ModuleEnvironment* moduleEnv,
CompilerEnvironment* compilerEnv,
const Atomic<bool>* cancelled, UniqueChars* error);
~ModuleGenerator();
MOZ_MUST_USE bool init(

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

@ -138,6 +138,7 @@ class FunctionCompiler {
stackResultPointer_(nullptr) {}
const ModuleEnvironment& moduleEnv() const { return moduleEnv_; }
IonOpIter& iter() { return iter_; }
TempAllocator& alloc() const { return alloc_; }
// FIXME(1401675): Replace with BlockType.
@ -5363,11 +5364,13 @@ static bool EmitBodyExprs(FunctionCompiler& f) {
}
bool wasm::IonCompileFunctions(const ModuleEnvironment& moduleEnv,
const CompilerEnvironment& compilerEnv,
LifoAlloc& lifo,
const FuncCompileInputVector& inputs,
CompiledCode* code, UniqueChars* error) {
MOZ_ASSERT(moduleEnv.tier() == Tier::Optimized);
MOZ_ASSERT(moduleEnv.optimizedBackend() == OptimizedBackend::Ion);
MOZ_ASSERT(compilerEnv.tier() == Tier::Optimized);
MOZ_ASSERT(compilerEnv.debug() == DebugEnabled::False);
MOZ_ASSERT(compilerEnv.optimizedBackend() == OptimizedBackend::Ion);
TempAllocator alloc(&lifo);
JitContext jitContext(&alloc);

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

@ -32,6 +32,7 @@ MOZ_MUST_USE bool IonPlatformSupport();
// Generates very fast code at the expense of compilation time.
MOZ_MUST_USE bool IonCompileFunctions(const ModuleEnvironment& moduleEnv,
const CompilerEnvironment& compilerEnv,
LifoAlloc& lifo,
const FuncCompileInputVector& inputs,
CompiledCode* code, UniqueChars* error);

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

@ -2871,8 +2871,6 @@ bool wasm::DecodeModuleEnvironment(Decoder& d, ModuleEnvironment* env) {
return false;
}
env->compilerEnv->computeParameters(d);
if (!DecodeTypeSection(d, env)) {
return false;
}
@ -3221,9 +3219,7 @@ bool wasm::Validate(JSContext* cx, const ShareableBytes& bytecode,
Decoder d(bytecode.bytes, 0, error);
FeatureArgs features = FeatureArgs::build(cx);
CompilerEnvironment compilerEnv(CompileMode::Once, Tier::Optimized,
OptimizedBackend::Ion, DebugEnabled::False);
ModuleEnvironment env(&compilerEnv, features);
ModuleEnvironment env(features);
if (!DecodeModuleEnvironment(d, &env)) {
return false;
}

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

@ -110,6 +110,7 @@ struct CompilerEnvironment {
MOZ_ASSERT(isComputed());
return debug_;
}
bool debugEnabled() const { return debug() == DebugEnabled::True; }
};
// ModuleEnvironment contains all the state necessary to process or render
@ -126,7 +127,6 @@ struct CompilerEnvironment {
struct ModuleEnvironment {
// Constant parameters for the entire compilation:
const ModuleKind kind;
CompilerEnvironment* const compilerEnv;
const FeatureArgs features;
// Module fields decoded from the module environment (or initialized while
@ -156,22 +156,14 @@ struct ModuleEnvironment {
Maybe<Name> moduleName;
NameVector funcNames;
explicit ModuleEnvironment(CompilerEnvironment* compilerEnv,
FeatureArgs features,
explicit ModuleEnvironment(FeatureArgs features,
ModuleKind kind = ModuleKind::Wasm)
: kind(kind),
compilerEnv(compilerEnv),
features(features),
memoryUsage(MemoryUsage::None),
minMemoryLength(0),
numStructTypes(0) {}
Tier tier() const { return compilerEnv->tier(); }
OptimizedBackend optimizedBackend() const {
return compilerEnv->optimizedBackend();
}
CompileMode mode() const { return compilerEnv->mode(); }
DebugEnabled debug() const { return compilerEnv->debug(); }
size_t numTables() const { return tables.length(); }
size_t numTypes() const { return types.length(); }
size_t numFuncs() const { return funcTypes.length(); }
@ -189,9 +181,7 @@ struct ModuleEnvironment {
bool usesMemory() const { return memoryUsage != MemoryUsage::None; }
bool usesSharedMemory() const { return memoryUsage == MemoryUsage::Shared; }
bool isAsmJS() const { return kind == ModuleKind::AsmJS; }
bool debugEnabled() const {
return compilerEnv->debug() == DebugEnabled::True;
}
uint32_t funcMaxResults() const {
return multiValueEnabled() ? MaxResults : 1;
}