Commit Graph
44 Commits
Author SHA1 Message Date
Sylvestre Ledru 0804530f25 Bug 2023419 - Remove Emacs/Vim modelines from ipc/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287850
2026-03-17 08:01:09 +00:00
André Bargull 22f5b5c7c5 Bug 2020608 - Part 12: Replace IsPowerOfTwo with std::has_single_bit outside of js/. r=sergesanspaille,profiler-reviewers,win-reviewers,gstoll,canaltinova
`mozilla::IsPowerOfTwo` is used in more code than the previous functions, so split
up the updates in three parts. This part updates non-SpiderMonkey code to use
`std::has_single_bit`. The next part updates SpiderMonkey code and the last part
finally removes `mozilla::IsPowerOfTwo`.

Differential Revision: https://phabricator.services.mozilla.com/D286320
2026-03-14 14:08:50 +00:00
Atila Butkovits 3578df2975 Revert "Bug 2020608 - Part 17: Use std::rot[lr] for Rotate(Left|Right). r=sergesanspaille" for causing bustages at PowerOfTwo.h.
This reverts commit eb884a9f65.

Revert "Bug 2020608 - Part 16: Use std::bit_ceil for RoundUpPow2. r=sergesanspaille"

This reverts commit 35a310aa8a.

Revert "Bug 2020608 - Part 15: Require unsigned integral types for CeilingLog2 and FindMostSignificantBit. r=sergesanspaille,nbp"

This reverts commit f682901ca2.

Revert "Bug 2020608 - Part 14: Remove mozilla::IsPowerOfTwo. r=sergesanspaille"

This reverts commit b998e4bd39.

Revert "Bug 2020608 - Part 13: Replace IsPowerOfTwo with std::has_single_bit in js/. r=sergesanspaille"

This reverts commit 00db5e1f32.

Revert "Bug 2020608 - Part 12: Replace IsPowerOfTwo with std::has_single_bit outside of js/. r=sergesanspaille,profiler-reviewers,win-reviewers,gstoll,canaltinova"

This reverts commit cec056f5d6.

Revert "Bug 2020608 - Part 11: Simplify PowerOfTwo. r=sergesanspaille,profiler-reviewers,canaltinova"

This reverts commit a2ee5b9053.

Revert "Bug 2020608 - Part 10: Prefer std::bit_width in MathAlgorithms.h. r=sergesanspaille"

This reverts commit 89d966bb97.

Revert "Bug 2020608 - Part 9: Prefer std::bit_width instead of std::countl_zero in js/src. r=sergesanspaille"

This reverts commit da9a43075a.

Revert "Bug 2020608 - Part 8: Replace CountTrailingZeroes with std::countr_zero. r=sergesanspaille"

This reverts commit d77ca273cb.

Revert "Bug 2020608 - Part 7: Replace CountLeadingZeroes32 with std::countl_zero or std::countl_one. r=sergesanspaille,nbp,profiler-reviewers,canaltinova"

This reverts commit 94929ae729.

Revert "Bug 2020608 - Part 6: Replace CountLeadingZeroes64 with std::countl_zero. r=sergesanspaille,profiler-reviewers,canaltinova"

This reverts commit 9b428168df.

Revert "Bug 2020608 - Part 5: Replace CountTrailingZeroes32 with std::countr_zero. r=sergesanspaille,manuel"

This reverts commit d3e77036b2.

Revert "Bug 2020608 - Part 4: Replace CountTrailingZeroes64 with std::countr_zero or std::countr_one. r=sergesanspaille"

This reverts commit 6a7bcee10e.

Revert "Bug 2020608 - Part 3: Replace CountPopulation32 with std::popcount. r=sergesanspaille"

This reverts commit e7b204177b.

Revert "Bug 2020608 - Part 2: Replace CountPopulation64 with std::popcount. r=sergesanspaille"

This reverts commit 1d6f98a622.

Revert "Bug 2020608 - Part 1: Add <bit> C++20 definitions to std.py. r=sergesanspaille"

This reverts commit 3ee4c6dcab.
2026-03-13 21:11:22 +00:00
André Bargull cec056f5d6 Bug 2020608 - Part 12: Replace IsPowerOfTwo with std::has_single_bit outside of js/. r=sergesanspaille,profiler-reviewers,win-reviewers,gstoll,canaltinova
`mozilla::IsPowerOfTwo` is used in more code than the previous functions, so split
up the updates in three parts. This part updates non-SpiderMonkey code to use
`std::has_single_bit`. The next part updates SpiderMonkey code and the last part
finally removes `mozilla::IsPowerOfTwo`.

Differential Revision: https://phabricator.services.mozilla.com/D286320
2026-03-13 20:20:10 +00:00
Alex Franchuk a3dfc25ed0 Bug 1954226 - Fix FreezeAndReprotect test r=jld
This should remap as read-only and use that address, because unmapping
allows the address to be used by anything else (causing intermittent
failure).

The other `LocalProtect` test was also bad, so I fixed that and a
few compiler warnings.

Differential Revision: https://phabricator.services.mozilla.com/D241865
2025-03-18 13:15:55 +00:00
Alex Franchuk b866d4a7b2 Bug 1951925 - Fix base content memory usage regressions r=nika
This disarms a footgun in the FreezableMapping::Freeze API, which was
causing read-only mappings in the global stylesheet cache to fail. These
failures caused content processes to re-load the style sheets,
increasing memory usage.

Differential Revision: https://phabricator.services.mozilla.com/D240928
2025-03-12 13:44:00 +00:00
Goloman Adrian 3bf4bdf4df Backed out changeset dca810679260 (bug 1951925) for causing build bustages @TestSharedMemory.cpp. CLOSED TREE 2025-03-12 05:55:09 +02:00
Alex Franchuk ec8529652d Bug 1951925 - Fix base content memory usage regressions r=nika
This disarms a footgun in the FreezableMapping::Freeze API, which was
causing read-only mappings in the global stylesheet cache to fail. These
failures caused content processes to re-load the style sheets,
increasing memory usage.

Differential Revision: https://phabricator.services.mozilla.com/D240928
2025-03-12 03:17:49 +00:00
Alex Franchuk 4ed9531818 Bug 1942129 pt5 - Update shared memory tests r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D236752
2025-03-04 22:11:12 +00:00
Butkovits Atila 2406ce261c Backed out 8 changesets (bug 1942129) for causing bustages at SharedMemoryMapping.h. CLOSED TREE
Backed out changeset 8d9053f1c203 (bug 1942129)
Backed out changeset 393e3c507c27 (bug 1942129)
Backed out changeset 8240d353d224 (bug 1942129)
Backed out changeset 8c4cd026b720 (bug 1942129)
Backed out changeset 742634b0d6e9 (bug 1942129)
Backed out changeset d16857f9812f (bug 1942129)
Backed out changeset 7ff7af041ee7 (bug 1942129)
Backed out changeset ef41d9e4c7de (bug 1942129)
2025-03-04 00:43:23 +02:00
Alex Franchuk fc0795d6b5 Bug 1942129 pt5 - Update shared memory tests r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D236752
2025-03-03 19:53:21 +00:00
Nika Layzell 1cecdf41cf Bug 1927209 - Try to handle fragmented memory better for large buffers in IPC, r=afranchuk,ipc-reviewers,jld
This adds a new type, `SharedMemoryCursor`, as well as platform support
for mapping subregions of shared memory handles. This type will attempt
to map the entire shared memory region, and will back off on the size of
the region until it can successfully map a portion of the region to read
data from.

Ideally, this should help reduce the chances of encountering memory
fragmentation issues when sending large JS structured clone buffers over
IPC.

Differential Revision: https://phabricator.services.mozilla.com/D233116
2025-02-13 21:29:21 +00:00
Alexandru Marc 514fa30328 Backed out 2 changesets (bug 1927209, bug 1947418) for causing out of memory issues a=backout
Backed out changeset 280cd0c72bdd (bug 1947418)
Backed out changeset 577fcfb38a89 (bug 1927209)
2025-02-12 13:00:53 +02:00
Nika Layzell a5bc212f36 Bug 1927209 - Try to handle fragmented memory better for large buffers in IPC, r=afranchuk,ipc-reviewers,jld
This adds a new type, `SharedMemoryCursor`, as well as platform support
for mapping subregions of shared memory handles. This type will attempt
to map the entire shared memory region, and will back off on the size of
the region until it can successfully map a portion of the region to read
data from.

Ideally, this should help reduce the chances of encountering memory
fragmentation issues when sending large JS structured clone buffers over
IPC.

Differential Revision: https://phabricator.services.mozilla.com/D233116
2025-02-10 19:30:09 +00:00
Otto Länd 2110f50a30 Bug 1901996: apply code formatting via Lando
# ignore-this-changeset
2024-10-29 03:24:23 +00:00
Jed Davis 0f5c33cd13 Bug 1901996 - Make IPC memfds non-executable if supported. r=ipc-reviewers,nika
This patch also uses `MFD_ALLOW_SEALING` unconditionally, even if we're
not planning to seal the memfd, because `MFD_NOEXEC_SEAL` implies it.
(We could re-add `F_SEAL_SEAL` explicitly in that case but I don't think
it makes a meaningful difference in our use cases.)

Differential Revision: https://phabricator.services.mozilla.com/D222575
2024-10-29 02:45:35 +00:00
Alex Franchuk 028c64fb69 Bug 1454816 - Replace uses of base::SharedMemory r=ipc-reviewers,media-playback-reviewers,padenot,nika
Differential Revision: https://phabricator.services.mozilla.com/D224153
2024-10-21 18:43:25 +00:00
Sandor Molnar abe7f841ca Backed out 4 changesets (bug 1454816) for causing build bustages. CLOSED TREE
Backed out changeset 3e8d2c47138c (bug 1454816)
Backed out changeset 80ff20241831 (bug 1454816)
Backed out changeset 28c2d6d2a683 (bug 1454816)
Backed out changeset 236943ab4142 (bug 1454816)
2024-10-21 20:15:13 +03:00
Alex Franchuk d60af44cea Bug 1454816 - Replace uses of base::SharedMemory r=ipc-reviewers,media-playback-reviewers,padenot,nika
Differential Revision: https://phabricator.services.mozilla.com/D224153
2024-10-21 13:08:44 +00:00
Cristina Horotan 9b33881471 Backed out 4 changesets (bug 1454816) for causing build bustages at nsIStringBundle.h CLOSED TREE
Backed out changeset bed340babebd (bug 1454816)
Backed out changeset f7499fb49eb0 (bug 1454816)
Backed out changeset 9a82c5828c53 (bug 1454816)
Backed out changeset efe7bc48a16d (bug 1454816)
2024-10-18 23:41:27 +03:00
Alex Franchuk a8de347355 Bug 1454816 - Replace uses of base::SharedMemory r=ipc-reviewers,media-playback-reviewers,padenot,nika
Differential Revision: https://phabricator.services.mozilla.com/D224153
2024-10-18 16:58:45 +00:00
Alex Franchuk 5a5e8a0b1c Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D217487
2024-08-06 18:16:08 +00:00
Noemi Erli 4a933a7f06 Backed out changeset e5864b976c3b (bug 1454819) for causing build bustages in SharedMemory.cpp CLOSED TREE 2024-08-05 18:08:32 +03:00
Alex Franchuk e7d059af48 Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D217487
2024-08-05 13:01:33 +00:00
serge-sans-paille a936c092c4 Bug 1775148 - Cleanup ipc/ includes r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D149802
2022-06-23 15:49:57 +00:00
Nika Layzell dbb5c64157 Bug 1732343 - Part 5: Use attached handles for Windows SharedMemory serialization, r=handyman
Differential Revision: https://phabricator.services.mozilla.com/D126567
2021-11-09 14:17:33 +00:00
Nika Layzell 6fed760187 Bug 1732343 - Part 2: Migrate all uses of base::FileDescriptor to UniqueFileHandle, r=handyman
This is useful for the following parts, as UniqueFileHandle is a cross-platform
type which can also be used to support transferring HANDLEs between processes.

This change requires fairly sweeping changes to existing callsites, which
previously did not require owning access to the handle types when transferring.
For the most part these changes were straightforward, but manual.

Differential Revision: https://phabricator.services.mozilla.com/D126564
2021-11-09 14:17:32 +00:00
Cristian Tuns 473401daa0 Backed out 10 changesets (bug 1732343) for causing coverage build bustages (Bug 1739590).
Backed out changeset bba94c79f3e1 (bug 1732343)
Backed out changeset d30fa1e1f605 (bug 1732343)
Backed out changeset ed0b4f757c4b (bug 1732343)
Backed out changeset a272da134c34 (bug 1732343)
Backed out changeset ccb259d73843 (bug 1732343)
Backed out changeset a292990b62de (bug 1732343)
Backed out changeset 7d1854782ca8 (bug 1732343)
Backed out changeset 29eaabd9ffb3 (bug 1732343)
Backed out changeset 1aa26657a7a6 (bug 1732343)
Backed out changeset 7a6708dc620a (bug 1732343)
2021-11-05 07:21:04 -04:00
Nika Layzell cb72586e3d Bug 1732343 - Part 5: Use attached handles for Windows SharedMemory serialization, r=handyman
Differential Revision: https://phabricator.services.mozilla.com/D126567
2021-11-04 19:20:19 +00:00
Nika Layzell 1db0a4660a Bug 1732343 - Part 2: Migrate all uses of base::FileDescriptor to UniqueFileHandle, r=handyman
This is useful for the following parts, as UniqueFileHandle is a cross-platform
type which can also be used to support transferring HANDLEs between processes.

This change requires fairly sweeping changes to existing callsites, which
previously did not require owning access to the handle types when transferring.
For the most part these changes were straightforward, but manual.

Differential Revision: https://phabricator.services.mozilla.com/D126564
2021-11-04 19:20:17 +00:00
Jed Davis 883da33e81 Bug 1440203 - Support memfd_create in IPC shared memory. r=glandium
This commit also allows `memfd_create` in the seccomp-bpf policy for all
process types.

`memfd_create` is an API added in Linux 3.17 (and adopted by FreeBSD
for the upcoming version 13) for creating anonymous shared memory
not connected to any filesystem.  Supporting it means that sandboxed
child processes on Linux can create shared memory directly instead of
messaging a broker, which is unavoidably slower, and it should avoid
the problems we'd been seeing with overly small `/dev/shm` in container
environments (which were causing serious problems for using Firefox for
automated testing of frontend projects).

`memfd_create` also introduces the related operation of file seals:
irrevocably preventing types of modifications to a file.  Unfortunately,
the most useful one, `F_SEAL_WRITE`, can't be relied on; see the large
comment in `SharedMemory:ReadOnlyCopy` for details.  So we still use
the applicable seals as defense in depth, but read-only copies are
implemented on Linux by using procfs (and see the comments on the
`ReadOnlyCopy` function in `shared_memory_posix.cc` for the subtleties
there).

There's also a FreeBSD implementation, using `cap_rights_limit` for
read-only copies, if the build host is new enough to have the
`memfd_create` function.

The support code for Android, which doesn't support shm_open and can't
use the memfd backend because of issues with its SELinux policy (see bug
1670277), has been reorganized to reflect that we'll always use its own
API, ashmem, in that case.

Differential Revision: https://phabricator.services.mozilla.com/D90605
2020-10-22 21:23:32 +00:00
Dorel Luca a5e9a6bb3a Backed out 2 changesets (bug 1440203) for Backout conflicts with Bug 1654103. CLOSED TREE
Backed out changeset 6e44c037b2dc (bug 1440203)
Backed out changeset ab11665d8607 (bug 1440203)
2020-10-22 03:47:17 +03:00
Jed Davis f542569245 Bug 1440203 - Support memfd_create in IPC shared memory. r=glandium
This commit also allows `memfd_create` in the seccomp-bpf policy for all
process types.

`memfd_create` is an API added in Linux 3.17 (and adopted by FreeBSD
for the upcoming version 13) for creating anonymous shared memory
not connected to any filesystem.  Supporting it means that sandboxed
child processes on Linux can create shared memory directly instead of
messaging a broker, which is unavoidably slower, and it should avoid
the problems we'd been seeing with overly small `/dev/shm` in container
environments (which were causing serious problems for using Firefox for
automated testing of frontend projects).

`memfd_create` also introduces the related operation of file seals:
irrevocably preventing types of modifications to a file.  Unfortunately,
the most useful one, `F_SEAL_WRITE`, can't be relied on; see the large
comment in `SharedMemory:ReadOnlyCopy` for details.  So we still use
the applicable seals as defense in depth, but read-only copies are
implemented on Linux by using procfs (and see the comments on the
`ReadOnlyCopy` function in `shared_memory_posix.cc` for the subtleties
there).

There's also a FreeBSD implementation, using `cap_rights_limit` for
read-only copies, if the build host is new enough to have the
`memfd_create` function.

The support code for Android, which doesn't support shm_open and can't
use the memfd backend because of issues with its SELinux policy (see bug
1670277), has been reorganized to reflect that we'll always use its own
API, ashmem, in that case.

Differential Revision: https://phabricator.services.mozilla.com/D90605
2020-10-21 23:34:46 +00:00
Jed Davis 203f3ed19d Bug 1652081 - Verify that newly allocated shared memory is zeroed. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D83144
2020-07-10 22:08:07 +00:00
Jed Davis 318606c6ea Bug 1550900 - Support "frozen" shared memory where the parent process retains write access. r=froydnj
This patch extends shared memory freezing to support the use case where
the parent process retains write access for incremental updates, while
other processes receive read-only access.

Note that, while some OSes allow independent read-only and read/write
capabilities for the same object, all we have on Android is an operation
that prevents future write mappings.  Therefore, this allows an existing
writeable mapping to be retained, but if that is unmapped then even the
parent process can't re-create it.

As with freezing, the read-only restriction may not be enforceable if
the recipient process isn't adequately sandboxed (e.g., on Linux, if it
can use /proc/self/fd to reopen the inode for writing).

Differential Revision: https://phabricator.services.mozilla.com/D67187
2020-03-20 16:23:59 +00:00
Sylvestre Ledru 0f8c6db00f Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D54686
2019-11-26 14:35:02 +00:00
Jed Davis a7817d9829 Bug 1573270 - Enhance shared memory freezing tests and add comments. r=bobowen on a CLOSED TREE
Differential Revision: https://phabricator.services.mozilla.com/D42048
2019-11-25 18:36:46 +00:00
Coroiu Cristina 68e955c81a Backed out changeset 9d28ee24c377 (bug 1573270) for xpcshell failures at toolkit/modules/tests/xpcshell/test_firstStartup.js on a CLOSED TREE 2019-11-26 02:29:15 +02:00
Jed Davis 6edb306f6c Bug 1573270 - Enhance shared memory freezing tests and add comments. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D42048
2019-11-25 18:36:46 +00:00
Jed Davis ee9caccb16 Bug 1479960 - Add unit tests for shared memory freezing. r=froydnj
Also refactor SharedMemoryBasic::SystemProtect to allow testing cases
that are expected to fail.

Depends on D26748

Differential Revision: https://phabricator.services.mozilla.com/D26749
2019-08-14 22:48:52 +00:00
Narcis Beleuzu 19d23ede71 Backed out 15 changesets (bug 1479960, bug 1426526, bug 1534780, bug 1536697) for toolchain bustages on UniquePtrExtensions.h . CLOSED TREE
Backed out changeset a8518ea4b594 (bug 1479960)
Backed out changeset 7172762c4b87 (bug 1536697)
Backed out changeset 2ea5ccb8f3a1 (bug 1426526)
Backed out changeset d892a888fe9c (bug 1426526)
Backed out changeset 2c4d12bdfec3 (bug 1479960)
Backed out changeset 8a322064cf6d (bug 1479960)
Backed out changeset 47d387b6cd4a (bug 1479960)
Backed out changeset 8332565a6943 (bug 1479960)
Backed out changeset 9d7f1835f96f (bug 1479960)
Backed out changeset 0aa8af4965c5 (bug 1479960)
Backed out changeset 036809330a51 (bug 1479960)
Backed out changeset 39e18373e3d3 (bug 1479960)
Backed out changeset 6c2b995a9d30 (bug 1479960)
Backed out changeset 3c2b31744645 (bug 1534780)
Backed out changeset 26bb00a94d5d (bug 1534780)
2019-06-28 22:42:00 +03:00
Jed Davis 917a571061 Bug 1479960 - Add unit tests for shared memory freezing. r=froydnj
Also refactor SharedMemoryBasic::SystemProtect to allow testing cases
that are expected to fail.

Depends on D26748

Differential Revision: https://phabricator.services.mozilla.com/D26749
2019-06-20 22:40:46 +00:00
Ciure Andrei 480547b1f4 Backed out 15 changesets (bug 1479960, bug 1426526, bug 1534780, bug 1536697) for causing build bustages CLOSED TREE
Backed out changeset 5645e0cc3915 (bug 1479960)
Backed out changeset a7c09894c6a0 (bug 1536697)
Backed out changeset 510f03381af9 (bug 1426526)
Backed out changeset 7cf4735a088f (bug 1426526)
Backed out changeset 41080844e645 (bug 1479960)
Backed out changeset fdba3c5f8fd0 (bug 1479960)
Backed out changeset 26a8ebcb2db4 (bug 1479960)
Backed out changeset d0d383e5bae1 (bug 1479960)
Backed out changeset c418095bb7b7 (bug 1479960)
Backed out changeset 7b78b1945532 (bug 1479960)
Backed out changeset c47d47d4073d (bug 1479960)
Backed out changeset 71253b62a633 (bug 1479960)
Backed out changeset ae525f20bdbb (bug 1479960)
Backed out changeset 7fba719355d7 (bug 1534780)
Backed out changeset 771db331860a (bug 1534780)
2019-06-20 19:54:57 +03:00
Jed Davis e1c650c95b Bug 1479960 - Add unit tests for shared memory freezing. r=froydnj
Also refactor SharedMemoryBasic::SystemProtect to allow testing cases
that are expected to fail.

Depends on D26748

Differential Revision: https://phabricator.services.mozilla.com/D26749
2019-06-17 02:20:12 +00:00