-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
src: migrated to new V8 ArrayBuffer API #30782
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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So… This looks correct and I currently don’t have any better ideas either, but maybe to give an idea about the “big picture” here: The idea behind It might be nice if we had a way to avoid free callbacks that only run Or, alternatively, it would be nice if we could implement (To be clear, this isn’t a request to change the code here. It’s just me rambling and trying to give some context.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll think of something and prepare a PR for this. |
||
} | ||
|
||
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.
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::Free
calls 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. 👍