Skip to content

Add tryGetMutableBuffer API (#55943)#55943

Closed
tsaichien wants to merge 3 commits intomainfrom
export-D91264901
Closed

Add tryGetMutableBuffer API (#55943)#55943
tsaichien wants to merge 3 commits intomainfrom
export-D91264901

Conversation

@tsaichien
Copy link
Copy Markdown
Contributor

@tsaichien tsaichien commented Mar 5, 2026

Summary:

Adds ArrayBuffer::tryGetMutableBuffer to JSI. This allows the user to
retrieve a MutableBuffer from the ArrayBuffer. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the MutableBuffer will be alive during the entirety
of the MutableBuffer lifespan.

Addresses: facebook/hermes#1578

Reviewed By: tmikov

Differential Revision: D91264901

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 5, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Mar 5, 2026

@tsaichien has exported this pull request. If you are a Meta employee, you can view the originating Diff in D91264901.

@meta-codesync meta-codesync bot changed the title Add tryGetMutableBuffer API Add tryGetMutableBuffer API (#55943) Mar 16, 2026
meta-codesync bot pushed a commit that referenced this pull request Mar 16, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Reviewed By: tmikov

Differential Revision: D91264901
meta-codesync bot pushed a commit that referenced this pull request Mar 18, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Reviewed By: tmikov

Differential Revision: D91264901
meta-codesync bot pushed a commit that referenced this pull request Mar 18, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
meta-codesync bot pushed a commit that referenced this pull request Mar 18, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
meta-codesync bot pushed a commit that referenced this pull request Mar 18, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
meta-codesync bot pushed a commit that referenced this pull request Mar 18, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
meta-codesync bot pushed a commit that referenced this pull request Mar 19, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 19, 2026
Summary:

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 30, 2026
Summary:
Pull Request resolved: facebook#56156

Pull Request resolved: facebook#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
tsaichien added a commit to tsaichien/react-native that referenced this pull request Mar 31, 2026
Summary:
Pull Request resolved: facebook#56156

Pull Request resolved: facebook#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
tsaichien added a commit to tsaichien/react-native that referenced this pull request Apr 14, 2026
Summary:
Pull Request resolved: facebook#56156

Pull Request resolved: facebook#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
@meta-codesync meta-codesync bot force-pushed the export-D91264901 branch 3 times, most recently from c2b13d5 to 85f48b8 Compare April 14, 2026 21:10
tsaichien added a commit to tsaichien/react-native that referenced this pull request Apr 15, 2026
Summary:
Pull Request resolved: facebook#56156

Pull Request resolved: facebook#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
Summary:

After reviewing the feasibility of adding new Runtime functionality, we
realized the current state of `Runtime` makes it hard/inconvenient to
add new basic functionality. It requires creating a new interface (e.g.
`IRuntime2`) to declare the new APIs. Then, everywhere it is needed,
both the original `Runtime` and `IRuntime2` needs to passed in to access
both APIs.

After discussion, we decided to introduce `IRuntime`, which will declare
most of the `Runtime` functionalities. All "protected" APIs, which made
sense before interfaces were introduced, will now be public. The
protected static methods of `Runtime` will remain as is for the Friends
to access.

After we decided to cut "stable" (after incoming JSI improvements), new
functionalities will be added in `IRuntime2` interface. `IRuntime2` will
inherit `IRuntime` to make existing functionality easy to access.

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D89093651
Summary:

Currently, the size of a jsi `Array` is immutable. Once the `Array` is
created, users can only set the element at an existing index, but not
append to it.

This change adds an `Array::push` API to improve ergonomics.
The default implementation is also provided in `jsi::Runtime`

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D82254334
Summary:


Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer 
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook/hermes#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901
meta-codesync bot pushed a commit to facebook/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: #1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
meta-codesync bot pushed a commit to facebook/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: #1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
@meta-codesync meta-codesync bot closed this in 79843fc Apr 15, 2026
meta-codesync bot pushed a commit to facebook/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: #1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
@facebook-github-tools facebook-github-tools bot added the Merged This PR has been merged. label Apr 15, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 15, 2026

This pull request has been merged in 79843fc.

tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 15, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
tsaichien added a commit to tsaichien/hermes that referenced this pull request Apr 16, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: facebook#1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
tsaichien added a commit to facebook/hermes that referenced this pull request Apr 16, 2026
Summary:
X-link: facebook/react-native#56156

X-link: facebook/react-native#55943

Adds `ArrayBuffer::tryGetMutableBuffer` to JSI. This allows the user to
retrieve a `MutableBuffer` from the `ArrayBuffer`. The returned buffer
will point directly into the same buffer as the runtime object, rather than
copying it out.

The data referencedby the `MutableBuffer` will be alive during the entirety
 of the `MutableBuffer` lifespan.

Addresses: #1578

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D91264901

fbshipit-source-id: 7edd66adae16551b64222c834d3fc211f7c88622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants