Skip to content

Commit

Permalink
WebAssembly | Memory - homogenise descriptions, and add note about SAB (
Browse files Browse the repository at this point in the history
#27021)

* js interface/memory - modify buffer description

* memory/grow - add note about SAB regarding detachment

* Update files/en-us/webassembly/javascript_interface/memory/grow/index.md

Co-authored-by: Brian Thomas Smith <[email protected]>

* Update files/en-us/webassembly/javascript_interface/memory/grow/index.md

Co-authored-by: Brian Thomas Smith <[email protected]>

---------

Co-authored-by: Joshua Chen <[email protected]>
Co-authored-by: Brian Thomas Smith <[email protected]>
  • Loading branch information
3 people authored Jul 20, 2023
1 parent c77cfcd commit 546e79b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ console.log(currentMemoryView); // Uint8Array(131072) [ 0, 0, 0, ... ]
// 131072 = 64KiB * 2
```

For a shared `Memory` instance, the initial `buffer` (which would be a [`SharedArrayBuffer`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) in such case) will not become detached, but rather its length will not be updated. Accesses to the `buffer` property after growing will yield a larger `SharedArrayBuffer` which may access a larger span of memory than the buffer from before growing the `Memory`. Every `SharedArrayBuffer` from the `buffer` property will all refer to the start of the same memory address range, and thus manipulate the same data.

## Specifications

{{Specifications}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Both WebAssembly and JavaScript can create `Memory` objects. If you want to acce
## Instance properties

- [`Memory.prototype.buffer`](/en-US/docs/WebAssembly/JavaScript_interface/Memory/buffer) {{ReadOnlyInline}}
- : An accessor property that returns the buffer contained in the memory.
- : Returns the buffer contained in the memory.

## Instance methods

Expand Down

0 comments on commit 546e79b

Please sign in to comment.