Skip to content

Commit 0333ed0

Browse files
authored
Assume all HEAPXX variables are SAB. NFC (#25690)
Also add a comment to clarify why the use of SHRINK_LEVEL here does not change semantics, only perf. This should decrease codesize of multi-threaded version of UTF16ToString which includes the line: `getUnsharedTextDecoderView('HEAPU16', 'idx', 'endIdx') }}})`
1 parent d02668a commit 0333ed0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/parseTools.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,9 +1043,10 @@ function getUnsharedTextDecoderView(heap, start, end) {
10431043
// No need to worry about this in non-shared memory builds
10441044
if (!SHARED_MEMORY) return unshared;
10451045

1046-
// If asked to get an unshared view to what we know will be a shared view, or if in -Oz,
1047-
// then unconditionally do a .slice() for smallest code size.
1048-
if (SHRINK_LEVEL == 2 || heap == 'HEAPU8') return shared;
1046+
// If asked to get an unshared view to what we know will be a shared view, or
1047+
// if in -Oz, then unconditionally do a .slice() for smallest code size.
1048+
// This is guaranteed to work but could be slower since it performs a copy.
1049+
if (SHRINK_LEVEL == 2 || heap.startsWith('HEAP')) return shared;
10491050

10501051
// Otherwise, generate a runtime type check: must do a .slice() if looking at
10511052
// a SAB, or can use .subarray() otherwise. Note: We compare with

0 commit comments

Comments
 (0)