Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index fe386ae12723afe650cdeae7ecefed1753a18ea8..1df792d4435caf5623e08e1b01e91f04f63e2d01 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -19463,6 +19463,20 @@ void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate, |
| } |
| } |
| +namespace { |
| + |
| +template <class T> |
| +int log2Value(T value) { |
|
bbudge
2017/03/31 19:01:18
Rather than roll your own, you could use the funct
kschimpf
2017/03/31 19:31:52
Thanks for the pointer. I agree that I shouldn't r
|
| + int count = 0; |
| + T base = 0; |
| + while (value > base) { |
| + ++count; |
| + value >>= 1; |
| + } |
| + return count; |
| +} |
| + |
| +} // namespace |
| bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
| Isolate* isolate, |
| @@ -19473,6 +19487,10 @@ bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
| // Prevent creating array buffers when serializing. |
| DCHECK(!isolate->serializer_enabled()); |
| if (allocated_length != 0) { |
| + constexpr size_t MinBigAllocation = 1 << 20; |
|
bbudge
2017/03/31 19:01:18
nit: convention is to prefix 'k' to constants
kschimpf
2017/03/31 19:31:52
Good point. I suffer from spending too many years
|
| + if (allocated_length >= MinBigAllocation) |
| + isolate->counters()->big_array_buffer_allocations()->AddSample( |
| + log2Value(allocated_length)); |
| if (initialize) { |
| data = isolate->array_buffer_allocator()->Allocate(allocated_length); |
| } else { |