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

#include <SkSLProgramUsage.h>

Classes

struct  VariableCounts
 

Public Member Functions

VariableCounts get (const Variable &) const
 
bool isDead (const Variable &) const
 
int get (const FunctionDeclaration &) const
 
void add (const Expression *expr)
 
void add (const Statement *stmt)
 
void add (const ProgramElement &element)
 
void remove (const Expression *expr)
 
void remove (const Statement *stmt)
 
void remove (const ProgramElement &element)
 
bool operator== (const ProgramUsage &that) const
 
bool operator!= (const ProgramUsage &that) const
 

Public Attributes

skia_private::THashMap< const Symbol *, intfStructCounts
 
skia_private::THashMap< const Symbol *, intfCallCounts
 
skia_private::THashMap< const Variable *, VariableCountsfVariableCounts
 

Detailed Description

Side-car class holding mutable information about a Program's IR

Definition at line 26 of file SkSLProgramUsage.h.

Member Function Documentation

◆ add() [1/3]

void SkSL::ProgramUsage::add ( const Expression expr)

Definition at line 190 of file SkSLProgramUsage.cpp.

190 {
191 ProgramUsageVisitor addRefs(this, /*delta=*/+1);
192 addRefs.visitExpression(*expr);
193}

◆ add() [2/3]

void SkSL::ProgramUsage::add ( const ProgramElement element)

Definition at line 200 of file SkSLProgramUsage.cpp.

200 {
201 ProgramUsageVisitor addRefs(this, /*delta=*/+1);
202 addRefs.visitProgramElement(element);
203}

◆ add() [3/3]

void SkSL::ProgramUsage::add ( const Statement stmt)

Definition at line 195 of file SkSLProgramUsage.cpp.

195 {
196 ProgramUsageVisitor addRefs(this, /*delta=*/+1);
197 addRefs.visitStatement(*stmt);
198}

◆ get() [1/2]

int SkSL::ProgramUsage::get ( const FunctionDeclaration f) const

Definition at line 185 of file SkSLProgramUsage.cpp.

185 {
186 const int* count = fCallCounts.find(&f);
187 return count ? *count : 0;
188}
int count
skia_private::THashMap< const Symbol *, int > fCallCounts

◆ get() [2/2]

ProgramUsage::VariableCounts SkSL::ProgramUsage::get ( const Variable v) const

Definition at line 164 of file SkSLProgramUsage.cpp.

164 {
165 const VariableCounts* counts = fVariableCounts.find(&v);
166 SkASSERT(counts);
167 return *counts;
168}
#define SkASSERT(cond)
Definition SkAssert.h:116
skia_private::THashMap< const Variable *, VariableCounts > fVariableCounts
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core counts
Definition switches.h:239

◆ isDead()

bool SkSL::ProgramUsage::isDead ( const Variable v) const

Definition at line 170 of file SkSLProgramUsage.cpp.

170 {
171 ModifierFlags flags = v.modifierFlags();
172 VariableCounts counts = this->get(v);
174 // Never eliminate ins, outs, or uniforms.
175 return false;
176 }
177 if (v.type().componentType().isOpaque()) {
178 // Never eliminate samplers, runtime-effect children, or atomics.
179 return false;
180 }
181 // Consider the variable dead if it's never read and never written (besides the initial-value).
182 return !counts.fRead && (counts.fWrite <= (v.initialValue() ? 1 : 0));
183}
VariableCounts get(const Variable &) const
FlutterSemanticsFlag flags

◆ operator!=()

bool SkSL::ProgramUsage::operator!= ( const ProgramUsage that) const
inline

Definition at line 46 of file SkSLProgramUsage.h.

46{ return !(*this == that); }

◆ operator==()

bool SkSL::ProgramUsage::operator== ( const ProgramUsage that) const

Definition at line 285 of file SkSLProgramUsage.cpp.

285 {
286 // ProgramUsage can be "equal" while the underlying hash maps look slightly different, because a
287 // dead-stripped variable or function will have a usage count of zero, but will still exist in
288 // the maps. If the program usage is re-analyzed from scratch, the maps will not contain an
289 // entry for these variables or functions at all. This means our maps can be "equal" while
290 // having different element counts.
291 //
292 // In order to check these maps, we compare map entries bi-directionally, skipping zero-usage
293 // entries. If all the non-zero elements in `this` match the elements in `that`, and all the
294 // non-zero elements in `that` match the elements in `this`, all the non-zero elements must be
295 // identical, and all the zero elements must be either zero or non-existent on both sides.
296 return contains_matching_data(*this, that) &&
297 contains_matching_data(that, *this);
298}
static bool contains_matching_data(const ProgramUsage &a, const ProgramUsage &b)

◆ remove() [1/3]

void SkSL::ProgramUsage::remove ( const Expression expr)

Definition at line 205 of file SkSLProgramUsage.cpp.

205 {
206 ProgramUsageVisitor subRefs(this, /*delta=*/-1);
207 subRefs.visitExpression(*expr);
208}

◆ remove() [2/3]

void SkSL::ProgramUsage::remove ( const ProgramElement element)

Definition at line 215 of file SkSLProgramUsage.cpp.

215 {
216 ProgramUsageVisitor subRefs(this, /*delta=*/-1);
217 subRefs.visitProgramElement(element);
218}

◆ remove() [3/3]

void SkSL::ProgramUsage::remove ( const Statement stmt)

Definition at line 210 of file SkSLProgramUsage.cpp.

210 {
211 ProgramUsageVisitor subRefs(this, /*delta=*/-1);
212 subRefs.visitStatement(*stmt);
213}

Member Data Documentation

◆ fCallCounts

skia_private::THashMap<const Symbol*, int> SkSL::ProgramUsage::fCallCounts

Definition at line 51 of file SkSLProgramUsage.h.

◆ fStructCounts

skia_private::THashMap<const Symbol*, int> SkSL::ProgramUsage::fStructCounts

Definition at line 49 of file SkSLProgramUsage.h.

◆ fVariableCounts

skia_private::THashMap<const Variable*, VariableCounts> SkSL::ProgramUsage::fVariableCounts

Definition at line 52 of file SkSLProgramUsage.h.


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