From cd067feb1c445b5436e246f04b6f9683b353e524 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Tue, 2 Feb 2021 18:35:09 -0500 Subject: [PATCH] Move the default inline threshold to SkSLDefines.h. Change-Id: Idf3f95ce3d0467c8273c627227c2e6bb16d04614 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/364837 Auto-Submit: John Stiles Commit-Queue: Brian Osman Reviewed-by: Brian Osman --- src/sksl/SkSLDefines.h | 8 ++++++++ src/sksl/ir/SkSLProgram.h | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/sksl/SkSLDefines.h b/src/sksl/SkSLDefines.h index 861a0e12a4..695892ce33 100644 --- a/src/sksl/SkSLDefines.h +++ b/src/sksl/SkSLDefines.h @@ -22,4 +22,12 @@ using SKSL_INT = int64_t; using SKSL_FLOAT = float; +namespace SkSL { +// Functions larger than this (measured in IR nodes) will not be inlined. This growth factor +// accounts for the number of calls being inlined--i.e., a function called five times (that is, with +// five inlining opportunities) would be considered 5x larger than if it were called once. This +// default threshold value is arbitrary, but tends to work well in practice. +static constexpr int kDefaultInlineThreshold = 50; +} + #endif diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h index e2e5339e3f..fc3195cfe2 100644 --- a/src/sksl/ir/SkSLProgram.h +++ b/src/sksl/ir/SkSLProgram.h @@ -13,6 +13,7 @@ #include "include/private/SkTHash.h" #include "src/sksl/SkSLAnalysis.h" +#include "src/sksl/SkSLDefines.h" #include "src/sksl/ir/SkSLBoolLiteral.h" #include "src/sksl/ir/SkSLExpression.h" #include "src/sksl/ir/SkSLFloatLiteral.h" @@ -137,9 +138,9 @@ struct Program { // If true, remove any uncalled functions other than main(). Note that a function which // starts out being used may end up being uncalled after optimization. bool fRemoveDeadFunctions = true; - // Functions larger than this (measured in IR nodes) will not be inlined. The default value - // is arbitrary. A value of zero will disable the inliner entirely. - int fInlineThreshold = 50; + // Sets an upper limit on the acceptable amount of code growth from inlining. + // A value of zero will disable the inliner entirely. + int fInlineThreshold = SkSL::kDefaultInlineThreshold; // true to enable optimization passes bool fOptimize = true; // If true, implicit conversions to lower precision numeric types are allowed