Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / v8 / src / arm64 / instrument-arm64.h
1 // Copyright 2013 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_ARM64_INSTRUMENT_ARM64_H_
6 #define V8_ARM64_INSTRUMENT_ARM64_H_
7
8 #include "globals.h"
9 #include "utils.h"
10 #include "arm64/decoder-arm64.h"
11 #include "arm64/constants-arm64.h"
12
13 namespace v8 {
14 namespace internal {
15
16 const int kCounterNameMaxLength = 256;
17 const uint64_t kDefaultInstrumentationSamplingPeriod = 1 << 22;
18
19
20 enum InstrumentState {
21   InstrumentStateDisable = 0,
22   InstrumentStateEnable = 1
23 };
24
25
26 enum CounterType {
27   Gauge = 0,      // Gauge counters reset themselves after reading.
28   Cumulative = 1  // Cumulative counters keep their value after reading.
29 };
30
31
32 class Counter {
33  public:
34   Counter(const char* name, CounterType type = Gauge);
35
36   void Increment();
37   void Enable();
38   void Disable();
39   bool IsEnabled();
40   uint64_t count();
41   const char* name();
42   CounterType type();
43
44  private:
45   char name_[kCounterNameMaxLength];
46   uint64_t count_;
47   bool enabled_;
48   CounterType type_;
49 };
50
51
52 class Instrument: public DecoderVisitor {
53  public:
54   explicit Instrument(const char* datafile = NULL,
55     uint64_t sample_period = kDefaultInstrumentationSamplingPeriod);
56   ~Instrument();
57
58   // Declare all Visitor functions.
59   #define DECLARE(A) void Visit##A(Instruction* instr);
60   VISITOR_LIST(DECLARE)
61   #undef DECLARE
62
63  private:
64   void Update();
65   void Enable();
66   void Disable();
67   void DumpCounters();
68   void DumpCounterNames();
69   void DumpEventMarker(unsigned marker);
70   void HandleInstrumentationEvent(unsigned event);
71   Counter* GetCounter(const char* name);
72
73   void InstrumentLoadStore(Instruction* instr);
74   void InstrumentLoadStorePair(Instruction* instr);
75
76   std::list<Counter*> counters_;
77
78   FILE *output_stream_;
79   uint64_t sample_period_;
80 };
81
82 } }  // namespace v8::internal
83
84 #endif  // V8_ARM64_INSTRUMENT_ARM64_H_