• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 //     * Redistributions of source code must retain the above copyright
7 //       notice, this list of conditions and the following disclaimer.
8 //     * Redistributions in binary form must reproduce the above
9 //       copyright notice, this list of conditions and the following
10 //       disclaimer in the documentation and/or other materials provided
11 //       with the distribution.
12 //     * Neither the name of Google Inc. nor the names of its
13 //       contributors may be used to endorse or promote products derived
14 //       from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_CPU_PROFILER_INL_H_
29 #define V8_CPU_PROFILER_INL_H_
30 
31 #include "cpu-profiler.h"
32 
33 #ifdef ENABLE_LOGGING_AND_PROFILING
34 
35 #include "circular-queue-inl.h"
36 #include "profile-generator-inl.h"
37 #include "unbound-queue-inl.h"
38 
39 namespace v8 {
40 namespace internal {
41 
UpdateCodeMap(CodeMap * code_map)42 void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) {
43   code_map->AddCode(start, entry, size);
44   if (shared != NULL) {
45     entry->set_shared_id(code_map->GetSharedId(shared));
46   }
47 }
48 
49 
UpdateCodeMap(CodeMap * code_map)50 void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
51   code_map->MoveCode(from, to);
52 }
53 
54 
UpdateCodeMap(CodeMap * code_map)55 void CodeDeleteEventRecord::UpdateCodeMap(CodeMap* code_map) {
56   code_map->DeleteCode(start);
57 }
58 
59 
UpdateCodeMap(CodeMap * code_map)60 void SharedFunctionInfoMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
61   code_map->MoveCode(from, to);
62 }
63 
64 
init(void * value)65 TickSampleEventRecord* TickSampleEventRecord::init(void* value) {
66   TickSampleEventRecord* result =
67       reinterpret_cast<TickSampleEventRecord*>(value);
68   result->filler = 1;
69   ASSERT(result->filler != SamplingCircularQueue::kClear);
70   // Init the required fields only.
71   result->sample.pc = NULL;
72   result->sample.frames_count = 0;
73   result->sample.has_external_callback = false;
74   return result;
75 }
76 
77 
TickSampleEvent()78 TickSample* ProfilerEventsProcessor::TickSampleEvent() {
79   generator_->Tick();
80   TickSampleEventRecord* evt =
81       TickSampleEventRecord::init(ticks_buffer_.Enqueue());
82   evt->order = enqueue_order_;  // No increment!
83   return &evt->sample;
84 }
85 
86 
FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)87 bool ProfilerEventsProcessor::FilterOutCodeCreateEvent(
88     Logger::LogEventsAndTags tag) {
89   return FLAG_prof_browser_mode
90       && (tag != Logger::CALLBACK_TAG
91           && tag != Logger::FUNCTION_TAG
92           && tag != Logger::LAZY_COMPILE_TAG
93           && tag != Logger::REG_EXP_TAG
94           && tag != Logger::SCRIPT_TAG);
95 }
96 
97 } }  // namespace v8::internal
98 
99 #endif  // ENABLE_LOGGING_AND_PROFILING
100 
101 #endif  // V8_CPU_PROFILER_INL_H_
102