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

Side by Side Diff: src/objects.cc

Issue 2792623002: Track large array buffer allocations. (Closed)
Patch Set: 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
« src/counters.h ('K') | « 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 template <class T>
19469 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
19470 int count = 0;
19471 T base = 0;
19472 while (value > base) {
19473 ++count;
19474 value >>= 1;
19475 }
19476 return count;
19477 }
19478
19479 } // namespace
19466 19480
19467 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, 19481 bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
19468 Isolate* isolate, 19482 Isolate* isolate,
19469 size_t allocated_length, 19483 size_t allocated_length,
19470 bool initialize, SharedFlag shared) { 19484 bool initialize, SharedFlag shared) {
19471 void* data; 19485 void* data;
19472 CHECK(isolate->array_buffer_allocator() != NULL); 19486 CHECK(isolate->array_buffer_allocator() != NULL);
19473 // Prevent creating array buffers when serializing. 19487 // Prevent creating array buffers when serializing.
19474 DCHECK(!isolate->serializer_enabled()); 19488 DCHECK(!isolate->serializer_enabled());
19475 if (allocated_length != 0) { 19489 if (allocated_length != 0) {
19490 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
19491 if (allocated_length >= MinBigAllocation)
19492 isolate->counters()->big_array_buffer_allocations()->AddSample(
19493 log2Value(allocated_length));
19476 if (initialize) { 19494 if (initialize) {
19477 data = isolate->array_buffer_allocator()->Allocate(allocated_length); 19495 data = isolate->array_buffer_allocator()->Allocate(allocated_length);
19478 } else { 19496 } else {
19479 data = isolate->array_buffer_allocator()->AllocateUninitialized( 19497 data = isolate->array_buffer_allocator()->AllocateUninitialized(
19480 allocated_length); 19498 allocated_length);
19481 } 19499 }
19482 if (data == NULL) return false; 19500 if (data == NULL) return false;
19483 } else { 19501 } else {
19484 data = NULL; 19502 data = NULL;
19485 } 19503 }
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
20409 // depend on this. 20427 // depend on this.
20410 return DICTIONARY_ELEMENTS; 20428 return DICTIONARY_ELEMENTS;
20411 } 20429 }
20412 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20430 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20413 return kind; 20431 return kind;
20414 } 20432 }
20415 } 20433 }
20416 20434
20417 } // namespace internal 20435 } // namespace internal
20418 } // namespace v8 20436 } // namespace v8
OLDNEW
« src/counters.h ('K') | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698