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

Side by Side Diff: src/runtime/runtime-typedarray.cc

Issue 1215103003: Register array buffer right after writing it into the object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/messages.h" 8 #include "src/messages.h"
9 #include "src/runtime/runtime.h" 9 #include "src/runtime/runtime.h"
10 #include "src/runtime/runtime-utils.h" 10 #include "src/runtime/runtime-utils.h"
(...skipping 10 matching lines...) Expand all
21 v8::ArrayBuffer::kInternalFieldCount); 21 v8::ArrayBuffer::kInternalFieldCount);
22 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { 22 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) {
23 array_buffer->SetInternalField(i, Smi::FromInt(0)); 23 array_buffer->SetInternalField(i, Smi::FromInt(0));
24 } 24 }
25 array_buffer->set_backing_store(data); 25 array_buffer->set_backing_store(data);
26 array_buffer->set_bit_field(0); 26 array_buffer->set_bit_field(0);
27 array_buffer->set_is_external(is_external); 27 array_buffer->set_is_external(is_external);
28 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); 28 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared);
29 array_buffer->set_is_shared(shared == SharedFlag::kShared); 29 array_buffer->set_is_shared(shared == SharedFlag::kShared);
30 30
31 if (data && !is_external) {
32 isolate->heap()->RegisterNewArrayBuffer(
33 isolate->heap()->InNewSpace(*array_buffer), data, allocated_length);
34 }
35
31 Handle<Object> byte_length = 36 Handle<Object> byte_length =
32 isolate->factory()->NewNumberFromSize(allocated_length); 37 isolate->factory()->NewNumberFromSize(allocated_length);
33 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); 38 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
34 array_buffer->set_byte_length(*byte_length); 39 array_buffer->set_byte_length(*byte_length);
35
36 if (data && !is_external) {
37 isolate->heap()->RegisterNewArrayBuffer(
38 isolate->heap()->InNewSpace(*array_buffer), data, allocated_length);
39 }
40 } 40 }
41 41
42 42
43 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate, 43 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate,
44 Handle<JSArrayBuffer> array_buffer, 44 Handle<JSArrayBuffer> array_buffer,
45 size_t allocated_length, 45 size_t allocated_length,
46 bool initialize, 46 bool initialize,
47 SharedFlag shared) { 47 SharedFlag shared) {
48 void* data; 48 void* data;
49 CHECK(isolate->array_buffer_allocator() != NULL); 49 CHECK(isolate->array_buffer_allocator() != NULL);
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 DATA_VIEW_SETTER(Uint16, uint16_t) 749 DATA_VIEW_SETTER(Uint16, uint16_t)
750 DATA_VIEW_SETTER(Int16, int16_t) 750 DATA_VIEW_SETTER(Int16, int16_t)
751 DATA_VIEW_SETTER(Uint32, uint32_t) 751 DATA_VIEW_SETTER(Uint32, uint32_t)
752 DATA_VIEW_SETTER(Int32, int32_t) 752 DATA_VIEW_SETTER(Int32, int32_t)
753 DATA_VIEW_SETTER(Float32, float) 753 DATA_VIEW_SETTER(Float32, float)
754 DATA_VIEW_SETTER(Float64, double) 754 DATA_VIEW_SETTER(Float64, double)
755 755
756 #undef DATA_VIEW_SETTER 756 #undef DATA_VIEW_SETTER
757 } // namespace internal 757 } // namespace internal
758 } // namespace v8 758 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698