Skip to content

Commit 57ee3c0

Browse files
hashseedCommit bot
authored andcommitted
Revert of Implement SharedArrayBuffer (patchset v8#7 id:120001 of https://codereview.chromium.org/1136553006/)
Reason for revert: breaks build Original issue's description: > Implement SharedArrayBuffer. > > This adds a new external type (v8::SharedArrayBuffer) that uses a JSArrayBuffer under the hood. It can be distinguished from an ArrayBuffer by the newly-added is_shared() bit. > > Currently there is no difference in functionality between a SharedArrayBuffer and an ArrayBuffer. However, a future CL will add the Atomics API, which is only available on an SharedArrayBuffer. All non-atomic accesses are identical to ArrayBuffer accesses. > > BUG= > > Committed: https://crrev.com/57170bff7baf341c666252a7f6a49e9c08d51263 > Cr-Commit-Position: refs/heads/master@{#28588} TBR=jarin@chromium.org,jochen@chromium.org,binji@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review URL: https://codereview.chromium.org/1149203003 Cr-Commit-Position: refs/heads/master@{#28589}
1 parent 57170bf commit 57ee3c0

20 files changed

Lines changed: 31 additions & 1046 deletions

BUILD.gn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ action("js2c_experimental") {
276276
"src/harmony-regexp.js",
277277
"src/harmony-reflect.js",
278278
"src/harmony-spread.js",
279-
"src/harmony-object.js",
280-
"src/harmony-sharedarraybuffer.js"
279+
"src/harmony-object.js"
281280
]
282281

283282
outputs = [

include/v8.h

Lines changed: 2 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,13 +1920,6 @@ class V8_EXPORT Value : public Data {
19201920
*/
19211921
bool IsDataView() const;
19221922

1923-
/**
1924-
* Returns true if this value is a SharedArrayBuffer.
1925-
* This is an experimental feature.
1926-
*/
1927-
bool IsSharedArrayBuffer() const;
1928-
1929-
19301923
V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
19311924
Local<Context> context) const;
19321925
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
@@ -3351,7 +3344,7 @@ class V8_EXPORT ArrayBuffer : public Object {
33513344
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
33523345

33533346
/**
3354-
* Returns true if ArrayBuffer is externalized, that is, does not
3347+
* Returns true if ArrayBuffer is extrenalized, that is, does not
33553348
* own its memory block.
33563349
*/
33573350
bool IsExternal() const;
@@ -3637,105 +3630,6 @@ class V8_EXPORT DataView : public ArrayBufferView {
36373630
};
36383631

36393632

3640-
/**
3641-
* An instance of the built-in SharedArrayBuffer constructor.
3642-
* This API is experimental and may change significantly.
3643-
*/
3644-
class V8_EXPORT SharedArrayBuffer : public Object {
3645-
public:
3646-
/**
3647-
* The contents of an |SharedArrayBuffer|. Externalization of
3648-
* |SharedArrayBuffer| returns an instance of this class, populated, with a
3649-
* pointer to data and byte length.
3650-
*
3651-
* The Data pointer of SharedArrayBuffer::Contents is always allocated with
3652-
* |ArrayBuffer::Allocator::Allocate| by the allocator specified in
3653-
* v8::Isolate::CreateParams::array_buffer_allocator.
3654-
*
3655-
* This API is experimental and may change significantly.
3656-
*/
3657-
class V8_EXPORT Contents { // NOLINT
3658-
public:
3659-
Contents() : data_(NULL), byte_length_(0) {}
3660-
3661-
void* Data() const { return data_; }
3662-
size_t ByteLength() const { return byte_length_; }
3663-
3664-
private:
3665-
void* data_;
3666-
size_t byte_length_;
3667-
3668-
friend class SharedArrayBuffer;
3669-
};
3670-
3671-
3672-
/**
3673-
* Data length in bytes.
3674-
*/
3675-
size_t ByteLength() const;
3676-
3677-
/**
3678-
* Create a new SharedArrayBuffer. Allocate |byte_length| bytes.
3679-
* Allocated memory will be owned by a created SharedArrayBuffer and
3680-
* will be deallocated when it is garbage-collected,
3681-
* unless the object is externalized.
3682-
*/
3683-
static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length);
3684-
3685-
/**
3686-
* Create a new SharedArrayBuffer over an existing memory block. The created
3687-
* array buffer is immediately in externalized state unless otherwise
3688-
* specified. The memory block will not be reclaimed when a created
3689-
* SharedArrayBuffer is garbage-collected.
3690-
*/
3691-
static Local<SharedArrayBuffer> New(
3692-
Isolate* isolate, void* data, size_t byte_length,
3693-
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
3694-
3695-
/**
3696-
* Returns true if SharedArrayBuffer is externalized, that is, does not
3697-
* own its memory block.
3698-
*/
3699-
bool IsExternal() const;
3700-
3701-
/**
3702-
* Make this SharedArrayBuffer external. The pointer to underlying memory
3703-
* block and byte length are returned as |Contents| structure. After
3704-
* SharedArrayBuffer had been etxrenalized, it does no longer owns the memory
3705-
* block. The caller should take steps to free memory when it is no longer
3706-
* needed.
3707-
*
3708-
* The memory block is guaranteed to be allocated with |Allocator::Allocate|
3709-
* by the allocator specified in
3710-
* v8::Isolate::CreateParams::array_buffer_allocator.
3711-
*
3712-
*/
3713-
Contents Externalize();
3714-
3715-
/**
3716-
* Get a pointer to the ArrayBuffer's underlying memory block without
3717-
* externalizing it. If the ArrayBuffer is not externalized, this pointer
3718-
* will become invalid as soon as the ArrayBuffer became garbage collected.
3719-
*
3720-
* The embedder should make sure to hold a strong reference to the
3721-
* ArrayBuffer while accessing this pointer.
3722-
*
3723-
* The memory block is guaranteed to be allocated with |Allocator::Allocate|
3724-
* by the allocator specified in
3725-
* v8::Isolate::CreateParams::array_buffer_allocator.
3726-
*/
3727-
Contents GetContents();
3728-
3729-
V8_INLINE static SharedArrayBuffer* Cast(Value* obj);
3730-
3731-
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
3732-
3733-
private:
3734-
SharedArrayBuffer();
3735-
static void CheckCast(Value* obj);
3736-
};
3737-
3738-
37393633
/**
37403634
* An instance of the built-in Date constructor (ECMA-262, 15.9).
37413635
*/
@@ -6852,7 +6746,7 @@ class Internals {
68526746
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
68536747
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
68546748
static const int kContextHeaderSize = 2 * kApiPointerSize;
6855-
static const int kContextEmbedderDataIndex = 79;
6749+
static const int kContextEmbedderDataIndex = 78;
68566750
static const int kFullStringRepresentationMask = 0x07;
68576751
static const int kStringEncodingMask = 0x4;
68586752
static const int kExternalTwoByteRepresentationTag = 0x02;
@@ -7923,14 +7817,6 @@ DataView* DataView::Cast(v8::Value* value) {
79237817
}
79247818

79257819

7926-
SharedArrayBuffer* SharedArrayBuffer::Cast(v8::Value* value) {
7927-
#ifdef V8_ENABLE_CHECKS
7928-
CheckCast(value);
7929-
#endif
7930-
return static_cast<SharedArrayBuffer*>(value);
7931-
}
7932-
7933-
79347820
Function* Function::Cast(v8::Value* value) {
79357821
#ifdef V8_ENABLE_CHECKS
79367822
CheckCast(value);

src/api.cc

Lines changed: 6 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,8 +2679,7 @@ bool Value::IsArray() const {
26792679

26802680

26812681
bool Value::IsArrayBuffer() const {
2682-
i::Handle<i::Object> obj = Utils::OpenHandle(this);
2683-
return obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared();
2682+
return Utils::OpenHandle(this)->IsJSArrayBuffer();
26842683
}
26852684

26862685

@@ -2701,7 +2700,6 @@ bool Value::IsTypedArray() const {
27012700
i::JSTypedArray::cast(*obj)->type() == i::kExternal##Type##Array; \
27022701
}
27032702

2704-
27052703
TYPED_ARRAYS(VALUE_IS_TYPED_ARRAY)
27062704

27072705
#undef VALUE_IS_TYPED_ARRAY
@@ -2712,12 +2710,6 @@ bool Value::IsDataView() const {
27122710
}
27132711

27142712

2715-
bool Value::IsSharedArrayBuffer() const {
2716-
i::Handle<i::Object> obj = Utils::OpenHandle(this);
2717-
return obj->IsJSArrayBuffer() && i::JSArrayBuffer::cast(*obj)->is_shared();
2718-
}
2719-
2720-
27212713
bool Value::IsObject() const {
27222714
return Utils::OpenHandle(this)->IsJSObject();
27232715
}
@@ -3094,9 +3086,9 @@ void v8::Promise::Resolver::CheckCast(Value* that) {
30943086

30953087
void v8::ArrayBuffer::CheckCast(Value* that) {
30963088
i::Handle<i::Object> obj = Utils::OpenHandle(that);
3097-
Utils::ApiCheck(
3098-
obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared(),
3099-
"v8::ArrayBuffer::Cast()", "Could not convert to ArrayBuffer");
3089+
Utils::ApiCheck(obj->IsJSArrayBuffer(),
3090+
"v8::ArrayBuffer::Cast()",
3091+
"Could not convert to ArrayBuffer");
31003092
}
31013093

31023094

@@ -3139,15 +3131,6 @@ void v8::DataView::CheckCast(Value* that) {
31393131
}
31403132

31413133

3142-
void v8::SharedArrayBuffer::CheckCast(Value* that) {
3143-
i::Handle<i::Object> obj = Utils::OpenHandle(that);
3144-
Utils::ApiCheck(
3145-
obj->IsJSArrayBuffer() && i::JSArrayBuffer::cast(*obj)->is_shared(),
3146-
"v8::SharedArrayBuffer::Cast()",
3147-
"Could not convert to SharedArrayBuffer");
3148-
}
3149-
3150-
31513134
void v8::Date::CheckCast(v8::Value* that) {
31523135
i::Handle<i::Object> obj = Utils::OpenHandle(that);
31533136
i::Isolate* isolate = NULL;
@@ -6322,7 +6305,7 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
63226305
LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)");
63236306
ENTER_V8(i_isolate);
63246307
i::Handle<i::JSArrayBuffer> obj =
6325-
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
6308+
i_isolate->factory()->NewJSArrayBuffer();
63266309
i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length);
63276310
return Utils::ToLocal(obj);
63286311
}
@@ -6335,7 +6318,7 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
63356318
LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
63366319
ENTER_V8(i_isolate);
63376320
i::Handle<i::JSArrayBuffer> obj =
6338-
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
6321+
i_isolate->factory()->NewJSArrayBuffer();
63396322
i::Runtime::SetupArrayBuffer(i_isolate, obj,
63406323
mode == ArrayBufferCreationMode::kExternalized,
63416324
data, byte_length);
@@ -6441,66 +6424,6 @@ Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer,
64416424
}
64426425

64436426

6444-
bool v8::SharedArrayBuffer::IsExternal() const {
6445-
return Utils::OpenHandle(this)->is_external();
6446-
}
6447-
6448-
6449-
v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() {
6450-
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
6451-
i::Isolate* isolate = self->GetIsolate();
6452-
Utils::ApiCheck(!self->is_external(), "v8::SharedArrayBuffer::Externalize",
6453-
"SharedArrayBuffer already externalized");
6454-
self->set_is_external(true);
6455-
isolate->heap()->UnregisterArrayBuffer(self->backing_store());
6456-
return GetContents();
6457-
}
6458-
6459-
6460-
v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() {
6461-
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
6462-
size_t byte_length = static_cast<size_t>(self->byte_length()->Number());
6463-
Contents contents;
6464-
contents.data_ = self->backing_store();
6465-
contents.byte_length_ = byte_length;
6466-
return contents;
6467-
}
6468-
6469-
6470-
size_t v8::SharedArrayBuffer::ByteLength() const {
6471-
i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6472-
return static_cast<size_t>(obj->byte_length()->Number());
6473-
}
6474-
6475-
6476-
Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate,
6477-
size_t byte_length) {
6478-
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6479-
LOG_API(i_isolate, "v8::SharedArrayBuffer::New(size_t)");
6480-
ENTER_V8(i_isolate);
6481-
i::Handle<i::JSArrayBuffer> obj =
6482-
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
6483-
i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length, true,
6484-
i::SharedFlag::kShared);
6485-
return Utils::ToLocalShared(obj);
6486-
}
6487-
6488-
6489-
Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(
6490-
Isolate* isolate, void* data, size_t byte_length,
6491-
ArrayBufferCreationMode mode) {
6492-
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6493-
LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)");
6494-
ENTER_V8(i_isolate);
6495-
i::Handle<i::JSArrayBuffer> obj =
6496-
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
6497-
i::Runtime::SetupArrayBuffer(i_isolate, obj,
6498-
mode == ArrayBufferCreationMode::kExternalized,
6499-
data, byte_length, i::SharedFlag::kShared);
6500-
return Utils::ToLocalShared(obj);
6501-
}
6502-
6503-
65046427
Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
65056428
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
65066429
LOG_API(i_isolate, "Symbol::New()");

src/api.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ class RegisteredExtension {
159159
V(Float32Array, JSTypedArray) \
160160
V(Float64Array, JSTypedArray) \
161161
V(DataView, JSDataView) \
162-
V(SharedArrayBuffer, JSArrayBuffer) \
163162
V(Name, Name) \
164163
V(String, String) \
165164
V(Symbol, Symbol) \
@@ -231,9 +230,6 @@ class Utils {
231230
static inline Local<Float64Array> ToLocalFloat64Array(
232231
v8::internal::Handle<v8::internal::JSTypedArray> obj);
233232

234-
static inline Local<SharedArrayBuffer> ToLocalShared(
235-
v8::internal::Handle<v8::internal::JSArrayBuffer> obj);
236-
237233
static inline Local<Message> MessageToLocal(
238234
v8::internal::Handle<v8::internal::Object> obj);
239235
static inline Local<Promise> PromiseToLocal(
@@ -364,7 +360,6 @@ MAKE_TO_LOCAL(ToLocal, JSArrayBuffer, ArrayBuffer)
364360
MAKE_TO_LOCAL(ToLocal, JSArrayBufferView, ArrayBufferView)
365361
MAKE_TO_LOCAL(ToLocal, JSDataView, DataView)
366362
MAKE_TO_LOCAL(ToLocal, JSTypedArray, TypedArray)
367-
MAKE_TO_LOCAL(ToLocalShared, JSArrayBuffer, SharedArrayBuffer)
368363

369364
TYPED_ARRAYS(MAKE_TO_LOCAL_TYPED_ARRAY)
370365

src/arraybuffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ utils.Import(function(from) {
2828
function ArrayBufferConstructor(length) { // length = 1
2929
if (%_IsConstructCall()) {
3030
var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength);
31-
%ArrayBufferInitialize(this, byteLength, kNotShared);
31+
%ArrayBufferInitialize(this, byteLength);
3232
} else {
3333
throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer");
3434
}

src/bootstrapper.cc

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,6 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls)
17531753
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring)
17541754
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object)
17551755
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays)
1756-
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer)
17571756

17581757

17591758
void Genesis::InstallNativeFunctions_harmony_proxies() {
@@ -1847,20 +1846,6 @@ void Genesis::InitializeGlobal_harmony_tostring() {
18471846
}
18481847

18491848

1850-
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
1851-
if (!FLAG_harmony_sharedarraybuffer) return;
1852-
1853-
Handle<JSGlobalObject> global(
1854-
JSGlobalObject::cast(native_context()->global_object()));
1855-
1856-
Handle<JSFunction> shared_array_buffer_fun = InstallFunction(
1857-
global, "SharedArrayBuffer", JS_ARRAY_BUFFER_TYPE,
1858-
JSArrayBuffer::kSizeWithInternalFields,
1859-
isolate()->initial_object_prototype(), Builtins::kIllegal);
1860-
native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun);
1861-
}
1862-
1863-
18641849
Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
18651850
const char* name,
18661851
ElementsKind elements_kind) {
@@ -2425,8 +2410,6 @@ bool Genesis::InstallExperimentalNatives() {
24252410
static const char* harmony_object_natives[] = {"native harmony-object.js",
24262411
NULL};
24272412
static const char* harmony_spread_arrays_natives[] = {nullptr};
2428-
static const char* harmony_sharedarraybuffer_natives[] = {
2429-
"native harmony-sharedarraybuffer.js", NULL};
24302413

24312414
for (int i = ExperimentalNatives::GetDebuggerCount();
24322415
i < ExperimentalNatives::GetBuiltinsCount(); i++) {

src/contexts.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ enum BindingFlags {
103103
V(TO_LENGTH_FUN_INDEX, JSFunction, to_length_fun) \
104104
V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \
105105
V(ARRAY_BUFFER_FUN_INDEX, JSFunction, array_buffer_fun) \
106-
V(SHARED_ARRAY_BUFFER_FUN_INDEX, JSFunction, shared_array_buffer_fun) \
107106
V(ARRAY_BUFFER_MAP_INDEX, Map, array_buffer_map) \
108107
V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \
109108
V(INT8_ARRAY_FUN_INDEX, JSFunction, int8_array_fun) \
@@ -382,7 +381,6 @@ class Context: public FixedArray {
382381
FLOAT64_ARRAY_EXTERNAL_MAP_INDEX,
383382
UINT8_CLAMPED_ARRAY_EXTERNAL_MAP_INDEX,
384383
DATA_VIEW_FUN_INDEX,
385-
SHARED_ARRAY_BUFFER_FUN_INDEX,
386384
MESSAGE_LISTENERS_INDEX,
387385
MAKE_MESSAGE_FUN_INDEX,
388386
GET_STACK_TRACE_LINE_INDEX,

0 commit comments

Comments
 (0)