diff options
Diffstat (limited to 'deps/v8/src/profiler/profile-generator.h')
-rw-r--r-- | deps/v8/src/profiler/profile-generator.h | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/deps/v8/src/profiler/profile-generator.h b/deps/v8/src/profiler/profile-generator.h index ac9506ab21..ebb4f0ea2c 100644 --- a/deps/v8/src/profiler/profile-generator.h +++ b/deps/v8/src/profiler/profile-generator.h @@ -16,7 +16,8 @@ #include "include/v8-profiler.h" #include "src/allocation.h" -#include "src/log.h" +#include "src/builtins/builtins.h" +#include "src/code-events.h" #include "src/profiler/strings-storage.h" #include "src/source-position.h" @@ -26,29 +27,35 @@ namespace internal { struct TickSample; // Provides a mapping from the offsets within generated code or a bytecode array -// to the source line. +// to the source line and inlining id. class SourcePositionTable : public Malloced { public: SourcePositionTable() = default; - void SetPosition(int pc_offset, int line); + void SetPosition(int pc_offset, int line, int inlining_id); int GetSourceLineNumber(int pc_offset) const; + int GetInliningId(int pc_offset) const; + + void print() const; private: - struct PCOffsetAndLineNumber { - bool operator<(const PCOffsetAndLineNumber& other) const { + struct SourcePositionTuple { + bool operator<(const SourcePositionTuple& other) const { return pc_offset < other.pc_offset; } int pc_offset; int line_number; + int inlining_id; }; - // This is logically a map, but we store it as a vector of pairs, sorted by + // This is logically a map, but we store it as a vector of tuples, sorted by // the pc offset, so that we can save space and look up items using binary // search. - std::vector<PCOffsetAndLineNumber> pc_offsets_to_lines_; + std::vector<SourcePositionTuple> pc_offsets_to_lines_; DISALLOW_COPY_AND_ASSIGN(SourcePositionTable); }; +struct CodeEntryAndLineNumber; + class CodeEntry { public: // CodeEntry doesn't own name strings, just references them. @@ -91,7 +98,7 @@ class CodeEntry { void mark_used() { bit_field_ = UsedField::update(bit_field_, true); } bool used() const { return UsedField::decode(bit_field_); } - void FillFunctionInfo(SharedFunctionInfo* shared); + void FillFunctionInfo(SharedFunctionInfo shared); void SetBuiltinId(Builtins::Name id); Builtins::Name builtin_id() const { @@ -103,9 +110,24 @@ class CodeEntry { int GetSourceLine(int pc_offset) const; - void AddInlineStack(int pc_offset, - std::vector<std::unique_ptr<CodeEntry>> inline_stack); - const std::vector<std::unique_ptr<CodeEntry>>* GetInlineStack( + struct Equals { + bool operator()(const std::unique_ptr<CodeEntry>& lhs, + const std::unique_ptr<CodeEntry>& rhs) const { + return lhs.get()->IsSameFunctionAs(rhs.get()); + } + }; + struct Hasher { + std::size_t operator()(const std::unique_ptr<CodeEntry>& e) const { + return e->GetHash(); + } + }; + + void SetInlineStacks( + std::unordered_set<std::unique_ptr<CodeEntry>, Hasher, Equals> + inline_entries, + std::unordered_map<int, std::vector<CodeEntryAndLineNumber>> + inline_stacks); + const std::vector<CodeEntryAndLineNumber>* GetInlineStack( int pc_offset) const; void set_instruction_start(Address start) { instruction_start_ = start; } @@ -136,13 +158,16 @@ class CodeEntry { return kUnresolvedEntry.Pointer(); } + void print() const; + private: struct RareData { const char* deopt_reason_ = kNoDeoptReason; const char* bailout_reason_ = kEmptyBailoutReason; int deopt_id_ = kNoDeoptimizationId; - std::unordered_map<int, std::vector<std::unique_ptr<CodeEntry>>> - inline_locations_; + std::unordered_map<int, std::vector<CodeEntryAndLineNumber>> inline_stacks_; + std::unordered_set<std::unique_ptr<CodeEntry>, Hasher, Equals> + inline_entries_; std::vector<CpuProfileDeoptFrame> deopt_inlined_frames_; }; @@ -170,7 +195,7 @@ class CodeEntry { static base::LazyDynamicInstance<CodeEntry, UnresolvedEntryCreateTrait>::type kUnresolvedEntry; - using TagField = BitField<Logger::LogEventsAndTags, 0, 8>; + using TagField = BitField<CodeEventListener::LogEventsAndTags, 0, 8>; using BuiltinIdField = BitField<Builtins::Name, 8, 23>; using UsedField = BitField<bool, 31, 1>; @@ -313,6 +338,7 @@ class ProfileTree { DISALLOW_COPY_AND_ASSIGN(ProfileTree); }; +class CpuProfiler; class CpuProfile { public: @@ -412,7 +438,7 @@ class CpuProfilesCollection { std::vector<std::unique_ptr<CpuProfile>>* profiles() { return &finished_profiles_; } - const char* GetName(Name* name) { return resource_names_.GetName(name); } + const char* GetName(Name name) { return resource_names_.GetName(name); } bool IsLastProfile(const char* title); void RemoveProfile(CpuProfile* profile); |