зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1721686 - wasm: Add mozIntGemm() to WebAssembly namespace in privileged content. r=yury
Differential Revision: https://phabricator.services.mozilla.com/D120662
This commit is contained in:
Родитель
99aa145400
Коммит
2bb63b5075
|
@ -867,6 +867,34 @@ def wasm_relaxed_simd(value, wasm_simd):
|
|||
set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
|
||||
set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
|
||||
|
||||
# Support for WebAssembly intgemm private intrinsics
|
||||
# =====================================================
|
||||
|
||||
|
||||
@depends(milestone.is_nightly)
|
||||
def default_wasm_moz_intgemm(is_nightly):
|
||||
if is_nightly:
|
||||
return True
|
||||
|
||||
|
||||
option(
|
||||
"--enable-wasm-moz-intgemm",
|
||||
default=default_wasm_moz_intgemm,
|
||||
help="{Enable|Disable} WebAssembly intgemm private intrinsics",
|
||||
)
|
||||
|
||||
|
||||
@depends("--enable-wasm-moz-intgemm")
|
||||
def wasm_moz_intgemm(value):
|
||||
if not value:
|
||||
return
|
||||
|
||||
return True
|
||||
|
||||
|
||||
set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
|
||||
set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
|
||||
|
||||
# Support for WebAssembly Memory64.
|
||||
# ===========================
|
||||
|
||||
|
|
|
@ -82,6 +82,11 @@
|
|||
#else
|
||||
# define WASM_MEMORY64_ENABLED 0
|
||||
#endif
|
||||
#ifdef ENABLE_WASM_MOZ_INTGEMM
|
||||
# define WASM_MOZ_INTGEMM_ENABLED 1
|
||||
#else
|
||||
# define WASM_MOZ_INTGEMM_ENABLED 0
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#define JS_FOR_WASM_FEATURES(DEFAULT, EXPERIMENTAL) \
|
||||
|
@ -138,7 +143,16 @@
|
|||
/* flag predicate */ !IsFuzzingIon(cx) && \
|
||||
!IsFuzzingCranelift(cx), \
|
||||
/* shell flag */ "memory64", \
|
||||
/* preference name */ "memory64")
|
||||
/* preference name */ "memory64") \
|
||||
EXPERIMENTAL(/* capitalized name */ MozIntGemm, \
|
||||
/* lower case name */ mozIntGemm, \
|
||||
/* compile predicate */ WASM_MOZ_INTGEMM_ENABLED, \
|
||||
/* compiler predicate */ BaselineAvailable(cx) || \
|
||||
IonAvailable(cx), \
|
||||
/* flag predicate */ IsSimdPrivilegedContext(cx) && \
|
||||
!IsFuzzingCranelift(cx), \
|
||||
/* shell flag */ "moz-intgemm", \
|
||||
/* preference name */ "moz_intgemm")
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "wasm/WasmCompile.h"
|
||||
#include "wasm/WasmCraneliftCompile.h"
|
||||
#include "wasm/WasmInstance.h"
|
||||
#include "wasm/WasmIntrinsic.h"
|
||||
#include "wasm/WasmIonCompile.h"
|
||||
#include "wasm/WasmModule.h"
|
||||
#include "wasm/WasmProcess.h"
|
||||
|
@ -343,14 +344,12 @@ bool wasm::AnyCompilerAvailable(JSContext* cx) {
|
|||
JS_FOR_WASM_FEATURES(WASM_FEATURE, WASM_FEATURE)
|
||||
#undef WASM_FEATURE
|
||||
|
||||
#ifdef ENABLE_WASM_SIMD_WORMHOLE
|
||||
static bool IsSimdPrivilegedContext(JSContext* cx) {
|
||||
bool wasm::IsSimdPrivilegedContext(JSContext* cx) {
|
||||
// This may be slightly more lenient than we want in an ideal world, but it
|
||||
// remains safe.
|
||||
return cx->realm() && cx->realm()->principals() &&
|
||||
cx->realm()->principals()->isSystemOrAddonPrincipal();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool wasm::SimdWormholeAvailable(JSContext* cx) {
|
||||
#ifdef ENABLE_WASM_SIMD_WORMHOLE
|
||||
|
@ -4988,6 +4987,27 @@ static bool WebAssembly_instantiateStreaming(JSContext* cx, unsigned argc,
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_MOZ_INTGEMM
|
||||
|
||||
static bool WebAssembly_mozIntGemm(JSContext* cx, unsigned argc, Value* vp) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
RootedWasmModuleObject module(cx);
|
||||
if (!wasm::CompileIntrinsicModule(cx, mozilla::Span<IntrinsicOp>(),
|
||||
Shareable::True, &module)) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
args.rval().set(ObjectValue(*module.get()));
|
||||
return true;
|
||||
}
|
||||
|
||||
static const JSFunctionSpec WebAssembly_mozIntGemm_methods[] = {
|
||||
JS_FN("mozIntGemm", WebAssembly_mozIntGemm, 0, JSPROP_ENUMERATE),
|
||||
JS_FS_END};
|
||||
|
||||
#endif // ENABLE_WASM_MOZ_INTGEMM
|
||||
|
||||
static const JSFunctionSpec WebAssembly_static_methods[] = {
|
||||
JS_FN(js_toSource_str, WebAssembly_toSource, 0, 0),
|
||||
JS_FN("compile", WebAssembly_compile, 1, JSPROP_ENUMERATE),
|
||||
|
@ -5058,6 +5078,13 @@ static bool WebAssemblyClassFinish(JSContext* cx, HandleObject object,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WASM_MOZ_INTGEMM
|
||||
if (MozIntGemmAvailable(cx) &&
|
||||
!JS_DefineFunctions(cx, wasm, WebAssembly_mozIntGemm_methods)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,6 +152,9 @@ bool ThreadsAvailable(JSContext* cx);
|
|||
JS_FOR_WASM_FEATURES(WASM_FEATURE, WASM_FEATURE)
|
||||
#undef WASM_FEATURE
|
||||
|
||||
// Privileged content that can access experimental intrinsics
|
||||
bool IsSimdPrivilegedContext(JSContext* cx);
|
||||
|
||||
// Very experimental SIMD operations.
|
||||
bool SimdWormholeAvailable(JSContext* cx);
|
||||
|
||||
|
|
|
@ -6009,6 +6009,13 @@
|
|||
mirror: always
|
||||
#endif // defined(ENABLE_WASM_RELAXED_SIMD)
|
||||
|
||||
#if defined(ENABLE_WASM_MOZ_INTGEMM)
|
||||
- name: javascript.options.wasm_moz_intgemm
|
||||
type: bool
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
mirror: always
|
||||
#endif // defined(ENABLE_WASM_MOZ_INTGEMM)
|
||||
|
||||
#if defined(ENABLE_WASM_EXTENDED_CONST)
|
||||
- name: javascript.options.wasm_extended_const
|
||||
type: bool
|
||||
|
|
Загрузка…
Ссылка в новой задаче