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 19455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19466 | 19466 |
19467 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, | 19467 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
19468 Isolate* isolate, | 19468 Isolate* isolate, |
19469 size_t allocated_length, | 19469 size_t allocated_length, |
19470 bool initialize, SharedFlag shared) { | 19470 bool initialize, SharedFlag shared) { |
19471 void* data; | 19471 void* data; |
19472 CHECK(isolate->array_buffer_allocator() != NULL); | 19472 CHECK(isolate->array_buffer_allocator() != NULL); |
19473 // Prevent creating array buffers when serializing. | 19473 // Prevent creating array buffers when serializing. |
19474 DCHECK(!isolate->serializer_enabled()); | 19474 DCHECK(!isolate->serializer_enabled()); |
19475 if (allocated_length != 0) { | 19475 if (allocated_length != 0) { |
19476 constexpr size_t kMinBigAllocation = 1 << 20; | |
19477 if (allocated_length >= kMinBigAllocation) { | |
19478 isolate->counters()->array_buffer_big_allocations()->AddSample( | |
19479 static_cast<int>( | |
19480 sizeof(size_t) == 32 | |
19481 ? (32 - base::bits::CountLeadingZeros32(allocated_length)) | |
19482 : (64 - base::bits::CountLeadingZeros64(allocated_length)))); | |
bbudge
2017/03/31 20:52:28
You could also just do:
sizeof(uint64_t) * kBitsP
Mircea Trofin
2017/03/31 21:01:38
The pointer sizes are something that may be fishab
kschimpf
2017/03/31 21:11:02
The recommendation is NOT to use value 0 in UMA hi
kschimpf
2017/03/31 21:11:02
size_t is the number of bytes. Using uint64_t, as
| |
19483 } | |
19476 if (initialize) { | 19484 if (initialize) { |
19477 data = isolate->array_buffer_allocator()->Allocate(allocated_length); | 19485 data = isolate->array_buffer_allocator()->Allocate(allocated_length); |
19478 } else { | 19486 } else { |
19479 data = isolate->array_buffer_allocator()->AllocateUninitialized( | 19487 data = isolate->array_buffer_allocator()->AllocateUninitialized( |
19480 allocated_length); | 19488 allocated_length); |
19481 } | 19489 } |
19482 if (data == NULL) return false; | 19490 if (data == NULL) return false; |
19483 } else { | 19491 } else { |
19484 data = NULL; | 19492 data = NULL; |
19485 } | 19493 } |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20409 // depend on this. | 20417 // depend on this. |
20410 return DICTIONARY_ELEMENTS; | 20418 return DICTIONARY_ELEMENTS; |
20411 } | 20419 } |
20412 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20420 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20413 return kind; | 20421 return kind; |
20414 } | 20422 } |
20415 } | 20423 } |
20416 | 20424 |
20417 } // namespace internal | 20425 } // namespace internal |
20418 } // namespace v8 | 20426 } // namespace v8 |
OLD | NEW |