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 : #include "src/profiler/unbound-queue-inl.h"
14 :
15 : namespace v8 {
16 : namespace internal {
17 :
18 : void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) {
19 665218 : code_map->AddCode(instruction_start, entry, instruction_size);
20 : }
21 :
22 :
23 : void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
24 5 : code_map->MoveCode(from_instruction_start, to_instruction_start);
25 : }
26 :
27 :
28 : void CodeDisableOptEventRecord::UpdateCodeMap(CodeMap* code_map) {
29 0 : CodeEntry* entry = code_map->FindEntry(instruction_start);
30 0 : if (entry != nullptr) {
31 0 : entry->set_bailout_reason(bailout_reason);
32 : }
33 : }
34 :
35 :
36 : void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) {
37 0 : CodeEntry* entry = code_map->FindEntry(instruction_start);
38 0 : if (entry == nullptr) return;
39 : std::vector<CpuProfileDeoptFrame> frames_vector(
40 0 : deopt_frames, deopt_frames + deopt_frame_count);
41 0 : entry->set_deopt_info(deopt_reason, deopt_id, std::move(frames_vector));
42 0 : delete[] deopt_frames;
43 : }
44 :
45 :
46 : void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
47 1122652 : CodeEntry* entry = code_map->FindEntry(instruction_start);
48 1122632 : if (!entry) {
49 : // Code objects for builtins should already have been added to the map but
50 : // some of them have been filtered out by CpuProfiler.
51 : return;
52 : }
53 26593 : entry->SetBuiltinId(builtin_id);
54 : }
55 :
56 27002 : TickSample* SamplingEventsProcessor::StartTickSample() {
57 27002 : void* address = ticks_buffer_.StartEnqueue();
58 27002 : if (address == nullptr) return nullptr;
59 : TickSampleEventRecord* evt =
60 27002 : new (address) TickSampleEventRecord(last_code_event_id_);
61 27002 : return &evt->sample;
62 : }
63 :
64 : void SamplingEventsProcessor::FinishTickSample() {
65 27002 : ticks_buffer_.FinishEnqueue();
66 : }
67 :
68 : } // namespace internal
69 : } // namespace v8
70 :
71 : #endif // V8_PROFILER_CPU_PROFILER_INL_H_
|