Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / v8 / src / log.h
index 7b2a8e0..51597dd 100644 (file)
@@ -5,12 +5,19 @@
 #ifndef V8_LOG_H_
 #define V8_LOG_H_
 
-#include "allocation.h"
-#include "objects.h"
-#include "platform.h"
-#include "platform/elapsed-timer.h"
+#include <string>
+
+#include "src/allocation.h"
+#include "src/base/platform/elapsed-timer.h"
+#include "src/base/platform/platform.h"
+#include "src/objects.h"
 
 namespace v8 {
+
+namespace base {
+class Semaphore;
+}
+
 namespace internal {
 
 // Logger is used for collecting logging information from V8 during
@@ -55,7 +62,6 @@ class Isolate;
 class Log;
 class PositionsRecorder;
 class Profiler;
-class Semaphore;
 class Ticker;
 struct TickSample;
 
@@ -79,6 +85,7 @@ struct TickSample;
 
 #define LOG_EVENTS_AND_TAGS_LIST(V)                                     \
   V(CODE_CREATION_EVENT,            "code-creation")                    \
+  V(CODE_DISABLE_OPT_EVENT,         "code-disable-optimization")        \
   V(CODE_MOVE_EVENT,                "code-move")                        \
   V(CODE_DELETE_EVENT,              "code-delete")                      \
   V(CODE_MOVING_GC,                 "code-moving-gc")                   \
@@ -142,78 +149,10 @@ class LowLevelLogger;
 class PerfJitLogger;
 class Sampler;
 
-// Mapping from the offset within generated code to source line number.
-class JITLineInfoTable : public Malloced {
- public:
-  JITLineInfoTable() : pc_offset_infos_(20) {}
-
-  void SetPosition(unsigned int pc_offset, unsigned int src_line) {
-    AddPcOffsetInfo(PcOffsetInfo(pc_offset, src_line));
-  }
-
-  int GetSourceLineNumber(unsigned int pc_offset) const {
-    int length = pc_offset_infos_.length();
-    if (0 == length) return 0;
-
-    int low = 0;
-    int high = length - 1;
-
-    if (pc_offset > pc_offset_infos_[high].pc_offset_) {
-      return 0;  // out of range
-    }
-
-    while (low < high) {
-      int mid = (low + high) / 2;
-      const JITLineInfoTable::PcOffsetInfo& elem = pc_offset_infos_[mid];
-      if (elem.pc_offset_ > pc_offset) {
-        high = mid;
-        continue;
-      }
-      if (elem.pc_offset_ < pc_offset) {
-        low = mid + 1;
-        continue;
-      }
-      return elem.line_;  // found the element
-    }
-
-    int line = pc_offset_infos_[high].line_;
-    return line;
-  }
-
-  struct PcOffsetInfo {
-    PcOffsetInfo(unsigned int pc_offset, unsigned int src_line)
-      : pc_offset_(pc_offset), line_(src_line) { }
-
-      unsigned int pc_offset_;
-      unsigned int line_;
-  };
-
-  List<PcOffsetInfo>* entries() { return &pc_offset_infos_; }
-  const List<PcOffsetInfo>* entries() const { return &pc_offset_infos_; }
-
-  JITLineInfoTable& operator=(const JITLineInfoTable& other) {
-    if (this != &other) {
-      const List<PcOffsetInfo>* entries = other.entries();
-      if (entries) {
-        pc_offset_infos_.Clear();
-        pc_offset_infos_.AddAll(*entries);
-      }
-    }
-    return *this;
-  }
-
- private:
-  void AddPcOffsetInfo(const PcOffsetInfo& pc_offset_info) {
-    pc_offset_infos_.Add(pc_offset_info);
-  }
-
-  // The data reported by code generator.
-  List<PcOffsetInfo> pc_offset_infos_;
-};
-
-
 class Logger {
  public:
+  enum StartEnd { START = 0, END = 1 };
+
 #define DECLARE_ENUM(enum_item, ignore) enum_item,
   enum LogEventsAndTags {
     LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM)
@@ -307,6 +246,8 @@ class Logger {
                        CompilationInfo* info,
                        Name* source, int line, int column);
   void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count);
+  // Emits a code deoptimization event.
+  void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared);
   void CodeMovingGCEvent();
   // Emits a code create event for a RegExp.
   void RegExpCodeCreateEvent(Code* code, String* source);
@@ -347,58 +288,26 @@ class Logger {
   void HeapSampleStats(const char* space, const char* kind,
                        intptr_t capacity, intptr_t used);
 
-  void SharedLibraryEvent(const char* library_path,
-                          uintptr_t start,
-                          uintptr_t end);
-  void SharedLibraryEvent(const wchar_t* library_path,
+  void SharedLibraryEvent(const std::string& library_path,
                           uintptr_t start,
                           uintptr_t end);
 
-  // ==== Events logged by --log-timer-events. ====
-  enum StartEnd { START, END };
-
   void CodeDeoptEvent(Code* code);
+  void CurrentTimeEvent();
 
   void TimerEvent(StartEnd se, const char* name);
 
   static void EnterExternal(Isolate* isolate);
   static void LeaveExternal(Isolate* isolate);
 
-  static void EmptyLogInternalEvents(const char* name, int se) { }
-  static void LogInternalEvents(const char* name, int se);
-
-  class TimerEventScope {
-   public:
-    TimerEventScope(Isolate* isolate, const char* name)
-        : isolate_(isolate), name_(name) {
-      LogTimerEvent(START);
-    }
-
-    ~TimerEventScope() {
-      LogTimerEvent(END);
-    }
-
-    void LogTimerEvent(StartEnd se);
-
-    static const char* v8_recompile_synchronous;
-    static const char* v8_recompile_concurrent;
-    static const char* v8_compile_full_code;
-    static const char* v8_execute;
-    static const char* v8_external;
-
-   private:
-    Isolate* isolate_;
-    const char* name_;
-  };
+  static void EmptyTimerEventsLogger(const char* name, int se) {}
+  static void DefaultTimerEventsLogger(const char* name, int se);
 
   // ==== Events logged by --log-regexp ====
   // Regexp compilation and execution events.
 
   void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache);
 
-  // Log an event reported from generated code
-  void LogRuntime(Vector<const char> format, Handle<JSArray> args);
-
   bool is_logging() {
     return is_logging_;
   }
@@ -411,13 +320,6 @@ class Logger {
   // When data collection is paused, CPU Tick events are discarded.
   void StopProfiler();
 
-  // Resumes collection of CPU Tick events.
-  void XDKResumeProfiler();
-
-  // XDK agent uses it log code map (list of CodeAdded event
-  // before resume CPU Tick events.
-  Log* XDKGetLog() { return log_; }
-
   void LogExistingFunction(Handle<SharedFunctionInfo> shared,
                            Handle<Code> code);
   // Logs all compiled functions found in the heap.
@@ -512,12 +414,46 @@ class Logger {
   // 'true' between SetUp() and TearDown().
   bool is_initialized_;
 
-  ElapsedTimer timer_;
+  base::ElapsedTimer timer_;
 
   friend class CpuProfiler;
 };
 
 
+#define TIMER_EVENTS_LIST(V)    \
+  V(RecompileSynchronous, true) \
+  V(RecompileConcurrent, true)  \
+  V(CompileFullCode, true)      \
+  V(Execute, true)              \
+  V(External, true)             \
+  V(IcMiss, false)
+
+#define V(TimerName, expose)                                                  \
+  class TimerEvent##TimerName : public AllStatic {                            \
+   public:                                                                    \
+    static const char* name(void* unused = NULL) { return "V8." #TimerName; } \
+    static bool expose_to_api() { return expose; }                            \
+  };
+TIMER_EVENTS_LIST(V)
+#undef V
+
+
+template <class TimerEvent>
+class TimerEventScope {
+ public:
+  explicit TimerEventScope(Isolate* isolate) : isolate_(isolate) {
+    LogTimerEvent(Logger::START);
+  }
+
+  ~TimerEventScope() { LogTimerEvent(Logger::END); }
+
+  void LogTimerEvent(Logger::StartEnd se);
+
+ private:
+  Isolate* isolate_;
+};
+
+
 class CodeEventListener {
  public:
   virtual ~CodeEventListener() {}
@@ -550,6 +486,7 @@ class CodeEventListener {
   virtual void CodeDeleteEvent(Address from) = 0;
   virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0;
   virtual void CodeMovingGCEvent() = 0;
+  virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) = 0;
 };
 
 
@@ -586,15 +523,15 @@ class CodeEventLogger : public CodeEventListener {
   virtual void SharedFunctionInfoMoveEvent(Address from, Address to) { }
   virtual void CodeMovingGCEvent() { }
 
- protected:
+ private:
   class NameBuffer;
-  NameBuffer* name_buffer_;
 
- private:
   virtual void LogRecordedBuffer(Code* code,
                                  SharedFunctionInfo* shared,
                                  const char* name,
                                  int length) = 0;
+
+  NameBuffer* name_buffer_;
 };