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/runtime/runtime.h" | 8 #include "src/runtime/runtime.h" |
9 #include "src/runtime/runtime-utils.h" | 9 #include "src/runtime/runtime-utils.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 array_buffer->set_backing_store(data); | 44 array_buffer->set_backing_store(data); |
45 array_buffer->set_flag(Smi::FromInt(0)); | 45 array_buffer->set_flag(Smi::FromInt(0)); |
46 array_buffer->set_is_external(is_external); | 46 array_buffer->set_is_external(is_external); |
47 array_buffer->set_is_neuterable(true); | 47 array_buffer->set_is_neuterable(true); |
48 | 48 |
49 Handle<Object> byte_length = | 49 Handle<Object> byte_length = |
50 isolate->factory()->NewNumberFromSize(allocated_length); | 50 isolate->factory()->NewNumberFromSize(allocated_length); |
51 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); | 51 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); |
52 array_buffer->set_byte_length(*byte_length); | 52 array_buffer->set_byte_length(*byte_length); |
53 | 53 |
54 array_buffer->set_weak_next(isolate->heap()->array_buffers_list()); | 54 if (isolate->heap()->InNewSpace(*array_buffer) || |
55 CHECK(isolate->heap()->InNewSpace(*array_buffer)); | 55 isolate->heap()->array_buffers_list()->IsUndefined()) { |
56 isolate->heap()->set_array_buffers_list(*array_buffer); | 56 array_buffer->set_weak_next(isolate->heap()->array_buffers_list()); |
| 57 isolate->heap()->set_array_buffers_list(*array_buffer); |
| 58 if (isolate->heap()->last_array_buffer_in_list()->IsUndefined()) { |
| 59 isolate->heap()->set_last_array_buffer_in_list(*array_buffer); |
| 60 } |
| 61 } else { |
| 62 JSArrayBuffer::cast(isolate->heap()->last_array_buffer_in_list()) |
| 63 ->set_weak_next(*array_buffer); |
| 64 isolate->heap()->set_last_array_buffer_in_list(*array_buffer); |
| 65 } |
57 array_buffer->set_weak_first_view(isolate->heap()->undefined_value()); | 66 array_buffer->set_weak_first_view(isolate->heap()->undefined_value()); |
58 } | 67 } |
59 | 68 |
60 | 69 |
61 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate, | 70 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate, |
62 Handle<JSArrayBuffer> array_buffer, | 71 Handle<JSArrayBuffer> array_buffer, |
63 size_t allocated_length, | 72 size_t allocated_length, |
64 bool initialize) { | 73 bool initialize) { |
65 void* data; | 74 void* data; |
66 CHECK(V8::ArrayBufferAllocator() != NULL); | 75 CHECK(V8::ArrayBufferAllocator() != NULL); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 DATA_VIEW_SETTER(Uint16, uint16_t) | 811 DATA_VIEW_SETTER(Uint16, uint16_t) |
803 DATA_VIEW_SETTER(Int16, int16_t) | 812 DATA_VIEW_SETTER(Int16, int16_t) |
804 DATA_VIEW_SETTER(Uint32, uint32_t) | 813 DATA_VIEW_SETTER(Uint32, uint32_t) |
805 DATA_VIEW_SETTER(Int32, int32_t) | 814 DATA_VIEW_SETTER(Int32, int32_t) |
806 DATA_VIEW_SETTER(Float32, float) | 815 DATA_VIEW_SETTER(Float32, float) |
807 DATA_VIEW_SETTER(Float64, double) | 816 DATA_VIEW_SETTER(Float64, double) |
808 | 817 |
809 #undef DATA_VIEW_SETTER | 818 #undef DATA_VIEW_SETTER |
810 } | 819 } |
811 } // namespace v8::internal | 820 } // namespace v8::internal |
OLD | NEW |