[scudo][standalone] Skip irrelevant regions during release
authorKostya Kortchinsky <kostyak@google.com>
Mon, 24 Aug 2020 21:13:12 +0000 (14:13 -0700)
committerKostya Kortchinsky <kostyak@google.com>
Tue, 25 Aug 2020 14:41:02 +0000 (07:41 -0700)
commitbd5ca4f0ed4adfa29150c18a621acb3e71d41450
tree843efad60ef3e1455ab8d00df64262c8c9e3ab31
parent1dc57ada0c79a57fbf7c87d5816e680cfd3bc077
[scudo][standalone] Skip irrelevant regions during release

With the 'new' way of releasing on 32-bit, we iterate through all the
regions in between `First` and `Last`, which covers regions that do not
belong to the class size we are working with. This is effectively wasted
cycles.

With this change, we add a `SkipRegion` lambda to `releaseFreeMemoryToOS`
that will allow the release function to know when to skip a region.
For the 64-bit primary, since we are only working with 1 region, we never
skip.

Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D86399
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h
compiler-rt/lib/scudo/standalone/release.h
compiler-rt/lib/scudo/standalone/tests/release_test.cpp