Skip to content

worker: use engine-provided deleter for SharedArrayBuffers - #25307

Closed
addaleax wants to merge 3 commits into
nodejs:masterfrom
addaleax:sab-deleter
Closed

worker: use engine-provided deleter for SharedArrayBuffers#25307
addaleax wants to merge 3 commits into
nodejs:masterfrom
addaleax:sab-deleter

Conversation

@addaleax

Copy link
Copy Markdown
Member

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

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).
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-botnodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 1, 2019
@addaleaxaddaleax added the worker Issues and PRs related to Worker support. label Jan 1, 2019
@devsnekdevsnek added experimental Issues and PRs related to experimental features. wasm Issues and PRs related to WebAssembly. labels Jan 1, 2019
@addaleax

Copy link
Copy Markdown
MemberAuthor

@addaleax

addaleax commented Jan 1, 2019

Copy link
Copy Markdown
MemberAuthor

Resume CI: https://ci.nodejs.org/job/node-test-pull-request/19907/ (:heavy_check_mark:)

@addaleaxaddaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 1, 2019
@addaleax

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
MemberAuthor

Fixed the extended test on Windows.

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

@addaleax

Copy link
Copy Markdown
MemberAuthor

Landed in 1f1a373

@addaleaxaddaleax closed this Jan 3, 2019
@addaleax
addaleax deleted the sab-deleter branch January 3, 2019 22:55
addaleax added a commit that referenced this pull request Jan 3, 2019
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
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 pushed a commit to refack/node that referenced this pull request Jan 14, 2019
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>
@BridgeARBridgeAR mentioned this pull request Jan 16, 2019
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Jan 16, 2019
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>
@MylesBorinsMylesBorins mentioned this pull request Jan 24, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.c++Issues and PRs that require attention from people who are familiar with C++.experimentalIssues and PRs related to experimental features.wasmIssues and PRs related to WebAssembly.workerIssues and PRs related to Worker support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@addaleax@nodejs-github-bot@jasnell@TimothyGu@devsnek