Home | History | Annotate | Download | only in profiler
      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   code_map->AddCode(start, entry, size);
     20 }
     21 
     22 
     23 void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
     24   code_map->MoveCode(from, to);
     25 }
     26 
     27 
     28 void CodeDisableOptEventRecord::UpdateCodeMap(CodeMap* code_map) {
     29   CodeEntry* entry = code_map->FindEntry(start);
     30   if (entry != NULL) {
     31     entry->set_bailout_reason(bailout_reason);
     32   }
     33 }
     34 
     35 
     36 void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) {
     37   CodeEntry* entry = code_map->FindEntry(start);
     38   if (entry != NULL) entry->set_deopt_info(deopt_reason, deopt_id);
     39 }
     40 
     41 
     42 void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
     43   CodeEntry* entry = code_map->FindEntry(start);
     44   if (!entry) {
     45     // Code objects for builtins should already have been added to the map but
     46     // some of them have been filtered out by CpuProfiler.
     47     return;
     48   }
     49   entry->SetBuiltinId(builtin_id);
     50 }
     51 
     52 
     53 TickSample* ProfilerEventsProcessor::StartTickSample() {
     54   void* address = ticks_buffer_.StartEnqueue();
     55   if (address == NULL) return NULL;
     56   TickSampleEventRecord* evt =
     57       new (address) TickSampleEventRecord(last_code_event_id_.Value());
     58   return &evt->sample;
     59 }
     60 
     61 
     62 void ProfilerEventsProcessor::FinishTickSample() {
     63   ticks_buffer_.FinishEnqueue();
     64 }
     65 
     66 }  // namespace internal
     67 }  // namespace v8
     68 
     69 #endif  // V8_PROFILER_CPU_PROFILER_INL_H_
     70