LCOV - code coverage report
Current view: top level - src/profiler - profiler-listener.h (source / functions) Hit Total Coverage
Test: app.info Lines: 12 13 92.3 %
Date: 2017-04-26 Functions: 1 4 25.0 %

          Line data    Source code
       1             : // Copyright 2016 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_PROFILER_LISTENER_H_
       6             : #define V8_PROFILER_PROFILER_LISTENER_H_
       7             : 
       8             : #include <vector>
       9             : 
      10             : #include "src/code-events.h"
      11             : #include "src/profiler/profile-generator.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : class CodeEventsContainer;
      17             : 
      18       61110 : class CodeEventObserver {
      19             :  public:
      20             :   virtual void CodeEventHandler(const CodeEventsContainer& evt_rec) = 0;
      21       59613 :   virtual ~CodeEventObserver() {}
      22             : };
      23             : 
      24             : class ProfilerListener : public CodeEventListener {
      25             :  public:
      26             :   explicit ProfilerListener(Isolate* isolate);
      27             :   ~ProfilerListener() override;
      28             : 
      29             :   void CallbackEvent(Name* name, Address entry_point) override;
      30             :   void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
      31             :                        AbstractCode* code, const char* comment) override;
      32             :   void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
      33             :                        AbstractCode* code, Name* name) override;
      34             :   void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
      35             :                        AbstractCode* code, SharedFunctionInfo* shared,
      36             :                        Name* script_name) override;
      37             :   void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
      38             :                        AbstractCode* code, SharedFunctionInfo* shared,
      39             :                        Name* script_name, int line, int column) override;
      40             :   void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
      41             :                        AbstractCode* code, int args_count) override;
      42         186 :   void CodeMovingGCEvent() override {}
      43             :   void CodeMoveEvent(AbstractCode* from, Address to) override;
      44             :   void CodeDisableOptEvent(AbstractCode* code,
      45             :                            SharedFunctionInfo* shared) override;
      46             :   void CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
      47             :                       int fp_to_sp_delta) override;
      48             :   void GetterCallbackEvent(Name* name, Address entry_point) override;
      49             :   void RegExpCodeCreateEvent(AbstractCode* code, String* source) override;
      50             :   void SetterCallbackEvent(Name* name, Address entry_point) override;
      51           0 :   void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
      52             : 
      53             :   CodeEntry* NewCodeEntry(
      54             :       CodeEventListener::LogEventsAndTags tag, const char* name,
      55             :       const char* name_prefix = CodeEntry::kEmptyNamePrefix,
      56             :       const char* resource_name = CodeEntry::kEmptyResourceName,
      57             :       int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
      58             :       int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
      59             :       JITLineInfoTable* line_info = NULL, Address instruction_start = NULL);
      60             : 
      61             :   void AddObserver(CodeEventObserver* observer);
      62             :   void RemoveObserver(CodeEventObserver* observer);
      63         294 :   V8_INLINE bool HasObservers() { return !observers_.empty(); }
      64             : 
      65             :   const char* GetName(Name* name) {
      66      175112 :     return function_and_resource_names_.GetName(name);
      67             :   }
      68             :   const char* GetName(int args_count) {
      69          24 :     return function_and_resource_names_.GetName(args_count);
      70             :   }
      71             :   const char* GetFunctionName(Name* name) {
      72      133417 :     return function_and_resource_names_.GetFunctionName(name);
      73             :   }
      74             :   const char* GetFunctionName(const char* name) {
      75       29485 :     return function_and_resource_names_.GetFunctionName(name);
      76             :   }
      77             : 
      78             :  private:
      79             :   void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code);
      80             :   void RecordDeoptInlinedFrames(CodeEntry* entry, AbstractCode* abstract_code);
      81             :   Name* InferScriptName(Name* name, SharedFunctionInfo* info);
      82             :   V8_INLINE void DispatchCodeEvent(const CodeEventsContainer& evt_rec) {
      83      204696 :     base::LockGuard<base::Mutex> guard(&mutex_);
      84      409392 :     for (auto observer : observers_) {
      85      204696 :       observer->CodeEventHandler(evt_rec);
      86      204696 :     }
      87             :   }
      88             : 
      89             :   StringsStorage function_and_resource_names_;
      90             :   std::vector<CodeEntry*> code_entries_;
      91             :   std::vector<CodeEventObserver*> observers_;
      92             :   base::Mutex mutex_;
      93             : 
      94             :   DISALLOW_COPY_AND_ASSIGN(ProfilerListener);
      95             : };
      96             : 
      97             : }  // namespace internal
      98             : }  // namespace v8
      99             : 
     100             : #endif  // V8_PROFILER_PROFILER_LISTENER_H_

Generated by: LCOV version 1.10