[api] Configure embedder fields of ABs and AB views via gn

Allow configuring the number of embedder fields ArrayBuffer and
ArrayBufferView objects have. Blink doesn't need these extra fields
anymore and we can save some space and speed up GC processing. Retain
ability for embedders to use the fields though via gn arg.

Bug: 346350847
Change-Id: I48e56de316ae932a43012c0736fd36ea6e9c80ab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5621990
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#94377}
This commit is contained in:
Michael Lippautz authored and V8 LUCI CQ committed 2024-06-11 15:55:15 +00:00
1 parent d7b8e6d2c4
commit efa2db35b9
4 files changed
+27 -10

No files matched your search

+2
View File
@@ -28,6 +28,8 @@ load(":bazel/v8-non-pointer-compression.bzl", "v8_binary_non_pointer_compression
# v8_custom_deps
# v8_embed_script
# v8_embedder_string
# v8_array_buffer_internal_field_count
# v8_array_buffer_view_internal_field_count
# v8_promise_internal_field_count
# v8_enable_vtunetracemark
# v8_enable_fast_torque
+14
View File
@@ -67,6 +67,14 @@ declare_args() {
# Sets the number of internal fields on promise objects.
v8_promise_internal_field_count = 0
# Sets the number of internal fields on array buffer objects.
# TODO(346350847): Switch default to 0.
v8_array_buffer_internal_field_count = 2
# Sets the number of internal fields on array buffer view objects.
# TODO(346350847): Switch default to 0.
v8_array_buffer_view_internal_field_count = 2
# Sets -dENABLE_GDB_JIT_INTERFACE.
v8_enable_gdbjit = ""
@@ -1064,6 +1072,12 @@ config("features") {
defines +=
[ "V8_PROMISE_INTERNAL_FIELD_COUNT=${v8_promise_internal_field_count}" ]
}
if (v8_array_buffer_internal_field_count != 0) {
defines += [ "V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT=${v8_array_buffer_internal_field_count}" ]
}
if (v8_array_buffer_view_internal_field_count != 0) {
defines += [ "V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT=${v8_array_buffer_view_internal_field_count}" ]
}
defines +=
[ "V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=${v8_typed_array_max_size_in_heap}" ]
+9 -8
View File
@@ -18,7 +18,7 @@ namespace v8 {
class SharedArrayBuffer;
#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder.
// Defined using gn arg `v8_array_buffer_internal_field_count`.
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
#endif
@@ -343,8 +343,9 @@ class V8_EXPORT ArrayBuffer : public Object {
return static_cast<ArrayBuffer*>(value);
}
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
static const int kEmbedderFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
static constexpr int kInternalFieldCount =
V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
static constexpr int kEmbedderFieldCount = kInternalFieldCount;
private:
ArrayBuffer();
@@ -352,7 +353,7 @@ class V8_EXPORT ArrayBuffer : public Object {
};
#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder.
// Defined using gn arg `v8_array_buffer_view_internal_field_count`.
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
#endif
@@ -399,10 +400,9 @@ class V8_EXPORT ArrayBufferView : public Object {
return static_cast<ArrayBufferView*>(value);
}
static const int kInternalFieldCount =
V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
static const int kEmbedderFieldCount =
static constexpr int kInternalFieldCount =
V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
static const int kEmbedderFieldCount = kInternalFieldCount;
private:
ArrayBufferView();
@@ -512,7 +512,8 @@ class V8_EXPORT SharedArrayBuffer : public Object {
return static_cast<SharedArrayBuffer*>(value);
}
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
static constexpr int kInternalFieldCount =
V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
private:
SharedArrayBuffer();
+2 -2
View File
@@ -14,7 +14,7 @@ namespace v8 {
class Context;
#ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder.
// Defined using gn arg `v8_promise_internal_field_count`.
#define V8_PROMISE_INTERNAL_FIELD_COUNT 0
#endif
@@ -115,7 +115,7 @@ class V8_EXPORT Promise : public Object {
return static_cast<Promise*>(value);
}
static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
static constexpr int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
private:
Promise();