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

Side by Side 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, 7 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 unified diff | Download patch
« no previous file with comments | « src/mips64/lithium-codegen-mips64.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 17023 matching lines...) Expand 10 before | Expand all | Expand 10 after
17034 17034
17035 Handle<Map> map(typed_array->map()); 17035 Handle<Map> map(typed_array->map());
17036 Isolate* isolate = typed_array->GetIsolate(); 17036 Isolate* isolate = typed_array->GetIsolate();
17037 17037
17038 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind())); 17038 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind()));
17039 17039
17040 Handle<Map> new_map = Map::TransitionElementsTo( 17040 Handle<Map> new_map = Map::TransitionElementsTo(
17041 map, 17041 map,
17042 FixedToExternalElementsKind(map->elements_kind())); 17042 FixedToExternalElementsKind(map->elements_kind()));
17043 17043
17044 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
17045 Handle<FixedTypedArrayBase> fixed_typed_array( 17044 Handle<FixedTypedArrayBase> fixed_typed_array(
17046 FixedTypedArrayBase::cast(typed_array->elements())); 17045 FixedTypedArrayBase::cast(typed_array->elements()));
17047 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, 17046
17048 fixed_typed_array->DataSize(), false); 17047 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()),
17048 isolate);
17049 void* backing_store =
17050 isolate->array_buffer_allocator()->AllocateUninitialized(
17051 fixed_typed_array->DataSize());
17052 isolate->heap()->RegisterNewArrayBuffer(backing_store,
17053 fixed_typed_array->DataSize());
17054 buffer->set_backing_store(backing_store);
17055 buffer->set_is_external(false);
17049 memcpy(buffer->backing_store(), 17056 memcpy(buffer->backing_store(),
17050 fixed_typed_array->DataPtr(), 17057 fixed_typed_array->DataPtr(),
17051 fixed_typed_array->DataSize()); 17058 fixed_typed_array->DataSize());
17052 Handle<ExternalArray> new_elements = 17059 Handle<ExternalArray> new_elements =
17053 isolate->factory()->NewExternalArray( 17060 isolate->factory()->NewExternalArray(
17054 fixed_typed_array->length(), typed_array->type(), 17061 fixed_typed_array->length(), typed_array->type(),
17055 static_cast<uint8_t*>(buffer->backing_store())); 17062 static_cast<uint8_t*>(buffer->backing_store()));
17056 17063
17057 typed_array->set_buffer(*buffer);
17058 JSObject::SetMapAndElements(typed_array, new_map, new_elements); 17064 JSObject::SetMapAndElements(typed_array, new_map, new_elements);
17059 17065
17060 return buffer; 17066 return buffer;
17061 } 17067 }
17062 17068
17063 17069
17064 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { 17070 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() {
17065 Handle<Object> result(buffer(), GetIsolate()); 17071 if (IsExternalArrayElementsKind(map()->elements_kind())) {
17066 if (*result != Smi::FromInt(0)) { 17072 Handle<Object> result(buffer(), GetIsolate());
17067 DCHECK(IsExternalArrayElementsKind(map()->elements_kind()));
17068 return Handle<JSArrayBuffer>::cast(result); 17073 return Handle<JSArrayBuffer>::cast(result);
17069 } 17074 }
17070 Handle<JSTypedArray> self(this); 17075 Handle<JSTypedArray> self(this);
17071 return MaterializeArrayBuffer(self); 17076 return MaterializeArrayBuffer(self);
17072 } 17077 }
17073 17078
17074 17079
17075 Handle<PropertyCell> PropertyCell::InvalidateEntry( 17080 Handle<PropertyCell> PropertyCell::InvalidateEntry(
17076 Handle<NameDictionary> dictionary, int entry) { 17081 Handle<NameDictionary> dictionary, int entry) {
17077 Isolate* isolate = dictionary->GetIsolate(); 17082 Isolate* isolate = dictionary->GetIsolate();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
17199 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, 17204 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell,
17200 Handle<Object> new_value) { 17205 Handle<Object> new_value) {
17201 if (cell->value() != *new_value) { 17206 if (cell->value() != *new_value) {
17202 cell->set_value(*new_value); 17207 cell->set_value(*new_value);
17203 Isolate* isolate = cell->GetIsolate(); 17208 Isolate* isolate = cell->GetIsolate();
17204 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17209 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17205 isolate, DependentCode::kPropertyCellChangedGroup); 17210 isolate, DependentCode::kPropertyCellChangedGroup);
17206 } 17211 }
17207 } 17212 }
17208 } } // namespace v8::internal 17213 } } // namespace v8::internal
OLDNEW
« 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