Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/objects.cc

Issue 2795763002: Collect array buffer allocation sizes for UMA in megabytes. (Closed)
Patch Set: Fix name of convertToMG. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19445 matching lines...) Expand 10 before | Expand all | Expand 10 after
19456 // are currently being constructed in the |ArrayBufferTracker|. The 19456 // are currently being constructed in the |ArrayBufferTracker|. The
19457 // registration method below handles the case of registering a buffer that has 19457 // registration method below handles the case of registering a buffer that has
19458 // already been promoted. 19458 // already been promoted.
19459 array_buffer->set_backing_store(data); 19459 array_buffer->set_backing_store(data);
19460 19460
19461 if (data && !is_external) { 19461 if (data && !is_external) {
19462 isolate->heap()->RegisterNewArrayBuffer(*array_buffer); 19462 isolate->heap()->RegisterNewArrayBuffer(*array_buffer);
19463 } 19463 }
19464 } 19464 }
19465 19465
19466 namespace {
19467
19468 inline int ConvertToMb(size_t size) {
19469 return static_cast<int>(size / static_cast<size_t>(MB));
19470 }
19471
19472 } // namespace
19466 19473
19467 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, 19474 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
19468 Isolate* isolate, 19475 Isolate* isolate,
19469 size_t allocated_length, 19476 size_t allocated_length,
19470 bool initialize, SharedFlag shared) { 19477 bool initialize, SharedFlag shared) {
19471 void* data; 19478 void* data;
19472 CHECK(isolate->array_buffer_allocator() != NULL); 19479 CHECK(isolate->array_buffer_allocator() != NULL);
19473 // Prevent creating array buffers when serializing. 19480 // Prevent creating array buffers when serializing.
19474 DCHECK(!isolate->serializer_enabled()); 19481 DCHECK(!isolate->serializer_enabled());
19475 if (allocated_length != 0) { 19482 if (allocated_length != 0) {
19476 constexpr size_t kMinBigAllocation = 1 << 20; 19483 isolate->counters()->array_buffer_big_allocations()->AddSample(
19477 if (allocated_length >= kMinBigAllocation) { 19484 ConvertToMb(allocated_length));
19478 isolate->counters()->array_buffer_big_allocations()->AddSample(
19479 sizeof(uint64_t) * kBitsPerByte -
19480 base::bits::CountLeadingZeros64(allocated_length));
19481 }
19482 if (initialize) { 19485 if (initialize) {
19483 data = isolate->array_buffer_allocator()->Allocate(allocated_length); 19486 data = isolate->array_buffer_allocator()->Allocate(allocated_length);
19484 } else { 19487 } else {
19485 data = isolate->array_buffer_allocator()->AllocateUninitialized( 19488 data = isolate->array_buffer_allocator()->AllocateUninitialized(
19486 allocated_length); 19489 allocated_length);
19487 } 19490 }
19488 if (data == NULL) { 19491 if (data == NULL) {
19489 isolate->counters()->array_buffer_new_size_failures()->AddSample( 19492 isolate->counters()->array_buffer_new_size_failures()->AddSample(
19490 sizeof(uint64_t) * kBitsPerByte - 19493 ConvertToMb(allocated_length));
19491 base::bits::CountLeadingZeros64(allocated_length));
19492 return false; 19494 return false;
19493 } 19495 }
19494 } else { 19496 } else {
19495 data = NULL; 19497 data = NULL;
19496 } 19498 }
19497 19499
19498 JSArrayBuffer::Setup(array_buffer, isolate, false, data, allocated_length, 19500 JSArrayBuffer::Setup(array_buffer, isolate, false, data, allocated_length,
19499 shared); 19501 shared);
19500 return true; 19502 return true;
19501 } 19503 }
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
20420 // depend on this. 20422 // depend on this.
20421 return DICTIONARY_ELEMENTS; 20423 return DICTIONARY_ELEMENTS;
20422 } 20424 }
20423 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20425 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20424 return kind; 20426 return kind;
20425 } 20427 }
20426 } 20428 }
20427 20429
20428 } // namespace internal 20430 } // namespace internal
20429 } // namespace v8 20431 } // namespace v8
OLDNEW
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698