Adjust inlining thresholds.

This commit is contained in:
chriseth 2019-01-09 16:51:09 +01:00
parent edda79eec5
commit d9c6773664
2 changed files with 10 additions and 6 deletions

View File

@ -80,9 +80,9 @@ void FullInliner::run()
} }
} }
void FullInliner::updateCodeSize(FunctionDefinition& fun) void FullInliner::updateCodeSize(FunctionDefinition const& _fun)
{ {
m_functionSizes[fun.name] = CodeSize::codeSize(fun.body); m_functionSizes[_fun.name] = CodeSize::codeSize(_fun.body);
} }
void FullInliner::handleBlock(YulString _currentFunctionName, Block& _block) void FullInliner::handleBlock(YulString _currentFunctionName, Block& _block)
@ -100,8 +100,13 @@ bool FullInliner::shallInline(FunctionCall const& _funCall, YulString _callSite)
if (!calledFunction) if (!calledFunction)
return false; return false;
// Inline really, really tiny functions
size_t size = m_functionSizes.at(calledFunction->name);
if (size <= 1)
return true;
// Do not inline into already big functions. // Do not inline into already big functions.
if (m_functionSizes.at(_callSite) > 100) if (m_functionSizes.at(_callSite) > 45)
return false; return false;
if (m_singleUse.count(calledFunction->name)) if (m_singleUse.count(calledFunction->name))
@ -119,8 +124,7 @@ bool FullInliner::shallInline(FunctionCall const& _funCall, YulString _callSite)
break; break;
} }
size_t size = m_functionSizes.at(calledFunction->name); return (size < 6 || (constantArg && size < 12));
return (size < 10 || (constantArg && size < 30));
} }
void FullInliner::tentativelyUpdateCodeSize(YulString _function, YulString _callSite) void FullInliner::tentativelyUpdateCodeSize(YulString _function, YulString _callSite)

View File

@ -91,7 +91,7 @@ public:
void tentativelyUpdateCodeSize(YulString _function, YulString _callSite); void tentativelyUpdateCodeSize(YulString _function, YulString _callSite);
private: private:
void updateCodeSize(FunctionDefinition& fun); void updateCodeSize(FunctionDefinition const& _fun);
void handleBlock(YulString _currentFunctionName, Block& _block); void handleBlock(YulString _currentFunctionName, Block& _block);
/// The AST to be modified. The root block itself will not be modified, because /// The AST to be modified. The root block itself will not be modified, because