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

Side by Side Diff: src/objects.cc

Issue 1324023007: [heap] introduce ArrayBufferTracker (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: destructor Created 5 years, 3 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/heap/objects-visiting-inl.h ('k') | src/runtime/runtime-typedarray.cc » ('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 "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 15924 matching lines...) Expand 10 before | Expand all | Expand 10 after
15935 v8::ArrayBuffer::kInternalFieldCount); 15935 v8::ArrayBuffer::kInternalFieldCount);
15936 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { 15936 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) {
15937 array_buffer->SetInternalField(i, Smi::FromInt(0)); 15937 array_buffer->SetInternalField(i, Smi::FromInt(0));
15938 } 15938 }
15939 array_buffer->set_backing_store(data); 15939 array_buffer->set_backing_store(data);
15940 array_buffer->set_bit_field(0); 15940 array_buffer->set_bit_field(0);
15941 array_buffer->set_is_external(is_external); 15941 array_buffer->set_is_external(is_external);
15942 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); 15942 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared);
15943 array_buffer->set_is_shared(shared == SharedFlag::kShared); 15943 array_buffer->set_is_shared(shared == SharedFlag::kShared);
15944 15944
15945 if (data && !is_external) {
15946 isolate->heap()->RegisterNewArrayBuffer(
15947 isolate->heap()->InNewSpace(*array_buffer), data, allocated_length);
15948 }
15949
15950 Handle<Object> byte_length = 15945 Handle<Object> byte_length =
15951 isolate->factory()->NewNumberFromSize(allocated_length); 15946 isolate->factory()->NewNumberFromSize(allocated_length);
15952 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); 15947 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
15953 array_buffer->set_byte_length(*byte_length); 15948 array_buffer->set_byte_length(*byte_length);
15949
15950 if (data && !is_external) {
15951 isolate->heap()->RegisterNewArrayBuffer(*array_buffer);
15952 }
15954 } 15953 }
15955 15954
15956 15955
15957 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, 15956 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
15958 Isolate* isolate, 15957 Isolate* isolate,
15959 size_t allocated_length, 15958 size_t allocated_length,
15960 bool initialize, SharedFlag shared) { 15959 bool initialize, SharedFlag shared) {
15961 void* data; 15960 void* data;
15962 CHECK(isolate->array_buffer_allocator() != NULL); 15961 CHECK(isolate->array_buffer_allocator() != NULL);
15963 // Prevent creating array buffers when serializing. 15962 // Prevent creating array buffers when serializing.
(...skipping 27 matching lines...) Expand all
15991 Handle<FixedTypedArrayBase> fixed_typed_array( 15990 Handle<FixedTypedArrayBase> fixed_typed_array(
15992 FixedTypedArrayBase::cast(typed_array->elements())); 15991 FixedTypedArrayBase::cast(typed_array->elements()));
15993 15992
15994 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()), 15993 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()),
15995 isolate); 15994 isolate);
15996 void* backing_store = 15995 void* backing_store =
15997 isolate->array_buffer_allocator()->AllocateUninitialized( 15996 isolate->array_buffer_allocator()->AllocateUninitialized(
15998 fixed_typed_array->DataSize()); 15997 fixed_typed_array->DataSize());
15999 buffer->set_backing_store(backing_store); 15998 buffer->set_backing_store(backing_store);
16000 buffer->set_is_external(false); 15999 buffer->set_is_external(false);
16001 isolate->heap()->RegisterNewArrayBuffer(isolate->heap()->InNewSpace(*buffer), 16000 isolate->heap()->RegisterNewArrayBuffer(*buffer);
16002 backing_store,
16003 fixed_typed_array->DataSize());
16004 memcpy(buffer->backing_store(), 16001 memcpy(buffer->backing_store(),
16005 fixed_typed_array->DataPtr(), 16002 fixed_typed_array->DataPtr(),
16006 fixed_typed_array->DataSize()); 16003 fixed_typed_array->DataSize());
16007 Handle<FixedTypedArrayBase> new_elements = 16004 Handle<FixedTypedArrayBase> new_elements =
16008 isolate->factory()->NewFixedTypedArrayWithExternalPointer( 16005 isolate->factory()->NewFixedTypedArrayWithExternalPointer(
16009 fixed_typed_array->length(), typed_array->type(), 16006 fixed_typed_array->length(), typed_array->type(),
16010 static_cast<uint8_t*>(buffer->backing_store())); 16007 static_cast<uint8_t*>(buffer->backing_store()));
16011 16008
16012 typed_array->set_elements(*new_elements); 16009 typed_array->set_elements(*new_elements);
16013 16010
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
16159 if (cell->value() != *new_value) { 16156 if (cell->value() != *new_value) {
16160 cell->set_value(*new_value); 16157 cell->set_value(*new_value);
16161 Isolate* isolate = cell->GetIsolate(); 16158 Isolate* isolate = cell->GetIsolate();
16162 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16159 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16163 isolate, DependentCode::kPropertyCellChangedGroup); 16160 isolate, DependentCode::kPropertyCellChangedGroup);
16164 } 16161 }
16165 } 16162 }
16166 16163
16167 } // namespace internal 16164 } // namespace internal
16168 } // namespace v8 16165 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/objects-visiting-inl.h ('k') | src/runtime/runtime-typedarray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698