node/deps/v8/src/basic-block-profiler.h

78 lines
1.9 KiB
C
Raw Normal View History

2014-10-10 18:49:02 +08:00
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_BASIC_BLOCK_PROFILER_H_
#define V8_BASIC_BLOCK_PROFILER_H_
2014-11-14 07:52:27 +08:00
#include <iosfwd>
2014-10-10 18:49:02 +08:00
#include <list>
2014-11-14 07:52:27 +08:00
#include <string>
2014-10-10 18:49:02 +08:00
#include "src/v8.h"
namespace v8 {
namespace internal {
class Schedule;
class Graph;
class BasicBlockProfiler {
public:
class Data {
public:
size_t n_blocks() const { return n_blocks_; }
const uint32_t* counts() const { return &counts_[0]; }
2014-11-14 07:52:27 +08:00
void SetCode(std::ostringstream* os);
void SetFunctionName(std::ostringstream* os);
void SetSchedule(std::ostringstream* os);
void SetBlockId(size_t offset, size_t block_id);
2014-10-10 18:49:02 +08:00
uint32_t* GetCounterAddress(size_t offset);
private:
friend class BasicBlockProfiler;
2014-11-14 07:52:27 +08:00
friend std::ostream& operator<<(std::ostream& os,
const BasicBlockProfiler::Data& s);
2014-10-10 18:49:02 +08:00
explicit Data(size_t n_blocks);
~Data();
void ResetCounts();
const size_t n_blocks_;
2014-11-14 07:52:27 +08:00
std::vector<size_t> block_ids_;
2014-10-10 18:49:02 +08:00
std::vector<uint32_t> counts_;
std::string function_name_;
std::string schedule_;
std::string code_;
DISALLOW_COPY_AND_ASSIGN(Data);
};
typedef std::list<Data*> DataList;
BasicBlockProfiler();
~BasicBlockProfiler();
Data* NewData(size_t n_blocks);
void ResetCounts();
const DataList* data_list() { return &data_list_; }
private:
2014-11-14 07:52:27 +08:00
friend std::ostream& operator<<(std::ostream& os,
const BasicBlockProfiler& s);
2014-10-10 18:49:02 +08:00
DataList data_list_;
DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler);
};
2014-11-14 07:52:27 +08:00
std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler& s);
std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s);
2014-10-10 18:49:02 +08:00
} // namespace internal
} // namespace v8
#endif // V8_BASIC_BLOCK_PROFILER_H_