2011-09-19 18:36:47 +00:00
|
|
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2015-09-28 19:34:08 +00:00
|
|
|
#ifndef V8_PROFILER_PROFILE_GENERATOR_H_
|
|
|
|
#define V8_PROFILER_PROFILE_GENERATOR_H_
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2014-11-06 09:16:34 +00:00
|
|
|
#include <map>
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
2016-06-09 17:58:10 +00:00
|
|
|
#include "src/base/hashmap.h"
|
2016-08-26 07:37:21 +00:00
|
|
|
#include "src/log.h"
|
2015-10-01 18:10:58 +00:00
|
|
|
#include "src/profiler/strings-storage.h"
|
2016-08-31 08:49:14 +00:00
|
|
|
#include "src/source-position.h"
|
2010-03-15 14:11:19 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
2016-07-12 02:10:05 +00:00
|
|
|
namespace internal {
|
2016-07-06 18:37:10 +00:00
|
|
|
|
|
|
|
struct TickSample;
|
|
|
|
|
2014-11-06 09:16:34 +00:00
|
|
|
// Provides a mapping from the offsets within generated code to
|
|
|
|
// the source line.
|
|
|
|
class JITLineInfoTable : public Malloced {
|
|
|
|
public:
|
|
|
|
JITLineInfoTable();
|
|
|
|
~JITLineInfoTable();
|
|
|
|
|
|
|
|
void SetPosition(int pc_offset, int line);
|
|
|
|
int GetSourceLineNumber(int pc_offset) const;
|
|
|
|
|
|
|
|
bool empty() const { return pc_offset_map_.empty(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
// pc_offset -> source line
|
|
|
|
typedef std::map<int, int> PcOffsetMap;
|
|
|
|
PcOffsetMap pc_offset_map_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(JITLineInfoTable);
|
|
|
|
};
|
|
|
|
|
2015-03-24 12:46:13 +00:00
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
class CodeEntry {
|
|
|
|
public:
|
2010-03-19 09:46:53 +00:00
|
|
|
// CodeEntry doesn't own name strings, just references them.
|
2016-06-15 13:22:39 +00:00
|
|
|
inline CodeEntry(CodeEventListener::LogEventsAndTags tag, const char* name,
|
2013-07-01 10:12:03 +00:00
|
|
|
const char* name_prefix = CodeEntry::kEmptyNamePrefix,
|
2013-06-26 16:04:25 +00:00
|
|
|
const char* resource_name = CodeEntry::kEmptyResourceName,
|
2013-10-10 13:15:47 +00:00
|
|
|
int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
|
2014-11-06 09:16:34 +00:00
|
|
|
int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
|
|
|
|
JITLineInfoTable* line_info = NULL,
|
|
|
|
Address instruction_start = NULL);
|
2013-05-14 22:51:33 +00:00
|
|
|
~CodeEntry();
|
2010-04-06 10:36:38 +00:00
|
|
|
|
2013-10-14 08:57:46 +00:00
|
|
|
const char* name_prefix() const { return name_prefix_; }
|
|
|
|
bool has_name_prefix() const { return name_prefix_[0] != '\0'; }
|
|
|
|
const char* name() const { return name_; }
|
|
|
|
const char* resource_name() const { return resource_name_; }
|
|
|
|
int line_number() const { return line_number_; }
|
2013-10-10 13:15:47 +00:00
|
|
|
int column_number() const { return column_number_; }
|
2014-11-06 09:16:34 +00:00
|
|
|
const JITLineInfoTable* line_info() const { return line_info_; }
|
2013-10-14 08:57:46 +00:00
|
|
|
int script_id() const { return script_id_; }
|
|
|
|
void set_script_id(int script_id) { script_id_ = script_id; }
|
2015-02-20 13:28:42 +00:00
|
|
|
int position() const { return position_; }
|
|
|
|
void set_position(int position) { position_ = position; }
|
2013-10-14 08:57:46 +00:00
|
|
|
void set_bailout_reason(const char* bailout_reason) {
|
2013-09-05 13:20:51 +00:00
|
|
|
bailout_reason_ = bailout_reason;
|
|
|
|
}
|
2015-02-12 19:51:26 +00:00
|
|
|
const char* bailout_reason() const { return bailout_reason_; }
|
|
|
|
|
2016-11-22 10:14:36 +00:00
|
|
|
void set_deopt_info(const char* deopt_reason, int deopt_id) {
|
2016-07-19 08:22:04 +00:00
|
|
|
DCHECK(!has_deopt_info());
|
2015-02-10 14:32:42 +00:00
|
|
|
deopt_reason_ = deopt_reason;
|
2016-05-13 08:49:49 +00:00
|
|
|
deopt_id_ = deopt_id;
|
2015-02-12 19:51:26 +00:00
|
|
|
}
|
2015-04-08 16:13:24 +00:00
|
|
|
CpuProfileDeoptInfo GetDeoptInfo();
|
2016-07-19 08:22:04 +00:00
|
|
|
bool has_deopt_info() const { return deopt_id_ != kNoDeoptimizationId; }
|
2015-02-12 19:51:26 +00:00
|
|
|
void clear_deopt_info() {
|
|
|
|
deopt_reason_ = kNoDeoptReason;
|
2016-07-19 08:22:04 +00:00
|
|
|
deopt_id_ = kNoDeoptimizationId;
|
2015-02-10 14:32:42 +00:00
|
|
|
}
|
2010-04-06 10:36:38 +00:00
|
|
|
|
2015-02-20 13:28:42 +00:00
|
|
|
void FillFunctionInfo(SharedFunctionInfo* shared);
|
|
|
|
|
2013-07-02 07:51:09 +00:00
|
|
|
void SetBuiltinId(Builtins::Name id);
|
2014-11-05 12:40:56 +00:00
|
|
|
Builtins::Name builtin_id() const {
|
|
|
|
return BuiltinIdField::decode(bit_field_);
|
|
|
|
}
|
2013-07-02 07:51:09 +00:00
|
|
|
|
2015-02-20 13:28:42 +00:00
|
|
|
uint32_t GetHash() const;
|
|
|
|
bool IsSameFunctionAs(CodeEntry* entry) const;
|
2010-05-18 14:19:33 +00:00
|
|
|
|
2014-11-06 09:16:34 +00:00
|
|
|
int GetSourceLine(int pc_offset) const;
|
|
|
|
|
2016-11-22 10:14:36 +00:00
|
|
|
void AddInlineStack(int pc_offset, std::vector<CodeEntry*> inline_stack);
|
2016-03-01 05:59:32 +00:00
|
|
|
const std::vector<CodeEntry*>* GetInlineStack(int pc_offset) const;
|
|
|
|
|
2016-11-22 10:14:36 +00:00
|
|
|
void AddDeoptInlinedFrames(int deopt_id, std::vector<CpuProfileDeoptFrame>);
|
2016-05-13 08:49:49 +00:00
|
|
|
bool HasDeoptInlinedFramesFor(int deopt_id) const;
|
|
|
|
|
2014-11-06 09:16:34 +00:00
|
|
|
Address instruction_start() const { return instruction_start_; }
|
2016-06-15 13:22:39 +00:00
|
|
|
CodeEventListener::LogEventsAndTags tag() const {
|
|
|
|
return TagField::decode(bit_field_);
|
|
|
|
}
|
2014-11-06 09:16:34 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
static const char* const kEmptyNamePrefix;
|
2013-06-26 16:04:25 +00:00
|
|
|
static const char* const kEmptyResourceName;
|
2013-09-05 13:20:51 +00:00
|
|
|
static const char* const kEmptyBailoutReason;
|
2015-02-12 19:51:26 +00:00
|
|
|
static const char* const kNoDeoptReason;
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2016-06-22 16:43:46 +00:00
|
|
|
static const char* const kProgramEntryName;
|
|
|
|
static const char* const kIdleEntryName;
|
|
|
|
static const char* const kGarbageCollectorEntryName;
|
|
|
|
// Used to represent frames for which we have no reliable way to
|
|
|
|
// detect function.
|
|
|
|
static const char* const kUnresolvedFunctionName;
|
|
|
|
|
|
|
|
V8_INLINE static CodeEntry* program_entry() {
|
|
|
|
return kProgramEntry.Pointer();
|
|
|
|
}
|
|
|
|
V8_INLINE static CodeEntry* idle_entry() { return kIdleEntry.Pointer(); }
|
|
|
|
V8_INLINE static CodeEntry* gc_entry() { return kGCEntry.Pointer(); }
|
|
|
|
V8_INLINE static CodeEntry* unresolved_entry() {
|
|
|
|
return kUnresolvedEntry.Pointer();
|
|
|
|
}
|
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
private:
|
2016-06-22 16:43:46 +00:00
|
|
|
struct ProgramEntryCreateTrait {
|
|
|
|
static CodeEntry* Create();
|
|
|
|
};
|
|
|
|
struct IdleEntryCreateTrait {
|
|
|
|
static CodeEntry* Create();
|
|
|
|
};
|
|
|
|
struct GCEntryCreateTrait {
|
|
|
|
static CodeEntry* Create();
|
|
|
|
};
|
|
|
|
struct UnresolvedEntryCreateTrait {
|
|
|
|
static CodeEntry* Create();
|
|
|
|
};
|
|
|
|
|
|
|
|
static base::LazyDynamicInstance<CodeEntry, ProgramEntryCreateTrait>::type
|
|
|
|
kProgramEntry;
|
|
|
|
static base::LazyDynamicInstance<CodeEntry, IdleEntryCreateTrait>::type
|
|
|
|
kIdleEntry;
|
|
|
|
static base::LazyDynamicInstance<CodeEntry, GCEntryCreateTrait>::type
|
|
|
|
kGCEntry;
|
|
|
|
static base::LazyDynamicInstance<CodeEntry, UnresolvedEntryCreateTrait>::type
|
|
|
|
kUnresolvedEntry;
|
|
|
|
|
2014-11-05 12:40:56 +00:00
|
|
|
class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {};
|
2016-06-13 05:46:38 +00:00
|
|
|
class BuiltinIdField : public BitField<Builtins::Name, 8, 24> {};
|
2014-11-05 12:40:56 +00:00
|
|
|
|
|
|
|
uint32_t bit_field_;
|
2010-04-06 10:36:38 +00:00
|
|
|
const char* name_prefix_;
|
2010-03-15 14:11:19 +00:00
|
|
|
const char* name_;
|
|
|
|
const char* resource_name_;
|
|
|
|
int line_number_;
|
2013-10-10 13:15:47 +00:00
|
|
|
int column_number_;
|
2013-07-02 06:14:01 +00:00
|
|
|
int script_id_;
|
2015-02-20 13:28:42 +00:00
|
|
|
int position_;
|
2013-09-05 13:20:51 +00:00
|
|
|
const char* bailout_reason_;
|
2015-02-10 14:32:42 +00:00
|
|
|
const char* deopt_reason_;
|
2016-05-13 08:49:49 +00:00
|
|
|
int deopt_id_;
|
2014-11-06 09:16:34 +00:00
|
|
|
JITLineInfoTable* line_info_;
|
|
|
|
Address instruction_start_;
|
2016-03-01 05:59:32 +00:00
|
|
|
// Should be an unordered_map, but it doesn't currently work on Win & MacOS.
|
|
|
|
std::map<int, std::vector<CodeEntry*>> inline_locations_;
|
2016-11-22 10:14:36 +00:00
|
|
|
std::map<int, std::vector<CpuProfileDeoptFrame>> deopt_inlined_frames_;
|
2015-03-24 12:46:13 +00:00
|
|
|
|
2010-03-19 09:46:53 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CodeEntry);
|
2010-03-15 14:11:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-04-15 11:37:29 +00:00
|
|
|
class ProfileTree;
|
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
class ProfileNode {
|
|
|
|
public:
|
2016-10-06 18:14:03 +00:00
|
|
|
inline ProfileNode(ProfileTree* tree, CodeEntry* entry, ProfileNode* parent);
|
2010-03-15 14:11:19 +00:00
|
|
|
|
|
|
|
ProfileNode* FindChild(CodeEntry* entry);
|
|
|
|
ProfileNode* FindOrAddChild(CodeEntry* entry);
|
2013-10-14 08:57:46 +00:00
|
|
|
void IncrementSelfTicks() { ++self_ticks_; }
|
|
|
|
void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; }
|
2014-11-06 09:16:34 +00:00
|
|
|
void IncrementLineTicks(int src_line);
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2013-10-14 08:57:46 +00:00
|
|
|
CodeEntry* entry() const { return entry_; }
|
|
|
|
unsigned self_ticks() const { return self_ticks_; }
|
2017-08-29 12:40:31 +00:00
|
|
|
const std::vector<ProfileNode*>* children() const { return &children_list_; }
|
2013-04-02 07:48:25 +00:00
|
|
|
unsigned id() const { return id_; }
|
2015-02-20 13:28:42 +00:00
|
|
|
unsigned function_id() const;
|
2016-10-06 18:14:03 +00:00
|
|
|
ProfileNode* parent() const { return parent_; }
|
2014-11-06 09:16:34 +00:00
|
|
|
unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); }
|
|
|
|
bool GetLineTicks(v8::CpuProfileNode::LineTick* entries,
|
|
|
|
unsigned int length) const;
|
2015-02-12 19:51:26 +00:00
|
|
|
void CollectDeoptInfo(CodeEntry* entry);
|
2015-04-08 16:13:24 +00:00
|
|
|
const std::vector<CpuProfileDeoptInfo>& deopt_infos() const {
|
|
|
|
return deopt_infos_;
|
|
|
|
}
|
2015-11-30 08:16:35 +00:00
|
|
|
Isolate* isolate() const;
|
2010-03-15 14:11:19 +00:00
|
|
|
|
|
|
|
void Print(int indent);
|
|
|
|
|
2013-10-14 08:57:46 +00:00
|
|
|
static bool CodeEntriesMatch(void* entry1, void* entry2) {
|
2015-02-20 13:28:42 +00:00
|
|
|
return reinterpret_cast<CodeEntry*>(entry1)
|
|
|
|
->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2));
|
2010-03-15 14:11:19 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 13:28:42 +00:00
|
|
|
private:
|
|
|
|
static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); }
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2014-11-06 09:16:34 +00:00
|
|
|
static bool LineTickMatch(void* a, void* b) { return a == b; }
|
|
|
|
|
2010-04-15 11:37:29 +00:00
|
|
|
ProfileTree* tree_;
|
2010-03-15 14:11:19 +00:00
|
|
|
CodeEntry* entry_;
|
|
|
|
unsigned self_ticks_;
|
2010-07-15 13:21:50 +00:00
|
|
|
// Mapping from CodeEntry* to ProfileNode*
|
2016-09-30 16:16:47 +00:00
|
|
|
base::CustomMatcherHashMap children_;
|
2017-08-29 12:40:31 +00:00
|
|
|
std::vector<ProfileNode*> children_list_;
|
2016-10-06 18:14:03 +00:00
|
|
|
ProfileNode* parent_;
|
2013-04-02 07:48:25 +00:00
|
|
|
unsigned id_;
|
2016-09-30 16:16:47 +00:00
|
|
|
base::CustomMatcherHashMap line_ticks_;
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2015-04-08 16:13:24 +00:00
|
|
|
std::vector<CpuProfileDeoptInfo> deopt_infos_;
|
2015-03-24 12:46:13 +00:00
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(ProfileNode);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-03-30 11:38:39 +00:00
|
|
|
class ProfileTree {
|
2010-03-15 14:11:19 +00:00
|
|
|
public:
|
2015-11-30 08:16:35 +00:00
|
|
|
explicit ProfileTree(Isolate* isolate);
|
2010-03-15 14:11:19 +00:00
|
|
|
~ProfileTree();
|
|
|
|
|
2014-11-06 09:16:34 +00:00
|
|
|
ProfileNode* AddPathFromEnd(
|
2016-03-01 05:59:32 +00:00
|
|
|
const std::vector<CodeEntry*>& path,
|
2016-01-26 20:47:23 +00:00
|
|
|
int src_line = v8::CpuProfileNode::kNoLineNumberInfo,
|
|
|
|
bool update_stats = true);
|
2010-03-30 11:38:39 +00:00
|
|
|
ProfileNode* root() const { return root_; }
|
2013-04-02 07:48:25 +00:00
|
|
|
unsigned next_node_id() { return next_node_id_++; }
|
2015-02-20 13:28:42 +00:00
|
|
|
unsigned GetFunctionId(const ProfileNode* node);
|
2013-04-02 07:48:25 +00:00
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
void Print() {
|
|
|
|
root_->Print(0);
|
|
|
|
}
|
|
|
|
|
2015-11-30 08:16:35 +00:00
|
|
|
Isolate* isolate() const { return isolate_; }
|
|
|
|
|
2016-10-06 18:14:03 +00:00
|
|
|
void EnqueueNode(const ProfileNode* node) { pending_nodes_.push_back(node); }
|
|
|
|
size_t pending_nodes_count() const { return pending_nodes_.size(); }
|
|
|
|
std::vector<const ProfileNode*> TakePendingNodes() {
|
|
|
|
return std::move(pending_nodes_);
|
|
|
|
}
|
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
private:
|
|
|
|
template <typename Callback>
|
2010-05-18 14:19:33 +00:00
|
|
|
void TraverseDepthFirst(Callback* callback);
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2016-10-06 18:14:03 +00:00
|
|
|
std::vector<const ProfileNode*> pending_nodes_;
|
|
|
|
|
2010-04-06 14:54:20 +00:00
|
|
|
CodeEntry root_entry_;
|
2013-04-02 07:48:25 +00:00
|
|
|
unsigned next_node_id_;
|
2010-03-15 14:11:19 +00:00
|
|
|
ProfileNode* root_;
|
2015-11-30 08:16:35 +00:00
|
|
|
Isolate* isolate_;
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2015-02-20 13:28:42 +00:00
|
|
|
unsigned next_function_id_;
|
2016-09-30 16:16:47 +00:00
|
|
|
base::CustomMatcherHashMap function_ids_;
|
2015-02-20 13:28:42 +00:00
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(ProfileTree);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-03-19 09:46:53 +00:00
|
|
|
class CpuProfile {
|
2010-03-15 14:11:19 +00:00
|
|
|
public:
|
2016-06-15 09:59:00 +00:00
|
|
|
CpuProfile(CpuProfiler* profiler, const char* title, bool record_samples);
|
2010-03-30 11:38:39 +00:00
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
// Add pc -> ... -> main() call path to the profile.
|
2016-03-01 05:59:32 +00:00
|
|
|
void AddPath(base::TimeTicks timestamp, const std::vector<CodeEntry*>& path,
|
2016-01-26 20:47:23 +00:00
|
|
|
int src_line, bool update_stats);
|
2016-10-06 18:14:03 +00:00
|
|
|
void FinishProfile();
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2013-08-05 07:17:08 +00:00
|
|
|
const char* title() const { return title_; }
|
|
|
|
const ProfileTree* top_down() const { return &top_down_; }
|
2010-03-19 09:46:53 +00:00
|
|
|
|
2013-08-05 07:17:08 +00:00
|
|
|
int samples_count() const { return samples_.length(); }
|
|
|
|
ProfileNode* sample(int index) const { return samples_.at(index); }
|
2014-06-30 13:25:46 +00:00
|
|
|
base::TimeTicks sample_timestamp(int index) const {
|
|
|
|
return timestamps_.at(index);
|
|
|
|
}
|
2013-08-05 07:17:08 +00:00
|
|
|
|
2014-06-30 13:25:46 +00:00
|
|
|
base::TimeTicks start_time() const { return start_time_; }
|
|
|
|
base::TimeTicks end_time() const { return end_time_; }
|
2016-06-15 09:59:00 +00:00
|
|
|
CpuProfiler* cpu_profiler() const { return profiler_; }
|
2013-04-02 07:48:25 +00:00
|
|
|
|
2010-04-15 11:37:29 +00:00
|
|
|
void UpdateTicksScale();
|
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
void Print();
|
|
|
|
|
|
|
|
private:
|
2016-10-06 18:14:03 +00:00
|
|
|
void StreamPendingTraceEvents();
|
|
|
|
|
2010-03-30 11:38:39 +00:00
|
|
|
const char* title_;
|
2013-04-02 07:48:25 +00:00
|
|
|
bool record_samples_;
|
2014-06-30 13:25:46 +00:00
|
|
|
base::TimeTicks start_time_;
|
|
|
|
base::TimeTicks end_time_;
|
2013-04-02 07:48:25 +00:00
|
|
|
List<ProfileNode*> samples_;
|
2014-06-30 13:25:46 +00:00
|
|
|
List<base::TimeTicks> timestamps_;
|
2010-03-15 14:11:19 +00:00
|
|
|
ProfileTree top_down_;
|
2016-06-15 09:59:00 +00:00
|
|
|
CpuProfiler* const profiler_;
|
2016-10-06 18:14:03 +00:00
|
|
|
int streaming_next_sample_;
|
2010-03-15 14:11:19 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CpuProfile);
|
|
|
|
};
|
|
|
|
|
2010-03-30 11:38:39 +00:00
|
|
|
class CodeMap {
|
2010-03-15 14:11:19 +00:00
|
|
|
public:
|
2015-02-20 13:28:42 +00:00
|
|
|
CodeMap() {}
|
2016-06-10 16:37:49 +00:00
|
|
|
|
2011-09-14 11:47:03 +00:00
|
|
|
void AddCode(Address addr, CodeEntry* entry, unsigned size);
|
|
|
|
void MoveCode(Address from, Address to);
|
2015-09-11 16:29:55 +00:00
|
|
|
CodeEntry* FindEntry(Address addr);
|
2010-03-30 11:38:39 +00:00
|
|
|
void Print();
|
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
private:
|
|
|
|
struct CodeEntryInfo {
|
|
|
|
CodeEntryInfo(CodeEntry* an_entry, unsigned a_size)
|
|
|
|
: entry(an_entry), size(a_size) { }
|
|
|
|
CodeEntry* entry;
|
|
|
|
unsigned size;
|
|
|
|
};
|
|
|
|
|
2011-09-14 11:47:03 +00:00
|
|
|
void DeleteAllCoveredCode(Address start, Address end);
|
|
|
|
|
2016-06-10 16:37:49 +00:00
|
|
|
std::map<Address, CodeEntryInfo> code_map_;
|
2010-03-15 14:11:19 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CodeMap);
|
|
|
|
};
|
|
|
|
|
2010-03-19 09:46:53 +00:00
|
|
|
class CpuProfilesCollection {
|
2010-03-15 14:11:19 +00:00
|
|
|
public:
|
2016-06-15 09:59:00 +00:00
|
|
|
explicit CpuProfilesCollection(Isolate* isolate);
|
2010-03-19 09:46:53 +00:00
|
|
|
~CpuProfilesCollection();
|
|
|
|
|
2016-06-15 09:59:00 +00:00
|
|
|
void set_cpu_profiler(CpuProfiler* profiler) { profiler_ = profiler; }
|
2013-12-18 08:59:09 +00:00
|
|
|
bool StartProfiling(const char* title, bool record_samples);
|
2013-07-30 07:01:16 +00:00
|
|
|
CpuProfile* StopProfiling(const char* title);
|
2013-07-06 09:12:09 +00:00
|
|
|
List<CpuProfile*>* profiles() { return &finished_profiles_; }
|
2016-06-22 16:43:46 +00:00
|
|
|
const char* GetName(Name* name) { return resource_names_.GetName(name); }
|
2010-08-10 12:06:42 +00:00
|
|
|
bool IsLastProfile(const char* title);
|
2011-03-22 16:10:01 +00:00
|
|
|
void RemoveProfile(CpuProfile* profile);
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2010-03-30 11:38:39 +00:00
|
|
|
// Called from profile generator thread.
|
2014-11-06 09:16:34 +00:00
|
|
|
void AddPathToCurrentProfiles(base::TimeTicks timestamp,
|
2016-03-01 05:59:32 +00:00
|
|
|
const std::vector<CodeEntry*>& path,
|
|
|
|
int src_line, bool update_stats);
|
2010-03-30 11:38:39 +00:00
|
|
|
|
2010-08-31 14:16:01 +00:00
|
|
|
// Limits the number of profiles that can be simultaneously collected.
|
|
|
|
static const int kMaxSimultaneousProfiles = 100;
|
|
|
|
|
2010-03-15 14:11:19 +00:00
|
|
|
private:
|
2016-06-22 16:43:46 +00:00
|
|
|
StringsStorage resource_names_;
|
2013-07-06 09:12:09 +00:00
|
|
|
List<CpuProfile*> finished_profiles_;
|
2016-06-15 09:59:00 +00:00
|
|
|
CpuProfiler* profiler_;
|
2015-11-30 08:16:35 +00:00
|
|
|
|
2010-03-30 11:38:39 +00:00
|
|
|
// Accessed by VM thread and profile generator thread.
|
|
|
|
List<CpuProfile*> current_profiles_;
|
2014-06-30 13:25:46 +00:00
|
|
|
base::Semaphore current_profiles_semaphore_;
|
2010-03-19 09:46:53 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ProfileGenerator {
|
|
|
|
public:
|
2017-01-27 01:12:53 +00:00
|
|
|
explicit ProfileGenerator(CpuProfilesCollection* profiles);
|
2010-03-19 09:46:53 +00:00
|
|
|
|
|
|
|
void RecordTickSample(const TickSample& sample);
|
|
|
|
|
2013-10-14 08:57:46 +00:00
|
|
|
CodeMap* code_map() { return &code_map_; }
|
2010-03-19 09:46:53 +00:00
|
|
|
|
|
|
|
private:
|
2016-10-28 20:17:44 +00:00
|
|
|
CodeEntry* FindEntry(void* address);
|
2013-10-14 08:57:46 +00:00
|
|
|
CodeEntry* EntryForVMState(StateTag tag);
|
2010-04-07 14:18:26 +00:00
|
|
|
|
2010-03-19 09:46:53 +00:00
|
|
|
CpuProfilesCollection* profiles_;
|
2010-03-15 14:11:19 +00:00
|
|
|
CodeMap code_map_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
|
|
|
|
};
|
|
|
|
|
2010-06-11 16:34:59 +00:00
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2010-03-15 14:11:19 +00:00
|
|
|
|
2015-09-28 19:34:08 +00:00
|
|
|
#endif // V8_PROFILER_PROFILE_GENERATOR_H_
|