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

Side by Side Diff: src/bootstrapper.cc

Issue 1110603005: Remove support for malloc'd typed arrays (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 7 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 | « samples/process.cc ('k') | src/d8.cc » ('j') | 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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 #undef INSTALL_NATIVE_FUNCTIONS_FOR 1596 #undef INSTALL_NATIVE_FUNCTIONS_FOR
1597 } 1597 }
1598 1598
1599 1599
1600 template <typename Data> 1600 template <typename Data>
1601 Data* SetBuiltinTypedArray(Isolate* isolate, Handle<JSBuiltinsObject> builtins, 1601 Data* SetBuiltinTypedArray(Isolate* isolate, Handle<JSBuiltinsObject> builtins,
1602 ExternalArrayType type, Data* data, 1602 ExternalArrayType type, Data* data,
1603 size_t num_elements, const char* name) { 1603 size_t num_elements, const char* name) {
1604 size_t byte_length = num_elements * sizeof(*data); 1604 size_t byte_length = num_elements * sizeof(*data);
1605 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); 1605 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
1606 bool should_be_freed = false; 1606 bool is_external = data != nullptr;
1607 if (data == NULL) { 1607 if (!is_external) {
1608 data = reinterpret_cast<Data*>(malloc(byte_length)); 1608 data = reinterpret_cast<Data*>(
1609 should_be_freed = true; 1609 V8::ArrayBufferAllocator()->Allocate(byte_length));
1610 } 1610 }
1611 Runtime::SetupArrayBuffer(isolate, buffer, true, data, byte_length); 1611 Runtime::SetupArrayBuffer(isolate, buffer, is_external, data, byte_length);
1612 buffer->set_should_be_freed(should_be_freed);
1613 1612
1614 Handle<JSTypedArray> typed_array = 1613 Handle<JSTypedArray> typed_array =
1615 isolate->factory()->NewJSTypedArray(type, buffer, 0, num_elements); 1614 isolate->factory()->NewJSTypedArray(type, buffer, 0, num_elements);
1616 Handle<String> name_string = isolate->factory()->InternalizeUtf8String(name); 1615 Handle<String> name_string = isolate->factory()->InternalizeUtf8String(name);
1617 // Reset property cell type before (re)initializing. 1616 // Reset property cell type before (re)initializing.
1618 JSBuiltinsObject::InvalidatePropertyCell(builtins, name_string); 1617 JSBuiltinsObject::InvalidatePropertyCell(builtins, name_string);
1619 JSObject::SetOwnPropertyIgnoreAttributes(builtins, name_string, typed_array, 1618 JSObject::SetOwnPropertyIgnoreAttributes(builtins, name_string, typed_array,
1620 DONT_DELETE).Assert(); 1619 DONT_DELETE).Assert();
1621 return data; 1620 return data;
1622 } 1621 }
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 return from + sizeof(NestingCounterType); 2959 return from + sizeof(NestingCounterType);
2961 } 2960 }
2962 2961
2963 2962
2964 // Called when the top-level V8 mutex is destroyed. 2963 // Called when the top-level V8 mutex is destroyed.
2965 void Bootstrapper::FreeThreadResources() { 2964 void Bootstrapper::FreeThreadResources() {
2966 DCHECK(!IsActive()); 2965 DCHECK(!IsActive());
2967 } 2966 }
2968 2967
2969 } } // namespace v8::internal 2968 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « samples/process.cc ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698