@@ -1398,7 +1398,8 @@ struct Inlining : public Pass {
13981398 continue ;
13991399 }
14001400 Name inlinedName = inlinedFunction->name ;
1401- if (!isUnderSizeLimit (func->name , inlinedName)) {
1401+ if (!isUnderSizeLimit (
1402+ func->name , inlinedName, getPassRunner ()->options )) {
14021403 continue ;
14031404 }
14041405
@@ -1501,21 +1502,12 @@ struct Inlining : public Pass {
15011502 }
15021503
15031504 // Checks if the combined size of the code after inlining is under the
1504- // absolute size limit. We have an absolute limit in order to avoid
1505- // extremely-large sizes after inlining, as they may hit limits in VMs and/or
1506- // slow down startup (measurements there indicate something like ~1 second to
1507- // optimize a 100K function). See e.g.
1508- // https://github.com/WebAssembly/binaryen/pull/3730#issuecomment-867939138
1509- // https://github.com/emscripten-core/emscripten/issues/13899#issuecomment-825073344
1510- bool isUnderSizeLimit (Name target, Name source) {
1505+ // absolute size limit.
1506+ bool isUnderSizeLimit (Name target, Name source, PassOptions& options) {
15111507 // Estimate the combined binary size from the number of instructions.
15121508 auto combinedSize = infos[target].size + infos[source].size ;
15131509 auto estimatedBinarySize = Measurer::BytesPerExpr * combinedSize;
1514- // The limit is arbitrary, but based on the links above. It is a very high
1515- // value that should appear very rarely in practice (for example, it does
1516- // not occur on the Emscripten benchmark suite of real-world codebases).
1517- const Index MaxCombinedBinarySize = 400 * 1024 ;
1518- return estimatedBinarySize < MaxCombinedBinarySize;
1510+ return estimatedBinarySize < options.inlining .maxCombinedBinarySize ;
15191511 }
15201512};
15211513
0 commit comments