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

Neutering ArrayBuffer #541

Closed
maierfelix opened this issue Sep 15, 2019 · 9 comments
Closed

Neutering ArrayBuffer #541

maierfelix opened this issue Sep 15, 2019 · 9 comments
Labels

Comments

@maierfelix
Copy link

maierfelix commented Sep 15, 2019

In v8, I see a method to neuter/detach an ArrayBuffer. Is there a way to this in NAPI and also gets exposed here?

@mhdawson
Copy link
Member

I think today the answer is no. Is it part of the ES spec? We work to ensure that we avoid implementation-specific features which might not be available on all JavaScript runtimes?

If it is in the ES spec can you point us to the section in the spec?

@devsnek
Copy link
Member

devsnek commented Sep 16, 2019

Neuter is a super super super old (that link is to node 0.12) method that is now better known as Detach: https://cs.chromium.org/chromium/src/v8/include/v8.h?l=4867&rcl=7720ac9d21ceeaa24715da66d11c0437010fbdee https://tc39.es/ecma262/#sec-detacharraybuffer

I agree this is a useful thing to have.

@mhdawson
Copy link
Member

@devsnek same question then, is Detach part of the ES spec?

@devsnek
Copy link
Member

devsnek commented Sep 16, 2019

@mhdawson yeah, second link there is the operation to detach an arraybuffer in the es spec.

@mhdawson
Copy link
Member

@devsnek thanks for the pointers. One more question. I can understand "useful" but wondering about how widely used it might be. Do you think it would be widely used if available?

@devsnek
Copy link
Member

devsnek commented Sep 27, 2019

In the ecosystem the operation exists for two reasons: 1) postMessage detaches arraybuffers that you pass to it, and 2) wasm memory is detached when it is resized. I can't really extrapolate that to anything specific, but I'm sure there are other use cases.

@maierfelix do you have a use case?

@maierfelix
Copy link
Author

maierfelix commented Sep 27, 2019

I found this test in blink for webgpu buffer mapping. I work on a webgpu api for node and couldn't find a way to detach through napi, just by:

let array = new Int8Array(new ArrayBuffer(100));
window.postMessage(array, "*", [array.buffer]);

@github-actions
Copy link
Contributor

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@mhdawson
Copy link
Member

We now have IsDetached() and Detach() support in N-API 7 closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants