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

worker: use engine-provided deleter for `SharedArrayBuffer`s #25307

Closed
wants to merge 3 commits into from

Conversation

@addaleax
Copy link
Member

commented Jan 1, 2019

Thanks to @devsnek for reporting this and coming up with a test case!


Store the full information we have on a given SharedArrayBuffer,
and use the deleter provided by the JS engine to free the memory
when that is needed.

This fixes memory lifetime management for WASM buffers that are
passed through a MessageChannel (e.g. between threads).

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
worker: use engine-provided deleter for `SharedArrayBuffer`s
Store the full information we have on a given `SharedArrayBuffer`,
and use the deleter provided by the JS engine to free the memory
when that is needed.

This fixes memory lifetime management for WASM buffers that are
passed through a `MessageChannel` (e.g. between threads).

@addaleax addaleax added the worker label Jan 1, 2019

@devsnek
devsnek approved these changes Jan 1, 2019
@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2019

@jasnell
jasnell approved these changes Jan 1, 2019
@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2019

@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jan 2, 2019

Fwiw, I’ve extended the test a bit. (@devsnek I’ve also figured out that we can’t transfer WebAssembly.Modules yet the way we should – also working on that.)

New CI: https://ci.nodejs.org/job/node-test-pull-request/19915/

@addaleax addaleax referenced this pull request Jan 2, 2019
3 of 3 tasks complete
@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jan 3, 2019

Fixed the extended test on Windows.

New CI: https://ci.nodejs.org/job/node-test-pull-request/19918/

@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jan 3, 2019

Landed in 1f1a373

@addaleax addaleax closed this Jan 3, 2019

@addaleax addaleax deleted the addaleax:sab-deleter branch Jan 3, 2019

addaleax added a commit that referenced this pull request Jan 3, 2019
worker: use engine-provided deleter for `SharedArrayBuffer`s
Store the full information we have on a given `SharedArrayBuffer`,
and use the deleter provided by the JS engine to free the memory
when that is needed.

This fixes memory lifetime management for WASM buffers that are
passed through a `MessageChannel` (e.g. between threads).

PR-URL: #25307
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
addaleax added a commit that referenced this pull request Jan 5, 2019
worker: use engine-provided deleter for `SharedArrayBuffer`s
Store the full information we have on a given `SharedArrayBuffer`,
and use the deleter provided by the JS engine to free the memory
when that is needed.

This fixes memory lifetime management for WASM buffers that are
passed through a `MessageChannel` (e.g. between threads).

PR-URL: #25307
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
refack added a commit to refack/node that referenced this pull request Jan 14, 2019
worker: use engine-provided deleter for `SharedArrayBuffer`s
Store the full information we have on a given `SharedArrayBuffer`,
and use the deleter provided by the JS engine to free the memory
when that is needed.

This fixes memory lifetime management for WASM buffers that are
passed through a `MessageChannel` (e.g. between threads).

PR-URL: nodejs#25307
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
@BridgeAR BridgeAR referenced this pull request Jan 16, 2019
BridgeAR added a commit to BridgeAR/node that referenced this pull request Jan 16, 2019
worker: use engine-provided deleter for `SharedArrayBuffer`s
Store the full information we have on a given `SharedArrayBuffer`,
and use the deleter provided by the JS engine to free the memory
when that is needed.

This fixes memory lifetime management for WASM buffers that are
passed through a `MessageChannel` (e.g. between threads).

PR-URL: nodejs#25307
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
@MylesBorins MylesBorins referenced this pull request Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.