Skip to content

Commit

Permalink
Backed out changeset 472418229a51 (bug 1757733) for causing bustages …
Browse files Browse the repository at this point in the history
…on testWasm.cpp.
  • Loading branch information
Marian-Vasile Laza committed Mar 15, 2022
1 parent 7d21796 commit 535a700
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 55 deletions.
6 changes: 1 addition & 5 deletions js/src/wasm/AsmJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2154,13 +2154,9 @@ class MOZ_STACK_CLASS ModuleValidator : public ModuleValidatorShared {

// The default options are fine for asm.js
FeatureOptions options;
CompileArgsError error;
SharedCompileArgs args =
CompileArgs::build(cx_, std::move(scriptedCaller), options, &error);
CompileArgs::build(cx_, std::move(scriptedCaller), options);
if (!args) {
// EstablishPreconditions will ensure that a compiler is available by
// this point
MOZ_RELEASE_ASSERT(error == CompileArgsError::OutOfMemory);
return nullptr;
}

Expand Down
39 changes: 7 additions & 32 deletions js/src/wasm/WasmCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ FeatureArgs FeatureArgs::build(JSContext* cx, const FeatureOptions& options) {

SharedCompileArgs CompileArgs::build(JSContext* cx,
ScriptedCaller&& scriptedCaller,
const FeatureOptions& options,
CompileArgsError* error) {
const FeatureOptions& options) {
bool baseline = BaselineAvailable(cx);
bool ion = IonAvailable(cx);
bool cranelift = CraneliftAvailable(cx);
Expand All @@ -129,7 +128,7 @@ SharedCompileArgs CompileArgs::build(JSContext* cx,
// when we're fuzzing we allow inconsistent switches and the check may thus
// fail. Let it go to a run-time error instead of crashing.
if (debug && (ion || cranelift)) {
*error = CompileArgsError::NoCompiler;
JS_ReportErrorASCII(cx, "no WebAssembly compiler available");
return nullptr;
}

Expand All @@ -141,13 +140,12 @@ SharedCompileArgs CompileArgs::build(JSContext* cx,
}

if (!(baseline || ion || cranelift)) {
*error = CompileArgsError::NoCompiler;
JS_ReportErrorASCII(cx, "no WebAssembly compiler available");
return nullptr;
}

CompileArgs* target = cx->new_<CompileArgs>(std::move(scriptedCaller));
if (!target) {
*error = CompileArgsError::OutOfMemory;
return nullptr;
}

Expand All @@ -158,34 +156,11 @@ SharedCompileArgs CompileArgs::build(JSContext* cx,
target->forceTiering = forceTiering;
target->features = FeatureArgs::build(cx, options);

return target;
}
Log(cx, "available wasm compilers: tier1=%s tier2=%s",
baseline ? "baseline" : "none",
ion ? "ion" : (cranelift ? "cranelift" : "none"));

SharedCompileArgs CompileArgs::buildAndReport(JSContext* cx,
ScriptedCaller&& scriptedCaller,
const FeatureOptions& options) {
CompileArgsError error;
SharedCompileArgs args =
CompileArgs::build(cx, std::move(scriptedCaller), options, &error);
if (args) {
Log(cx, "available wasm compilers: tier1=%s tier2=%s",
args->baselineEnabled ? "baseline" : "none",
args->ionEnabled ? "ion"
: (args->craneliftEnabled ? "cranelift" : "none"));
return args;
}

switch (error) {
case CompileArgsError::NoCompiler: {
JS_ReportErrorASCII(cx, "no WebAssembly compiler available");
break;
}
case CompileArgsError::OutOfMemory: {
// Intentionally do not report the OOM, as callers expect this behavior
break;
}
}
return nullptr;
return target;
}

/*
Expand Down
19 changes: 4 additions & 15 deletions js/src/wasm/WasmCompileArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ struct ScriptedCaller {
ScriptedCaller() : filenameIsURL(false), line(0) {}
};

// Describes the reasons we cannot compute compile args

enum class CompileArgsError {
OutOfMemory,
NoCompiler,
};

// Describes all the parameters that control wasm compilation.

struct CompileArgs;
Expand All @@ -143,21 +136,17 @@ struct CompileArgs : ShareableBase<CompileArgs> {

FeatureArgs features;

// CompileArgs has three constructors:
// CompileArgs has two constructors:
//
// - two through a factory function `build`, which checks that flags are
// consistent with each other, and optionally reports any errors.
// - one through a factory function `build`, which checks that flags are
// consistent with each other.
// - one that gives complete access to underlying fields.
//
// You should use the first one in general, unless you have a very good
// reason (i.e. no JSContext around and you know which flags have been used).

static SharedCompileArgs build(JSContext* cx, ScriptedCaller&& scriptedCaller,
const FeatureOptions& options,
CompileArgsError* error);
static SharedCompileArgs buildAndReport(JSContext* cx,
ScriptedCaller&& scriptedCaller,
const FeatureOptions& options);
const FeatureOptions& options);

explicit CompileArgs(ScriptedCaller&& scriptedCaller)
: scriptedCaller(std::move(scriptedCaller)),
Expand Down
2 changes: 1 addition & 1 deletion js/src/wasm/WasmIntrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bool wasm::CompileIntrinsicModule(JSContext* cx,

// Initialize the compiler environment, choosing the best tier possible
SharedCompileArgs compileArgs =
CompileArgs::buildAndReport(cx, ScriptedCaller(), featureOptions);
CompileArgs::build(cx, ScriptedCaller(), featureOptions);
if (!compileArgs) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/wasm/WasmJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ static SharedCompileArgs InitCompileArgs(JSContext* cx,
if (!ParseCompileOptions(cx, maybeOptions, &options)) {
return nullptr;
}
return CompileArgs::buildAndReport(cx, std::move(scriptedCaller), options);
return CompileArgs::build(cx, std::move(scriptedCaller), options);
}

// ============================================================================
Expand Down Expand Up @@ -4283,7 +4283,7 @@ JSFunction* WasmFunctionCreate(JSContext* cx, HandleFunction func,
FeatureOptions options;
ScriptedCaller scriptedCaller;
SharedCompileArgs compileArgs =
CompileArgs::buildAndReport(cx, std::move(scriptedCaller), options);
CompileArgs::build(cx, std::move(scriptedCaller), options);
if (!compileArgs) {
return nullptr;
}
Expand Down

0 comments on commit 535a700

Please sign in to comment.