| 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 15 matching lines...) Expand all Loading... |
| 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(true); | 28 array_buffer->set_is_neuterable(true); |
| 29 | 29 |
| 30 Handle<Object> byte_length = | 30 Handle<Object> byte_length = |
| 31 isolate->factory()->NewNumberFromSize(allocated_length); | 31 isolate->factory()->NewNumberFromSize(allocated_length); |
| 32 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); | 32 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); |
| 33 array_buffer->set_byte_length(*byte_length); | 33 array_buffer->set_byte_length(*byte_length); |
| 34 | 34 |
| 35 if (data && !is_external) { | 35 if (data && !is_external) { |
| 36 isolate->heap()->RegisterNewArrayBuffer(data, allocated_length); | 36 isolate->heap()->RegisterNewArrayBuffer( |
| 37 isolate->heap()->InNewSpace(*array_buffer), data, allocated_length); |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 | 41 |
| 41 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate, | 42 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate, |
| 42 Handle<JSArrayBuffer> array_buffer, | 43 Handle<JSArrayBuffer> array_buffer, |
| 43 size_t allocated_length, | 44 size_t allocated_length, |
| 44 bool initialize) { | 45 bool initialize) { |
| 45 void* data; | 46 void* data; |
| 46 CHECK(isolate->array_buffer_allocator() != NULL); | 47 CHECK(isolate->array_buffer_allocator() != NULL); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); | 137 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); |
| 137 if (array_buffer->backing_store() == NULL) { | 138 if (array_buffer->backing_store() == NULL) { |
| 138 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); | 139 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); |
| 139 return isolate->heap()->undefined_value(); | 140 return isolate->heap()->undefined_value(); |
| 140 } | 141 } |
| 141 DCHECK(!array_buffer->is_external()); | 142 DCHECK(!array_buffer->is_external()); |
| 142 void* backing_store = array_buffer->backing_store(); | 143 void* backing_store = array_buffer->backing_store(); |
| 143 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); | 144 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); |
| 144 array_buffer->set_is_external(true); | 145 array_buffer->set_is_external(true); |
| 145 Runtime::NeuterArrayBuffer(array_buffer); | 146 Runtime::NeuterArrayBuffer(array_buffer); |
| 146 isolate->heap()->UnregisterArrayBuffer(backing_store); | 147 isolate->heap()->UnregisterArrayBuffer( |
| 148 isolate->heap()->InNewSpace(*array_buffer), backing_store); |
| 147 isolate->array_buffer_allocator()->Free(backing_store, byte_length); | 149 isolate->array_buffer_allocator()->Free(backing_store, byte_length); |
| 148 return isolate->heap()->undefined_value(); | 150 return isolate->heap()->undefined_value(); |
| 149 } | 151 } |
| 150 | 152 |
| 151 | 153 |
| 152 void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type, | 154 void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type, |
| 153 ElementsKind* external_elements_kind, | 155 ElementsKind* external_elements_kind, |
| 154 ElementsKind* fixed_elements_kind, | 156 ElementsKind* fixed_elements_kind, |
| 155 size_t* element_size) { | 157 size_t* element_size) { |
| 156 switch (arrayId) { | 158 switch (arrayId) { |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 DATA_VIEW_SETTER(Uint16, uint16_t) | 715 DATA_VIEW_SETTER(Uint16, uint16_t) |
| 714 DATA_VIEW_SETTER(Int16, int16_t) | 716 DATA_VIEW_SETTER(Int16, int16_t) |
| 715 DATA_VIEW_SETTER(Uint32, uint32_t) | 717 DATA_VIEW_SETTER(Uint32, uint32_t) |
| 716 DATA_VIEW_SETTER(Int32, int32_t) | 718 DATA_VIEW_SETTER(Int32, int32_t) |
| 717 DATA_VIEW_SETTER(Float32, float) | 719 DATA_VIEW_SETTER(Float32, float) |
| 718 DATA_VIEW_SETTER(Float64, double) | 720 DATA_VIEW_SETTER(Float64, double) |
| 719 | 721 |
| 720 #undef DATA_VIEW_SETTER | 722 #undef DATA_VIEW_SETTER |
| 721 } | 723 } |
| 722 } // namespace v8::internal | 724 } // namespace v8::internal |
| OLD | NEW |