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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/factory.h" | 8 #include "src/factory.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } else { | 60 } else { |
61 data = NULL; | 61 data = NULL; |
62 } | 62 } |
63 | 63 |
64 SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length, | 64 SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length, |
65 shared); | 65 shared); |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 void Runtime::NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer) { | |
71 array_buffer->Neuter(); | |
72 } | |
73 | |
74 | |
75 RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) { | 70 RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) { |
76 HandleScope scope(isolate); | 71 HandleScope scope(isolate); |
77 DCHECK(args.length() == 3); | 72 DCHECK(args.length() == 3); |
78 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); | 73 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); |
79 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); | 74 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); |
80 CONVERT_BOOLEAN_ARG_CHECKED(is_shared, 2); | 75 CONVERT_BOOLEAN_ARG_CHECKED(is_shared, 2); |
81 if (!holder->byte_length()->IsUndefined()) { | 76 if (!holder->byte_length()->IsUndefined()) { |
82 // ArrayBuffer is already initialized; probably a fuzz test. | 77 // ArrayBuffer is already initialized; probably a fuzz test. |
83 return *holder; | 78 return *holder; |
84 } | 79 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 if (array_buffer->backing_store() == NULL) { | 138 if (array_buffer->backing_store() == NULL) { |
144 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); | 139 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); |
145 return isolate->heap()->undefined_value(); | 140 return isolate->heap()->undefined_value(); |
146 } | 141 } |
147 // Shared array buffers should never be neutered. | 142 // Shared array buffers should never be neutered. |
148 RUNTIME_ASSERT(!array_buffer->is_shared()); | 143 RUNTIME_ASSERT(!array_buffer->is_shared()); |
149 DCHECK(!array_buffer->is_external()); | 144 DCHECK(!array_buffer->is_external()); |
150 void* backing_store = array_buffer->backing_store(); | 145 void* backing_store = array_buffer->backing_store(); |
151 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); | 146 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); |
152 array_buffer->set_is_external(true); | 147 array_buffer->set_is_external(true); |
153 Runtime::NeuterArrayBuffer(array_buffer); | 148 array_buffer->Neuter(); |
154 isolate->heap()->UnregisterArrayBuffer( | 149 isolate->heap()->UnregisterArrayBuffer( |
155 isolate->heap()->InNewSpace(*array_buffer), backing_store); | 150 isolate->heap()->InNewSpace(*array_buffer), backing_store); |
156 isolate->array_buffer_allocator()->Free(backing_store, byte_length); | 151 isolate->array_buffer_allocator()->Free(backing_store, byte_length); |
157 return isolate->heap()->undefined_value(); | 152 return isolate->heap()->undefined_value(); |
158 } | 153 } |
159 | 154 |
160 | 155 |
161 void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type, | 156 void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type, |
162 ElementsKind* fixed_elements_kind, | 157 ElementsKind* fixed_elements_kind, |
163 size_t* element_size) { | 158 size_t* element_size) { |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 DATA_VIEW_SETTER(Uint16, uint16_t) | 735 DATA_VIEW_SETTER(Uint16, uint16_t) |
741 DATA_VIEW_SETTER(Int16, int16_t) | 736 DATA_VIEW_SETTER(Int16, int16_t) |
742 DATA_VIEW_SETTER(Uint32, uint32_t) | 737 DATA_VIEW_SETTER(Uint32, uint32_t) |
743 DATA_VIEW_SETTER(Int32, int32_t) | 738 DATA_VIEW_SETTER(Int32, int32_t) |
744 DATA_VIEW_SETTER(Float32, float) | 739 DATA_VIEW_SETTER(Float32, float) |
745 DATA_VIEW_SETTER(Float64, double) | 740 DATA_VIEW_SETTER(Float64, double) |
746 | 741 |
747 #undef DATA_VIEW_SETTER | 742 #undef DATA_VIEW_SETTER |
748 } // namespace internal | 743 } // namespace internal |
749 } // namespace v8 | 744 } // namespace v8 |
OLD | NEW |