Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: src/runtime/runtime-typedarray.cc

Issue 1177293003: Reland "Keep track of array buffers in new space separately" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
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 Handle<Object> byte_length = 31 Handle<Object> byte_length =
32 isolate->factory()->NewNumberFromSize(allocated_length); 32 isolate->factory()->NewNumberFromSize(allocated_length);
33 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); 33 CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
34 array_buffer->set_byte_length(*byte_length); 34 array_buffer->set_byte_length(*byte_length);
35 35
36 if (data && !is_external) { 36 if (data && !is_external) {
37 isolate->heap()->RegisterNewArrayBuffer(data, allocated_length); 37 isolate->heap()->RegisterNewArrayBuffer(
38 isolate->heap()->InNewSpace(*array_buffer), data, allocated_length);
38 } 39 }
39 } 40 }
40 41
41 42
42 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate, 43 bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate,
43 Handle<JSArrayBuffer> array_buffer, 44 Handle<JSArrayBuffer> array_buffer,
44 size_t allocated_length, 45 size_t allocated_length,
45 bool initialize, 46 bool initialize,
46 SharedFlag shared) { 47 SharedFlag shared) {
47 void* data; 48 void* data;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); 144 CHECK(Smi::FromInt(0) == array_buffer->byte_length());
144 return isolate->heap()->undefined_value(); 145 return isolate->heap()->undefined_value();
145 } 146 }
146 // Shared array buffers should never be neutered. 147 // Shared array buffers should never be neutered.
147 RUNTIME_ASSERT(!array_buffer->is_shared()); 148 RUNTIME_ASSERT(!array_buffer->is_shared());
148 DCHECK(!array_buffer->is_external()); 149 DCHECK(!array_buffer->is_external());
149 void* backing_store = array_buffer->backing_store(); 150 void* backing_store = array_buffer->backing_store();
150 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); 151 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
151 array_buffer->set_is_external(true); 152 array_buffer->set_is_external(true);
152 Runtime::NeuterArrayBuffer(array_buffer); 153 Runtime::NeuterArrayBuffer(array_buffer);
153 isolate->heap()->UnregisterArrayBuffer(backing_store); 154 isolate->heap()->UnregisterArrayBuffer(
155 isolate->heap()->InNewSpace(*array_buffer), backing_store);
154 isolate->array_buffer_allocator()->Free(backing_store, byte_length); 156 isolate->array_buffer_allocator()->Free(backing_store, byte_length);
155 return isolate->heap()->undefined_value(); 157 return isolate->heap()->undefined_value();
156 } 158 }
157 159
158 160
159 void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type, 161 void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type,
160 ElementsKind* external_elements_kind, 162 ElementsKind* external_elements_kind,
161 ElementsKind* fixed_elements_kind, 163 ElementsKind* fixed_elements_kind,
162 size_t* element_size) { 164 size_t* element_size) {
163 switch (arrayId) { 165 switch (arrayId) {
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 DATA_VIEW_SETTER(Uint16, uint16_t) 749 DATA_VIEW_SETTER(Uint16, uint16_t)
748 DATA_VIEW_SETTER(Int16, int16_t) 750 DATA_VIEW_SETTER(Int16, int16_t)
749 DATA_VIEW_SETTER(Uint32, uint32_t) 751 DATA_VIEW_SETTER(Uint32, uint32_t)
750 DATA_VIEW_SETTER(Int32, int32_t) 752 DATA_VIEW_SETTER(Int32, int32_t)
751 DATA_VIEW_SETTER(Float32, float) 753 DATA_VIEW_SETTER(Float32, float)
752 DATA_VIEW_SETTER(Float64, double) 754 DATA_VIEW_SETTER(Float64, double)
753 755
754 #undef DATA_VIEW_SETTER 756 #undef DATA_VIEW_SETTER
755 } // namespace internal 757 } // namespace internal
756 } // namespace v8 758 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698