10 unaccounted_bytes_ = 0;
12 object_header_bytes_ = 0;
13 return_const_count_ = 0;
14 return_const_with_load_field_count_ = 0;
17#define DO(type, attrs) \
18 entries_[i].name = #type; \
19 entries_[i].bytes = 0; \
20 entries_[i++].count = 0;
26#define DO(type, attrs) \
27 entries_[i].name = "SlowPath:" #type; \
28 entries_[i].bytes = 0; \
29 entries_[i++].count = 0;
35#define INIT_SPECIAL_ENTRY(tag, str) \
36 entries_[tag].name = str; \
37 entries_[tag].bytes = 0; \
38 entries_[tag].count = 0;
41 "AssertAssignable:ParameterCheck");
43 "AssertAssignable:InsertedByFrontend");
45 "AssertAssignable:FromSource");
49#undef INIT_SPECIAL_ENTRY
53 ASSERT(unaccounted_bytes_ >= 0);
57 sorted[
i] = &entries_[
i];
61 intptr_t instruction_bytes = 0;
63 instruction_bytes += entries_[
i].bytes;
65 intptr_t total = object_header_bytes_ + instruction_bytes +
66 unaccounted_bytes_ + alignment_bytes_;
67 float ftotal =
static_cast<float>(total) / 100.0;
73 const char*
name = entry->name;
74 intptr_t bytes = entry->bytes;
75 intptr_t
count = entry->count;
76 float percent = bytes / ftotal;
77 float avg =
static_cast<float>(bytes) /
count;
85 "%8.2f avg bytes/entry "
94 unaccounted_bytes_ / ftotal, unaccounted_bytes_);
96 alignment_bytes_ / ftotal, alignment_bytes_);
97 OS::PrintErr(
"%5.2f %% % 8" Pd " bytes instruction object header\n",
98 object_header_bytes_ / ftotal, object_header_bytes_);
100 instruction_bytes / ftotal, instruction_bytes);
102 OS::PrintErr(
"%5.2f %% % 8" Pd " bytes in total\n", total / ftotal, total);
104 OS::PrintErr(
"% 8" Pd " return-constant functions\n", return_const_count_);
105 OS::PrintErr(
"% 8" Pd " return-constant-with-load-field functions\n",
106 return_const_with_load_field_count_);
110int CombinedCodeStatistics::CompareEntries(
const void*
a,
const void*
b) {
111 const intptr_t a_size = (*
static_cast<const Entry* const*
>(
a))->bytes;
112 const intptr_t b_size = (*
static_cast<const Entry* const*
>(
b))->bytes;
113 if (a_size < b_size) {
115 }
else if (a_size > b_size) {
123 : assembler_(assembler) {
125 instruction_bytes_ = 0;
126 unaccounted_bytes_ = 0;
127 alignment_bytes_ = 0;
130 for (intptr_t
i = 0;
i < kStackSize;
i++)
147 stack_[stack_index_] = assembler_->
CodeSize();
155 intptr_t diff = assembler_->
CodeSize() - stack_[stack_index_];
159 entries_[tag].bytes += diff;
160 entries_[tag].count++;
161 instruction_bytes_ += diff;
162 stack_[stack_index_] = -1;
167 intptr_t function_size = assembler_->
CodeSize();
168 unaccounted_bytes_ = function_size - instruction_bytes_;
169 ASSERT(unaccounted_bytes_ >= 0);
174 assembler_ =
nullptr;
178 bool returns_constant =
true;
179 bool returns_const_with_load_field_ =
true;
182 intptr_t bytes = entries_[
i].bytes;
183 stat->entries_[
i].count += entries_[
i].count;
185 stat->entries_[
i].bytes += bytes;
186 if (
i != CombinedCodeStatistics::kTagParallelMove &&
187 i != CombinedCodeStatistics::kTagDartReturn &&
188 i != CombinedCodeStatistics::kTagCheckStackOverflow &&
189 i != CombinedCodeStatistics::kTagCheckStackOverflowSlowPath) {
190 returns_constant =
false;
191 if (
i != CombinedCodeStatistics::kTagLoadField &&
192 i != CombinedCodeStatistics::kTagTargetEntry &&
193 i != CombinedCodeStatistics::kTagJoinEntry) {
194 returns_const_with_load_field_ =
false;
199 stat->unaccounted_bytes_ += unaccounted_bytes_;
200 ASSERT(stat->unaccounted_bytes_ >= 0);
201 stat->alignment_bytes_ += alignment_bytes_;
204 if (returns_constant) stat->return_const_count_++;
205 if (returns_const_with_load_field_) {
206 stat->return_const_with_load_field_count_++;
#define RELEASE_ASSERT(cond)
void End(Instruction *instruction)
void AppendTo(CombinedCodeStatistics *stat)
void SpecialBegin(intptr_t tag)
void SpecialEnd(intptr_t tag)
void Begin(Instruction *instruction)
CodeStatistics(compiler::Assembler *assembler)
@ kTagAssertAssignableFromSource
@ kTagAssertAssignableInsertedByFrontend
@ kTagAssertAssignableParameterCheck
virtual intptr_t statistics_tag() const
static intptr_t HeaderSize()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
intptr_t CodeSize() const
#define INIT_SPECIAL_ENTRY(tag, str)
#define FOR_EACH_INSTRUCTION(M)
static constexpr intptr_t kObjectAlignment