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

Unified Diff: src/runtime/runtime-typedarray.cc

Issue 1257223002: Revert of Remove ExternalArray, derived types, and element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/runtime/runtime-test.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-typedarray.cc
diff --git a/src/runtime/runtime-typedarray.cc b/src/runtime/runtime-typedarray.cc
index bfb810e76d9cf16a580d601993cc3956ce40bae3..4d355247037e57e46c0130b01a39f9b1068b4da0 100644
--- a/src/runtime/runtime-typedarray.cc
+++ b/src/runtime/runtime-typedarray.cc
@@ -159,12 +159,14 @@
void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type,
+ ElementsKind* external_elements_kind,
ElementsKind* fixed_elements_kind,
size_t* element_size) {
switch (arrayId) {
#define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \
case ARRAY_ID_##TYPE: \
*array_type = kExternal##Type##Array; \
+ *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS; \
*fixed_elements_kind = TYPE##_ELEMENTS; \
*element_size = size; \
break;
@@ -193,9 +195,11 @@
ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
size_t element_size = 1; // Bogus initialization.
+ ElementsKind external_elements_kind =
+ EXTERNAL_INT8_ELEMENTS; // Bogus initialization.
ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization.
- Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &fixed_elements_kind,
- &element_size);
+ Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &external_elements_kind,
+ &fixed_elements_kind, &element_size);
RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind);
size_t byte_offset = 0;
@@ -237,11 +241,13 @@
Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
holder->set_buffer(*buffer);
- Handle<FixedTypedArrayBase> elements =
- isolate->factory()->NewFixedTypedArrayWithExternalPointer(
- static_cast<int>(length), array_type,
- static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
- holder->set_elements(*elements);
+ Handle<ExternalArray> elements = isolate->factory()->NewExternalArray(
+ static_cast<int>(length), array_type,
+ static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
+ Handle<Map> map =
+ JSObject::GetElementsTransitionMap(holder, external_elements_kind);
+ JSObject::SetMapAndElements(holder, map, elements);
+ DCHECK(IsExternalArrayElementsKind(holder->map()->elements_kind()));
} else {
Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
Runtime::SetupArrayBuffer(isolate, buffer, true, NULL, byte_length,
@@ -274,9 +280,11 @@
ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
size_t element_size = 1; // Bogus initialization.
+ ElementsKind external_elements_kind =
+ EXTERNAL_INT8_ELEMENTS; // Bogus intialization.
ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization.
- Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &fixed_elements_kind,
- &element_size);
+ Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &external_elements_kind,
+ &fixed_elements_kind, &element_size);
RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind);
@@ -332,11 +340,12 @@
holder->set_byte_length(*byte_length_obj);
holder->set_length(*length_obj);
- Handle<FixedTypedArrayBase> elements =
- isolate->factory()->NewFixedTypedArrayWithExternalPointer(
- static_cast<int>(length), array_type,
- static_cast<uint8_t*>(buffer->backing_store()));
- holder->set_elements(*elements);
+ Handle<ExternalArray> elements = isolate->factory()->NewExternalArray(
+ static_cast<int>(length), array_type,
+ static_cast<uint8_t*>(buffer->backing_store()));
+ Handle<Map> map =
+ JSObject::GetElementsTransitionMap(holder, external_elements_kind);
+ JSObject::SetMapAndElements(holder, map, elements);
if (source->IsJSTypedArray()) {
Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source));
« no previous file with comments | « src/runtime/runtime-test.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698