0320ed5a79d0ac28472050f8972e738e4cadfec5
[platform/upstream/nodejs.git] / deps / v8 / src / cpu-profiler-inl.h
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_CPU_PROFILER_INL_H_
6 #define V8_CPU_PROFILER_INL_H_
7
8 #include "src/cpu-profiler.h"
9
10 #include <new>
11 #include "src/circular-queue-inl.h"
12 #include "src/profile-generator-inl.h"
13 #include "src/unbound-queue-inl.h"
14
15 namespace v8 {
16 namespace internal {
17
18 void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) {
19   code_map->AddCode(start, entry, size);
20   if (shared != NULL) {
21     entry->set_shared_id(code_map->GetSharedId(shared));
22   }
23 }
24
25
26 void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
27   code_map->MoveCode(from, to);
28 }
29
30
31 void CodeDisableOptEventRecord::UpdateCodeMap(CodeMap* code_map) {
32   CodeEntry* entry = code_map->FindEntry(start);
33   if (entry != NULL) {
34     entry->set_bailout_reason(bailout_reason);
35   }
36 }
37
38
39 void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) {
40   CodeEntry* entry = code_map->FindEntry(start);
41   if (entry != NULL) entry->set_deopt_info(deopt_reason, raw_position);
42 }
43
44
45 void SharedFunctionInfoMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
46   code_map->MoveCode(from, to);
47 }
48
49
50 void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
51   CodeEntry* entry = code_map->FindEntry(start);
52   if (!entry) {
53     // Code objects for builtins should already have been added to the map but
54     // some of them have been filtered out by CpuProfiler.
55     return;
56   }
57   entry->SetBuiltinId(builtin_id);
58 }
59
60
61 TickSample* CpuProfiler::StartTickSample() {
62   if (is_profiling_) return processor_->StartTickSample();
63   return NULL;
64 }
65
66
67 void CpuProfiler::FinishTickSample() {
68   processor_->FinishTickSample();
69 }
70
71
72 TickSample* ProfilerEventsProcessor::StartTickSample() {
73   void* address = ticks_buffer_.StartEnqueue();
74   if (address == NULL) return NULL;
75   TickSampleEventRecord* evt =
76       new(address) TickSampleEventRecord(last_code_event_id_);
77   return &evt->sample;
78 }
79
80
81 void ProfilerEventsProcessor::FinishTickSample() {
82   ticks_buffer_.FinishEnqueue();
83 }
84
85 } }  // namespace v8::internal
86
87 #endif  // V8_CPU_PROFILER_INL_H_