OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 19704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19715 | 19715 |
19716 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, | 19716 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
19717 Isolate* isolate, | 19717 Isolate* isolate, |
19718 size_t allocated_length, | 19718 size_t allocated_length, |
19719 bool initialize, SharedFlag shared) { | 19719 bool initialize, SharedFlag shared) { |
19720 void* data; | 19720 void* data; |
19721 CHECK(isolate->array_buffer_allocator() != NULL); | 19721 CHECK(isolate->array_buffer_allocator() != NULL); |
19722 // Prevent creating array buffers when serializing. | 19722 // Prevent creating array buffers when serializing. |
19723 DCHECK(!isolate->serializer_enabled()); | 19723 DCHECK(!isolate->serializer_enabled()); |
19724 if (allocated_length != 0) { | 19724 if (allocated_length != 0) { |
19725 isolate->counters()->array_buffer_big_allocations()->AddSample( | 19725 if (allocated_length >= MB) |
19726 ConvertToMb(allocated_length)); | 19726 isolate->counters()->array_buffer_big_allocations()->AddSample( |
| 19727 ConvertToMb(allocated_length)); |
19727 if (initialize) { | 19728 if (initialize) { |
19728 data = isolate->array_buffer_allocator()->Allocate(allocated_length); | 19729 data = isolate->array_buffer_allocator()->Allocate(allocated_length); |
19729 } else { | 19730 } else { |
19730 data = isolate->array_buffer_allocator()->AllocateUninitialized( | 19731 data = isolate->array_buffer_allocator()->AllocateUninitialized( |
19731 allocated_length); | 19732 allocated_length); |
19732 } | 19733 } |
19733 if (data == NULL) { | 19734 if (data == NULL) { |
19734 isolate->counters()->array_buffer_new_size_failures()->AddSample( | 19735 isolate->counters()->array_buffer_new_size_failures()->AddSample( |
19735 ConvertToMb(allocated_length)); | 19736 ConvertToMb(allocated_length)); |
19736 return false; | 19737 return false; |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20659 // depend on this. | 20660 // depend on this. |
20660 return DICTIONARY_ELEMENTS; | 20661 return DICTIONARY_ELEMENTS; |
20661 } | 20662 } |
20662 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20663 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20663 return kind; | 20664 return kind; |
20664 } | 20665 } |
20665 } | 20666 } |
20666 | 20667 |
20667 } // namespace internal | 20668 } // namespace internal |
20668 } // namespace v8 | 20669 } // namespace v8 |
OLD | NEW |