v8/test/cctest/heap
Igor Sheludko 449ece383b Reland "[rwx][mac] Support fast W^X permission switching on Apple Silicon (M1)"
This is a reland of commit 9d31f8663a
There were issues with --future flag implications on M1.

Original change's description:
> [rwx][mac] Support fast W^X permission switching on Apple Silicon (M1)
>
> ... for V8 code space. The feature is currently disabled.
>
> In order to use fast W^X permission switching we must allocate
> executable pages with readable writable executable permissions (RWX).
> However, MacOS on ARM64 ("Apple M1"/Apple Silicon) prohibits further
> permission changing of RWX memory pages. This means that the code page
> headers must be allocated with RWX permissions too because otherwise
> it wouldn't be possible to allocate a large code page over the freed
> regular code page and vice versa.
>
> When enabled, the new machinery works as follows:
>
> 1) when memory region is reserved for allocating executable pages, the
>    whole region is committed with RWX permissions and then decommitted,
> 2) since reconfiguration of RWX page permissions is not allowed on
>    MacOS on ARM64 ("Apple M1"/Apple Silicon), there must be no attempts
>    to change them,
> 3) the request to set RWX permissions in the executable page region
>    just recommits the pages without changing permissions (see (1), they
>    were already allocated as RWX and then discarded),
> 4) in order to make executable pages inaccessible one must use
>    OS::DiscardSystemPages() instead of OS::DecommitPages() or
>    setting permissions to kNoAccess because the latter two are not
>    allowed by the MacOS (see (2)).
> 5) since code space page headers are allocated as RWX pages it's also
>    necessary to switch between W^X modes when updating the data in the
>    page headers (i.e. when marking, updating stats, wiring pages in
>    lists, etc.). The new CodePageHeaderModificationScope class is used
>    in the respective places. On unrelated configurations it's a no-op.
>
> The fast permission switching can't be used for V8 configuration with
> enabled pointer compression and disabled external code space because
> a) the pointer compression cage has to be reserved with MAP_JIT flag
>    which is too expensive,
> b) in case of shared pointer compression cage if the code range will
>    be deleted while the cage is still alive then attempt to configure
>    permissions of pages that were previously set to RWX will fail.
>
> This also CL extends the unmapper unit tests with permissions tracking
> for discarded pages.
>
> Bug: v8:12797
> Change-Id: Idb28cbc481306477589eee9962d2e75167d87c61
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3579303
> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Igor Sheludko <ishell@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#80238}

Bug: v8:12797
Change-Id: I0fe86666f31bad37d7074e217555c95900d2afba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3610433
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80259}
2022-04-28 14:08:11 +00:00
..
heap-tester.h Reland "Reland "[deoptimizer] Change deopt entries into builtins"" 2020-10-21 06:01:38 +00:00
heap-utils.cc [heap] Add Heap::NotifyObjectSizeChange for right-trimming 2022-04-27 08:01:24 +00:00
heap-utils.h [heap, infra] Remove --local-heaps and --concurrent-allocation flags 2021-02-01 11:01:26 +00:00
test-alloc.cc [heap] Add Heap::NotifyObjectSizeChange for right-trimming 2022-04-27 08:01:24 +00:00
test-array-buffer-tracker.cc [heap] Separate GC phases flag. 2022-04-06 07:23:39 +00:00
test-compaction.cc Revert "[heap] Store size with invalidated object" 2022-04-26 08:45:13 +00:00
test-concurrent-allocation.cc Reland "[rwx][mac] Support fast W^X permission switching on Apple Silicon (M1)" 2022-04-28 14:08:11 +00:00
test-concurrent-marking.cc heap: Refactor sweeping finalization for young GC 2022-03-08 16:48:43 +00:00
test-external-string-tracker.cc heap: Rename compaction flags 2021-11-10 09:01:59 +00:00
test-heap.cc [string] Add flag to use string forwarding table instead of ThinString 2022-04-27 09:09:30 +00:00
test-incremental-marking.cc [test] Make cctest run one test, with maybe custom platform 2022-04-05 09:39:18 +00:00
test-invalidated-slots.cc Revert "[heap] Store size with invalidated object" 2022-04-26 08:45:13 +00:00
test-iterators.cc Reland "[include] Split out v8.h" 2021-08-24 13:08:55 +00:00
test-mark-compact.cc [heap] Add Heap::NotifyObjectSizeChange for right-trimming 2022-04-27 08:01:24 +00:00
test-memory-measurement.cc [test] Make cctest run one test, with maybe custom platform 2022-04-05 09:39:18 +00:00
test-page-promotion.cc [heap] Remove flag always_promote_young_mc 2021-11-09 19:37:39 +00:00
test-shared-heap.cc [heap] Find references in client heaps to shared objects in shared GC 2021-12-06 12:00:18 +00:00
test-spaces.cc Reland "[rwx][mac] Support fast W^X permission switching on Apple Silicon (M1)" 2022-04-28 14:08:11 +00:00
test-unmapper.cc [test] Make cctest run one test, with maybe custom platform 2022-04-05 09:39:18 +00:00
test-weak-references.cc [heap] Separate GC phases flag. 2022-04-06 07:23:39 +00:00
test-write-barrier.cc [heap] Fix failed tests when enabling single generation 2021-04-21 07:33:51 +00:00