Commit 221f4068 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[objects] Add extension field to JSArrayBuffer

Add pointer-sized field extension to the JSArrayBuffer class. Only
reserve space for this field when feature is enabled for now.

Bug: v8:10064
Change-Id: Idb6fdcdce2a048e6aed9a892bc46ce029e1119f3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1956166Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65471}
parent 9c37ec0b
...@@ -124,6 +124,9 @@ declare_args() { ...@@ -124,6 +124,9 @@ declare_args() {
# Sets -dV8_CONCURRENT_MARKING # Sets -dV8_CONCURRENT_MARKING
v8_enable_concurrent_marking = true v8_enable_concurrent_marking = true
# Sets -dV8_ARRAY_BUFFER_EXTENSION
v8_enable_array_buffer_extension = true
# Enables various testing features. # Enables various testing features.
v8_enable_test_features = "" v8_enable_test_features = ""
...@@ -455,6 +458,9 @@ config("features") { ...@@ -455,6 +458,9 @@ config("features") {
if (v8_enable_concurrent_marking) { if (v8_enable_concurrent_marking) {
defines += [ "V8_CONCURRENT_MARKING" ] defines += [ "V8_CONCURRENT_MARKING" ]
} }
if (v8_enable_array_buffer_extension) {
defines += [ "V8_ARRAY_BUFFER_EXTENSION" ]
}
if (v8_enable_lazy_source_positions) { if (v8_enable_lazy_source_positions) {
defines += [ "V8_ENABLE_LAZY_SOURCE_POSITIONS" ] defines += [ "V8_ENABLE_LAZY_SOURCE_POSITIONS" ]
} }
...@@ -1665,6 +1671,8 @@ v8_compiler_sources = [ ...@@ -1665,6 +1671,8 @@ v8_compiler_sources = [
"src/compiler/access-builder.h", "src/compiler/access-builder.h",
"src/compiler/access-info.cc", "src/compiler/access-info.cc",
"src/compiler/access-info.h", "src/compiler/access-info.h",
"src/compiler/add-type-assertions-reducer.cc",
"src/compiler/add-type-assertions-reducer.h",
"src/compiler/all-nodes.cc", "src/compiler/all-nodes.cc",
"src/compiler/all-nodes.h", "src/compiler/all-nodes.h",
"src/compiler/allocation-builder-inl.h", "src/compiler/allocation-builder-inl.h",
...@@ -1873,8 +1881,6 @@ v8_compiler_sources = [ ...@@ -1873,8 +1881,6 @@ v8_compiler_sources = [
"src/compiler/state-values-utils.h", "src/compiler/state-values-utils.h",
"src/compiler/store-store-elimination.cc", "src/compiler/store-store-elimination.cc",
"src/compiler/store-store-elimination.h", "src/compiler/store-store-elimination.h",
"src/compiler/add-type-assertions-reducer.cc",
"src/compiler/add-type-assertions-reducer.h",
"src/compiler/type-cache.cc", "src/compiler/type-cache.cc",
"src/compiler/type-cache.h", "src/compiler/type-cache.h",
"src/compiler/type-narrowing-reducer.cc", "src/compiler/type-narrowing-reducer.cc",
......
...@@ -886,6 +886,11 @@ DEFINE_BOOL(write_protect_code_memory, true, "write protect code memory") ...@@ -886,6 +886,11 @@ DEFINE_BOOL(write_protect_code_memory, true, "write protect code memory")
#endif #endif
DEFINE_BOOL(concurrent_marking, V8_CONCURRENT_MARKING_BOOL, DEFINE_BOOL(concurrent_marking, V8_CONCURRENT_MARKING_BOOL,
"use concurrent marking") "use concurrent marking")
#ifdef V8_ARRAY_BUFFER_EXTENSION
#define V8_ARRAY_BUFFER_EXTENSION_BOOL true
#else
#define V8_ARRAY_BUFFER_EXTENSION_BOOL false
#endif
DEFINE_BOOL(parallel_marking, true, "use parallel marking in atomic pause") DEFINE_BOOL(parallel_marking, true, "use parallel marking in atomic pause")
DEFINE_INT(ephemeron_fixpoint_iterations, 10, DEFINE_INT(ephemeron_fixpoint_iterations, 10,
"number of fixpoint iterations it takes to switch to linear " "number of fixpoint iterations it takes to switch to linear "
......
...@@ -40,10 +40,26 @@ void* JSArrayBuffer::backing_store() const { ...@@ -40,10 +40,26 @@ void* JSArrayBuffer::backing_store() const {
return reinterpret_cast<void*>(ReadField<Address>(kBackingStoreOffset)); return reinterpret_cast<void*>(ReadField<Address>(kBackingStoreOffset));
} }
void JSArrayBuffer::set_backing_store(void* value, WriteBarrierMode mode) { void JSArrayBuffer::set_backing_store(void* value) {
WriteField<Address>(kBackingStoreOffset, reinterpret_cast<Address>(value)); WriteField<Address>(kBackingStoreOffset, reinterpret_cast<Address>(value));
} }
void* JSArrayBuffer::extension() const {
if (V8_ARRAY_BUFFER_EXTENSION_BOOL) {
return reinterpret_cast<void*>(ReadField<Address>(kExtensionOffset));
} else {
return nullptr;
}
}
void JSArrayBuffer::set_extension(void* value) {
if (V8_ARRAY_BUFFER_EXTENSION_BOOL) {
WriteField<Address>(kExtensionOffset, reinterpret_cast<Address>(value));
} else {
CHECK_EQ(value, nullptr);
}
}
size_t JSArrayBuffer::allocation_length() const { size_t JSArrayBuffer::allocation_length() const {
if (backing_store() == nullptr) { if (backing_store() == nullptr) {
return 0; return 0;
......
...@@ -43,13 +43,13 @@ void JSArrayBuffer::Setup(SharedFlag shared, ...@@ -43,13 +43,13 @@ void JSArrayBuffer::Setup(SharedFlag shared,
for (int i = 0; i < v8::ArrayBuffer::kEmbedderFieldCount; i++) { for (int i = 0; i < v8::ArrayBuffer::kEmbedderFieldCount; i++) {
SetEmbedderField(i, Smi::zero()); SetEmbedderField(i, Smi::zero());
} }
set_extension(nullptr);
if (!backing_store) { if (!backing_store) {
set_backing_store(nullptr); set_backing_store(nullptr);
set_byte_length(0); set_byte_length(0);
} else { } else {
Attach(std::move(backing_store)); Attach(std::move(backing_store));
} }
if (shared == SharedFlag::kShared) { if (shared == SharedFlag::kShared) {
GetIsolate()->CountUsage( GetIsolate()->CountUsage(
v8::Isolate::UseCounterFeature::kSharedArrayBufferConstructed); v8::Isolate::UseCounterFeature::kSharedArrayBufferConstructed);
......
...@@ -31,7 +31,10 @@ class JSArrayBuffer : public JSObject { ...@@ -31,7 +31,10 @@ class JSArrayBuffer : public JSObject {
DECL_PRIMITIVE_ACCESSORS(byte_length, size_t) DECL_PRIMITIVE_ACCESSORS(byte_length, size_t)
// [backing_store]: backing memory for this array // [backing_store]: backing memory for this array
DECL_ACCESSORS(backing_store, void*) DECL_PRIMITIVE_ACCESSORS(backing_store, void*)
// [extension]: extension object used for GC
DECL_PRIMITIVE_ACCESSORS(extension, void*)
// For non-wasm, allocation_length and allocation_base are byte_length and // For non-wasm, allocation_length and allocation_base are byte_length and
// backing_store, respectively. // backing_store, respectively.
...@@ -110,6 +113,8 @@ class JSArrayBuffer : public JSObject { ...@@ -110,6 +113,8 @@ class JSArrayBuffer : public JSObject {
/* Raw data fields. */ \ /* Raw data fields. */ \
V(kByteLengthOffset, kUIntptrSize) \ V(kByteLengthOffset, kUIntptrSize) \
V(kBackingStoreOffset, kSystemPointerSize) \ V(kBackingStoreOffset, kSystemPointerSize) \
V(kExtensionOffset, \
(V8_ARRAY_BUFFER_EXTENSION_BOOL ? kSystemPointerSize : 0)) \
V(kBitFieldOffset, kInt32Size) \ V(kBitFieldOffset, kInt32Size) \
/* Pads header size to be a multiple of kTaggedSize. */ \ /* Pads header size to be a multiple of kTaggedSize. */ \
V(kOptionalPaddingOffset, OBJECT_POINTER_PADDING(kOptionalPaddingOffset)) \ V(kOptionalPaddingOffset, OBJECT_POINTER_PADDING(kOptionalPaddingOffset)) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment