mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 03:24:26 +00:00
Bug 1879179 - wasm: Merge function references flag into GC flag. r=bvisness
Function references is not useful on it's own without GC enabled. We should just merge the flags into just 'GC'. Differential Revision: https://phabricator.services.mozilla.com/D201872
This commit is contained in:
parent
1fef284630
commit
bc75aa21e2
@ -705,29 +705,6 @@ option(
|
||||
help="Force disable all wasm experimental features for testing.",
|
||||
)
|
||||
|
||||
# Support for WebAssembly function-references.
|
||||
# ===========================
|
||||
|
||||
|
||||
option(
|
||||
"--disable-wasm-function-references",
|
||||
default=True,
|
||||
help="{Enable|Disable} WebAssembly function-references",
|
||||
)
|
||||
|
||||
|
||||
@depends("--disable-wasm-function-references", "--wasm-no-experimental")
|
||||
def wasm_function_references(value, no_experimental):
|
||||
if no_experimental:
|
||||
return
|
||||
|
||||
if value:
|
||||
return True
|
||||
|
||||
|
||||
set_config("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
|
||||
set_define("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
|
||||
|
||||
# Support for WebAssembly tail-calls.
|
||||
# ===========================
|
||||
|
||||
@ -765,28 +742,14 @@ set_define("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
|
||||
# ===========================
|
||||
|
||||
|
||||
@depends("--disable-wasm-function-references")
|
||||
def default_wasm_gc(function_references):
|
||||
if function_references:
|
||||
return True
|
||||
option("--disable-wasm-gc", default=True, help="{Enable|Disable} WebAssembly GC")
|
||||
|
||||
|
||||
option(
|
||||
"--disable-wasm-gc", default=default_wasm_gc, help="{Enable|Disable} WebAssembly GC"
|
||||
)
|
||||
|
||||
|
||||
@depends(
|
||||
"--disable-wasm-gc", "--disable-wasm-function-references", "--wasm-no-experimental"
|
||||
)
|
||||
def wasm_gc(value, function_references, no_experimental):
|
||||
@depends("--disable-wasm-gc", "--wasm-no-experimental")
|
||||
def wasm_gc(value, no_experimental):
|
||||
if no_experimental or not value:
|
||||
return
|
||||
|
||||
if function_references:
|
||||
return True
|
||||
|
||||
die("--disable-wasm-gc only possible with --disable-wasm-function-references")
|
||||
return True
|
||||
|
||||
|
||||
set_config("ENABLE_WASM_GC", wasm_gc)
|
||||
|
@ -42,11 +42,6 @@
|
||||
#else
|
||||
# define WASM_RELAXED_SIMD_ENABLED 0
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
# define WASM_FUNCTION_REFERENCES_ENABLED 1
|
||||
#else
|
||||
# define WASM_FUNCTION_REFERENCES_ENABLED 0
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_GC
|
||||
# define WASM_GC_ENABLED 1
|
||||
#else
|
||||
@ -94,15 +89,6 @@
|
||||
/* flag force enable */ false, \
|
||||
/* flag fuzz enable */ true, \
|
||||
/* preference name */ exnref) \
|
||||
FEATURE( \
|
||||
/* capitalized name */ FunctionReferences, \
|
||||
/* lower case name */ functionReferences, \
|
||||
/* compile predicate */ WASM_FUNCTION_REFERENCES_ENABLED, \
|
||||
/* compiler predicate */ AnyCompilerAvailable(cx), \
|
||||
/* flag predicate */ true, \
|
||||
/* flag force enable */ WasmGcFlag(cx), \
|
||||
/* flag fuzz enable */ false, \
|
||||
/* preference name */ function_references) \
|
||||
FEATURE( \
|
||||
/* capitalized name */ Gc, \
|
||||
/* lower case name */ gc, \
|
||||
|
@ -61,7 +61,7 @@ name = "function-references"
|
||||
url = "https://github.com/WebAssembly/function-references"
|
||||
branch = "main"
|
||||
parent = "spec"
|
||||
directive = "; --setpref=wasm_function_references=true; skip-if: !wasmFunctionReferencesEnabled()"
|
||||
directive = "; --setpref=wasm_gc=true; skip-if: !wasmGcEnabled()"
|
||||
excluded_tests = [
|
||||
# duplicate tail calls tests
|
||||
"return_call.wast",
|
||||
|
@ -164,9 +164,9 @@ const definedOpcodes =
|
||||
0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11,
|
||||
...(wasmTailCallsEnabled() ? [0x12, 0x13] : []),
|
||||
...(wasmFunctionReferencesEnabled() ? [0x14] : []),
|
||||
...(wasmGcEnabled() ? [0x14] : []),
|
||||
...(wasmTailCallsEnabled() &&
|
||||
wasmFunctionReferencesEnabled() ? [0x15] : []),
|
||||
wasmGcEnabled() ? [0x15] : []),
|
||||
0x18, 0x19,
|
||||
0x1a, 0x1b, 0x1c,
|
||||
...(wasmExnRefEnabled() ? [0x1f] : []),
|
||||
|
@ -63,7 +63,7 @@ wasmRunWithDebugger(
|
||||
);
|
||||
|
||||
// Checking if enter/leave frame at return_call_ref.
|
||||
wasmFunctionReferencesEnabled() && wasmRunWithDebugger(
|
||||
wasmGcEnabled() && wasmRunWithDebugger(
|
||||
'(module (type $t (func)) (elem declare func 0) (func) (func (return_call_ref $t (ref.func 0))) (func (call 1)) (export "test" (func 2)))',
|
||||
undefined,
|
||||
function ({dbg}) {
|
||||
|
@ -70,6 +70,7 @@ let releasedFeatures = [
|
||||
wasmTailCallsEnabled(),
|
||||
`(module (func) (func (return_call 0)))`
|
||||
],
|
||||
['gc', wasmGcEnabled(), `(module (type (struct)))`],
|
||||
];
|
||||
|
||||
for (let [name, enabled, test] of releasedFeatures) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
let {checkNonNull} = wasmEvalText(`(module
|
||||
(func (export "checkNonNull") (param externref) (result (ref extern))
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
load(libdir + "wasm-binary.js");
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
// br_on_non_null from constant
|
||||
wasmValidateText(`(module
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
// br_on_null from constant
|
||||
wasmValidateText(`(module
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
let { plusOne } = wasmEvalText(`(module
|
||||
(; forward declaration so that ref.func works ;)
|
||||
|
@ -1 +1 @@
|
||||
|jit-test| test-also=--setpref=wasm_function_references=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js
|
||||
|jit-test| test-also=--setpref=wasm_gc=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: wasmGcEnabled()
|
||||
|
||||
const { CompileError, validate } = WebAssembly;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
// Generates combinations of different block types and operations for
|
||||
// non-defaultable locals (local.set / .tee / .get).
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
// non-null table initialization
|
||||
var { get1, get2, get3, get4 } = wasmEvalText(`(module
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
// non-null values are subtype of null values
|
||||
wasmValidateText(`(module
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| skip-if: !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| skip-if: !wasmGcEnabled()
|
||||
|
||||
// RefType/ValueType as a simple string
|
||||
const t01 = new WebAssembly.Table({element: 'funcref', initial: 3});
|
||||
|
@ -173,7 +173,7 @@ assertErrorMessage(() => wasmEvalText(`
|
||||
`),
|
||||
WebAssembly.CompileError, /expression has type \(ref null.*\) but expected \(ref null.*\)/);
|
||||
|
||||
if (!wasmFunctionReferencesEnabled()) {
|
||||
if (!wasmGcEnabled()) {
|
||||
// Ref type can't reference a function type
|
||||
|
||||
assertErrorMessage(() => wasmEvalText(`
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| --setpref=wasm_gc=true; --setpref=wasm_function_references=true; skip-if: !wasmGcEnabled() || !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() || !wasmGcEnabled()
|
||||
function wasmEvalText(str, imports) {
|
||||
let binary = wasmTextToBinary(str);
|
||||
m = new WebAssembly.Module(binary);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| --setpref=wasm_gc=true; --setpref=wasm_function_references=true; skip-if: !wasmSimdEnabled() || !wasmGcEnabled() || !wasmFunctionReferencesEnabled()
|
||||
// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmSimdEnabled() || !wasmGcEnabled() || !wasmGcEnabled()
|
||||
var wasm_code = new Uint8Array([0,97,115,109,1,0,0,0,1,152,128,128,128,0,4,80,0,95,1,126,0,80,0,94,124,1,80,0,96,3,127,127,127,1,127,96,0,0,3,130,128,128,128,0,1,2,4,133,128,128,128,0,1,112,1,1,1,5,132,128,128,128,0,1,1,16,32,13,131,128,128,128,0,1,0,3,6,204,131,128,128,0,62,100,107,0,66,197,129,131,134,140,152,176,224,64,251,0,0,11,127,0,65,196,129,131,134,124,11,100,107,0,66,192,129,131,134,204,132,137,146,36,251,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,100,107,0,66,192,129,131,134,140,216,53,251,0,0,11,100,107,1,66,210,164,201,146,165,202,148,169,210,0,66,210,164,201,146,165,202,212,156,218,0,66,192,129,131,134,140,152,176,224,64,66,192,129,131,134,140,152,176,224,64,126,125,66,192,129,131,128,130,152,176,224,64,125,66,192,129,131,190,130,152,176,224,36,125,66,164,200,0,125,125,66,0,125,66,0,125,66,0,125,251,0,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,7,136,128,128,128,0,1,4,109,97,105,110,0,0,9,139,128,128,128,0,1,6,0,65,0,11,112,1,210,0,11,10,141,133,128,128,0,1,138,5,0,65,238,235,177,226,126,253,15,253,83,32,0,65,235,146,246,155,122,65,244,231,246,248,124,253,15,253,164,1,65,230,152,157,154,7,253,15,253,164,1,118,65,167,184,218,133,127,253,15,253,164,1,118,118,66,149,131,127,66,164,128,218,132,206,227,209,231,254,0,65,230,133,189,200,126,65,252,208,237,164,5,254,32,0,132,245,241,222,13,27,254,71,2,211,226,246,158,7,66,243,213,226,237,209,166,141,199,0,68,76,189,205,180,194,110,195,89,36,3,131,253,18,253,127,253,127,253,127,253,127,253,164,1,65,138,173,198,47,65,138,248,237,203,120,65,205,162,146,252,5,65,190,148,192,156,5,254,53,0,200,229,139,195,9,65,167,139,216,173,5,65,215,146,221,45,254,53,0,169,255,135,252,1,254,53,0,193,209,131,217,7,40,2,134,242,184,197,3,65,228,191,145,146,6,65,142,162,226,169,4,254,53,0,168,178,151,189,15,113,109,71,109,107,254,46,0,191,232,145,230,9,67,66,84,34,11,67,88,147,220,200,91,68,233,240,20,66,52,37,190,38,182,187,182,187,182,187,182,187,182,187,57,3,168,169,148,198,10,65,226,162,208,167,7,65,221,226,226,242,120,107,65,140,215,139,233,5,65,141,151,153,19,107,107,65,188,134,175,165,5,65,183,219,200,136,121,107,65,250,197,157,214,123,65,139,168,173,167,126,107,107,107,42,1,249,156,171,169,13,187,182,187,182,187,182,187,182,187,182,65,191,253,243,170,122,253,15,65,203,195,202,169,122,253,15,65,179,204,244,234,123,253,15,253,119,65,166,184,138,186,122,253,15,65,129,140,243,163,6,253,15,253,119,65,229,139,254,233,121,253,15,65,183,191,195,183,122,253,15,253,119,253,119,65,151,211,231,151,122,253,15,253,119,253,119,253,119,65,192,156,192,215,3,65,178,193,209,198,7,107,65,240,157,246,199,6,65,221,225,148,169,1,107,65,145,183,142,141,127,65,188,218,139,244,7,107,107,65,236,243,250,169,127,65,146,241,174,181,120,107,65,139,147,232,229,124,65,255,203,253,217,3,107,107,65,250,197,224,140,2,65,202,242,215,181,3,107,65,135,244,246,28,65,140,170,229,200,123,107,107,107,65,154,217,196,153,1,65,137,128,243,231,123,107,107,107,107,65,227,146,143,180,126,40,1,245,130,139,196,13,40,2,244,172,225,238,10,40,0,216,160,178,215,11,40,1,197,193,230,178,3,40,2,195,241,223,254,2,65,158,240,247,204,124,40,2,140,190,218,180,14,40,2,215,128,167,146,8,40,0,141,143,157,196,10,40,0,147,146,185,143,13,40,1,195,168,134,179,5,107,107,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,253,15,253,119,253,31,0,91,254,46,0,203,243,148,239,8,11]);
|
||||
var wasm_module = new WebAssembly.Module(wasm_code);
|
||||
var wasm_instance = new WebAssembly.Instance(wasm_module);
|
||||
|
@ -1 +1 @@
|
||||
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_function_references=true; skip-if: !wasmFunctionReferencesEnabled()
|
||||
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_gc=true; skip-if: !wasmGcEnabled()
|
@ -1,4 +1,4 @@
|
||||
// |jit-test| --setpref=wasm_function_references=true; --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() || getBuildConfiguration("simulator")
|
||||
// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() || getBuildConfiguration("simulator")
|
||||
|
||||
// Tests GC references passed as arguments during return calls.
|
||||
// Similar to js/src/jit-test/tests/wasm/gc/trailers-gc-stress.js
|
||||
|
@ -973,7 +973,7 @@ struct BaseCompiler final {
|
||||
bool tailCall, CodeOffset* fastCallOffset,
|
||||
CodeOffset* slowCallOffset);
|
||||
CodeOffset callImport(unsigned instanceDataOffset, const FunctionCall& call);
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
void callRef(const Stk& calleeRef, const FunctionCall& call,
|
||||
CodeOffset* fastCallOffset, CodeOffset* slowCallOffset);
|
||||
# ifdef ENABLE_WASM_TAIL_CALLS
|
||||
@ -1641,7 +1641,7 @@ struct BaseCompiler final {
|
||||
[[nodiscard]] bool emitRefFunc();
|
||||
[[nodiscard]] bool emitRefNull();
|
||||
[[nodiscard]] bool emitRefIsNull();
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
[[nodiscard]] bool emitRefAsNonNull();
|
||||
[[nodiscard]] bool emitBrOnNull();
|
||||
[[nodiscard]] bool emitBrOnNonNull();
|
||||
|
@ -1658,7 +1658,7 @@ bool BaseCompiler::callIndirect(uint32_t funcTypeIndex, uint32_t tableIndex,
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
void BaseCompiler::callRef(const Stk& calleeRef, const FunctionCall& call,
|
||||
CodeOffset* fastCallOffset,
|
||||
CodeOffset* slowCallOffset) {
|
||||
@ -3875,7 +3875,7 @@ bool BaseCompiler::emitBrIf() {
|
||||
return emitBranchPerform(&b);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
bool BaseCompiler::emitBrOnNull() {
|
||||
MOZ_ASSERT(!hasLatentOp());
|
||||
|
||||
@ -5286,7 +5286,7 @@ bool BaseCompiler::emitReturnCallIndirect() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
bool BaseCompiler::emitCallRef() {
|
||||
const FuncType* funcType;
|
||||
Nothing unused_callee;
|
||||
@ -6289,7 +6289,7 @@ bool BaseCompiler::emitRefIsNull() {
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
bool BaseCompiler::emitRefAsNonNull() {
|
||||
Nothing nothing;
|
||||
if (!iter_.readRefAsNonNull(¬hing)) {
|
||||
@ -10045,16 +10045,15 @@ bool BaseCompiler::emitBody() {
|
||||
}
|
||||
CHECK_NEXT(emitReturnCallIndirect());
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
case uint16_t(Op::CallRef):
|
||||
if (!moduleEnv_.functionReferencesEnabled()) {
|
||||
if (!moduleEnv_.gcEnabled()) {
|
||||
return iter_.unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK_NEXT(emitCallRef());
|
||||
# ifdef ENABLE_WASM_TAIL_CALLS
|
||||
case uint16_t(Op::ReturnCallRef):
|
||||
if (!moduleEnv_.functionReferencesEnabled() ||
|
||||
!moduleEnv_.tailCallsEnabled()) {
|
||||
if (!moduleEnv_.gcEnabled() || !moduleEnv_.tailCallsEnabled()) {
|
||||
return iter_.unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK_NEXT(emitReturnCallRef());
|
||||
@ -10591,19 +10590,19 @@ bool BaseCompiler::emitBody() {
|
||||
case uint16_t(Op::MemorySize):
|
||||
CHECK_NEXT(emitMemorySize());
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
case uint16_t(Op::RefAsNonNull):
|
||||
if (!moduleEnv_.functionReferencesEnabled()) {
|
||||
if (!moduleEnv_.gcEnabled()) {
|
||||
return iter_.unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK_NEXT(emitRefAsNonNull());
|
||||
case uint16_t(Op::BrOnNull):
|
||||
if (!moduleEnv_.functionReferencesEnabled()) {
|
||||
if (!moduleEnv_.gcEnabled()) {
|
||||
return iter_.unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK_NEXT(emitBrOnNull());
|
||||
case uint16_t(Op::BrOnNonNull):
|
||||
if (!moduleEnv_.functionReferencesEnabled()) {
|
||||
if (!moduleEnv_.gcEnabled()) {
|
||||
return iter_.unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK_NEXT(emitBrOnNonNull());
|
||||
|
@ -718,8 +718,8 @@ inline bool Decoder::readPackedType(const TypeContext& types,
|
||||
}
|
||||
case uint8_t(TypeCode::Ref):
|
||||
case uint8_t(TypeCode::NullableRef): {
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
if (!features.functionReferences) {
|
||||
#ifdef ENABLE_WASM_GC
|
||||
if (!features.gc) {
|
||||
return fail("(ref T) types not enabled");
|
||||
}
|
||||
bool nullable = code == uint8_t(TypeCode::NullableRef);
|
||||
@ -819,8 +819,8 @@ inline bool Decoder::readHeapType(const TypeContext& types,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
if (features.functionReferences) {
|
||||
#ifdef ENABLE_WASM_GC
|
||||
if (features.gc) {
|
||||
int32_t x;
|
||||
if (!readVarS32(&x) || x < 0 || uint32_t(x) >= types.length()) {
|
||||
return fail("invalid heap type index");
|
||||
|
@ -900,7 +900,7 @@ class FunctionCompiler {
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
[[nodiscard]] bool brOnNull(uint32_t relativeDepth, const DefVector& values,
|
||||
const ResultType& type, MDefinition* condition) {
|
||||
if (inDeadCode()) {
|
||||
@ -963,7 +963,7 @@ class FunctionCompiler {
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#endif // ENABLE_WASM_GC
|
||||
|
||||
#ifdef ENABLE_WASM_GC
|
||||
MDefinition* refI31(MDefinition* input) {
|
||||
@ -2447,7 +2447,7 @@ class FunctionCompiler {
|
||||
return collectUnaryCallResult(builtin.retType, def);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
[[nodiscard]] bool callRef(const FuncType& funcType, MDefinition* ref,
|
||||
uint32_t lineOrBytecode,
|
||||
const CallCompileState& call, DefVector* results) {
|
||||
@ -2489,7 +2489,7 @@ class FunctionCompiler {
|
||||
|
||||
# endif // ENABLE_WASM_TAIL_CALLS
|
||||
|
||||
#endif // ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#endif // ENABLE_WASM_GC
|
||||
|
||||
/*********************************************** Control flow generation */
|
||||
|
||||
@ -5440,7 +5440,7 @@ static bool EmitReturnCallIndirect(FunctionCompiler& f) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_WASM_TAIL_CALLS) && defined(ENABLE_WASM_FUNCTION_REFERENCES)
|
||||
#if defined(ENABLE_WASM_TAIL_CALLS) && defined(ENABLE_WASM_GC)
|
||||
static bool EmitReturnCallRef(FunctionCompiler& f) {
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
||||
@ -7157,7 +7157,7 @@ static bool EmitStoreLaneSimd128(FunctionCompiler& f, uint32_t laneSize) {
|
||||
|
||||
#endif // ENABLE_WASM_SIMD
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
static bool EmitRefAsNonNull(FunctionCompiler& f) {
|
||||
MDefinition* ref;
|
||||
if (!f.iter().readRefAsNonNull(&ref)) {
|
||||
@ -7220,7 +7220,7 @@ static bool EmitCallRef(FunctionCompiler& f) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#endif // ENABLE_WASM_GC
|
||||
|
||||
#ifdef ENABLE_WASM_GC
|
||||
|
||||
@ -8472,36 +8472,35 @@ static bool EmitBodyExprs(FunctionCompiler& f) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
case uint16_t(Op::RefAsNonNull):
|
||||
if (!f.moduleEnv().functionReferencesEnabled()) {
|
||||
if (!f.moduleEnv().gcEnabled()) {
|
||||
return f.iter().unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK(EmitRefAsNonNull(f));
|
||||
case uint16_t(Op::BrOnNull): {
|
||||
if (!f.moduleEnv().functionReferencesEnabled()) {
|
||||
if (!f.moduleEnv().gcEnabled()) {
|
||||
return f.iter().unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK(EmitBrOnNull(f));
|
||||
}
|
||||
case uint16_t(Op::BrOnNonNull): {
|
||||
if (!f.moduleEnv().functionReferencesEnabled()) {
|
||||
if (!f.moduleEnv().gcEnabled()) {
|
||||
return f.iter().unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK(EmitBrOnNonNull(f));
|
||||
}
|
||||
case uint16_t(Op::CallRef): {
|
||||
if (!f.moduleEnv().functionReferencesEnabled()) {
|
||||
if (!f.moduleEnv().gcEnabled()) {
|
||||
return f.iter().unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK(EmitCallRef(f));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_WASM_TAIL_CALLS) && defined(ENABLE_WASM_FUNCTION_REFERENCES)
|
||||
#if defined(ENABLE_WASM_TAIL_CALLS) && defined(ENABLE_WASM_GC)
|
||||
case uint16_t(Op::ReturnCallRef): {
|
||||
if (!f.moduleEnv().functionReferencesEnabled() ||
|
||||
!f.moduleEnv().tailCallsEnabled()) {
|
||||
if (!f.moduleEnv().gcEnabled() || !f.moduleEnv().tailCallsEnabled()) {
|
||||
return f.iter().unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK(EmitReturnCallRef(f));
|
||||
|
@ -25,14 +25,14 @@ using namespace js::jit;
|
||||
using namespace js::wasm;
|
||||
|
||||
#ifdef ENABLE_WASM_GC
|
||||
# ifndef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
# ifndef ENABLE_WASM_GC
|
||||
# error "GC types require the function-references feature"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
# ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
# ifdef ENABLE_WASM_GC
|
||||
# define WASM_FUNCTION_REFERENCES_OP(code) return code
|
||||
# else
|
||||
# define WASM_FUNCTION_REFERENCES_OP(code) break
|
||||
|
@ -165,7 +165,7 @@ enum class OpKind {
|
||||
ReturnCall,
|
||||
CallIndirect,
|
||||
ReturnCallIndirect,
|
||||
# ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
# ifdef ENABLE_WASM_GC
|
||||
CallRef,
|
||||
ReturnCallRef,
|
||||
# endif
|
||||
@ -534,7 +534,7 @@ class MOZ_STACK_CLASS OpIter : private Policy {
|
||||
|
||||
inline bool checkIsSubtypeOf(ResultType params, ResultType results);
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
inline bool checkIsSubtypeOf(uint32_t actualTypeIndex,
|
||||
uint32_t expectedTypeIndex);
|
||||
#endif
|
||||
@ -704,7 +704,7 @@ class MOZ_STACK_CLASS OpIter : private Policy {
|
||||
uint32_t* tableIndex, Value* callee,
|
||||
ValueVector* argValues);
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
[[nodiscard]] bool readCallRef(const FuncType** funcType, Value* callee,
|
||||
ValueVector* argValues);
|
||||
|
||||
@ -933,7 +933,7 @@ inline bool OpIter<Policy>::checkIsSubtypeOf(ResultType params,
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
template <typename Policy>
|
||||
inline bool OpIter<Policy>::checkIsSubtypeOf(uint32_t actualTypeIndex,
|
||||
uint32_t expectedTypeIndex) {
|
||||
@ -2396,10 +2396,10 @@ inline bool OpIter<Policy>::readRefFunc(uint32_t* funcIndex) {
|
||||
"function index is not declared in a section before the code section");
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
// When function references enabled, push type index on the stack, e.g. for
|
||||
// validation of the call_ref instruction.
|
||||
if (env_.functionReferencesEnabled()) {
|
||||
if (env_.gcEnabled()) {
|
||||
const uint32_t typeIndex = env_.funcs[*funcIndex].typeIndex;
|
||||
const TypeDef& typeDef = env_.types->type(typeIndex);
|
||||
return push(RefType::fromTypeDef(&typeDef, false));
|
||||
@ -2698,7 +2698,7 @@ inline bool OpIter<Policy>::readReturnCallIndirect(uint32_t* funcTypeIndex,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
template <typename Policy>
|
||||
inline bool OpIter<Policy>::readCallRef(const FuncType** funcType,
|
||||
Value* callee, ValueVector* argValues) {
|
||||
@ -2724,7 +2724,7 @@ inline bool OpIter<Policy>::readCallRef(const FuncType** funcType,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_WASM_TAIL_CALLS) && defined(ENABLE_WASM_FUNCTION_REFERENCES)
|
||||
#if defined(ENABLE_WASM_TAIL_CALLS) && defined(ENABLE_WASM_GC)
|
||||
template <typename Policy>
|
||||
inline bool OpIter<Policy>::readReturnCallRef(const FuncType** funcType,
|
||||
Value* callee,
|
||||
|
@ -479,7 +479,7 @@ class StorageTypeTraits {
|
||||
case TypeCode::NullExternRef:
|
||||
case TypeCode::NullAnyRef:
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
case AbstractTypeRefCode:
|
||||
#endif
|
||||
return true;
|
||||
@ -557,7 +557,7 @@ class ValTypeTraits {
|
||||
case TypeCode::NullExternRef:
|
||||
case TypeCode::NullAnyRef:
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
case AbstractTypeRefCode:
|
||||
#endif
|
||||
return true;
|
||||
|
@ -235,9 +235,9 @@ static bool DecodeFunctionBodyExprs(const ModuleEnvironment& env,
|
||||
&unusedArgs));
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
case uint16_t(Op::CallRef): {
|
||||
if (!env.functionReferencesEnabled()) {
|
||||
if (!env.gcEnabled()) {
|
||||
return iter.unrecognizedOpcode(&op);
|
||||
}
|
||||
const FuncType* unusedType;
|
||||
@ -246,7 +246,7 @@ static bool DecodeFunctionBodyExprs(const ModuleEnvironment& env,
|
||||
}
|
||||
# ifdef ENABLE_WASM_TAIL_CALLS
|
||||
case uint16_t(Op::ReturnCallRef): {
|
||||
if (!env.functionReferencesEnabled() || !env.tailCallsEnabled()) {
|
||||
if (!env.gcEnabled() || !env.tailCallsEnabled()) {
|
||||
return iter.unrecognizedOpcode(&op);
|
||||
}
|
||||
const FuncType* unusedType;
|
||||
@ -1240,15 +1240,15 @@ static bool DecodeFunctionBodyExprs(const ModuleEnvironment& env,
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
case uint16_t(Op::RefAsNonNull): {
|
||||
if (!env.functionReferencesEnabled()) {
|
||||
if (!env.gcEnabled()) {
|
||||
return iter.unrecognizedOpcode(&op);
|
||||
}
|
||||
CHECK(iter.readRefAsNonNull(¬hing));
|
||||
}
|
||||
case uint16_t(Op::BrOnNull): {
|
||||
if (!env.functionReferencesEnabled()) {
|
||||
if (!env.gcEnabled()) {
|
||||
return iter.unrecognizedOpcode(&op);
|
||||
}
|
||||
uint32_t unusedDepth;
|
||||
@ -1256,7 +1256,7 @@ static bool DecodeFunctionBodyExprs(const ModuleEnvironment& env,
|
||||
iter.readBrOnNull(&unusedDepth, &unusedType, ¬hings, ¬hing));
|
||||
}
|
||||
case uint16_t(Op::BrOnNonNull): {
|
||||
if (!env.functionReferencesEnabled()) {
|
||||
if (!env.gcEnabled()) {
|
||||
return iter.unrecognizedOpcode(&op);
|
||||
}
|
||||
uint32_t unusedDepth;
|
||||
|
@ -642,7 +642,7 @@ bool wasm::ToWebAssemblyValue(JSContext* cx, HandleValue val, ValType type,
|
||||
case ValType::V128:
|
||||
break;
|
||||
case ValType::Ref:
|
||||
#ifdef ENABLE_WASM_FUNCTION_REFERENCES
|
||||
#ifdef ENABLE_WASM_GC
|
||||
if (!type.isNullable() && val.isNull()) {
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
|
||||
JSMSG_WASM_BAD_REF_NONNULLABLE_VALUE);
|
||||
|
@ -7707,16 +7707,6 @@
|
||||
mirror: always
|
||||
set_spidermonkey_pref: startup
|
||||
|
||||
- name: javascript.options.wasm_function_references
|
||||
type: bool
|
||||
#if defined(ENABLE_WASM_FUNCTION_REFERENCES)
|
||||
value: true
|
||||
#else
|
||||
value: false
|
||||
#endif
|
||||
mirror: always
|
||||
set_spidermonkey_pref: startup
|
||||
|
||||
- name: javascript.options.wasm_gc
|
||||
type: bool
|
||||
#if defined(ENABLE_WASM_GC)
|
||||
|
Loading…
x
Reference in New Issue
Block a user