Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
dart::CodeStatistics Class Reference

#include <code_statistics.h>

Public Member Functions

 CodeStatistics (compiler::Assembler *assembler)
 
void Begin (Instruction *instruction)
 
void End (Instruction *instruction)
 
void SpecialBegin (intptr_t tag)
 
void SpecialEnd (intptr_t tag)
 
void AppendTo (CombinedCodeStatistics *stat)
 
void Finalize ()
 

Detailed Description

Definition at line 72 of file code_statistics.h.

Constructor & Destructor Documentation

◆ CodeStatistics()

dart::CodeStatistics::CodeStatistics ( compiler::Assembler assembler)
explicit

Definition at line 122 of file code_statistics.cc.

123 : assembler_(assembler) {
124 memset(entries_, 0, CombinedCodeStatistics::kNumEntries * sizeof(Entry));
125 instruction_bytes_ = 0;
126 unaccounted_bytes_ = 0;
127 alignment_bytes_ = 0;
128
129 stack_index_ = -1;
130 for (intptr_t i = 0; i < kStackSize; i++)
131 stack_[i] = -1;
132}

Member Function Documentation

◆ AppendTo()

void dart::CodeStatistics::AppendTo ( CombinedCodeStatistics stat)

Definition at line 177 of file code_statistics.cc.

177 {
178 bool returns_constant = true;
179 bool returns_const_with_load_field_ = true;
180
181 for (intptr_t i = 0; i < CombinedCodeStatistics::kNumEntries; i++) {
182 intptr_t bytes = entries_[i].bytes;
183 stat->entries_[i].count += entries_[i].count;
184 if (bytes > 0) {
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;
195 }
196 }
197 }
198 }
199 stat->unaccounted_bytes_ += unaccounted_bytes_;
200 ASSERT(stat->unaccounted_bytes_ >= 0);
201 stat->alignment_bytes_ += alignment_bytes_;
202 stat->object_header_bytes_ += Instructions::HeaderSize();
203
204 if (returns_constant) stat->return_const_count_++;
205 if (returns_const_with_load_field_) {
206 stat->return_const_with_load_field_count_++;
207 }
208}
static intptr_t HeaderSize()
Definition object.h:5796
#define ASSERT(E)

◆ Begin()

void dart::CodeStatistics::Begin ( Instruction instruction)

Definition at line 134 of file code_statistics.cc.

134 {
135 SpecialBegin(static_cast<intptr_t>(instruction->statistics_tag()));
136}
void SpecialBegin(intptr_t tag)

◆ End()

void dart::CodeStatistics::End ( Instruction instruction)

Definition at line 138 of file code_statistics.cc.

138 {
139 SpecialEnd(static_cast<intptr_t>(instruction->statistics_tag()));
140}
void SpecialEnd(intptr_t tag)

◆ Finalize()

void dart::CodeStatistics::Finalize ( )

Definition at line 166 of file code_statistics.cc.

166 {
167 intptr_t function_size = assembler_->CodeSize();
168 unaccounted_bytes_ = function_size - instruction_bytes_;
169 ASSERT(unaccounted_bytes_ >= 0);
170
171 const intptr_t unaligned_bytes = Instructions::HeaderSize() + function_size;
172 alignment_bytes_ =
173 Utils::RoundUp(unaligned_bytes, kObjectAlignment) - unaligned_bytes;
174 assembler_ = nullptr;
175}
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition utils.h:105
static constexpr intptr_t kObjectAlignment

◆ SpecialBegin()

void dart::CodeStatistics::SpecialBegin ( intptr_t  tag)

Definition at line 142 of file code_statistics.cc.

142 {
143 stack_index_++;
144 RELEASE_ASSERT(stack_index_ < kStackSize);
145 RELEASE_ASSERT(stack_[stack_index_] == -1);
147 stack_[stack_index_] = assembler_->CodeSize();
148 RELEASE_ASSERT(stack_[stack_index_] >= 0);
149}
#define RELEASE_ASSERT(cond)
Definition assert.h:327

◆ SpecialEnd()

void dart::CodeStatistics::SpecialEnd ( intptr_t  tag)

Definition at line 151 of file code_statistics.cc.

151 {
152 RELEASE_ASSERT(stack_index_ > 0 || stack_[stack_index_] >= 0);
154
155 intptr_t diff = assembler_->CodeSize() - stack_[stack_index_];
156 RELEASE_ASSERT(diff >= 0);
157 RELEASE_ASSERT(entries_[tag].bytes >= 0);
158 RELEASE_ASSERT(entries_[tag].count >= 0);
159 entries_[tag].bytes += diff;
160 entries_[tag].count++;
161 instruction_bytes_ += diff;
162 stack_[stack_index_] = -1;
163 stack_index_--;
164}
int count

The documentation for this class was generated from the following files: