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; | 19476 isolate->counters()->array_buffer_big_allocations()->Add(allocated_length); |
19477 if (allocated_length >= kMinBigAllocation) { | |
19478 isolate->counters()->array_buffer_big_allocations()->AddSample( | |
19479 sizeof(uint64_t) * kBitsPerByte - | |
19480 base::bits::CountLeadingZeros64(allocated_length)); | |
19481 } | |
19482 if (initialize) { | 19477 if (initialize) { |
19483 data = isolate->array_buffer_allocator()->Allocate(allocated_length); | 19478 data = isolate->array_buffer_allocator()->Allocate(allocated_length); |
19484 } else { | 19479 } else { |
19485 data = isolate->array_buffer_allocator()->AllocateUninitialized( | 19480 data = isolate->array_buffer_allocator()->AllocateUninitialized( |
19486 allocated_length); | 19481 allocated_length); |
19487 } | 19482 } |
19488 if (data == NULL) { | 19483 if (data == NULL) { |
19489 isolate->counters()->array_buffer_new_size_failures()->AddSample( | 19484 isolate->counters()->array_buffer_new_size_failures()->Add( |
19490 sizeof(uint64_t) * kBitsPerByte - | 19485 allocated_length); |
19491 base::bits::CountLeadingZeros64(allocated_length)); | |
19492 return false; | 19486 return false; |
19493 } | 19487 } |
19494 } else { | 19488 } else { |
19495 data = NULL; | 19489 data = NULL; |
19496 } | 19490 } |
19497 | 19491 |
19498 JSArrayBuffer::Setup(array_buffer, isolate, false, data, allocated_length, | 19492 JSArrayBuffer::Setup(array_buffer, isolate, false, data, allocated_length, |
19499 shared); | 19493 shared); |
19500 return true; | 19494 return true; |
19501 } | 19495 } |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20420 // depend on this. | 20414 // depend on this. |
20421 return DICTIONARY_ELEMENTS; | 20415 return DICTIONARY_ELEMENTS; |
20422 } | 20416 } |
20423 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20417 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20424 return kind; | 20418 return kind; |
20425 } | 20419 } |
20426 } | 20420 } |
20427 | 20421 |
20428 } // namespace internal | 20422 } // namespace internal |
20429 } // namespace v8 | 20423 } // namespace v8 |
OLD | NEW |