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

Side by Side Diff: src/profiler/sampling-heap-profiler.cc

Issue 1702023002: [wasm] Replace the BufferedRawMachineAssemblerTester in the WasmRunner. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code cleanup. Created 4 years, 10 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 | « no previous file | test/cctest/compiler/c-signature.h » ('j') | 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/profiler/sampling-heap-profiler.h" 5 #include "src/profiler/sampling-heap-profiler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <memory> 8 #include <memory>
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
11 #include "src/frames-inl.h" 11 #include "src/frames-inl.h"
12 #include "src/heap/heap.h" 12 #include "src/heap/heap.h"
13 #include "src/isolate.h" 13 #include "src/isolate.h"
14 #include "src/profiler/strings-storage.h" 14 #include "src/profiler/strings-storage.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 18
19 // We sample with a Poisson process, with constant average sampling interval. 19 // We sample with a Poisson process, with constant average sampling interval.
20 // This follows the exponential probability distribution with parameter 20 // This follows the exponential probability distribution with parameter
21 // λ = 1/rate where rate is the average number of bytes between samples. 21 // λ = 1/rate where rate is the average number of bytes between samples.
22 // 22 //
23 // Let u be a uniformly distributed random number between 0 and 1, then 23 // Let u be a uniformly distributed random number between 0 and 1, then
24 // next_sample = (- ln u) / λ 24 // next_sample = (- ln u) / λ
25 intptr_t SamplingAllocationObserver::GetNextSampleInterval(uint64_t rate) { 25 intptr_t SamplingAllocationObserver::GetNextSampleInterval(uint64_t rate) {
26 if (FLAG_sampling_heap_profiler_suppress_randomness) { 26 if (FLAG_sampling_heap_profiler_suppress_randomness) {
27 return rate; 27 return static_cast<intptr_t>(rate);
28 } 28 }
29 double u = random_->NextDouble(); 29 double u = random_->NextDouble();
30 double next = (-std::log(u)) * rate; 30 double next = (-std::log(u)) * rate;
31 return next < kPointerSize 31 return next < kPointerSize
32 ? kPointerSize 32 ? kPointerSize
33 : (next > INT_MAX ? INT_MAX : static_cast<intptr_t>(next)); 33 : (next > INT_MAX ? INT_MAX : static_cast<intptr_t>(next));
34 } 34 }
35 35
36 SamplingHeapProfiler::SamplingHeapProfiler(Heap* heap, StringsStorage* names, 36 SamplingHeapProfiler::SamplingHeapProfiler(Heap* heap, StringsStorage* names,
37 uint64_t rate, int stack_depth) 37 uint64_t rate, int stack_depth)
38 : isolate_(heap->isolate()), 38 : isolate_(heap->isolate()),
39 heap_(heap), 39 heap_(heap),
40 new_space_observer_(new SamplingAllocationObserver( 40 new_space_observer_(new SamplingAllocationObserver(
41 heap_, rate, rate, this, heap->isolate()->random_number_generator())), 41 heap_, static_cast<intptr_t>(rate), rate, this,
42 heap->isolate()->random_number_generator())),
42 other_spaces_observer_(new SamplingAllocationObserver( 43 other_spaces_observer_(new SamplingAllocationObserver(
43 heap_, rate, rate, this, heap->isolate()->random_number_generator())), 44 heap_, static_cast<intptr_t>(rate), rate, this,
45 heap->isolate()->random_number_generator())),
44 names_(names), 46 names_(names),
45 samples_(), 47 samples_(),
46 stack_depth_(stack_depth) { 48 stack_depth_(stack_depth) {
47 heap->new_space()->AddAllocationObserver(new_space_observer_.get()); 49 heap->new_space()->AddAllocationObserver(new_space_observer_.get());
48 AllSpaces spaces(heap); 50 AllSpaces spaces(heap);
49 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { 51 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) {
50 if (space != heap->new_space()) { 52 if (space != heap->new_space()) {
51 space->AddAllocationObserver(other_spaces_observer_.get()); 53 space->AddAllocationObserver(other_spaces_observer_.get());
52 } 54 }
53 } 55 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 AddStack(profile, scripts, allocation->get_stack()); 248 AddStack(profile, scripts, allocation->get_stack());
247 node->allocations.push_back({allocation->get_size(), 1}); 249 node->allocations.push_back({allocation->get_size(), 1});
248 } 250 }
249 251
250 return profile; 252 return profile;
251 } 253 }
252 254
253 255
254 } // namespace internal 256 } // namespace internal
255 } // namespace v8 257 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/compiler/c-signature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698