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 c900bc1

Browse filesBrowse files
kvakildanielleadams
authored andcommitted
deps: cherry-pick 00704f5a from V8 upstream
Original commit message: Add more efficient API for accesssing ArrayBuffer raw data Raw data access is already possible via GetBackingStore()->GetData(). This API exposes a more efficient way for accessing JSArrayBuffer::backing_store (which, despite the confusing name, is no the BackingStore but its raw data pointer). Bug: v8:10343 Change-Id: I695cea91e2c3de75ce6c86bac6e413ce6617958b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3764341 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/main@{#81745} Refs: v8/v8@00704f5 Refs: #32226 PR-URL: #43921 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com>
1 parent 373523b commit c900bc1
Copy full SHA for c900bc1

File tree

Expand file treeCollapse file tree

4 files changed

+27
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+27
-2
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.9',
39+
'v8_embedder_string': '-node.10',
4040

4141
##### V8 defaults for Node.js #####
4242

Collapse file

‎deps/v8/include/v8-array-buffer.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8-array-buffer.h
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ class V8_EXPORT ArrayBuffer : public Object {
256256
*/
257257
std::shared_ptr<BackingStore> GetBackingStore();
258258

259+
/**
260+
* More efficient shortcut for GetBackingStore()->Data(). The returned pointer
261+
* is valid as long as the ArrayBuffer is alive.
262+
*/
263+
void* Data() const;
264+
259265
V8_INLINE static ArrayBuffer* Cast(Value* value) {
260266
#ifdef V8_ENABLE_CHECKS
261267
CheckCast(value);
@@ -414,6 +420,12 @@ class V8_EXPORT SharedArrayBuffer : public Object {
414420
*/
415421
std::shared_ptr<BackingStore> GetBackingStore();
416422

423+
/**
424+
* More efficient shortcut for GetBackingStore()->Data(). The returned pointer
425+
* is valid as long as the ArrayBuffer is alive.
426+
*/
427+
void* Data() const;
428+
417429
V8_INLINE static SharedArrayBuffer* Cast(Value* value) {
418430
#ifdef V8_ENABLE_CHECKS
419431
CheckCast(value);
Collapse file

‎deps/v8/src/api/api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/api/api.cc
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,6 +4038,11 @@ std::shared_ptr<v8::BackingStore> v8::ArrayBuffer::GetBackingStore() {
40384038
return std::static_pointer_cast<v8::BackingStore>(bs_base);
40394039
}
40404040

4041+
void* v8::ArrayBuffer::Data() const {
4042+
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
4043+
return self->backing_store();
4044+
}
4045+
40414046
std::shared_ptr<v8::BackingStore> v8::SharedArrayBuffer::GetBackingStore() {
40424047
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
40434048
std::shared_ptr<i::BackingStore> backing_store = self->GetBackingStore();
@@ -4048,6 +4053,11 @@ std::shared_ptr<v8::BackingStore> v8::SharedArrayBuffer::GetBackingStore() {
40484053
return std::static_pointer_cast<v8::BackingStore>(bs_base);
40494054
}
40504055

4056+
void* v8::SharedArrayBuffer::Data() const {
4057+
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
4058+
return self->backing_store();
4059+
}
4060+
40514061
void v8::ArrayBuffer::CheckCast(Value* that) {
40524062
i::Handle<i::Object> obj = Utils::OpenHandle(that);
40534063
Utils::ApiCheck(
Collapse file

‎deps/v8/test/cctest/test-api-array-buffer.cc‎

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-api-array-buffer.cc
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ THREADED_TEST(SkipArrayBufferBackingStoreDuringGC) {
366366

367367
// Should not move the pointer
368368
CHECK_EQ(ab->GetBackingStore()->Data(), store_ptr);
369+
CHECK_EQ(ab->Data(), store_ptr);
369370

370371
CcTest::array_buffer_allocator()->Free(buffer, 100);
371372
}
@@ -394,8 +395,8 @@ THREADED_TEST(SkipArrayBufferDuringScavenge) {
394395
CcTest::CollectGarbage(i::NEW_SPACE); // in survivor space now
395396
CcTest::CollectGarbage(i::NEW_SPACE); // in old gen now
396397

397-
// Use `ab` to silence compiler warning
398398
CHECK_EQ(ab->GetBackingStore()->Data(), store_ptr);
399+
CHECK_EQ(ab->Data(), store_ptr);
399400
}
400401

401402
THREADED_TEST(Regress1006600) {
@@ -418,6 +419,7 @@ THREADED_TEST(ArrayBuffer_NewBackingStore) {
418419
CHECK(!backing_store->IsShared());
419420
Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, backing_store);
420421
CHECK_EQ(backing_store.get(), ab->GetBackingStore().get());
422+
CHECK_EQ(backing_store->Data(), ab->Data());
421423
}
422424

423425
THREADED_TEST(SharedArrayBuffer_NewBackingStore) {
@@ -430,6 +432,7 @@ THREADED_TEST(SharedArrayBuffer_NewBackingStore) {
430432
Local<v8::SharedArrayBuffer> ab =
431433
v8::SharedArrayBuffer::New(isolate, backing_store);
432434
CHECK_EQ(backing_store.get(), ab->GetBackingStore().get());
435+
CHECK_EQ(backing_store->Data(), ab->Data());
433436
}
434437

435438
static void* backing_store_custom_data = nullptr;

0 commit comments

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