blob: c63a9c3cc251dd4805a14b122db20fb5fae0de9f [file] [log] [blame]
Steve Block6ded16b2010-05-10 14:33:55 +01001// Copyright 2010 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Block6ded16b2010-05-10 14:33:55 +01004
5#ifndef V8_CPU_PROFILER_INL_H_
6#define V8_CPU_PROFILER_INL_H_
7
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/cpu-profiler.h"
Steve Block6ded16b2010-05-10 14:33:55 +01009
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000010#include <new>
Ben Murdochb8a8cc12014-11-26 15:28:44 +000011#include "src/circular-queue-inl.h"
12#include "src/profile-generator-inl.h"
13#include "src/unbound-queue-inl.h"
Steve Block6ded16b2010-05-10 14:33:55 +010014
15namespace v8 {
16namespace internal {
17
18void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) {
19 code_map->AddCode(start, entry, size);
Steve Block44f0eee2011-05-26 01:26:41 +010020 if (shared != NULL) {
21 entry->set_shared_id(code_map->GetSharedId(shared));
Ben Murdoche0cee9b2011-05-25 10:26:03 +010022 }
Steve Block6ded16b2010-05-10 14:33:55 +010023}
24
25
26void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
27 code_map->MoveCode(from, to);
28}
29
30
Ben Murdochb8a8cc12014-11-26 15:28:44 +000031void 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
Steve Block44f0eee2011-05-26 01:26:41 +010039void SharedFunctionInfoMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
Ben Murdoche0cee9b2011-05-25 10:26:03 +010040 code_map->MoveCode(from, to);
Steve Block6ded16b2010-05-10 14:33:55 +010041}
42
43
Ben Murdochb8a8cc12014-11-26 15:28:44 +000044void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
45 CodeEntry* entry = code_map->FindEntry(start);
46 if (!entry) {
47 // Code objects for builtins should already have been added to the map but
48 // some of them have been filtered out by CpuProfiler.
49 return;
50 }
51 entry->SetBuiltinId(builtin_id);
52}
53
54
55TickSample* CpuProfiler::StartTickSample() {
56 if (is_profiling_) return processor_->StartTickSample();
57 return NULL;
58}
59
60
61void CpuProfiler::FinishTickSample() {
62 processor_->FinishTickSample();
63}
64
65
66TickSample* ProfilerEventsProcessor::StartTickSample() {
67 void* address = ticks_buffer_.StartEnqueue();
68 if (address == NULL) return NULL;
Steve Block6ded16b2010-05-10 14:33:55 +010069 TickSampleEventRecord* evt =
Ben Murdochb8a8cc12014-11-26 15:28:44 +000070 new(address) TickSampleEventRecord(last_code_event_id_);
Steve Block6ded16b2010-05-10 14:33:55 +010071 return &evt->sample;
72}
73
74
Ben Murdochb8a8cc12014-11-26 15:28:44 +000075void ProfilerEventsProcessor::FinishTickSample() {
76 ticks_buffer_.FinishEnqueue();
Steve Block6ded16b2010-05-10 14:33:55 +010077}
78
79} } // namespace v8::internal
80
Steve Block6ded16b2010-05-10 14:33:55 +010081#endif // V8_CPU_PROFILER_INL_H_