Line data Source code
1 : // Copyright 2010 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_PROFILER_CPU_PROFILER_INL_H_
6 : #define V8_PROFILER_CPU_PROFILER_INL_H_
7 :
8 : #include "src/profiler/cpu-profiler.h"
9 :
10 : #include <new>
11 : #include "src/profiler/circular-queue-inl.h"
12 : #include "src/profiler/profile-generator-inl.h"
13 :
14 : namespace v8 {
15 : namespace internal {
16 :
17 : void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) {
18 663877 : code_map->AddCode(instruction_start, entry, instruction_size);
19 : }
20 :
21 :
22 : void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
23 5 : code_map->MoveCode(from_instruction_start, to_instruction_start);
24 : }
25 :
26 :
27 : void CodeDisableOptEventRecord::UpdateCodeMap(CodeMap* code_map) {
28 0 : CodeEntry* entry = code_map->FindEntry(instruction_start);
29 0 : if (entry != nullptr) {
30 0 : entry->set_bailout_reason(bailout_reason);
31 : }
32 : }
33 :
34 :
35 : void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) {
36 6 : CodeEntry* entry = code_map->FindEntry(instruction_start);
37 6 : if (entry == nullptr) return;
38 : std::vector<CpuProfileDeoptFrame> frames_vector(
39 12 : deopt_frames, deopt_frames + deopt_frame_count);
40 6 : entry->set_deopt_info(deopt_reason, deopt_id, std::move(frames_vector));
41 6 : delete[] deopt_frames;
42 : }
43 :
44 :
45 : void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
46 1161286 : CodeEntry* entry = code_map->FindEntry(instruction_start);
47 1161286 : if (!entry) {
48 : // Code objects for builtins should already have been added to the map but
49 : // some of them have been filtered out by CpuProfiler.
50 : return;
51 : }
52 26888 : entry->SetBuiltinId(builtin_id);
53 : }
54 :
55 63078 : TickSample* SamplingEventsProcessor::StartTickSample() {
56 63078 : void* address = ticks_buffer_.StartEnqueue();
57 63078 : if (address == nullptr) return nullptr;
58 : TickSampleEventRecord* evt =
59 63078 : new (address) TickSampleEventRecord(last_code_event_id_);
60 63078 : return &evt->sample;
61 : }
62 :
63 : void SamplingEventsProcessor::FinishTickSample() {
64 : ticks_buffer_.FinishEnqueue();
65 : }
66 :
67 : } // namespace internal
68 : } // namespace v8
69 :
70 : #endif // V8_PROFILER_CPU_PROFILER_INL_H_
|