Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser][mt] Update memory views after growth, refactor string processing, fix SharedArrayBuffer detection #86664

Merged
merged 17 commits into from
May 28, 2023
Merged
Changes from 2 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
6 changes: 5 additions & 1 deletion src/mono/wasm/runtime/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ export class StringDecoder {
// When threading is enabled, TextDecoder does not accept a view of a
// SharedArrayBuffer, we must make a copy of the array first.
// See https://github.com/whatwg/encoding/issues/172
const subArray = typeof SharedArrayBuffer !== "undefined" && Module.HEAPU8.buffer instanceof SharedArrayBuffer

// BEWARE: In some cases, `instanceof SharedArrayBuffer` returns false even though buffer is an SAB.
// Patch adapted from https://github.com/emscripten-core/emscripten/pull/16994
// See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
const subArray = typeof SharedArrayBuffer !== "undefined" && Module.HEAPU8.buffer[Symbol.toStringTag] === "SharedArrayBuffer"
? Module.HEAPU8.slice(<any>start, <any>end)
: Module.HEAPU8.subarray(<any>start, <any>end);

Expand Down