Remove ProgramSettings from IRGenerator and the Inliner.
These classes now read the program configuration from the Context.
Change-Id: I15c95cacebb9836ee8f2162c4f4b7f99d453639c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371396
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 0243d47..c4d3a6f 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -291,9 +291,8 @@
}
}
-void Inliner::reset(ModifiersPool* modifiers, const Program::Settings* settings) {
+void Inliner::reset(ModifiersPool* modifiers) {
fModifiers = modifiers;
- fSettings = settings;
fMangler.reset();
fInlinedStatementCounter = 0;
}
@@ -622,7 +621,6 @@
// order guarantees. Since we can't use gotos (which are normally used to replace return
// statements), we wrap the whole function in a loop and use break statements to jump to the
// end.
- SkASSERT(fSettings);
SkASSERT(fContext);
SkASSERT(call);
SkASSERT(this->isSafeToInline(call->function().definition()));
@@ -772,10 +770,8 @@
}
bool Inliner::isSafeToInline(const FunctionDefinition* functionDef) {
- SkASSERT(fSettings);
-
// A threshold of zero indicates that the inliner is completely disabled, so we can just return.
- if (fSettings->fInlineThreshold <= 0) {
+ if (this->settings().fInlineThreshold <= 0) {
return false;
}
@@ -1098,7 +1094,7 @@
auto [iter, wasInserted] = cache->insert({&funcDecl, 0});
if (wasInserted) {
iter->second = Analysis::NodeCountUpToLimit(*funcDecl.definition(),
- fSettings->fInlineThreshold);
+ this->settings().fInlineThreshold);
}
return iter->second;
}
@@ -1130,7 +1126,7 @@
// If the inline threshold is unlimited, or if we have no candidates left, our candidate list is
// complete.
- if (fSettings->fInlineThreshold == INT_MAX || candidates.empty()) {
+ if (this->settings().fInlineThreshold == INT_MAX || candidates.empty()) {
return;
}
@@ -1144,34 +1140,32 @@
candidateTotalCost[&fnDecl] += this->getFunctionSize(fnDecl, &functionSizeCache);
}
- candidates.erase(
- std::remove_if(candidates.begin(),
- candidates.end(),
- [&](const InlineCandidate& candidate) {
- const FunctionDeclaration& fnDecl = candidate_func(candidate);
- if (fnDecl.modifiers().fFlags & Modifiers::kInline_Flag) {
- // Functions marked `inline` ignore size limitations.
- return false;
- }
- if (usage->get(fnDecl) == 1) {
- // If a function is only used once, it's cost-free to inline.
- return false;
- }
- if (candidateTotalCost[&fnDecl] <= fSettings->fInlineThreshold) {
- // We won't exceed the inline threshold by inlining this.
- return false;
- }
- // Inlining this function will add too many IRNodes.
- return true;
- }),
- candidates.end());
+ candidates.erase(std::remove_if(candidates.begin(), candidates.end(),
+ [&](const InlineCandidate& candidate) {
+ const FunctionDeclaration& fnDecl = candidate_func(candidate);
+ if (fnDecl.modifiers().fFlags & Modifiers::kInline_Flag) {
+ // Functions marked `inline` ignore size limitations.
+ return false;
+ }
+ if (usage->get(fnDecl) == 1) {
+ // If a function is only used once, it's cost-free to inline.
+ return false;
+ }
+ if (candidateTotalCost[&fnDecl] <= this->settings().fInlineThreshold) {
+ // We won't exceed the inline threshold by inlining this.
+ return false;
+ }
+ // Inlining this function will add too many IRNodes.
+ return true;
+ }),
+ candidates.end());
}
bool Inliner::analyze(const std::vector<std::unique_ptr<ProgramElement>>& elements,
std::shared_ptr<SymbolTable> symbols,
ProgramUsage* usage) {
// A threshold of zero indicates that the inliner is completely disabled, so we can just return.
- if (fSettings->fInlineThreshold <= 0) {
+ if (this->settings().fInlineThreshold <= 0) {
return false;
}