Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 16114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16125 | 16125 |
| 16126 | 16126 |
| 16127 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate, | 16127 void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate, |
| 16128 bool is_external, void* data, size_t allocated_length, | 16128 bool is_external, void* data, size_t allocated_length, |
| 16129 SharedFlag shared) { | 16129 SharedFlag shared) { |
| 16130 DCHECK(array_buffer->GetInternalFieldCount() == | 16130 DCHECK(array_buffer->GetInternalFieldCount() == |
| 16131 v8::ArrayBuffer::kInternalFieldCount); | 16131 v8::ArrayBuffer::kInternalFieldCount); |
| 16132 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { | 16132 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { |
| 16133 array_buffer->SetInternalField(i, Smi::FromInt(0)); | 16133 array_buffer->SetInternalField(i, Smi::FromInt(0)); |
| 16134 } | 16134 } |
| 16135 array_buffer->set_backing_store(data); | |
| 16136 array_buffer->set_bit_field(0); | 16135 array_buffer->set_bit_field(0); |
| 16137 array_buffer->set_is_external(is_external); | 16136 array_buffer->set_is_external(is_external); |
| 16138 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); | 16137 array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); |
| 16139 array_buffer->set_is_shared(shared == SharedFlag::kShared); | 16138 array_buffer->set_is_shared(shared == SharedFlag::kShared); |
| 16140 | 16139 |
| 16141 Handle<Object> byte_length = | 16140 Handle<Object> byte_length = |
| 16142 isolate->factory()->NewNumberFromSize(allocated_length); | 16141 isolate->factory()->NewNumberFromSize(allocated_length); |
| 16143 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); | 16142 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); |
| 16144 array_buffer->set_byte_length(*byte_length); | 16143 array_buffer->set_byte_length(*byte_length); |
| 16144 // Initialize backing store at last to avoid handling of |JSArrayBuffers| that | |
| 16145 // are currently being constructed in the |ArrayBufferTracker|. The | |
| 16146 // registration method below handles the case of registering a buffer that has | |
| 16147 // already been promoted. | |
| 16148 array_buffer->set_backing_store(data); | |
| 16145 | 16149 |
| 16146 if (data && !is_external) { | 16150 if (data && !is_external) { |
| 16147 isolate->heap()->RegisterNewArrayBuffer(*array_buffer); | 16151 isolate->heap()->RegisterNewArrayBuffer(*array_buffer); |
| 16148 } | 16152 } |
| 16149 } | 16153 } |
| 16150 | 16154 |
| 16151 | 16155 |
| 16152 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, | 16156 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
| 16153 Isolate* isolate, | 16157 Isolate* isolate, |
| 16154 size_t allocated_length, | 16158 size_t allocated_length, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 16184 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind())); | 16188 DCHECK(IsFixedTypedArrayElementsKind(map->elements_kind())); |
| 16185 | 16189 |
| 16186 Handle<FixedTypedArrayBase> fixed_typed_array( | 16190 Handle<FixedTypedArrayBase> fixed_typed_array( |
| 16187 FixedTypedArrayBase::cast(typed_array->elements())); | 16191 FixedTypedArrayBase::cast(typed_array->elements())); |
| 16188 | 16192 |
| 16189 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()), | 16193 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(typed_array->buffer()), |
| 16190 isolate); | 16194 isolate); |
| 16191 void* backing_store = | 16195 void* backing_store = |
| 16192 isolate->array_buffer_allocator()->AllocateUninitialized( | 16196 isolate->array_buffer_allocator()->AllocateUninitialized( |
| 16193 fixed_typed_array->DataSize()); | 16197 fixed_typed_array->DataSize()); |
| 16198 buffer->set_is_external(false); | |
| 16199 DCHECK(buffer->byte_length->IsHeapNumber() && | |
|
jochen (gone - plz use gerrit)
2015/09/14 11:06:24
can also be a smi, no?
Michael Lippautz
2015/09/14 11:09:45
Yes, figured this out after starting the dry run..
| |
| 16200 (*(buffer->byte_length) == fixed_typed_array->DataSize())); | |
| 16201 // Initialize backing store at last to avoid handling of |JSArrayBuffers| that | |
| 16202 // are currently being constructed in the |ArrayBufferTracker|. The | |
| 16203 // registration method below handles the case of registering a buffer that has | |
| 16204 // already been promoted. | |
| 16194 buffer->set_backing_store(backing_store); | 16205 buffer->set_backing_store(backing_store); |
| 16195 buffer->set_is_external(false); | |
| 16196 isolate->heap()->RegisterNewArrayBuffer(*buffer); | 16206 isolate->heap()->RegisterNewArrayBuffer(*buffer); |
| 16197 memcpy(buffer->backing_store(), | 16207 memcpy(buffer->backing_store(), |
| 16198 fixed_typed_array->DataPtr(), | 16208 fixed_typed_array->DataPtr(), |
| 16199 fixed_typed_array->DataSize()); | 16209 fixed_typed_array->DataSize()); |
| 16200 Handle<FixedTypedArrayBase> new_elements = | 16210 Handle<FixedTypedArrayBase> new_elements = |
| 16201 isolate->factory()->NewFixedTypedArrayWithExternalPointer( | 16211 isolate->factory()->NewFixedTypedArrayWithExternalPointer( |
| 16202 fixed_typed_array->length(), typed_array->type(), | 16212 fixed_typed_array->length(), typed_array->type(), |
| 16203 static_cast<uint8_t*>(buffer->backing_store())); | 16213 static_cast<uint8_t*>(buffer->backing_store())); |
| 16204 | 16214 |
| 16205 typed_array->set_elements(*new_elements); | 16215 typed_array->set_elements(*new_elements); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16352 if (cell->value() != *new_value) { | 16362 if (cell->value() != *new_value) { |
| 16353 cell->set_value(*new_value); | 16363 cell->set_value(*new_value); |
| 16354 Isolate* isolate = cell->GetIsolate(); | 16364 Isolate* isolate = cell->GetIsolate(); |
| 16355 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16365 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 16356 isolate, DependentCode::kPropertyCellChangedGroup); | 16366 isolate, DependentCode::kPropertyCellChangedGroup); |
| 16357 } | 16367 } |
| 16358 } | 16368 } |
| 16359 | 16369 |
| 16360 } // namespace internal | 16370 } // namespace internal |
| 16361 } // namespace v8 | 16371 } // namespace v8 |
| OLD | NEW |