The new API is present in V8 7.9, so we can already migrate to it:
| /** |
| * Create a new ArrayBuffer with an existing backing store. |
| * The created array keeps a reference to the backing store until the array |
| * is garbage collected. Note that the IsExternal bit does not affect this |
| * reference from the array to the backing store. |
| * |
| * In future IsExternal bit will be removed. Until then the bit is set as |
| * follows. If the backing store does not own the underlying buffer, then |
| * the array is created in externalized state. Otherwise, the array is created |
| * in internalized state. In the latter case the array can be transitioned |
| * to the externalized state using Externalize(backing_store). |
| */ |
| static Local<ArrayBuffer> New(Isolate* isolate, |
| std::shared_ptr<BackingStore> backing_store); |
| |
| /** |
| * Returns a new standalone BackingStore that is allocated using the array |
| * buffer allocator of the isolate. The result can be later passed to |
| * ArrayBuffer::New. |
| * |
| * If the allocator returns nullptr, then the function may cause GCs in the |
| * given isolate and re-try the allocation. If GCs do not help, then the |
| * function will crash with an out-of-memory error. |
| */ |
| static std::unique_ptr<BackingStore> NewBackingStore(Isolate* isolate, |
| size_t byte_length); |
| /** |
| * Returns a new standalone BackingStore that takes over the ownership of |
| * the given buffer. The destructor of the BackingStore invokes the given |
| * deleter callback. |
| * |
| * The result can be later passed to ArrayBuffer::New. The raw pointer |
| * to the buffer must not be passed again to any V8 API function. |
| */ |
| static std::unique_ptr<BackingStore> NewBackingStore( |
| void* data, size_t byte_length, BackingStoreDeleterCallback deleter, |
| void* deleter_data); |
There is an upstream issue to gather feedback: v8:9908.
The new API is present in V8 7.9, so we can already migrate to it:
node/deps/v8/include/v8.h
Lines 5007 to 5043 in b551c65
There is an upstream issue to gather feedback: v8:9908.