Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 2901840af92fbe0b1cd995ba1129a4cb4024befa..957fe771b4a020bbeb08e477a68acacedc0b117e 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -19463,6 +19463,13 @@ void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate, |
| } |
| } |
| +namespace { |
| + |
| +inline int convertToMb(size_t size) { |
|
bbudge
2017/04/03 23:11:40
nit: ConvertToMb (first letter upper case for free
kschimpf
2017/04/04 17:00:01
Done.
|
| + return static_cast<int>(size / static_cast<size_t>(MB)); |
| +} |
| + |
| +} // namespace |
| bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
| Isolate* isolate, |
| @@ -19473,12 +19480,8 @@ bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
| // Prevent creating array buffers when serializing. |
| DCHECK(!isolate->serializer_enabled()); |
| if (allocated_length != 0) { |
| - constexpr size_t kMinBigAllocation = 1 << 20; |
| - if (allocated_length >= kMinBigAllocation) { |
| - isolate->counters()->array_buffer_big_allocations()->AddSample( |
| - sizeof(uint64_t) * kBitsPerByte - |
| - base::bits::CountLeadingZeros64(allocated_length)); |
| - } |
| + isolate->counters()->array_buffer_big_allocations()->AddSample( |
| + convertToMb(allocated_length)); |
| if (initialize) { |
| data = isolate->array_buffer_allocator()->Allocate(allocated_length); |
| } else { |
| @@ -19487,8 +19490,7 @@ bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
| } |
| if (data == NULL) { |
| isolate->counters()->array_buffer_new_size_failures()->AddSample( |
| - sizeof(uint64_t) * kBitsPerByte - |
| - base::bits::CountLeadingZeros64(allocated_length)); |
| + convertToMb(allocated_length)); |
| return false; |
| } |
| } else { |