-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
src: migrated to new V8 ArrayBuffer API #30782
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -983,10 +983,20 @@ inline v8::MaybeLocal<v8::Object> AllocatedBuffer::ToBuffer() { | |
| inline v8::Local<v8::ArrayBuffer> AllocatedBuffer::ToArrayBuffer() { | ||
| CHECK_NOT_NULL(env_); | ||
| uv_buf_t buf = release(); | ||
| auto callback = [](void* data, size_t length, void* deleter_data){ | ||
| CHECK_NOT_NULL(deleter_data); | ||
|
|
||
| static_cast<v8::ArrayBuffer::Allocator*>(deleter_data) | ||
| ->Free(data, length); | ||
| }; | ||
| std::unique_ptr<v8::BackingStore> backing = | ||
| v8::ArrayBuffer::NewBackingStore(buf.base, | ||
| buf.len, | ||
| callback, | ||
| env_->isolate() | ||
| ->GetArrayBufferAllocator()); | ||
| return v8::ArrayBuffer::New(env_->isolate(), | ||
| buf.base, | ||
| buf.len, | ||
| v8::ArrayBufferCreationMode::kInternalized); | ||
| std::move(backing)); | ||
|
||
| } | ||
|
|
||
| inline void Environment::ThrowError(const char* errmsg) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s an issue with this that I didn’t realize during review, sorry … see https://bugs.chromium.org/p/v8/issues/detail?id=9908#c10 for details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@addaleax should i force-push here or open a new PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thangktran I think neither. I believe @addaleax already opened a PR to fix: #30946
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Trott i checked it just now and it's actually still there.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Trott This here is a V8 API issue, #30946 fixes a different bug in our code. So there is something we need to do.
I think the 3 options here are:
v8::ArrayBuffer::Allocator::Freecalls and go back to using the deprecated APIs, effectively blocking the upgrade to 8.0 or 8.1 (not sure which)std::shared_ptr<v8::ArrayBuffer::Allocator>that is also passed to V8 and then use a pointer to that instead of a rawv8::ArrayBuffer::Allocator*(I don’t like this one, it’s quite a bit of work and complexity with little gain)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@addaleax : Thank you for offering me help. I'm looking forward to it :D
What is your opinion about @ulan 's alternatives? :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thangktran Thanks for the ping! I’ve commented in the issue. Basically, I’m good with Ulan’s suggestion. 👍