Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / 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 "cpu-profiler.h"
9
10 #include <new>
11 #include "circular-queue-inl.h"
12 #include "profile-generator-inl.h"
13 #include "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 SharedFunctionInfoMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
32   code_map->MoveCode(from, to);
33 }
34
35
36 void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
37   CodeEntry* entry = code_map->FindEntry(start);
38   if (!entry) {
39     // Code objects for builtins should already have been added to the map but
40     // some of them have been filtered out by CpuProfiler.
41     return;
42   }
43   entry->SetBuiltinId(builtin_id);
44 }
45
46
47 TickSample* CpuProfiler::StartTickSample() {
48   if (is_profiling_) return processor_->StartTickSample();
49   return NULL;
50 }
51
52
53 void CpuProfiler::FinishTickSample() {
54   processor_->FinishTickSample();
55 }
56
57
58 TickSample* ProfilerEventsProcessor::StartTickSample() {
59   void* address = ticks_buffer_.StartEnqueue();
60   if (address == NULL) return NULL;
61   TickSampleEventRecord* evt =
62       new(address) TickSampleEventRecord(last_code_event_id_);
63   return &evt->sample;
64 }
65
66
67 void ProfilerEventsProcessor::FinishTickSample() {
68   ticks_buffer_.FinishEnqueue();
69 }
70
71 } }  // namespace v8::internal
72
73 #endif  // V8_CPU_PROFILER_INL_H_