Introduce `LocalAddressSpaceView::LoadWritable(...)` and make the `Load(...)` method...
authorDan Liew <dan@su-root.co.uk>
Fri, 28 Dec 2018 19:30:51 +0000 (19:30 +0000)
committerDan Liew <dan@su-root.co.uk>
Fri, 28 Dec 2018 19:30:51 +0000 (19:30 +0000)
commit8c11fb3ed419a8c48f0f36af6e0a621aa75be320
tree1725a89afdd72dd48f0cd41cb27940833c60f19e
parentbae11e79990a97133cfced28796a5695d823015c
Introduce `LocalAddressSpaceView::LoadWritable(...)` and make the `Load(...)` method return a const pointer.

Summary:
This is a follow-up to r346956 (https://reviews.llvm.org/D53975).

The purpose of this change to allow implementers of the
`AddressSpaceView` to be able to distinguish between when a caller wants
read-only memory and when a caller wants writable memory. Being able
distinguish these cases allows implementations to optimize for the
different cases and also provides a way to workaround possible platform
restrictions (e.g. the low level platform interface for reading
out-of-process memory may place memory in read-only pages).

For allocator enumeration in almost all cases read-only is sufficient so
we make `Load(...)` take on this new requirement and introduce the
`LoadWritable(...)` variants for cases where memory needs to be
writable.

The behaviour of `LoadWritable(...)` documented in comments are
deliberately very restrictive so that it will be possible in the future
to implement a simple write-cache (i.e. just a map from target address
to a writable region of memory). These restrictions can be loosened in
the future if necessary by implementing a more sophisticated
write-cache.

rdar://problem/45284065

Reviewers: kcc, cryptoad, eugenis, kubamracek, george.karpenkov

Subscribers: #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D54879

llvm-svn: 350136
compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h
compiler-rt/lib/sanitizer_common/sanitizer_local_address_space_view.h