-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
src: remove usages of GetBackingStore in crypto #44079
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 |
|---|---|---|
|
|
@@ -696,24 +696,30 @@ template <typename T> | |
| class ArrayBufferOrViewContents { | ||
| public: | ||
| ArrayBufferOrViewContents() = default; | ||
| ArrayBufferOrViewContents(const ArrayBufferOrViewContents&) = delete; | ||
| void operator=(const ArrayBufferOrViewContents&) = delete; | ||
|
|
||
| inline explicit ArrayBufferOrViewContents(v8::Local<v8::Value> buf) { | ||
| if (buf.IsEmpty()) { | ||
|
Member
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 understand why this exists, but it feels somewhat strange to explicitly allow passing in empty
Contributor
Author
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 agree. An alternative would be to allocate an empty Do you think that would be acceptable wrt to performance? (P.S. if your concern here is blocking, feel free to request changes on the PR.) |
||
| return; | ||
| } | ||
|
|
||
| CHECK(IsAnyByteSource(buf)); | ||
| if (buf->IsArrayBufferView()) { | ||
| auto view = buf.As<v8::ArrayBufferView>(); | ||
| offset_ = view->ByteOffset(); | ||
| length_ = view->ByteLength(); | ||
| store_ = view->Buffer()->GetBackingStore(); | ||
| data_ = view->Buffer()->Data(); | ||
| } else if (buf->IsArrayBuffer()) { | ||
| auto ab = buf.As<v8::ArrayBuffer>(); | ||
| offset_ = 0; | ||
| length_ = ab->ByteLength(); | ||
| store_ = ab->GetBackingStore(); | ||
| data_ = ab->Data(); | ||
| } else { | ||
| auto sab = buf.As<v8::SharedArrayBuffer>(); | ||
| offset_ = 0; | ||
| length_ = sab->ByteLength(); | ||
| store_ = sab->GetBackingStore(); | ||
| data_ = sab->Data(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -723,7 +729,7 @@ class ArrayBufferOrViewContents { | |
| // length is zero, so we have to return something. | ||
| if (size() == 0) | ||
| return &buf; | ||
| return reinterpret_cast<T*>(store_->Data()) + offset_; | ||
| return reinterpret_cast<T*>(data_) + offset_; | ||
| } | ||
|
|
||
| inline T* data() { | ||
|
|
@@ -732,7 +738,7 @@ class ArrayBufferOrViewContents { | |
| // length is zero, so we have to return something. | ||
| if (size() == 0) | ||
| return &buf; | ||
| return reinterpret_cast<T*>(store_->Data()) + offset_; | ||
| return reinterpret_cast<T*>(data_) + offset_; | ||
| } | ||
|
|
||
| inline size_t size() const { return length_; } | ||
|
|
@@ -772,7 +778,14 @@ class ArrayBufferOrViewContents { | |
| T buf = 0; | ||
| size_t offset_ = 0; | ||
| size_t length_ = 0; | ||
| std::shared_ptr<v8::BackingStore> store_; | ||
| void* data_ = nullptr; | ||
|
|
||
| // Declaring operator new and delete as deleted is not spec compliant. | ||
| // Therefore declare them private instead to disable dynamic alloc | ||
| void* operator new(size_t); | ||
| void* operator new[](size_t); | ||
| void operator delete(void*); | ||
| void operator delete[](void*); | ||
| }; | ||
|
|
||
| v8::MaybeLocal<v8::Value> EncodeBignum( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.