Skip to content

Conversation

mrousavy
Copy link
Contributor

@mrousavy mrousavy commented Jul 14, 2025

Summary

Adds a new API to jsi::ArrayBuffer: getMutableBuffer() - which returns a std::shared_ptr<MutableBuffer> if it carries one (external buffer, held in InternalPropertyArrayBufferExternalFinalizer), or nullptr otherwise.

I needed this in Nitro to efficiently pass native buffers between JS and native, and back.

Before this API, I lost all native buffer information if it was passed native -> JS -> native again.

Test Plan

(haven't tested this yet, trying to figure out how you guys run tests in hermes)

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jul 14, 2025
@mrousavy
Copy link
Contributor Author

mrousavy commented Jul 14, 2025

sry for the messy commit history, I was testing in CI until I figured out how to build the test suite locally, lol

@mrousavy
Copy link
Contributor Author

@tmikov do we need an implementation for HermesABIRuntimeWrapper::getMutableBuffer(...)?

@erights
Copy link

erights commented Jul 14, 2025

Why not just implement the Immutable ArrayBuffers proposal?

@mrousavy
Copy link
Contributor Author

Why not just implement the Immutable ArrayBuffers proposal?

  1. This doesn't have anything to do with what I'm implementing. I implemented a native API to get a native buffer. You're talking about JS APIs.
  2. The linked proposal is not even yet final, and not implemented in V8 nor JSC.

@erights
Copy link

erights commented Jul 15, 2025

This doesn't have anything to do with what I'm implementing. I implemented a native API to get a native buffer. You're talking about JS APIs

Thanks for the clarification. I had not understood that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for ArrayBuffer::isMutableBuffer() and ArrayBuffer::getMutableBuffer()
3 participants