2014-09-29 07:29:14 +00: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-09-30 10:29:32 +00:00
|
|
|
#include <iosfwd>
|
2014-09-29 07:29:14 +00:00
|
|
|
#include <list>
|
2014-09-30 10:29:32 +00:00
|
|
|
#include <string>
|
2015-08-11 07:34:10 +00:00
|
|
|
#include <vector>
|
2014-09-29 07:29:14 +00:00
|
|
|
|
2015-08-11 07:34:10 +00:00
|
|
|
#include "src/base/macros.h"
|
2018-08-14 12:30:05 +00:00
|
|
|
#include "src/base/platform/mutex.h"
|
2016-09-20 12:06:34 +00:00
|
|
|
#include "src/globals.h"
|
2014-09-29 07:29:14 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class BasicBlockProfiler {
|
|
|
|
public:
|
|
|
|
class Data {
|
|
|
|
public:
|
|
|
|
size_t n_blocks() const { return n_blocks_; }
|
|
|
|
const uint32_t* counts() const { return &counts_[0]; }
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
void SetCode(std::ostringstream* os);
|
2018-08-14 12:30:05 +00:00
|
|
|
void SetFunctionName(std::unique_ptr<char[]> name);
|
2014-09-30 10:29:32 +00:00
|
|
|
void SetSchedule(std::ostringstream* os);
|
2018-08-14 12:30:05 +00:00
|
|
|
void SetBlockRpoNumber(size_t offset, int32_t block_rpo);
|
|
|
|
intptr_t GetCounterAddress(size_t offset);
|
2014-09-29 07:29:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BasicBlockProfiler;
|
2014-09-30 10:29:32 +00:00
|
|
|
friend std::ostream& operator<<(std::ostream& os,
|
|
|
|
const BasicBlockProfiler::Data& s);
|
2014-09-29 07:29:14 +00:00
|
|
|
|
|
|
|
explicit Data(size_t n_blocks);
|
2018-09-19 17:03:08 +00:00
|
|
|
~Data() = default;
|
2014-09-29 07:29:14 +00:00
|
|
|
|
|
|
|
void ResetCounts();
|
|
|
|
|
|
|
|
const size_t n_blocks_;
|
2018-08-14 12:30:05 +00:00
|
|
|
std::vector<int32_t> block_rpo_numbers_;
|
2014-09-29 07:29:14 +00: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;
|
|
|
|
|
2018-09-19 17:03:08 +00:00
|
|
|
BasicBlockProfiler() = default;
|
2014-09-29 07:29:14 +00:00
|
|
|
~BasicBlockProfiler();
|
|
|
|
|
2018-07-26 13:10:28 +00:00
|
|
|
V8_EXPORT_PRIVATE static BasicBlockProfiler* Get();
|
2014-09-29 07:29:14 +00:00
|
|
|
Data* NewData(size_t n_blocks);
|
|
|
|
void ResetCounts();
|
|
|
|
|
|
|
|
const DataList* data_list() { return &data_list_; }
|
|
|
|
|
|
|
|
private:
|
2016-09-20 12:06:34 +00:00
|
|
|
friend V8_EXPORT_PRIVATE std::ostream& operator<<(
|
|
|
|
std::ostream& os, const BasicBlockProfiler& s);
|
2014-09-29 07:29:14 +00:00
|
|
|
|
|
|
|
DataList data_list_;
|
2018-08-14 12:30:05 +00:00
|
|
|
base::Mutex data_list_mutex_;
|
2014-09-29 07:29:14 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler);
|
|
|
|
};
|
|
|
|
|
2016-09-20 12:06:34 +00:00
|
|
|
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
|
|
|
|
const BasicBlockProfiler& s);
|
2014-09-30 10:29:32 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s);
|
2014-09-29 07:29:14 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif // V8_BASIC_BLOCK_PROFILER_H_
|