Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: src/factory.cc

Issue 1069883002: WIP SharedArrayBuffer implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 96b564f432703ca947395682d493615e26be13b5..302c04cf83fad8b11aaff1562d3f6b2e574b0f1b 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1710,9 +1710,10 @@ Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
}
-Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
+Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(bool is_shared) {
Handle<JSFunction> array_buffer_fun(
- isolate()->native_context()->array_buffer_fun());
+ is_shared ? isolate()->native_context()->shared_array_buffer_fun()
+ : isolate()->native_context()->array_buffer_fun());
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateJSObject(*array_buffer_fun),
@@ -1791,6 +1792,23 @@ JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) {
}
+JSFunction* GetSharedTypedArrayFun(ExternalArrayType type, Isolate* isolate) {
+ Context* native_context = isolate->context()->native_context();
+ switch (type) {
+#define SHARED_TYPED_ARRAY_FUN(Type, type, TYPE, ctype, size) \
+ case kExternal##Type##Array: \
+ return native_context->shared_##type##_array_fun();
+
+ TYPED_ARRAYS(SHARED_TYPED_ARRAY_FUN)
+#undef SHARED_TYPED_ARRAY_FUN
+
+ default:
+ UNREACHABLE();
+ return NULL;
+ }
+}
+
+
void SetupArrayBufferView(i::Isolate* isolate,
i::Handle<i::JSArrayBufferView> obj,
i::Handle<i::JSArrayBuffer> buffer,
@@ -1822,8 +1840,11 @@ void SetupArrayBufferView(i::Isolate* isolate,
} // namespace
-Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
- Handle<JSFunction> typed_array_fun_handle(GetTypedArrayFun(type, isolate()));
+Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type,
+ bool is_shared) {
+ Handle<JSFunction> typed_array_fun_handle(
+ is_shared ? GetSharedTypedArrayFun(type, isolate())
+ : GetTypedArrayFun(type, isolate()));
CALL_HEAP_FUNCTION(
isolate(),
@@ -1834,9 +1855,9 @@ Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type,
Handle<JSArrayBuffer> buffer,
- size_t byte_offset,
- size_t length) {
- Handle<JSTypedArray> obj = NewJSTypedArray(type);
+ size_t byte_offset, size_t length,
+ bool is_shared) {
+ Handle<JSTypedArray> obj = NewJSTypedArray(type, is_shared);
size_t element_size = GetExternalArrayElementSize(type);
ElementsKind elements_kind = GetExternalArrayElementsKind(type);
@@ -1850,6 +1871,7 @@ Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type,
Handle<Object> length_object = NewNumberFromSize(length);
obj->set_length(*length_object);
+ obj->set_is_shared(is_shared);
Handle<ExternalArray> elements = NewExternalArray(
static_cast<int>(length), type,

Powered by Google App Engine
This is Rietveld 408576698