зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1531670
- Replace ENABLE_WASM_GENERALIZED_TABLES. r=bbouvier
Replace all uses of ENABLE_WASM_GENERALIZED_TABLES with ENABLE_WASM_REFTYPES, plus some knock-on effects. Replace all uses of wasmGeneralizedTables with wasmReftypesEnabled. Drive-by fix: replace 'anyfunc' in a couple of error strings with the canonical 'funcref'. Drive-by fix: remove isSimdAvailable, it is not used and we have no SIMD. Differential Revision: https://phabricator.services.mozilla.com/D21653 --HG-- extra : rebase_source : 043732afa1661133eaff54554e56f76fe3e32504
This commit is contained in:
Родитель
62b87fa98a
Коммит
2f39ed5e4a
|
@ -558,22 +558,6 @@ set_config('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x
|
|||
set_define('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
|
||||
|
||||
|
||||
# Support for WebAssembly generalized tables (anyref tables, multiple tables).
|
||||
# ============================================================================
|
||||
|
||||
@depends(milestone.is_nightly, '--enable-wasm-reftypes')
|
||||
def default_wasm_generalized_tables(is_nightly, reftypes):
|
||||
if reftypes and is_nightly:
|
||||
return True
|
||||
|
||||
js_option('--enable-wasm-generalized-tables',
|
||||
default=default_wasm_generalized_tables,
|
||||
help='{Enable|Disable} WebAssembly generalized reference tables')
|
||||
|
||||
set_config('ENABLE_WASM_GENERALIZED_TABLES', depends_if('--enable-wasm-generalized-tables')(lambda x: True))
|
||||
set_define('ENABLE_WASM_GENERALIZED_TABLES', depends_if('--enable-wasm-generalized-tables')(lambda x: True))
|
||||
|
||||
|
||||
# Support for WebAssembly GC.
|
||||
# ===========================
|
||||
|
||||
|
|
|
@ -704,19 +704,6 @@ static bool WasmDebugSupport(JSContext* cx, unsigned argc, Value* vp) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool WasmGeneralizedTables(JSContext* cx, unsigned argc, Value* vp) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
// Generalized tables depend on anyref, though not currently on (ref T)
|
||||
// types nor on structures or other GC-proposal features.
|
||||
bool isSupported = wasm::HasReftypesSupport(cx);
|
||||
#else
|
||||
bool isSupported = false;
|
||||
#endif
|
||||
args.rval().setBoolean(isSupported);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool WasmCompileMode(JSContext* cx, unsigned argc, Value* vp) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
|
@ -4011,12 +3998,6 @@ static bool ShellCloneAndExecuteScript(JSContext* cx, unsigned argc,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool IsSimdAvailable(JSContext* cx, unsigned argc, Value* vp) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().set(BooleanValue(cx->jitSupportsSimd()));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ByteSize(JSContext* cx, unsigned argc, Value* vp) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
mozilla::MallocSizeOf mallocSizeOf = cx->runtime()->debuggerMallocSizeOf;
|
||||
|
@ -5928,10 +5909,6 @@ gc::ZealModeHelpText),
|
|||
" Returns whether asm.js compilation is currently available or whether it is disabled\n"
|
||||
" (e.g., by the debugger)."),
|
||||
|
||||
JS_FN_HELP("isSimdAvailable", IsSimdAvailable, 0, 0,
|
||||
"isSimdAvailable",
|
||||
" Returns true if SIMD extensions are supported on this platform."),
|
||||
|
||||
JS_FN_HELP("getJitCompilerOptions", GetJitCompilerOptions, 0, 0,
|
||||
"getJitCompilerOptions()",
|
||||
" Return an object describing some of the JIT compiler options.\n"),
|
||||
|
@ -6010,12 +5987,6 @@ gc::ZealModeHelpText),
|
|||
"wasmDebugSupport(bool)",
|
||||
" Returns a boolean indicating whether the WebAssembly compilers support debugging."),
|
||||
|
||||
JS_FN_HELP("wasmGeneralizedTables", WasmGeneralizedTables, 1, 0,
|
||||
"wasmGeneralizedTables(bool)",
|
||||
" Returns a boolean indicating whether generalized tables are available.\n"
|
||||
" This feature set includes 'anyref' as a table type, and new instructions\n"
|
||||
" including table.get, table.set, table.grow, and table.size."),
|
||||
|
||||
JS_FN_HELP("isLazyFunction", IsLazyFunction, 1, 0,
|
||||
"isLazyFunction(fun)",
|
||||
" True if fun is a lazy JSFunction."),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// |jit-test| skip-if: wasmGeneralizedTables()
|
||||
// |jit-test| skip-if: wasmReftypesEnabled()
|
||||
|
||||
assertErrorMessage(() => new WebAssembly.Table({element:"anyref", initial:10}),
|
||||
TypeError,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// |jit-test| skip-if: !wasmGeneralizedTables() || !wasmGcEnabled() || wasmCompileMode() != 'baseline'
|
||||
// |jit-test| skip-if: !wasmReftypesEnabled() || !wasmGcEnabled() || wasmCompileMode() != 'baseline'
|
||||
|
||||
// table.set in bounds with i32 x anyref - works, no value generated
|
||||
// table.set with (ref T) - works
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// |jit-test| skip-if: !wasmGeneralizedTables()
|
||||
// |jit-test| skip-if: !wasmReftypesEnabled()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// |jit-test| skip-if: !wasmGeneralizedTables()
|
||||
// |jit-test| skip-if: !wasmReftypesEnabled()
|
||||
|
||||
// Note that negative tests not having to do with table indices have been taken
|
||||
// care of by tables-generalized.js.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// |jit-test| skip-if: !wasmGeneralizedTables()
|
||||
// |jit-test| skip-if: !wasmReftypesEnabled()
|
||||
|
||||
for ( let prefix of ['', '(table $prefix 0 32 funcref)']) {
|
||||
let mod = new WebAssembly.Module(wasmTextToBinary(
|
||||
|
|
|
@ -429,7 +429,7 @@ enum class AstExprKind {
|
|||
StructSet,
|
||||
StructNarrow,
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
TableGet,
|
||||
TableGrow,
|
||||
TableSet,
|
||||
|
@ -918,7 +918,7 @@ class AstMemOrTableInit : public AstExpr {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
class AstTableGet : public AstExpr {
|
||||
AstRef targetTable_;
|
||||
AstExpr* index_;
|
||||
|
@ -980,7 +980,7 @@ class AstTableSize : public AstExpr {
|
|||
|
||||
AstRef& targetTable() { return targetTable_; }
|
||||
};
|
||||
#endif // ENABLE_WASM_GENERALIZED_TABLES
|
||||
#endif // ENABLE_WASM_REFTYPES
|
||||
|
||||
#ifdef ENABLE_WASM_GC
|
||||
class AstStructNew : public AstExpr {
|
||||
|
|
|
@ -10942,7 +10942,7 @@ bool BaseCompiler::emitBody() {
|
|||
CHECK_NEXT(emitGetGlobal());
|
||||
case uint16_t(Op::SetGlobal):
|
||||
CHECK_NEXT(emitSetGlobal());
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case uint16_t(Op::TableGet):
|
||||
CHECK_NEXT(emitTableGet());
|
||||
case uint16_t(Op::TableSet):
|
||||
|
@ -11544,7 +11544,7 @@ bool BaseCompiler::emitBody() {
|
|||
case uint16_t(MiscOp::TableInit):
|
||||
CHECK_NEXT(emitMemOrTableInit(/*isMem=*/false));
|
||||
#endif // ENABLE_WASM_BULKMEM_OPS
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case uint16_t(MiscOp::TableGrow):
|
||||
CHECK_NEXT(emitTableGrow());
|
||||
case uint16_t(MiscOp::TableSize):
|
||||
|
|
|
@ -170,7 +170,7 @@ enum class Op {
|
|||
TeeLocal = 0x22,
|
||||
GetGlobal = 0x23,
|
||||
SetGlobal = 0x24,
|
||||
TableGet = 0x25, // Generalized table ops,
|
||||
TableGet = 0x25, // Reftypes,
|
||||
TableSet = 0x26, // per proposal as of February 2019
|
||||
|
||||
// Memory-related operators
|
||||
|
@ -382,7 +382,7 @@ enum class MiscOp {
|
|||
ElemDrop = 0x0d,
|
||||
TableCopy = 0x0e,
|
||||
|
||||
// Generalized table operations, per proposal as of February 2019.
|
||||
// Reftypes, per proposal as of February 2019.
|
||||
TableGrow = 0x0f,
|
||||
TableSize = 0x10,
|
||||
// TableFill = 0x11, // reserved
|
||||
|
|
|
@ -3113,7 +3113,7 @@ static bool EmitMemOrTableInit(FunctionCompiler& f, bool isMem) {
|
|||
}
|
||||
#endif // ENABLE_WASM_BULKMEM_OPS
|
||||
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
// Note, table.{get,grow,set} on table(anyfunc) are currently rejected by the
|
||||
// verifier.
|
||||
|
||||
|
@ -3311,7 +3311,7 @@ static bool EmitTableSize(FunctionCompiler& f) {
|
|||
f.iter().setResult(ret);
|
||||
return true;
|
||||
}
|
||||
#endif // ENABLE_WASM_GENERALIZED_TABLES
|
||||
#endif // ENABLE_WASM_REFTYPES
|
||||
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
static bool EmitRefNull(FunctionCompiler& f) {
|
||||
|
@ -3425,7 +3425,7 @@ static bool EmitBodyExprs(FunctionCompiler& f) {
|
|||
CHECK(EmitGetGlobal(f));
|
||||
case uint16_t(Op::SetGlobal):
|
||||
CHECK(EmitSetGlobal(f));
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case uint16_t(Op::TableGet):
|
||||
CHECK(EmitTableGet(f));
|
||||
case uint16_t(Op::TableSet):
|
||||
|
@ -3849,7 +3849,7 @@ static bool EmitBodyExprs(FunctionCompiler& f) {
|
|||
case uint16_t(MiscOp::TableInit):
|
||||
CHECK(EmitMemOrTableInit(f, /*isMem=*/false));
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case uint16_t(MiscOp::TableGrow):
|
||||
CHECK(EmitTableGrow(f));
|
||||
case uint16_t(MiscOp::TableSize):
|
||||
|
|
|
@ -2103,7 +2103,7 @@ bool WasmTableObject::construct(JSContext* cx, unsigned argc, Value* vp) {
|
|||
StringEqualsAscii(elementLinearStr, "funcref"))
|
||||
{
|
||||
tableKind = TableKind::AnyFunction;
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
} else if (StringEqualsAscii(elementLinearStr, "anyref")) {
|
||||
if (!HasReftypesSupport(cx)) {
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
|
||||
|
@ -2113,7 +2113,7 @@ bool WasmTableObject::construct(JSContext* cx, unsigned argc, Value* vp) {
|
|||
tableKind = TableKind::AnyRef;
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
|
||||
JSMSG_WASM_BAD_ELEMENT_GENERALIZED);
|
||||
#else
|
||||
|
|
|
@ -22,12 +22,6 @@ using namespace js;
|
|||
using namespace js::jit;
|
||||
using namespace js::wasm;
|
||||
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
# ifndef ENABLE_WASM_REFTYPES
|
||||
# error "Generalized tables require the reftypes feature"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_GC
|
||||
# ifndef ENABLE_WASM_REFTYPES
|
||||
# error "GC types require the reftypes feature"
|
||||
|
@ -51,11 +45,6 @@ using namespace js::wasm;
|
|||
# else
|
||||
# define WASM_BULK_OP(code) break
|
||||
# endif
|
||||
# ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
# define WASM_TABLE_OP(code) return code
|
||||
# else
|
||||
# define WASM_TABLE_OP(code) break
|
||||
# endif
|
||||
|
||||
OpKind wasm::Classify(OpBytes op) {
|
||||
switch (Op(op.b0)) {
|
||||
|
@ -253,9 +242,9 @@ OpKind wasm::Classify(OpBytes op) {
|
|||
case Op::SetGlobal:
|
||||
return OpKind::SetGlobal;
|
||||
case Op::TableGet:
|
||||
WASM_TABLE_OP(OpKind::TableGet);
|
||||
WASM_REF_OP(OpKind::TableGet);
|
||||
case Op::TableSet:
|
||||
WASM_TABLE_OP(OpKind::TableSet);
|
||||
WASM_REF_OP(OpKind::TableSet);
|
||||
case Op::Call:
|
||||
return OpKind::Call;
|
||||
case Op::CallIndirect:
|
||||
|
@ -308,9 +297,9 @@ OpKind wasm::Classify(OpBytes op) {
|
|||
case MiscOp::TableInit:
|
||||
WASM_BULK_OP(OpKind::MemOrTableInit);
|
||||
case MiscOp::TableGrow:
|
||||
WASM_TABLE_OP(OpKind::TableGrow);
|
||||
WASM_REF_OP(OpKind::TableGrow);
|
||||
case MiscOp::TableSize:
|
||||
WASM_TABLE_OP(OpKind::TableSize);
|
||||
WASM_REF_OP(OpKind::TableSize);
|
||||
case MiscOp::StructNew:
|
||||
WASM_GC_OP(OpKind::StructNew);
|
||||
case MiscOp::StructGet:
|
||||
|
@ -455,6 +444,6 @@ OpKind wasm::Classify(OpBytes op) {
|
|||
|
||||
# undef WASM_GC_OP
|
||||
# undef WASM_BULK_OP
|
||||
# undef WASM_TABLE_OP
|
||||
# undef WASM_REF_OP
|
||||
|
||||
#endif
|
||||
|
|
|
@ -145,7 +145,7 @@ class WasmToken {
|
|||
ElemDrop,
|
||||
TableInit,
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
TableGet,
|
||||
TableGrow,
|
||||
TableSet,
|
||||
|
@ -345,7 +345,7 @@ class WasmToken {
|
|||
case TableCopy:
|
||||
case TableInit:
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case TableGet:
|
||||
case TableGrow:
|
||||
case TableSet:
|
||||
|
@ -2256,7 +2256,7 @@ WasmToken WasmTokenStream::next() {
|
|||
return WasmToken(WasmToken::TableInit, begin, cur_);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
if (consume(u"get")) {
|
||||
return WasmToken(WasmToken::TableGet, begin, cur_);
|
||||
}
|
||||
|
@ -3782,7 +3782,7 @@ static AstMemOrTableInit* ParseMemOrTableInit(WasmParseContext& c,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
static AstTableGet* ParseTableGet(WasmParseContext& c, bool inParens) {
|
||||
// (table.get table index)
|
||||
// (table.get index)
|
||||
|
@ -4037,7 +4037,7 @@ static AstExpr* ParseExprBody(WasmParseContext& c, WasmToken token,
|
|||
case WasmToken::TableInit:
|
||||
return ParseMemOrTableInit(c, inParens, /*isMem=*/false);
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case WasmToken::TableGet:
|
||||
return ParseTableGet(c, inParens);
|
||||
case WasmToken::TableGrow:
|
||||
|
@ -4656,7 +4656,7 @@ static bool ParseElemType(WasmParseContext& c, TableKind* tableKind) {
|
|||
*tableKind = TableKind::AnyFunction;
|
||||
return true;
|
||||
}
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
if (c.ts.getIf(WasmToken::ValueType, &token) &&
|
||||
token.valueType() == ValType::AnyRef) {
|
||||
*tableKind = TableKind::AnyRef;
|
||||
|
@ -5650,7 +5650,7 @@ static bool ResolveMemOrTableInit(Resolver& r, AstMemOrTableInit& s) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
static bool ResolveTableGet(Resolver& r, AstTableGet& s) {
|
||||
return ResolveExpr(r, s.index()) && r.resolveTable(s.targetTable());
|
||||
}
|
||||
|
@ -5802,7 +5802,7 @@ static bool ResolveExpr(Resolver& r, AstExpr& expr) {
|
|||
case AstExprKind::MemOrTableInit:
|
||||
return ResolveMemOrTableInit(r, expr.as<AstMemOrTableInit>());
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case AstExprKind::TableGet:
|
||||
return ResolveTableGet(r, expr.as<AstTableGet>());
|
||||
case AstExprKind::TableGrow:
|
||||
|
@ -6424,7 +6424,7 @@ static bool EncodeMemOrTableInit(Encoder& e, AstMemOrTableInit& s) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
static bool EncodeTableGet(Encoder& e, AstTableGet& s) {
|
||||
return EncodeExpr(e, s.index()) && e.writeOp(Op::TableGet) &&
|
||||
e.writeVarU32(s.targetTable().index());
|
||||
|
@ -6604,7 +6604,7 @@ static bool EncodeExpr(Encoder& e, AstExpr& expr) {
|
|||
case AstExprKind::MemOrTableInit:
|
||||
return EncodeMemOrTableInit(e, expr.as<AstMemOrTableInit>());
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case AstExprKind::TableGet:
|
||||
return EncodeTableGet(e, expr.as<AstTableGet>());
|
||||
case AstExprKind::TableGrow:
|
||||
|
|
|
@ -534,7 +534,7 @@ static bool DecodeFunctionBodyExprs(const ModuleEnvironment& env,
|
|||
uint32_t unused;
|
||||
CHECK(iter.readSetGlobal(&unused, ¬hing));
|
||||
}
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case uint16_t(Op::TableGet): {
|
||||
uint32_t unusedTableIndex;
|
||||
CHECK(iter.readTableGet(&unusedTableIndex, ¬hing));
|
||||
|
@ -869,7 +869,7 @@ static bool DecodeFunctionBodyExprs(const ModuleEnvironment& env,
|
|||
¬hing));
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
case uint16_t(MiscOp::TableGrow): {
|
||||
uint32_t unusedTableIndex;
|
||||
CHECK(iter.readTableGrow(&unusedTableIndex, ¬hing, ¬hing));
|
||||
|
@ -1562,7 +1562,7 @@ static bool DecodeTableTypeAndLimits(Decoder& d, bool gcTypesEnabled,
|
|||
TableKind tableKind;
|
||||
if (elementType == uint8_t(TypeCode::AnyFunc)) {
|
||||
tableKind = TableKind::AnyFunction;
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
} else if (elementType == uint8_t(TypeCode::AnyRef)) {
|
||||
if (!gcTypesEnabled) {
|
||||
return d.fail("reference types not enabled");
|
||||
|
@ -1570,10 +1570,10 @@ static bool DecodeTableTypeAndLimits(Decoder& d, bool gcTypesEnabled,
|
|||
tableKind = TableKind::AnyRef;
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ENABLE_WASM_GENERALIZED_TABLES
|
||||
return d.fail("expected 'anyfunc' or 'anyref' element type");
|
||||
#ifdef ENABLE_WASM_REFTYPES
|
||||
return d.fail("expected 'funcref' or 'anyref' element type");
|
||||
#else
|
||||
return d.fail("expected 'anyfunc' element type");
|
||||
return d.fail("expected 'funcref' element type");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче