Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/mono/browser/runtime/jiterpreter-opcodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export const enum WasmSimdOpcode {
v128_const = 0x0c,
i8x16_shuffle = 0x0d,
i8x16_swizzle = 0x0e,
i8x16_relaxed_swizzle = 0x100,
i8x16_splat = 0x0f,
i16x8_splat = 0x10,
i32x4_splat = 0x11,
Expand Down Expand Up @@ -466,6 +467,8 @@ export const enum WasmSimdOpcode {
f64x2_pmax = 0xf7,
i32x4_trunc_sat_f32x4_s = 0xf8,
i32x4_trunc_sat_f32x4_u = 0xf9,
i32x4_relaxed_trunc_f32x4_s = 0x101,
i32x4_relaxed_trunc_f32x4_u = 0x102,
f32x4_convert_i32x4_s = 0xfa,
f32x4_convert_i32x4_u = 0xfb,
v128_load32_zero = 0x5c,
Expand All @@ -483,6 +486,7 @@ export const enum WasmSimdOpcode {
i64x2_extmul_low_i32x4_u = 0xde,
i64x2_extmul_high_i32x4_u = 0xdf,
i16x8_q15mulr_sat_s = 0x82,
i16x8_relaxed_q15mulr_sat_s = 0x111,
v128_any_true = 0x53,
v128_load8_lane = 0x54,
v128_load16_lane = 0x55,
Expand All @@ -503,13 +507,30 @@ export const enum WasmSimdOpcode {
f64x2_convert_low_i32x4_u = 0xff,
i32x4_trunc_sat_f64x2_s_zero = 0xfc,
i32x4_trunc_sat_f64x2_u_zero = 0xfd,
i32x4_relaxed_trunc_f64_s_zero = 0x103,
i32x4_relaxed_trunc_f64_u_zero = 0x104,
f32x4_demote_f64x2_zero = 0x5e,
f64x2_promote_low_f32x4 = 0x5f,
i8x16_popcnt = 0x62,
i16x8_extadd_pairwise_i8x16_s = 0x7c,
i16x8_extadd_pairwise_i8x16_u = 0x7d,
i32x4_extadd_pairwise_i16x8_s = 0x7e,
i32x4_extadd_pairwise_i16x8_u = 0x7f,
f32x4_relaxed_madd = 0x105,
f32x4_relaxed_mnadd = 0x106,
f64x2_relaxed_madd = 0x107,
f64x2_relaxed_mnadd = 0x108,
i8x16_relaxed_lane_select = 0x109,
i16x8_relaxed_lane_select = 0x10a,
i32x4_relaxed_lane_select = 0x10b,
i64x2_relaxed_lane_select = 0x10c,
f32x4_relaxed_min = 0x10d,
f32x4_relaxed_max = 0x10e,
f64x2_relaxed_min = 0x10f,
f64x2_relaxed_max = 0x110,
i16x8_relaxed_dot_i8x16_i7x16_s = 0x112,
i16x8_relaxed_dot_i8x16_i7x16_u = 0x113,
i32x4_relaxed_dot_i8x16_i7x16_s = 0x114,
}

export const enum WasmAtomicOpcode {
Expand Down
6 changes: 5 additions & 1 deletion src/mono/browser/runtime/jiterpreter-trace-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3919,7 +3919,11 @@ function emit_shuffle (builder: WasmBuilder, ip: MintOpcodePtr, elementCount: nu
for (let j = 0; j < elementSize; j++)
builder.appendU8(i);
}
builder.appendSimd(WasmSimdOpcode.i8x16_swizzle);
if (runtimeHelpers.featureWasmRelaxedSimd) {
builder.appendSimd(WasmSimdOpcode.i8x16_relaxed_swizzle);
} else {
builder.appendSimd(WasmSimdOpcode.i8x16_swizzle);
}
// multiply indices by 2 or 4 to scale from elt indices to byte indices
builder.i32_const(elementCount === 4 ? 2 : 1);
builder.appendSimd(WasmSimdOpcode.i8x16_shl);
Expand Down
3 changes: 2 additions & 1 deletion src/mono/browser/runtime/loader/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="../types/sidecar.d.ts" />

import { exceptions, simd } from "wasm-feature-detect";
import { exceptions, simd, relaxedSimd } from "wasm-feature-detect";

import gitHash from "consts:gitHash";

Expand Down Expand Up @@ -133,6 +133,7 @@ export function setLoaderGlobals (
// from wasm-feature-detect npm package
exceptions,
simd,
relaxedSimd
};
Object.assign(runtimeHelpers, rh);
Object.assign(loaderHelpers, lh);
Expand Down
8 changes: 6 additions & 2 deletions src/mono/browser/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,12 @@ async function instantiate_wasm_module (
}

async function ensureUsedWasmFeatures () {
runtimeHelpers.featureWasmSimd = await loaderHelpers.simd();
runtimeHelpers.featureWasmEh = await loaderHelpers.exceptions();
const simd = loaderHelpers.simd();
const relaxedSimd = loaderHelpers.relaxedSimd();
const exceptions = loaderHelpers.exceptions();
runtimeHelpers.featureWasmSimd = await simd;
runtimeHelpers.featureWasmRelaxedSimd = await relaxedSimd;
runtimeHelpers.featureWasmEh = await exceptions;
if (runtimeHelpers.emscriptenBuildOptions.wasmEnableSIMD) {
mono_assert(runtimeHelpers.featureWasmSimd, "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
}
Expand Down
2 changes: 2 additions & 0 deletions src/mono/browser/runtime/types/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export type LoaderHelpers = {
// from wasm-feature-detect npm package
exceptions: () => Promise<boolean>,
simd: () => Promise<boolean>,
relaxedSimd: () => Promise<boolean>,
}
export type RuntimeHelpers = {
emscriptenBuildOptions: EmscriptenBuildOptions,
Expand Down Expand Up @@ -232,6 +233,7 @@ export type RuntimeHelpers = {

featureWasmEh: boolean,
featureWasmSimd: boolean,
featureWasmRelaxedSimd: boolean,

//core
stringify_as_error_with_stack?: (error: any) => string,
Expand Down
Loading