Avoid quadratic growth of cleanup blocks
Currently, cleanup blocks are only reused when there are nested scopes, the child scope's cleanup block will terminate with a jump to the parent scope's cleanup block. But within a single scope, adding or revoking any cleanup will force a fresh cleanup block. This means quadratic growth with the number of allocations in a scope, because each allocation needs a landing pad. Instead of forcing a fresh cleanup block, we can keep a list chained cleanup blocks that form a prefix of the currently required cleanups. That way, the next cleanup block only has to handle newly added cleanups. And by keeping the whole list instead of just the latest block, we can also handle revocations more efficiently, by only dropping those blocks that are no longer required, instead of all of them. Reduces the size of librustc by about 5% and the time required to build it by about 10%.
Showing
想要评论请 注册 或 登录