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

Unified Diff: src/objects.cc

Issue 1109353003: Unify internal and external typed arrays a bit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates 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
« no previous file with comments | « src/mips64/lithium-codegen-mips64.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 5981c7aaeb01c7919d180dc9d993a84ba56e1679..b89404352325a83eb221a9a195ea959458e104da 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -17041,11 +17041,18 @@ Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer(
map,
FixedToExternalElementsKind(map->elements_kind()));
- Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
Handle<FixedTypedArrayBase> fixed_typed_array(
FixedTypedArrayBase::cast(typed_array->elements()));
- Runtime::SetupArrayBufferAllocatingData(isolate, buffer,
- fixed_typed_array->DataSize(), false);
+
+ Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()),
+ isolate);
+ void* backing_store =
+ isolate->array_buffer_allocator()->AllocateUninitialized(
+ fixed_typed_array->DataSize());
+ isolate->heap()->RegisterNewArrayBuffer(backing_store,
+ fixed_typed_array->DataSize());
+ buffer->set_backing_store(backing_store);
+ buffer->set_is_external(false);
memcpy(buffer->backing_store(),
fixed_typed_array->DataPtr(),
fixed_typed_array->DataSize());
@@ -17054,7 +17061,6 @@ Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer(
fixed_typed_array->length(), typed_array->type(),
static_cast<uint8_t*>(buffer->backing_store()));
- typed_array->set_buffer(*buffer);
JSObject::SetMapAndElements(typed_array, new_map, new_elements);
return buffer;
@@ -17062,9 +17068,8 @@ Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer(
Handle<JSArrayBuffer> JSTypedArray::GetBuffer() {
- Handle<Object> result(buffer(), GetIsolate());
- if (*result != Smi::FromInt(0)) {
- DCHECK(IsExternalArrayElementsKind(map()->elements_kind()));
+ if (IsExternalArrayElementsKind(map()->elements_kind())) {
+ Handle<Object> result(buffer(), GetIsolate());
return Handle<JSArrayBuffer>::cast(result);
}
Handle<JSTypedArray> self(this);
« no previous file with comments | « src/mips64/lithium-codegen-mips64.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698