Inline some of the most called functions in SCI and SCUMM #4852
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When profiling a few games, we have spotted some functions which repeatedly made it to the top ten most called / cpu eating functions (on a 32 MHz hardware, so that explains why those numbers are so high...)
From the SCI camp we tested Gabriel Knight, Larry 2, Larry 7 and Sierra's Christmas Card 1988. The most CPU intensive functions (shown on Larry 2 intro but it is similar for the others):
8.30% of all spent CPU cycles:
Sci::reg_t::getOffset() const6.08% of all spent CPU cycles:
Sci::getSciVersion()1.80% of all spent CPU cycles:
Sci::reg_t::setOffset(unsigned int)1.25% of all spent CPU cycles:
Sci::Script::offsetIsObject(unsigned int) constAfter applying this PR, the total
run_vm()cost went from 0.00940s / call, down to 0.00672s / call, which is 28.5% improvement!During a run of Full Throttle,
testGfxUsageBit()calls account for 6.2% of all function calls (!) and ~2% of used cycles.The
getSciVersioncommit is perhaps the most interesting for review purposes; I was thinking about doing what theFIXMEsuggests but that wouldn't be such a win for performance as it could be inlined, sure, but also it would be replaced with another indirect jump caused byg_sci->getSciVersion()so I've taken the most efficient path even if it doesn't improve the code.