Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 120ac74

Browse filesBrowse files
legendecasRafaelGSS
authored andcommitted
src: remove aliased buffer weak callback
An AliasedBuffer can be nested in a BaseObject and their weak callbacks invoke order are not guaranteed. Prevent aliased buffer from being accessed in its weak callback as its validness can be checked with the emptiness of the persistent handle. PR-URL: #47688 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent de4f14c commit 120ac74
Copy full SHA for 120ac74

File tree

Expand file treeCollapse file tree

2 files changed

+3
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-15
lines changed
Open diff view settings
Collapse file

‎src/aliased_buffer-inl.h‎

Copy file name to clipboardExpand all lines: src/aliased_buffer-inl.h
+3-12Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ AliasedBufferBase<NativeT, V8T>::AliasedBufferBase(
7070
count_(that.count_),
7171
byte_offset_(that.byte_offset_),
7272
buffer_(that.buffer_) {
73-
DCHECK(is_valid());
7473
js_array_ = v8::Global<V8T>(that.isolate_, that.GetJSArray());
74+
DCHECK(is_valid());
7575
}
7676

7777
template <typename NativeT, typename V8T>
@@ -126,19 +126,10 @@ void AliasedBufferBase<NativeT, V8T>::Release() {
126126
js_array_.Reset();
127127
}
128128

129-
template <typename NativeT, typename V8T>
130-
inline void AliasedBufferBase<NativeT, V8T>::WeakCallback(
131-
const v8::WeakCallbackInfo<AliasedBufferBase<NativeT, V8T>>& data) {
132-
AliasedBufferBase<NativeT, V8T>* buffer = data.GetParameter();
133-
DCHECK(buffer->is_valid());
134-
buffer->cleared_ = true;
135-
buffer->js_array_.Reset();
136-
}
137-
138129
template <typename NativeT, typename V8T>
139130
inline void AliasedBufferBase<NativeT, V8T>::MakeWeak() {
140131
DCHECK(is_valid());
141-
js_array_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter);
132+
js_array_.SetWeak();
142133
}
143134

144135
template <typename NativeT, typename V8T>
@@ -223,7 +214,7 @@ void AliasedBufferBase<NativeT, V8T>::reserve(size_t new_capacity) {
223214

224215
template <typename NativeT, typename V8T>
225216
inline bool AliasedBufferBase<NativeT, V8T>::is_valid() const {
226-
return index_ == nullptr && !cleared_;
217+
return index_ == nullptr && !js_array_.IsEmpty();
227218
}
228219

229220
template <typename NativeT, typename V8T>
Collapse file

‎src/aliased_buffer.h‎

Copy file name to clipboardExpand all lines: src/aliased_buffer.h
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,11 @@ class AliasedBufferBase : public MemoryRetainer {
173173

174174
private:
175175
inline bool is_valid() const;
176-
static inline void WeakCallback(
177-
const v8::WeakCallbackInfo<AliasedBufferBase<NativeT, V8T>>& data);
178176
v8::Isolate* isolate_ = nullptr;
179177
size_t count_ = 0;
180178
size_t byte_offset_ = 0;
181179
NativeT* buffer_ = nullptr;
182180
v8::Global<V8T> js_array_;
183-
bool cleared_ = false;
184181

185182
// Deserialize data
186183
const AliasedBufferIndex* index_ = nullptr;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.