2014-10-23 09:14:35 +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_COMPILATION_STATISTICS_H_
|
|
|
|
#define V8_COMPILATION_STATISTICS_H_
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/base/platform/time.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2018-04-04 20:30:34 +00:00
|
|
|
class OptimizedCompilationInfo;
|
2016-06-13 09:35:37 +00:00
|
|
|
class CompilationStatistics;
|
|
|
|
|
|
|
|
struct AsPrintableStatistics {
|
|
|
|
const CompilationStatistics& s;
|
|
|
|
const bool machine_output;
|
|
|
|
};
|
2014-10-23 09:14:35 +00:00
|
|
|
|
2015-04-20 13:08:11 +00:00
|
|
|
class CompilationStatistics final : public Malloced {
|
2014-10-23 09:14:35 +00:00
|
|
|
public:
|
|
|
|
CompilationStatistics() {}
|
|
|
|
|
|
|
|
class BasicStats {
|
|
|
|
public:
|
2014-10-27 08:58:55 +00:00
|
|
|
BasicStats()
|
|
|
|
: total_allocated_bytes_(0),
|
|
|
|
max_allocated_bytes_(0),
|
|
|
|
absolute_max_allocated_bytes_(0) {}
|
2014-10-23 09:14:35 +00:00
|
|
|
|
|
|
|
void Accumulate(const BasicStats& stats);
|
|
|
|
|
|
|
|
base::TimeDelta delta_;
|
|
|
|
size_t total_allocated_bytes_;
|
|
|
|
size_t max_allocated_bytes_;
|
2014-10-27 08:58:55 +00:00
|
|
|
size_t absolute_max_allocated_bytes_;
|
2014-10-23 09:14:35 +00:00
|
|
|
std::string function_name_;
|
|
|
|
};
|
|
|
|
|
|
|
|
void RecordPhaseStats(const char* phase_kind_name, const char* phase_name,
|
|
|
|
const BasicStats& stats);
|
|
|
|
|
|
|
|
void RecordPhaseKindStats(const char* phase_kind_name,
|
|
|
|
const BasicStats& stats);
|
|
|
|
|
|
|
|
void RecordTotalStats(size_t source_size, const BasicStats& stats);
|
|
|
|
|
|
|
|
private:
|
|
|
|
class TotalStats : public BasicStats {
|
|
|
|
public:
|
|
|
|
TotalStats() : source_size_(0) {}
|
|
|
|
uint64_t source_size_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OrderedStats : public BasicStats {
|
|
|
|
public:
|
|
|
|
explicit OrderedStats(size_t insert_order) : insert_order_(insert_order) {}
|
|
|
|
size_t insert_order_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhaseStats : public OrderedStats {
|
|
|
|
public:
|
|
|
|
PhaseStats(size_t insert_order, const char* phase_kind_name)
|
|
|
|
: OrderedStats(insert_order), phase_kind_name_(phase_kind_name) {}
|
|
|
|
std::string phase_kind_name_;
|
|
|
|
};
|
|
|
|
|
|
|
|
friend std::ostream& operator<<(std::ostream& os,
|
2016-06-13 09:35:37 +00:00
|
|
|
const AsPrintableStatistics& s);
|
2014-10-23 09:14:35 +00:00
|
|
|
|
|
|
|
typedef OrderedStats PhaseKindStats;
|
|
|
|
typedef std::map<std::string, PhaseKindStats> PhaseKindMap;
|
|
|
|
typedef std::map<std::string, PhaseStats> PhaseMap;
|
|
|
|
|
|
|
|
TotalStats total_stats_;
|
|
|
|
PhaseKindMap phase_kind_map_;
|
|
|
|
PhaseMap phase_map_;
|
2016-12-13 12:14:04 +00:00
|
|
|
base::Mutex record_mutex_;
|
2014-10-23 09:14:35 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CompilationStatistics);
|
|
|
|
};
|
|
|
|
|
2016-06-13 09:35:37 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, const AsPrintableStatistics& s);
|
2014-10-23 09:14:35 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
2018-02-02 12:05:19 +00:00
|
|
|
#endif // V8_COMPILATION_STATISTICS_H_
|