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