Commit Graph

34 Commits

Author SHA1 Message Date
Ryan Macnak da5fa77042 [vm] Avoid populating page table entries for the compressed heap up front.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45331
Change-Id: I1bb8e7ea3fce88dceb28edf8a81cee48db83f144
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191982
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-03-18 23:04:14 +00:00
Ryan Macnak 2472db0031 [vm] Inform the OS that it can reclaim free'd portions of the compressed heap.
TEST=ci
Change-Id: I26c5963d5d3596f95d3089b1dadc482bd2182543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191301
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-03-16 00:12:54 +00:00
Ryan Macnak 9d803a5263 [vm] Fail gracefully when unable to reserve address space for the compresssed heap.
TEST=ulimit -v 900000 && dart hello.dart
Bug: https://github.com/dart-lang/sdk/issues/45132
Change-Id: Ifcb0ad26f59ef4269b3e60dccc844d34406f4fcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189162
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-03-04 22:32:20 +00:00
Liam Appelbe 807874d51a [vm] Align compressed pointer allocations on windows.
Change-Id: I95ad0a2cf679a5918d42b12bb95f1503bb219fca
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184846
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-25 20:48:07 +00:00
Liam Appelbe be0978cbde Reland "[vm] Align heap allocations to 2GB regions in comp ptr mode"
Fixed the mac build.

This reverts commit 0ed3fb3dee.

Bug: https://github.com/dart-lang/sdk/issues/45059
Change-Id: I0cd6710a641b195403dda717108bdbe3395a21fa
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186340
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-22 19:58:49 +00:00
Vyacheslav Egorov 0ed3fb3dee Revert "[vm] Align heap allocations to 2GB regions in comp ptr mode"
This reverts commit d10d17cca2.

Reason for revert: Broke Mac builds

Original change's description:
> [vm] Align heap allocations to 2GB regions in comp ptr mode
>
> This only handles the POSIX case. The Windows case will work exactly the
> same as this, so I want to get this reviewed before I start porting it
> to windows.
>
> TEST=Manual testing. I'll update the unit tests once it's ported.
>
> Bug: https://github.com/dart-lang/sdk/issues/45059
> Change-Id: I0bc0eddd95101fc2fddfe5668488670e741af586
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183142
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Liam Appelbe <liama@google.com>

Bug: https://github.com/dart-lang/sdk/issues/45059
Change-Id: I840c31ead015f60bca32b551c8f8d31fa75ad645
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186101
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-02-21 15:25:03 +00:00
Liam Appelbe d10d17cca2 [vm] Align heap allocations to 2GB regions in comp ptr mode
This only handles the POSIX case. The Windows case will work exactly the
same as this, so I want to get this reviewed before I start porting it
to windows.

TEST=Manual testing. I'll update the unit tests once it's ported.

Bug: https://github.com/dart-lang/sdk/issues/45059
Change-Id: I0bc0eddd95101fc2fddfe5668488670e741af586
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183142
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2021-02-20 01:29:35 +00:00
Ryan Macnak 3b05ddef10 [vm, gc] Issue a warning when Linux's vm.max_map_count is not large enough to support fully allocating a max heap size given by --old_gen_heap_size.
TEST=manually adjusting --old_gen_heap_size
Bug: https://github.com/dart-lang/sdk/issues/44219
Change-Id: I7ef6d46aca85024028dbd64bddd84438d028f0cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172361
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-11-17 17:50:08 +00:00
Martin Kustermann dae308461c [vm/concurrency] Share [Heap] and [SharedClassTable] between all isolates within one isolate group
This CL:

  * Moves [Heap]/[SharedClassTable] from [Isolate] to [IsolateGroup], which
    will make all isolates in the group use the same heap. The GC will use
    the shared class table for object size information.

  * Adds support for entering/leaving an isolate group as a helper thread
    (e.g. via [Thread::EnterIsolateGroupAsHelper]). The current active
    isolate group can be accessed via TLS `IsolateGroup::Current()` or
    `Thread::isolate_group_`. When entering as a helper thread there will be
    no current isolate.

  * Changes the GC to use the above mechanism and ensures GC works without
    a currently active isolate. The GC will use information purely available via
    [IsolateGroup]. The GC will iterate all isolates within an isolate
    group e.g. for scanning roots.

  * Makes spawning of new isolates start in their own isolate group.
    Once the isolate is fully functional it's heap will be merged into
    the original isolate group

  * Moves ApiState, containing persistent and weak persistent handles,
    from [Isolate] to [IsolateGroup], plus adds appropriate locking.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Ia8e1d8aa78750e8400864200f4825395a182c004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126646
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-02-20 21:08:35 +00:00
Alexander Aprelev 0cc27b5db0 Reland "[vm, linux] Try to attach names to all VirtualMemory allocations using memfd."
This reverts commit 4dee4bd204 as it now has the fix for precompiled flow in patchsets 3, 7.

Change-Id: Ib99763a91073df7698e8b597a67e11e557fc131e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128574
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-12-18 18:02:41 +00:00
Clement Skau 4dee4bd204 Revert "[vm, linux] Try to attach names to all VirtualMemory allocations using memfd."
This reverts commit f5e57f89d2.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> [vm, linux] Try to attach names to all VirtualMemory allocations using memfd.
> 
> For example,
> 
> $ cat /proc/<pid>/smaps
> ...
> 7fd2ad2e0000-7fd2ad2f0000 rw-s 00000000 00:05 15576579 /memfd:dart-zone (deleted)
> 7fd2b2b7f000-7fd2b2d7f000 rw-s 00000000 00:05 15695692 /memfd:dart-newspace (deleted)
> 7fd2b2f00000-7fd2b2f80000 r--s 00000000 00:05 15695687 /memfd:dart-codespace (deleted)
> 7fd2b2f80000-7fd2b3000000 r--s 00000000 00:05 15695685 /memfd:dart-oldspace (deleted)
> 7fd2b3163000-7fd2b3beb000 rw-s 00000000 00:05 15695684 /memfd:dart-profiler (deleted)
> 7fd2b3beb000-7fd2b3eb0000 rw-s 00000000 00:05 15695683 /memfd:dart-timeline (deleted)
> ...
> 
> Bug: b/144232910
> Change-Id: I9722247853b244daff63b7a631678d44e19c2d69
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128603
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=aam@google.com,rmacnak@google.com,asiva@google.com,chinmaygarde@google.com

Change-Id: I8a983d4650ca10e9c7396536603af21c974dcb78
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/144232910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128587
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2019-12-17 11:14:19 +00:00
Ryan Macnak f5e57f89d2 [vm, linux] Try to attach names to all VirtualMemory allocations using memfd.
For example,

$ cat /proc/<pid>/smaps
...
7fd2ad2e0000-7fd2ad2f0000 rw-s 00000000 00:05 15576579 /memfd:dart-zone (deleted)
7fd2b2b7f000-7fd2b2d7f000 rw-s 00000000 00:05 15695692 /memfd:dart-newspace (deleted)
7fd2b2f00000-7fd2b2f80000 r--s 00000000 00:05 15695687 /memfd:dart-codespace (deleted)
7fd2b2f80000-7fd2b3000000 r--s 00000000 00:05 15695685 /memfd:dart-oldspace (deleted)
7fd2b3163000-7fd2b3beb000 rw-s 00000000 00:05 15695684 /memfd:dart-profiler (deleted)
7fd2b3beb000-7fd2b3eb0000 rw-s 00000000 00:05 15695683 /memfd:dart-timeline (deleted)
...

Bug: b/144232910
Change-Id: I9722247853b244daff63b7a631678d44e19c2d69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128603
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-12-16 23:30:03 +00:00
Samir Jindel c885bdde1d [vm] DBC is obsolete. Remove dead code.
Change-Id: Ica33af158cca53c8e951e4b2582de83660e8a60d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121851
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-27 18:18:29 +00:00
Ryan Macnak b5bbc97566 Revert "[vm, linux] Try to attach names to all VirtualMemory allocations using memfd."
This reverts commit 48e93d3d3b.

Reason for revert: ~10% regression on Isolate.SendReceiveBytes benchmarks, likely heavy allocation and freeing of large heap pages

Original change's description:
> [vm, linux] Try to attach names to all VirtualMemory allocations using memfd.
>
> For example,
>
> $ cat /proc/<pid>/smaps
> ...
> 7fe527158000-7fe527be0000 rw-s 00000000 00:05 35765318                   /memfd:dart-profiler (deleted)
> 7fe527be0000-7fe527ea5000 rw-s 00000000 00:05 35765317                   /memfd:dart-timeline (deleted)
> 7fe528a40000-7fe528a51000 rw-s 00000000 00:05 35762832                   /memfd:dart-heap (deleted)
> ...
>
> Change-Id: I10452a1261cec26719ceadf569aadd864be5378e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120981
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>

TBR=rmacnak@google.com,zra@google.com,regis@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ic839bd0ce67d8ac438916d6b4c626f0f7d6991d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121412
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-14 16:59:31 +00:00
Ryan Macnak 48e93d3d3b [vm, linux] Try to attach names to all VirtualMemory allocations using memfd.
For example,

$ cat /proc/<pid>/smaps
...
7fe527158000-7fe527be0000 rw-s 00000000 00:05 35765318                   /memfd:dart-profiler (deleted)
7fe527be0000-7fe527ea5000 rw-s 00000000 00:05 35765317                   /memfd:dart-timeline (deleted)
7fe528a40000-7fe528a51000 rw-s 00000000 00:05 35762832                   /memfd:dart-heap (deleted)
...

Change-Id: I10452a1261cec26719ceadf569aadd864be5378e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120981
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-10-10 00:49:41 +00:00
Samir Jindel 9a683de40d [vm] Support testing assembly snapshots for ARM.
We have had several bugs propagate to Flutter end-users due to our lack of testing of
AOT Assembly snapshots on ARM (SIMARM_X64 in particular), causing reverts of SDK commits
and disrupting the Dart -> Flutter roll.

This leverages our custom ELF loader to load the generated ELF objects, which cannot be
loaded by dlopen() because they are marked with the ARM ABI.

For example, see:
  - https://github.com/flutter/flutter/issues/40114
  - https://github.com/flutter/flutter/issues/41228

Also do some tree-shaking of the snapshot writers for dart_precompiled_runtime.

Fixes https://github.com/dart-lang/sdk/issues/38433.

Change-Id: I5990769c623b8a13131b1848349af2c0a026272b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118569
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2019-09-25 17:09:16 +00:00
Samir Jindel 362ef8e67c [vm/aot] Add a custom ELF loader in dart_precompiled_runtime.
Also switch some CQ bots using blobs to ELF. Once all embedders have migrated, we will remove blobs
support entirely.

Change-Id: Ie5e8c1187ad6c1af362b5715daafd3641bc8cc0e
Cq-Include-Trybots:luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-bare-linux-release-simarm-try,vm-kernel-precomp-mac-debug-simarm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-android-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116620
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-09-24 15:03:19 +00:00
asiva 2023f09b56 [VM] For app-jit snapshot on MacOS 10.15 and higher mmap ANONYMOUS pages and
read the app-jit snapshot into this memory instead of directly mapping
the app-jit snapshot.

use MAP_JIT option only for executable pages and do not use it on iOS.

Change-Id: I8db6f29293677bbf36209473709077115b7b489e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113219
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-08-16 04:39:02 +00:00
Siva Annamalai ec2d06d4b9 Use MAP_JIT when doing an mmap for executable pages (needed for macOS Catalina).
Please refer to https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_cs_allow-jit for more details.

This is the Dart VM part for https://github.com/flutter/flutter/issues/36714

Change-Id: Ifbc0ce82921d5f05421e01ce2d19423a5f3e32f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112849
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-08-14 16:51:49 +00:00
Martin Kustermann 7693da7967 [vm] When dual mapping is enabled map the executable part as RX immediately
Currently the initial mapping for the executable mapping is read-only.
Once the first instruction object was allocated into an OS page we would
map that page as RX. Any further allocations of instructions objects
into the same page would just end up mapping it to RX again (even though
it is already that way).

To avoid those additional protection calls we can map the executable
mapping RX from the beginning (it will be filled with zeros after
allocation).

Issue https://github.com/dart-lang/sdk/issues/37739
Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Ib83f0be8ea8dacc86646c0a3c0335f4886516caa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112244
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-08-08 18:29:33 +00:00
Samir Jindel e59a4a2b42 [vm/ffi] Call natives through stubs if write-protection is enabled without dual-mapping.
Addresses the Dart -> Native half of dartbug.com/37629

Change-Id: I242b7f3a14dd105334a8b6e5c089b173c398491e
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111280
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-07 11:37:20 +00:00
Samir Jindel 3ff7bc3992 [vm] Disable dual code mapping when perf flags are passed.
Otherwise these perf flags are broken by default.

Change-Id: I17cdb54b03da38fc6384116cecbdee60e7e5ed93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102161
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-06-04 15:10:42 +00:00
Ryan Macnak a2d7227a76 [vm] Never give DBC instructions executable permissions.
Bug: https://github.com/flutter/flutter/issues/29022
Change-Id: I8f264ffca79d7684643d74033e2cd79f2b2f35a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97275
Reviewed-by: Régis Crelier <regis@google.com>
2019-03-20 16:13:55 +00:00
Régis Crelier 00a478ca80 [VM runtime] Do not leak file descriptors of dual mappings to child processes.
This applies to linux only and is a suggested precaution.

Change-Id: I81cc345eb2c316530de1fd779cdf392804a68490
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96982
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-03-14 20:47:14 +00:00
Régis Crelier e2a86d9081 [VM runtime] Use memfd_create instead of shm_open for dual mapping of code.
Detect both at compile time and runtime for memfd_create support and disable
dual code mapping if not available.

Change-Id: I6908e6c116a60218bb5002378470011dfe76a257
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96845
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-03-14 16:56:34 +00:00
Régis Crelier 1bd36d694d [vm runtime] Dynamically disable dual mapping of code on some platforms.
Until a better solution is found, disable dual mapping of code on docker
containers that fail setting exec permissions on dual mappings.

Change-Id: Ic7477e1ef70ae0ea4d0187284702d5a3ee594edf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96668
Commit-Queue: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2019-03-12 23:42:35 +00:00
Régis Crelier a39833d957 Reland "Reland "[VM runtime] Dual mapping of executable pages.""
This is a reland of 6da340bf76

Original change's description:
> Reland "[VM runtime] Dual mapping of executable pages."
> 
> This is a reland of 44186dfdcd
> 
> Original change's description:
> > [VM runtime] Dual mapping of executable pages.
> > 
> > Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> > Reviewed-on: https://dart-review.googlesource.com/c/93377
> > Commit-Queue: Régis Crelier <regis@google.com>
> > Reviewed-by: Ryan Macnak <rmacnak@google.com>
> 
> Change-Id: I7a0caa078950637d9fe831732577fd2467061099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95263
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: I3a01f0e67d733c5db41618f691431e72c1e1cb2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96422
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-03-12 20:45:45 +00:00
Vyacheslav Egorov 9ff0a654ca Revert "Reland "[VM runtime] Dual mapping of executable pages.""
This reverts commit 6da340bf76.

Reason for revert: almost all benchmarks are now failing on Golem linux-x64 target. Flutter Golem build is broken 

Original change's description:
> Reland "[VM runtime] Dual mapping of executable pages."
> 
> This is a reland of 44186dfdcd
> 
> Original change's description:
> > [VM runtime] Dual mapping of executable pages.
> > 
> > Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> > Reviewed-on: https://dart-review.googlesource.com/c/93377
> > Commit-Queue: Régis Crelier <regis@google.com>
> > Reviewed-by: Ryan Macnak <rmacnak@google.com>
> 
> Change-Id: I7a0caa078950637d9fe831732577fd2467061099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95263
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,regis@google.com

Change-Id: I3342de2584537269ffe9a53946bef27cb25a69fc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96161
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2019-03-09 14:15:39 +00:00
Régis Crelier 6da340bf76 Reland "[VM runtime] Dual mapping of executable pages."
This is a reland of 44186dfdcd

Original change's description:
> [VM runtime] Dual mapping of executable pages.
> 
> Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> Reviewed-on: https://dart-review.googlesource.com/c/93377
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: I7a0caa078950637d9fe831732577fd2467061099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95263
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-08 18:33:02 +00:00
Régis Crelier 0491d5cde7 Revert "[VM runtime] Dual mapping of executable pages."
This reverts commit 44186dfdcd.

Reason for revert: not working on vm-kernel-precomp-android-release-arm

Original change's description:
> [VM runtime] Dual mapping of executable pages.
> 
> Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> Reviewed-on: https://dart-review.googlesource.com/c/93377
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,regis@google.com

Change-Id: I793ceee6252111eafbcbfe6e28268f4f6f2d7215
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/94989
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-03-01 22:55:14 +00:00
Régis Crelier 44186dfdcd [VM runtime] Dual mapping of executable pages.
Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
Reviewed-on: https://dart-review.googlesource.com/c/93377
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-01 22:19:31 +00:00
Matthew Dempsky 9308cac681 [vm] Simplify VirtualMemory::Truncate
Callers always want to try to unmap the trailing pages, and the
OS-specific FreeSubSegment helper routine can never fail. Simplify
code accordingly.

Change-Id: I32e4bc72f626e15032d73326bee76a4a2ef71025
Reviewed-on: https://dart-review.googlesource.com/c/91146
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-01-31 21:01:48 +00:00
Matthew Dempsky b11f2d8e69 [vm] Implement VirtualMemory::Allocate using AllocateAligned
Instead of implementing separate aligned and unaligned memory
allocation primitives for each OS, just change the unaligned allocator
into a wrapper around the aligned primitive.

While here, we can optimize the AllocateAligned logic slightly: if we
want an N-page-aligned allocation, we only need to increase the
allocation size by N-1 pages instead of N.

Notably, this means 1-page-aligned allocations don't require any extra
alignment pages, so the new logic behaves identically as before on
Android, Fuchsia, Linux, and macOS.

On Windows, it behaves slightly differently only in that unaligned
requests used to be handled as a single VirtualAlloc call with
MEM_RESERVE | MEM_COMMIT, but now they're handled as two separate
calls (reserve *then* commit). Naively, I don't expect this matters in
practice, but if it does, we can always add a fast path for
alignment==page_size_ without affecting the OS-independent API.

Change-Id: I42b2cf5dfc6e137546d8acfb6cc8939a01687948
Reviewed-on: https://dart-review.googlesource.com/c/91081
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-01-25 01:22:20 +00:00
Matthew Dempsky 0193dd58fa [vm] Deduplicate POSIX-based memory allocation code
The Android, Linux, and macOS VirtualMemory implementations were
identical and using the same POSIX-standardized interfaces, so
deduplicate them into a common virtual_memory_posix.cc implementation.

Change-Id: I58a2aaa959aac69af52d9faba88865a4ef20d004
Reviewed-on: https://dart-review.googlesource.com/c/91080
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2019-01-24 22:39:50 +00:00