OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |