cpu-profiler-inl.h 2.05 KB
Newer Older
1
// Copyright 2010 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_PROFILER_CPU_PROFILER_INL_H_
#define V8_PROFILER_CPU_PROFILER_INL_H_
7

8
#include "src/profiler/cpu-profiler.h"
9

10
#include <new>
11 12 13
#include "src/profiler/circular-queue-inl.h"
#include "src/profiler/profile-generator-inl.h"
#include "src/profiler/unbound-queue-inl.h"
14 15 16 17

namespace v8 {
namespace internal {

18
void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) {
19
  code_map->AddCode(instruction_start, entry, instruction_size);
20 21 22 23
}


void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) {
24
  code_map->MoveCode(from_instruction_start, to_instruction_start);
25 26 27
}


28
void CodeDisableOptEventRecord::UpdateCodeMap(CodeMap* code_map) {
29
  CodeEntry* entry = code_map->FindEntry(instruction_start);
30
  if (entry != nullptr) {
31 32 33 34 35
    entry->set_bailout_reason(bailout_reason);
  }
}


36
void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) {
37
  CodeEntry* entry = code_map->FindEntry(instruction_start);
38 39 40 41 42
  if (entry == nullptr) return;
  std::vector<CpuProfileDeoptFrame> frames_vector(
      deopt_frames, deopt_frames + deopt_frame_count);
  entry->set_deopt_info(deopt_reason, deopt_id, std::move(frames_vector));
  delete[] deopt_frames;
43 44 45
}


46
void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
47
  CodeEntry* entry = code_map->FindEntry(instruction_start);
48 49 50 51 52 53 54 55
  if (!entry) {
    // Code objects for builtins should already have been added to the map but
    // some of them have been filtered out by CpuProfiler.
    return;
  }
  entry->SetBuiltinId(builtin_id);
}

56
TickSample* SamplingEventsProcessor::StartTickSample() {
57
  void* address = ticks_buffer_.StartEnqueue();
58
  if (address == nullptr) return nullptr;
59
  TickSampleEventRecord* evt =
Hannes Payer's avatar
Hannes Payer committed
60
      new (address) TickSampleEventRecord(last_code_event_id_);
61
  return &evt->sample;
62 63
}

64
void SamplingEventsProcessor::FinishTickSample() {
65 66 67
  ticks_buffer_.FinishEnqueue();
}

68 69
}  // namespace internal
}  // namespace v8
70

71
#endif  // V8_PROFILER_CPU_PROFILER_INL_H_