Граф коммитов

1487 Коммитов

Автор SHA1 Сообщение Дата
Mike Hommey 2c90fad39d Bug 1559379 - Remove GCC ASAN workaround that seems to be unnecessary nowadays. r=froydnj
Bug 1147248 added the workaround for GCC 4.9, but from an attempt with
GCC 6, it seems unnecessary anymore.

Differential Revision: https://phabricator.services.mozilla.com/D36165

--HG--
extra : moz-landing-system : lando
2019-06-27 13:37:36 +00:00
Tom Ritter 0b01745031 Bug 1376408 - Randomize free region selection for small allocations in a run r=glandium
This allows freelist randomization on a per-arena basis, by supplying parameters to
arena creation.

It uses an xorshift PRNG with a 128-bit state. It is not cryptographically secure. An
attacker who can observe outputs of the RNG, or read its state, is already in a position
to bypass the randomization applied. At the same time we make its state 128 bit to prevent
a trivial bypass if one or two outputs are observed.

The way a run selects masks to check has not been modified, so the randomization is limited
to at most 32 bits in the current mask being tested. It should be noted that while allocations
from the same run may now be non deterministic (up to the maximum entropy as previously
stated), an attacker who can perform multiple allocations will still be able to allocate
a targeted free region (for example while exploiting a use after free vulnerability in the
DOM). Non deterministic allocations will only impede an attacker who has less control over
how they allocate a targeted free region, and may provide some benefit during exploitation
of a heap based buffer overflow vulnerability where the attacker wishes to construct a
precise layout of regions pre overflow.

Differential Revision: https://phabricator.services.mozilla.com/D32219

--HG--
extra : moz-landing-system : lando
2019-06-18 21:18:23 +00:00
Nicholas Nethercote 94ec493862 Bug 1557907 - Fix `jemalloc_replace_dynamic()`. r=glandium
`jemalloc_replace_dynamic()` is badly broken. If you install a malloc table
other than the default at startup (e.g. DMD's or PHC's), when you call
`jemalloc_replace_dynamic()` it installs a new allocator that wraps the
*default* allocator, and then when you call `jemalloc_replace_dynamic(nullptr)`
it switches back to the *default* allocator.

This commits makes numerous improvements.

- It removes the "flip-flopping" between malloc tables, which didn't really
  work and isn't necessary.

- `jemalloc_replace_dynamic()` now switches between the *original* malloc table
  and the new one, rather than the *default* malloc table and the new one.

- It renames various things, to make the names shorter and clearer.

- It clearly documents the dangers and limitations of
  `jemalloc_replace_dynamic()`.

- It removes and inlines `profiler::Init()`, because there was only one call
  site.

- It rearranges `install_memory_counter()` so the control flow is simpler.

Differential Revision: https://phabricator.services.mozilla.com/D34266

--HG--
extra : moz-landing-system : lando
2019-06-13 20:42:19 +00:00
Nicholas Nethercote 637456901b Bug 1558365 - Simplify `PtrInfoTag`. r=glandium
This makes it less mozjemalloc-specific, which is helpful for PHC. No non-test
code uses the extra detail anyway.

Differential Revision: https://phabricator.services.mozilla.com/D34441

--HG--
extra : moz-landing-system : lando
2019-06-12 07:38:30 +00:00
Mike Hommey a36bd5ae07 Bug 997353 - Make powerpc not use static page sizes in mozjemalloc. r=njn
__powerpc__ covers powerpc and powerpc64.

Differential Revision: https://phabricator.services.mozilla.com/D33750

--HG--
extra : moz-landing-system : lando
2019-06-06 05:25:59 +00:00
Mike Hommey 2abcc3d7cb Bug 1553363 - Generalize the *_impl goop for allocation functions in mozglue. r=froydnj
The current situation is suboptimal, where we have the same goop
repeated in multiple files, and where things kinda sorta work out fine
thanks to the linker for files that would have been forbidden, except
when the linker doesn't do its job, which apparently happen on
mingwclang builds.

This change only really covers C++ code using operator new/delete, and
not things that would be using malloc/free, because it's easier.
malloc/free is left for a followup.

Differential Revision: https://phabricator.services.mozilla.com/D32119

--HG--
extra : moz-landing-system : lando
2019-05-29 22:49:42 +00:00
Mike Hommey 4a87ec2ddc Bug 1553058 - Remove unused gPageSize case. r=njn
MALLOC_STATIC_PAGESIZE is only set on some platforms. Specifically, it's
not set on ia64 and sparc. Which means the case MALLOC_STATIC_PAGESIZE
&& (sparc || ia64) never happens, and gPageSize is never 8 KiB.

Differential Revision: https://phabricator.services.mozilla.com/D31965

--HG--
extra : moz-landing-system : lando
2019-05-21 23:01:21 +00:00
Chris Martin 7d1181258d Bug 1052579 - Modify GTest for jemalloc_ptr_info() to check arenaId r=glandium
In D25711, I added an arenaId member to `jemalloc_ptr_info_t` when `MOZ_DEBUG`
is defined. This modifies the GTest for `jemalloc_ptr_info()` to ensure that
the new member returns the correct value.

Differential Revision: https://phabricator.services.mozilla.com/D30087

--HG--
extra : moz-landing-system : lando
2019-05-07 00:34:42 +00:00
Gian-Carlo Pascutto 3c771d5a8b Bug 1537781 - Test for trailing guard pages for normal allocations. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D27913

--HG--
extra : moz-landing-system : lando
2019-05-02 14:19:19 +00:00
Gian-Carlo Pascutto 3b43637e56 Bug 1537781 - Trailing guard pages for normal allocations. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D27912

--HG--
extra : moz-landing-system : lando
2019-05-02 14:19:17 +00:00
Sylvestre Ledru e226046cb8 Bug 1547143 - Format the tree: Be prescriptive with the pointer style (left) r=Ehsan
# ignore-this-changeset

Depends on D28954

Differential Revision: https://phabricator.services.mozilla.com/D28956

--HG--
extra : moz-landing-system : lando
2019-05-01 08:47:10 +00:00
Chris Martin ef8ae4fcb3 Bug 1052579 - Add ability to query ArenaID to mozjemalloc_ptr_info r=glandium
To ensure that any new JSString has its char buffer allocated in the new arena,
it is useful to be able to query a pointer and assert that it is in the
correct arena (at-least in Debug Build).

This adds the required functionality to mozjemalloc, and JSString can use it
for its new assertion in a later change.

Differential Revision: https://phabricator.services.mozilla.com/D25711

--HG--
extra : moz-landing-system : lando
2019-04-23 12:39:58 +00:00
Edwin Gao 9994405ece Bug 1544961 - comment on gtests that are disabled, disable ThreadUtils.IdleRunnableMethod and Timers.FindExpirationTime for windows10-aarch64 r=jmaher,gbrown,dmajor
Changes:
- added comments for tests being disabled
- disabled two additional tests in order to green the run

Differential Revision: https://phabricator.services.mozilla.com/D28085

--HG--
extra : moz-landing-system : lando
2019-04-23 00:21:37 +00:00
Narcis Beleuzu cd1fcbc396 Backed out changeset 497561b76737 (bug 1052579) for bustages on mozjemalloc_types.h . CLOSED TREE 2019-04-22 19:00:58 +03:00
Chris Martin cb3f697d99 Bug 1052579 - Add ability to query ArenaID to mozjemalloc_ptr_info. r=glandium
To ensure that any new JSString has its char buffer allocated in the new arena,
it is useful to be able to query a pointer and assert that it is in the
correct arena (at-least in Debug Build).

This adds the required functionality to mozjemalloc, and JSString can use it
for its new assertion in a later change.

Differential Revision: https://phabricator.services.mozilla.com/D25711
2019-04-02 03:55:06 +00:00
Edwin Gao 4b2a06ae0f Bug 1544961 - disable tests that cause gtest harness to crash on windows10-aarch64 r=jmaher,gbrown
Changes:
- most tests are skipped using `moz.build` configuration file.
- `MultiWriterQueue` had to be skipped with `define` clauses in the test file due to build bustages when its `moz.build` file was used.

Differential Revision: https://phabricator.services.mozilla.com/D27944

--HG--
extra : moz-landing-system : lando
2019-04-17 23:12:19 +00:00
Gian-Carlo Pascutto bfcbc83c13 Bug 1542290 - Decommit unused base_page allocations. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D26327

--HG--
extra : moz-landing-system : lando
2019-04-16 11:04:21 +00:00
Sylvestre Ledru 7f60810d86 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D27245

--HG--
extra : moz-landing-system : lando
2019-04-12 13:14:25 +00:00
Geoff Brown 7897534073 Bug 1318091 - Skip jemalloc gtests on android; r=bc
The jemalloc tests leave behind minidumps. Disable for now, for a green run.

Differential Revision: https://phabricator.services.mozilla.com/D27014

--HG--
extra : moz-landing-system : lando
2019-04-11 10:57:50 +00:00
Petr Sumbera a65de26d20 Bug 1542758 - mozjemalloc.cpp should use posix_madvise on Solaris r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D26529

--HG--
extra : moz-landing-system : lando
2019-04-09 08:20:48 +00:00
Sylvestre Ledru 03fc65347c Bug 1542146 - Apply the change with the option StatementMacros from clang-format-8 r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D26280

--HG--
extra : moz-landing-system : lando
2019-04-05 21:42:17 +00:00
Csoregi Natalia ba58e936bd Backed out changeset 4ad80127f89f (bug 1519636) for bustage on MarkupMap.h and nsAccessibilityService.cpp. CLOSED TREE 2019-04-05 09:48:19 +03:00
Sylvestre Ledru d1c1878603 Bug 1519636 - clang-format-8: Reformat recent changes to the Google coding style r=Ehsan
clang-format-8 upstream had some improvements wrt macros
See: https://reviews.llvm.org/D33440
This is why the diff is bigger than usual

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D26098

--HG--
extra : moz-landing-system : lando
2019-04-04 21:36:16 +00:00
Narcis Beleuzu 24dbe577a5 Backed out changeset 389b6bbd76db (bug 1519636) for bustages on MarkupMap.h . CLOSED TREE 2019-04-05 00:27:56 +03:00
Sylvestre Ledru 399dbd28fe Bug 1519636 - clang-format-8: Reformat recent changes to the Google coding style r=Ehsan
clang-format-8 upstream had some improvements wrt macros
See: https://reviews.llvm.org/D33440
This is why the diff is bigger than usual

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D26098

--HG--
extra : moz-landing-system : lando
2019-04-04 20:12:23 +00:00
Nicholas Nethercote 653456467a Bug 1533240 - Replace DMD's custom TLS code with use of mozilla/ThreadLocal.h. r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D22448

--HG--
extra : moz-landing-system : lando
2019-03-22 20:07:30 +00:00
Gian-Carlo Pascutto d735d8aa70 Bug 1529922 - Add guard pages following huge allocations. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D23292

--HG--
extra : moz-landing-system : lando
2019-03-20 10:45:15 +00:00
Edwin Gao b0ed46de2e Bug 1536250 - disable test_dmd.js r=jmaher
Disable this test which intermittently fails in xpcshell.

Differential Revision: https://phabricator.services.mozilla.com/D23956

--HG--
extra : moz-landing-system : lando
2019-03-19 01:12:08 +00:00
Gurzau Raul 0f47ac1ab9 Backed out changeset 46f6705f9c0c (bug 1533240) for xpcshell failures at /test/test_dmd.js on a CLOSED TREE. 2019-03-14 07:03:38 +02:00
Nicholas Nethercote f3a720ae86 Bug 1533240 - Replace DMD's custom TLS code with use of mozilla/ThreadLocal.h. r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D22448

--HG--
extra : moz-landing-system : lando
2019-03-14 01:05:15 +00:00
David Major e5773183d6 Bug 1528074 - Remove MSVC warning flags that clang-cl doesn't understand r=chmanchester
Per the previous patch, clang-cl only understands five MSVC-style warning flags: 7219c7e9af/clang/include/clang/Driver/CLCompatOptions.td (L188-L197)

This patch removes the flags that clang-cl doesn't understand.

Differential Revision: https://phabricator.services.mozilla.com/D22588

--HG--
extra : moz-landing-system : lando
2019-03-13 20:19:08 +00:00
Ryan Hunt bc6f68363a Bug 1523969 part 16 - Move method definition inline comments to new line in 'memory/'. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D21117

--HG--
extra : rebase_source : 73bb987caf0e10f7168610a3d6d3b993afeb7dd3
2019-02-25 16:10:15 -06:00
Nicholas Nethercote e01d4bc8cc Bug 1531027 - Add an explicit copy constructor to StackTrace. r=ehsan
This only copies the first `mLength` elements in `mPcs`.

Differential Revision: https://phabricator.services.mozilla.com/D21488

--HG--
extra : rebase_source : 91601501056fe7ea5b011adeca59033568fbde4a
2019-02-28 11:00:14 +11:00
Nicholas Nethercote 3494926e55 Bug 1531029 - Fix incorrect `sizeof` expression. r=ehsan
This doesn't change behaviour because `sizeof(uintptr_t)` equals
`sizeof(uintptr_t*)`, but it's good to make things more obviously correct.

Differential Revision: https://phabricator.services.mozilla.com/D21487

--HG--
extra : rebase_source : 4df36d1d1e85a671c297e6e761b44b7da5b85343
2019-02-28 11:05:34 +11:00
Ehsan Akhgari 1ca16ce872 Bug 1531027 - Make InfallibleAllocPolicy::new_ accept its argument as a reference; r=njn
Differential Revision: https://phabricator.services.mozilla.com/D21486

--HG--
extra : moz-landing-system : lando
2019-02-28 06:41:09 +00:00
Mike Hommey 9ca5062588 Bug 1530562 - Set SmokeDMD compiler flags depending on compiler type rather than target OS. r=mshal
Differential Revision: https://phabricator.services.mozilla.com/D21161

--HG--
extra : moz-landing-system : lando
2019-02-26 22:06:37 +00:00
Nicholas Nethercote 06e15020fe Bug 1529452 - Fix a silly bug. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D20772

--HG--
extra : moz-landing-system : lando
2019-02-22 10:52:03 +00:00
Jeff Gilbert ec5431c0a2 Bug 1349064 - Wrap std::regex_error for GCC. r=glandium 2019-02-21 11:23:59 -08:00
Nicholas Nethercote 4e8b423a96 Bug 1529452 - Avoid a multiplication that could overflow. r=glandium
Also add a comment about another multiplication.

Differential Revision: https://phabricator.services.mozilla.com/D20617

--HG--
extra : moz-landing-system : lando
2019-02-21 04:28:15 +00:00
Masatoshi Kimura e59e3b3e20 Bug 1528651 - Fix some trivial warnings and re-enable warnings-as-errors on Windows in some directories. r=dmajor
--HG--
extra : source : 5ee9efeda9e67f6af0521be85266703763cc4c50
2019-02-19 20:42:11 +09:00
Mike Hommey ef3ad686ee Bug 1512504 - Remove support for MSVC. r=froydnj
Consequently, this removes:
- MOZ_LIBPRIO, which is now always enabled.
- non_msvc_compiler, which is now always true.
- The cl.py wrapper, since it's not used anymore.
- CL_INCLUDES_PREFIX, which was only used for the cl.py wrapper.
- NONASCII, which was only there to ensure CL_INCLUDES_PREFIX still
  worked in non-ASCII cases.

This however keeps a large part of detecting and configuring for MSVC,
because we still do need it for at least headers, libraries, and midl.

Depends on D19614

Differential Revision: https://phabricator.services.mozilla.com/D19615

--HG--
extra : moz-landing-system : lando
2019-02-14 21:45:27 +00:00
Myk Melez 25349d2601 Bug 1518283 - prohibit blank lines at the beginning and end of blocks (eslint padded-blocks) r=mossop,Standard8
Differential Revision: https://phabricator.services.mozilla.com/D17526

--HG--
extra : moz-landing-system : lando
2019-01-30 17:26:25 +00:00
Kris Maglione e930b89c34 Bug 1514594: Part 3 - Change ChromeUtils.import API.
***
Bug 1514594: Part 3a - Change ChromeUtils.import to return an exports object; not pollute global. r=mccr8

This changes the behavior of ChromeUtils.import() to return an exports object,
rather than a module global, in all cases except when `null` is passed as a
second argument, and changes the default behavior not to pollute the global
scope with the module's exports. Thus, the following code written for the old
model:

  ChromeUtils.import("resource://gre/modules/Services.jsm");

is approximately the same as the following, in the new model:

  var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");

Since the two behaviors are mutually incompatible, this patch will land with a
scripted rewrite to update all existing callers to use the new model rather
than the old.
***
Bug 1514594: Part 3b - Mass rewrite all JS code to use the new ChromeUtils.import API. rs=Gijs

This was done using the followng script:

https://bitbucket.org/kmaglione/m-c-rewrites/src/tip/processors/cu-import-exports.jsm
***
Bug 1514594: Part 3c - Update ESLint plugin for ChromeUtils.import API changes. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D16747
***
Bug 1514594: Part 3d - Remove/fix hundreds of duplicate imports from sync tests. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16748
***
Bug 1514594: Part 3e - Remove no-op ChromeUtils.import() calls. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16749
***
Bug 1514594: Part 3f.1 - Cleanup various test corner cases after mass rewrite. r=Gijs
***
Bug 1514594: Part 3f.2 - Cleanup various non-test corner cases after mass rewrite. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D16750

--HG--
extra : rebase_source : 359574ee3064c90f33bf36c2ebe3159a24cc8895
extra : histedit_source : b93c8f42808b1599f9122d7842d2c0b3e656a594%2C64a3a4e3359dc889e2ab2b49461bab9e27fc10a7
2019-01-17 10:18:31 -08:00
Ehsan Akhgari e5e885ae31 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
# ignore-this-changeset

--HG--
extra : amend_source : 7221c8d15a765df71171099468e7c7faa648f37c
extra : histedit_source : a0cce6015636202bff09e35a13f72e03257a7695
2019-01-18 10:16:18 +01:00
Andrew McCreight 4f8e71a1ca Bug 1519224 - Fix stack frame printing in block_analyzer.py. r=erahm
Also, add a new allocator function.

Differential Revision: https://phabricator.services.mozilla.com/D16241

--HG--
extra : moz-landing-system : lando
2019-01-14 18:41:35 +00:00
Emilio Cobos Álvarez d2ed260822 Bug 1517241 - Rename nsIDocument to mozilla::dom::Document. r=smaug
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.

Overall it's not a very interesting patch I think.

nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.

I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.

While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.
2019-01-03 17:48:33 +01:00
Mike Hommey a8d4234310 Bug 1511251 - Remove redundant and costly assert. r=njn
The diagnostic assert (so fortunately, it doesn't impact release builds)
as added in bug 1405159, but is costly because it uses the modulus of
the division with a variable integer, which is a slow operation.
However, in arena_run_reg_dalloc, we end up doing the same diagnostic
assert, in a different form: after performing the division in a faster
manner, we assert that the result, multiplied by the diviser, returns
the original number.

Differential Revision: https://phabricator.services.mozilla.com/D13501

--HG--
extra : moz-landing-system : lando
2018-12-05 14:45:52 +00:00
Tooru Fujisawa 7983faeb5d Bug 1511393 - Use c-basic-offset: 2 in Emacs mode line for C/C++ code. r=nbp 2018-12-01 04:52:05 +09:00
Benjamin Bouvier a7f1d173a0 Bug 1511383: Update vim modelines after clang-format; r=sylvestre
- modify line wrap up to 80 chars; (tw=80)
- modify size of tab to 2 chars everywhere; (sts=2, sw=2)

--HG--
extra : rebase_source : 7eedce0311b340c9a5a1265dc42d3121cc0f32a0
extra : amend_source : 9cb4ffdd5005f5c4c14172390dd00b04b2066cd7
2018-11-30 16:39:55 +01:00
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Nicholas Nethercote 953ed1dcc1 Bug 1499907 - Add a `jsonEscape` argument to `fixSymbols`. r=erahm
So that dmd.py isn't broken by function names that, after stack fixing, contain
escape-worthy chars such as " and /.

--HG--
extra : rebase_source : 625cef56e4599bbb810273ef04af2b971e777b58
2018-11-21 10:28:00 +11:00
Chris Martin adde9e8556 Bug 1402282 - Change jemalloc to use secure random private arena ids r=glandium
Previously the id for a new arena was just a counter that increased by one
every time. For hardening purposes, we want to make private arenas use a secure
random ID, so an attacker will have a more difficult time finding the memory
they are looking for.

Differential Revision: https://phabricator.services.mozilla.com/D10158

--HG--
extra : moz-landing-system : lando
2018-11-21 01:52:26 +00:00
Mike Hommey c4ea7f7d5a Bug 1507035 - Fix run sizes for size classes >= 16KB on systems with large pages. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D11836

--HG--
extra : moz-landing-system : lando
2018-11-14 06:58:53 +00:00
Mark Banner 50fbf54ef3 Bug 1506559 - Enable ESLint for memory/replace/dmd/test/. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D11619

--HG--
extra : moz-landing-system : lando
2018-11-13 09:07:38 +00:00
arthur.iakab 27754a7d12 Backed out 2 changesets (bug 1402282) for turning multiple browser chrome bugs into permafail
Backed out changeset db7059b57f92 (bug 1402282)
Backed out changeset cea1d44ac776 (bug 1402282)
2018-11-05 17:56:37 +02:00
Chris Martin 3824b0d43e Bug 1402282 - Change jemalloc to use secure random arena ids r=glandium
Previously the id for a new arena was just a counter that increased by one
every time. For hardening purposes, we want to make the new counter a secure
random ID, so an attacker will have a more difficult time finding the memory
they are looking for.

Differential Revision: https://phabricator.services.mozilla.com/D10158

--HG--
extra : moz-landing-system : lando
2018-11-05 00:27:31 +00:00
Chris Martin a1d5bd1909 Bug 1402282 - Clang-format on mozjemalloc r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D10794

--HG--
extra : moz-landing-system : lando
2018-11-05 00:26:00 +00:00
Noemi Erli 06a8cd8e3c Backed out changeset bee1c344cb47 (bug 1491909) for failures in browser/components/extensions/test/xpcshell/test_ext_geckoProfiler_control.js 2018-10-24 04:23:13 +03:00
Denis Palmeiro fc930ad16f Bug 1491909 - Add an AllocPolicy to mozilla::JSONWriter r=jwalden,mstange
JSONWriter currently calls new and delete indirectly through mozilla::MakeUnique to allocate a buffer.  Becuase of this, the methods of this class cannot be invoked within Spidermonkey due to https://searchfox.org/mozilla-central/source/config/check_vanilla_allocations.py#6-14.  Therefore, JSONWriter needs an AllocPolicy template parameter so that the allocation and deallocation routines can be changed to match the JS AllocPolicy when invoked within SpiderMonkey.

Differential Revision: https://phabricator.services.mozilla.com/D7279

--HG--
extra : moz-landing-system : lando
2018-10-23 20:46:31 +00:00
Randell Jesup 0f390bf1a5 Bug 1480430: Modify jemalloc to allow dynamic replacement r=glandium 2018-10-09 22:28:37 -04:00
Eric Rahm c5bb74ff5d Bug 1409739 - Part 1: Accept SmokeDMD when filtering test DMD stacks. r=njn
On some builds we only get 'SmokeDMD' references during testing rather than a full file path. This adds 'SmokeDMD' to the acceptable frame description list.

--HG--
extra : rebase_source : 475166fa6d1f241bf4d67cbdda1aab73000a5c3a
extra : intermediate-source : fcdc1d5eaf1a932992287074d0c91504dd7180d8
extra : source : 1192c15fc9347ccd6169dcb5bea81d7f2399e3fd
2018-10-01 16:38:17 -07:00
Cosmin Sabou 5a8eb92385 Backed out 3 changesets (bug 1409739) for causing Linux x64 ccov & fuzzing bustages. a=backout
Backed out changeset 387f946c7c48 (bug 1409739)
Backed out changeset 617288a6b2d9 (bug 1409739)
Backed out changeset fcdc1d5eaf1a (bug 1409739)
2018-10-03 20:29:42 +03:00
Eric Rahm 703da53d94 Bug 1409739 - Part 1: Accept SmokeDMD when filtering test DMD stacks. r=njn
On some builds we only get 'SmokeDMD' references during testing rather than a full file path. This adds 'SmokeDMD' to the acceptable frame description list.

--HG--
extra : source : 1192c15fc9347ccd6169dcb5bea81d7f2399e3fd
extra : intermediate-source : d39c2dfcc7004a4736436c564de239ba68b20c03
extra : histedit_source : 5a75a20f5b88481c994597da81fdbc29186aba3d%2C3f60f2bfbe54ab3843d4b18d66296cd4aadf4a30
2018-10-01 16:38:17 -07:00
Coroiu Cristina 7f6d72d2a2 Backed out 3 changesets (bug 1409739) for xpcshell failures at memory/replace/dmd/test/test_dmd.js
Backed out changeset dc3c5143ba4e (bug 1409739)
Backed out changeset e37ea5eb932a (bug 1409739)
Backed out changeset d39c2dfcc700 (bug 1409739)
2018-10-03 02:07:19 +03:00
Eric Rahm 6566498f9e Bug 1409739 - Part 1: Accept SmokeDMD when filtering test DMD stacks. r=njn
On some builds we only get 'SmokeDMD' references during testing rather than a full file path. This adds 'SmokeDMD' to the acceptable frame description list.

--HG--
extra : rebase_source : 2b1d2dbf8a3a538533554c6697f0e9ee51ec1bed
extra : source : 1192c15fc9347ccd6169dcb5bea81d7f2399e3fd
2018-10-01 16:38:17 -07:00
Gurzau Raul 4f0690bc0d Backed out 3 changesets (bug 1409739) for failing at /dmd/test/test_dmd.js on a CLOSED TREE
Backed out changeset 39c8abcf9cb2 (bug 1409739)
Backed out changeset c0da83c08b62 (bug 1409739)
Backed out changeset 1192c15fc934 (bug 1409739)
2018-10-02 18:43:32 +03:00
Eric Rahm 0196b4c2ca Bug 1409739 - Part 1: Accept SmokeDMD when filtering test DMD stacks. r=njn
On some builds we only get 'SmokeDMD' references during testing rather than a full file path. This adds 'SmokeDMD' to the acceptable frame description list.

--HG--
extra : rebase_source : 147e62e22248971980d95fe211c86116a98cbdf4
2018-10-01 16:38:17 -07:00
Tom Ritter 934ba40bb8 Bug 1480457-Correct typedef so it matches an earlier typedef r=aklotz
--HG--
extra : amend_source : c6796d3a8bb13939440b390ac9af11054b46dd15
2018-08-30 23:05:59 +03:00
Nicholas Nethercote fe34f19459 Bug 1486690 - Rename nsMemory::Clone() and remove unnecessary checks after it. r=glandium
The 'x' in the new name makes it clearer that it's infallible.

--HG--
extra : rebase_source : 51fd946c482befe8a8ca5bd88ecc967971f455da
2018-08-28 15:59:19 +10:00
Masatoshi Kimura 3d01e517aa Bug 1484184 - Remove now unused _RAISE macro check to deal with MSVC 2017 15.8. r=froydnj
--HG--
extra : source : b38403f36056d301321c128be96ee60d14739859
2018-08-17 01:27:29 +09:00
Narcis Beleuzu 96343e8f1f Backed out 3 changesets (bug 1484184, bug 1484190, bug 1484191) for bustages on test_toolchain_configure.py. CLOSED TREE
Backed out changeset dca5444170e0 (bug 1484190)
Backed out changeset 1ef81d07bc5b (bug 1484184)
Backed out changeset 2a42fd4df1bb (bug 1484191)
2018-08-20 19:49:37 +03:00
Masatoshi Kimura 59a91c2a72 Bug 1484184 - Remove now unused _RAISE macro check to deal with MSVC 2017 15.8. r=froydnj
--HG--
extra : rebase_source : d93dbda28fff9cdbf0f6a908e0c1d59c152665e5
extra : source : b38403f36056d301321c128be96ee60d14739859
2018-08-17 01:27:29 +09:00
Mike Hommey 5f59918688 Bug 1482797 - Don't use MADV_FREE on Linux until we support it properly. r=njn 2018-08-15 21:33:57 +09:00
Nicholas Nethercote b9e071e2e8 Bug 1481998 - Make mozilla::Hash{Map,Set}'s entry storage allocation lazy. r=luke,sfink
Entry storage allocation now occurs on the first lookupForAdd()/put()/putNew().
This removes the need for init() and initialized(), and matches how
PLDHashTable/nsTHashtable work. It also removes the need for init() functions
in a lot of types that are built on top of mozilla::Hash{Map,Set}.

Pros:

- No need for init() calls and subsequent checks.

- No memory allocated for empty tables, which are not that uncommon.

Cons:

- An extra branch in lookup() and lookupForAdd(), but not in put()/putNew(),
  because the existing checkOverloaded() can handle it.

Specifics:

- Construction now can take a length parameter.

- init() is removed. Explicit length-setting, when necessary, now occurs in the
  constructors.

- initialized() is removed.

- capacity() now returns zero when the entry storage is absent.

- lookupForAdd() is no longer `const`, because it can instantiate the storage,
  which requires modifications.

- lookupForAdd() can now return an invalid AddPtr in two cases:

  - old: hashing failure (due to OOM in the hasher)

  - new: OOM while instantiating entry storage

  The existing failure handling paths for the old case work for the new case.

- clear(), finish(), and clearAndShrink() are replaced by clear(), compact(),
  and reserve(). The old compactIfUnderloaded() is also removed.

- Capacity computation code is now in its own functions, bestCapacity() and
  hashShift(). setTableSizeLog2() is removed.

- uint32_t is used throughout for capacities, instead of size_t, for
  consistency with other similar values.

- changeTableSize() now takes a capacity instead of a deltaLog2, and it can now
  handle !mTable.

Measurements:

- Total source code size is reduced by over 900 lines. Also, lots of existing
  lines got shorter (i.e. two checks were reduced to one).

- Executable size barely changed, down by 2 KiB on Linux64. The extra branches
  are compensated for by the lack of init() calls.

- Speed changed negligibly. The instruction count for Bench_Cpp_MozHash
  increased from 2.84 billion to 2.89 billion but any execution time change was
  well below noise.
2018-08-10 18:00:29 +10:00
Mike Hommey f4f54e5aeb Bug 1482330 - Upgrade to Android NDK r17b and API level 16 (JB). r=snorp
We're currently using NDK r15c, which is rather old, and happens to come
with a buggy gold linker. Let's use a more recent NDK, with a fixed
linker.

Unfortunately, we're currently at NDK API level 9, which the newer NDK
doesn't provide for x86 anymore. But that corresponds to Gingerbread
(2.3), which we've long stopped supporting. On the SDK side, we already
dropped support of versions before Jelly Bean, so we can do the same on
the NDK side. That corresponds to API level 16. So let's just use that
as a baseline.

Another change in the newer NDK is that the target-name changed from
i386-linux-android to i686-linux-android, so adjust for that in the
android x86 mozconfigs.
2018-08-11 09:47:41 +09:00
Masatoshi Kimura 3b21b7868b Bug 1090497 - Re-enable warnings as errors on clang-cl. r=froydnj
--HG--
extra : rebase_source : c09366fb93e5b0f72abe1e99d3094e3d96a934fb
extra : intermediate-source : 5950c9d63c3b4fd63a25464a7b50944aaec7079f
extra : source : ca1b9a2bcc4381795f556fea2fb59066567c30f3
2018-07-31 22:10:07 +09:00
Cosmin Sabou de8c2bd891 Backed out changeset 5950c9d63c3b (bug 1090497) for build bustages on several files. CLOSED TREE 2018-08-02 19:59:53 +03:00
Masatoshi Kimura feea19030c Bug 1090497 - Re-enable warnings as errors on clang-cl. r=froydnj
--HG--
extra : rebase_source : a62521fdc66def4e4d5d7bf52e68365a786b5c55
extra : source : ca1b9a2bcc4381795f556fea2fb59066567c30f3
2018-07-31 22:10:07 +09:00
Nicholas Nethercote a4cfd53308 Bug 1478879 - Remove Range/Enum use in DMD. r=mccr8
--HG--
extra : rebase_source : 19428e3d0d1b8676fe55be729b0e75d787086b6c
2018-07-27 12:21:01 +10:00
Nicholas Nethercote 6141e31ef4 Bug 1479954 - Rename Hash{Set,Map}::sizeOf{In,Ex}cludingThis(). r=luke
In PLDHashTable the equivalent functions have a "Shallow" prefix, which makes
it clear that they don't measure things hanging off the table. This patch makes
mozilla::Hash{Set,Map} do likewise.

MozReview-Commit-ID: 3kwCJynhW7d

--HG--
extra : rebase_source : 9c03d11f376a9fd4cfd5cfcdc0c446c00633b210
2018-08-01 09:57:52 +10:00
Nicholas Nethercote 6998f465ed Bug 1477626 - Use mozilla::HashTable instead of JS::HashTable in DMD. r=erahm
Also use mozilla::HashNumber where appropriate.

MozReview-Commit-ID: BTq0XDS5UfQ

--HG--
extra : rebase_source : 28f45a9b27e831e99620a2b575f373003f1301f2
2018-07-26 20:15:58 +10:00
Calixte Denizet 38484d357e Bug 1474254 -- Disable test Jemalloc.JunkPoison for Windows ccov builds.
Summary: GTest is permafailing on Windows because of timeout.

Reviewers: glandium

Reviewed By: glandium

Bug #: 1474254

Differential Revision: https://phabricator.services.mozilla.com/D2043

--HG--
extra : rebase_source : cea68e50f96a1788bf15dc6ca7859e5f698a6209
2018-07-27 22:48:14 +03:00
Brian Hackett 29bb91306b Bug 1465452 Part 5 - Don't record some jemalloc atomics, r=njn.
--HG--
extra : rebase_source : a1dacd30546372e836b69e51f200e4c3e1295930
2018-07-21 14:30:33 +00:00
Brian Hackett f6b8e6f81c Bug 1309552 - Specify buffer size when freeing data in AllocPolicy, r=waldo.
--HG--
extra : rebase_source : f4e2d9f8831cf41c19d592ce252e87161f32250b
2018-07-20 23:58:34 +00:00
Masatoshi Kimura cc03337492 Bug 1476597 - Stop using dynamic exception specification in mozalloc.h. r=froydnj
--HG--
extra : rebase_source : 48047a82e42dc7688fb3ed484d01794ccbd86763
2018-07-18 20:36:25 +09:00
Jacek Caban 505960071d Bug 1471352 - Don't export functions from gcc_throw.h in mingw builds. r=froydnj
MozReview-Commit-ID: D5HQWCN12oI

--HG--
extra : rebase_source : 890d816347162f54204df4dcd5c3297c917da867
2018-06-26 18:55:14 +02:00
Eric Rahm ca834a09a7 Bug 1470268 - Add allocation filter to dmd.py. r=njn
This adds an '--allocation-filter' param that can be used to limit output to
only allocations that include the filter in their stack. For example:
  dmd.py --allocation-filter fontconfig dmd.json.gz
limits its output to just allocations that have an instance of 'fontconfig' in
in one of their stack frames.

--HG--
extra : rebase_source : 9ed34d5c7a6a2b76e96455e66b2e8196686ade16
2018-06-20 13:11:50 -07:00
Jon Coppeard 858a13bce3 Bug 1468767 - Check result of calling vm_copy() r=njn 2018-06-14 14:58:45 -07:00
Sylvestre Ledru 3e84d308c3 Bug 1464869 - Fix flake8/pep8 issue by hand in memory/ r=njn
MozReview-Commit-ID: 8bkhAB4g6rv

--HG--
extra : rebase_source : 623f4ed95d601b47878c910859f3b91e87897011
2018-05-25 23:27:02 -07:00
Sylvestre Ledru 21f28e8329 Bug 1464869 - Run autopep8 on memory/ r=njn
MozReview-Commit-ID: GzFGXZ8WLX5

--HG--
extra : rebase_source : 15b2f8fefaa4ee32a4f655086194202d9e82efb6
2018-05-25 23:16:07 -07:00
Emilio Cobos Álvarez fffb25b74f Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
This was done automatically replacing:

  s/mozilla::Move/std::move/
  s/ Move(/ std::move(/
  s/(Move(/(std::move(/

Removing the 'using mozilla::Move;' lines.

And then with a few manual fixups, see the bug for the split series..

MozReview-Commit-ID: Jxze3adipUh
2018-06-01 10:45:27 +02:00
Margareta Eliza Balazs 03394c438d Merge inbound to mozilla-central. a=merge 2018-05-24 12:37:58 +03:00
Mike Hommey 7c246fac68 Bug 1460838 - Avoid static initializers in mozjemalloc with MSVC. r=njn
--HG--
extra : rebase_source : dd2106192a90fbade6f89dfa1169c6e9ab3a553b
2018-05-24 11:23:10 +09:00
Andreea Pavel 8469234a9f Bug 1461964 - removed mac 10.6 reference r=njn 2018-05-20 23:08:00 +03:00
Tom Ritter 4e3daa47c1 Bug 1460720 Do not define _aligned_malloc - instead define _aligned_malloc_impl and export _aligned_malloc r=glandium
MozReview-Commit-ID: 3EwAd81Iz7r

--HG--
extra : rebase_source : 899303e4c5db39b24451692f59a9d3bd1f9fd5a2
2018-05-15 11:10:48 -05:00
Tom Ritter 799ec67a16 Bug 1448749 Resolve undefined references to '_imp__mozalloc_abort' in the MinGW build r=glandium
MozReview-Commit-ID: 5enjU5Xp8G9

--HG--
extra : rebase_source : 21e8f5aff8f3d6f26fd9127e0b30099031a587a7
2018-05-16 22:02:05 -05:00
Masatoshi Kimura e98b2c42f0 Bug 1445601 - Stop using LoadLibraryA in replace_malloc. r=glandium
MozReview-Commit-ID: 8EzDtCIlg7F

--HG--
extra : rebase_source : cf909f472c1c0007b2ff759d011435b8b6bc0f37
2018-03-25 13:12:03 +09:00
David Major fa8d998487 Bug 1447795: Add even more UseItOrLoseIt to SmokeDMD.cpp 2018-04-01 09:37:42 -04:00
Tom Ritter 5fda6df793 Bug 1446466 Remove Nightly-only restriction on jemalloc arena implementation r=glandium
MozReview-Commit-ID: CC2cftngmli

--HG--
extra : rebase_source : 5cc5d5b0638b29074cc0e497f4669ebabcf6578a
2018-03-21 20:53:46 -05:00
Tom Ritter 51a8daef9d Bug 1446466 Crash if moz_dispose_arena is called, and comment out all callers r=glandium
Bug 1364359 is to fix a leaked arena. Until that is fixed; it is unsafe to
call moz_dispose_arena more than once.

MozReview-Commit-ID: KIby1RLtrPK

--HG--
extra : rebase_source : 6ea41001e9f0c4d5eb24ee678d6c1c0218991ac3
2018-03-21 20:49:35 -05:00
Margareta Eliza Balazs adebb06ac1 Merge inbound to mozilla-central. a=merge 2018-03-28 00:48:11 +03:00
Carl Corcoran 6766b3d082 Bug 1448546: Adding sized operator delete overloads on Windows builds; r=froydnj
MozReview-Commit-ID: EzhNZEf0suT

--HG--
extra : rebase_source : 695258d519654c9f0f69dc8a1446f28136ae8273
extra : source : 013cfa5c5f358aa02784a8a20bf181d3751d0bbf
2018-03-27 14:42:17 +02:00
Nathan Froyd 3d6d46eaba Bug 1448030 - use SprintfLiteral in fillAbortMessage; r=glandium
The SprintfLiteral checker complains that:

  snprintf(msg, sizeof(msg), ...);

should be using SprintfLiteral instead.  Let's do that.
2018-03-27 10:51:32 -04:00
David Major 0fab6b57fc Bug 1447795 - Add some more UseItOrLoseIt to SmokeDMD.cpp. r=njn 2018-03-21 13:52:00 +02:00
Nathan Froyd b68dfdbc2d Bug 1435407 - declare our wrapped delete definitions with noexcept(true); r=glandium
This behavior matches what gets used in mozalloc.h to define these
wrappers, and is particularly necessary for newer versions of clang to
not complain about our definitions.
2018-03-13 11:10:06 -05:00
Andreea Pavel 6e194b7c24 Merge mozilla-central to mozilla-inbound. a=merge on a CLOSED TREE 2018-03-02 18:24:58 +02:00
Mike Hommey 61d75ea276 Bug 1442468 - Remove workaround for http://code.google.com/p/android/issues/detail?id=23203. r=froydnj
That NDK bug has been fixed since r8c, and we now require something more
recent than that. This effectively reverts the changes from bug 720621
and bug 734832.

--HG--
extra : rebase_source : 9ff76a790ec4135dc0172cfd0f11fc1ecef7df64
2018-03-01 15:15:02 +09:00
Nathan Froyd 9133c59dba Bug 1442325 - remove some dead preprocessor logic; r=glandium
We always compile with C++11 (er, C++14), so there's no need to include
clauses that suggest otherwise.
2018-03-02 07:06:08 -05:00
Florian Quèze c714053d73 Bug 1433175 - scripted patch to replace Components.classes[, Components.interfaces.nsI, Components.utils. and Components.results. with Cc, Ci, Cu and Cr, r=Mossop. 2018-02-28 18:51:33 +01:00
Mike Hommey 5f11951b9b Bug 1441335 - Fix base allocator commit evaluation. r=njn
Base allocator commit stats were added in bug 515556, along other commit
stats, but they have actually been wrong since then: the committed count
is updated with the difference between pbase_next_addr and
base_next_decommitted *after* the latter is set to the former, making
the difference always 0.

--HG--
extra : rebase_source : a2aed523314549a37a61bd4ab300c98f198f9252
2018-02-27 07:39:34 +09:00
Mike Hommey ef4741aa26 Bug 1439470 - Remove some now unnecessary checks. r=njn
Since TreeNode::{Left,Right,Color} is always a valid call to make, we
don't need to check if for nullity before calling those functions.

This effectively kind of reverts some parts of bug 1412722.

--HG--
extra : rebase_source : 3deb316f463b51fdbb3aebc2e57e437018b3a829
2018-02-15 20:25:57 +09:00
Mike Hommey 6442687426 Bug 1439470 - Turn TreeNode(nullptr) into a "virtual" sentinel. r=njn
The code before bug 1412722 benefitted from the sentinel being an actual
node object, and some code paths ended up checking its color (always
black) or getting its right and left node, that always returned to the
sentinel.

When TreeNode currently contains a nullptr, all those lead to a null
deref if the calling code is not doing the right checks, which happens
to be the case in at least some places. Instead of relying on the
callers doing the right thing, make the TreeNode do the right thing when
it contains a nullptr, effectively acting as the sentinel in that case.

We additionally ensure that nothing in the calling code will be trying
to change the color or left/right pointers on the sentinel, which is an
extra safe net compared to the code before bug 1412722.

--HG--
extra : rebase_source : 09ab0bf8682092ef6d9a0a5921be3da787d0d548
2018-02-15 20:20:11 +09:00
Mike Hommey 1c0141e333 Bug 1439470 - Turn TreeNode into a smart pointer-like type. r=njn
This will allow the upcoming changes to add some safety back to the code
after bug 1412722.

--HG--
extra : rebase_source : 5033b8034cabaf5a7fdd578459588d5099402d02
2018-02-15 20:15:00 +09:00
Andreea Pavel e7ca112682 Backed out 3 changesets (bug 1439470) for failing automation.py on a CLOSED TREE
Backed out changeset c43ee00c3e6b (bug 1439470)
Backed out changeset cf9d00862149 (bug 1439470)
Backed out changeset f95559ae3134 (bug 1439470)
2018-02-20 13:39:28 +02:00
Mike Hommey a70ca542aa Bug 1439470 - Remove some now unnecessary checks. r=njn
Since TreeNode::{Left,Right,Color} is always a valid call to make, we
don't need to check if for nullity before calling those functions.

This effectively kind of reverts some parts of bug 1412722.

--HG--
extra : rebase_source : 172f1c042bdbb4d500e1afb4d57774ab76826876
2018-02-15 20:25:57 +09:00
Mike Hommey b4f9300f41 Bug 1439470 - Turn TreeNode(nullptr) into a "virtual" sentinel. r=njn
The code before bug 1412722 benefitted from the sentinel being an actual
node object, and some code paths ended up checking its color (always
black) or getting its right and left node, that always returned to the
sentinel.

When TreeNode currently contains a nullptr, all those lead to a null
deref if the calling code is not doing the right checks, which happens
to be the case in at least some places. Instead of relying on the
callers doing the right thing, make the TreeNode do the right thing when
it contains a nullptr, effectively acting as the sentinel in that case.

We additionally ensure that nothing in the calling code will be trying
to change the color or left/right pointers on the sentinel, which is an
extra safe net compared to the code before bug 1412722.

--HG--
extra : rebase_source : ac61ea259ac49bf76e2f8f6f54dda991498d4664
2018-02-15 20:20:11 +09:00
Mike Hommey 4489841597 Bug 1439470 - Turn TreeNode into a smart pointer-like type. r=njn
This will allow the upcoming changes to add some safety back to the code
after bug 1412722.

--HG--
extra : rebase_source : c906e9b3168fe738cba8a3de3fdf4efee1f0d4df
2018-02-15 20:15:00 +09:00
Mike Hommey c60ee1a610 Bug 1439474 - Make double-free crashes more identifiable. r=njn
- Turn MOZ_DIAGNOSTIC_ASSERTs related to double-frees into
MOZ_RELEASE_ASSERTs with a crash message making them more identifiable
than the asserted condition.
- In huge_dalloc, MOZ_RELEASE_ASSERT early, instead of letting
RedBlackTree::Remove end up crashing because the node is not in the
tree.

--HG--
extra : rebase_source : e051caaf371e88a9db6b5153f58c8a4aa4cde757
2018-02-20 11:39:04 +09:00
Mike Hommey 5c18ecad6b Bug 1438427 - Fix wrong change from bug 1412722 in RedBlackTree::Remove. r=njn
Before bug 1412722, which removed the sentinels, the code looked like:

  if (rbp_r_c->Right()->Left()->IsBlack()) {

At that point in the code, rbp_r_c is the root node of the tree. If
rbp_r_c->Right() was the sentinel, ->Right()->Left() would be the
sentinel too, and the sentinel is black. Which means the condition would
be true.

The code after was:

  if (rbp_r_c->Right() && (!rbp_r_c->Right()->Left() ||
                           rbp_r_c->Right()->Left()->IsBlack())) {

The second half correctly deals with the case of
rbp_r_c->Right()->Left() being the sentinel. But the first half now
makes things different: ->Right() being null would correspond to the
previous case where it was the sentinel, and the test would not return
true in that case when it would have before. When ->Right() is not null,
things are normal again.

The correct check is to make the branch taken when ->Right() is null.

Now, looking under which conditions we may get in that branch wrongly:
- The root node's right link must be empty, which means a very small tree.
- The comparison between the removed key and the root node must indicate
  the key is greater than the value of the root node.
- There's another case where the comparison result (rbp_r_cmp) can be
  eGreater, when it is reassigned under one of the branches under the
  eEqual test, and that branch is only taken when ->Right() on the root
  node was non-null, which was the non-broken case.

So it would seem we can't reach that code when rbp_r_c->Right() is null
anyways, so it /should/ practically make no difference. Better safe than
sorry, though. It's hard to tell anything from crash stats, because
since the templatization in bug 1403444, all crashes fit in one bucket,
when there used to be 5 functions before :(

While here, add a missing include in rb.h.

--HG--
extra : rebase_source : 2ebcb84345ad52059b0c081b9e2e1af1d0bbb7bc
2018-02-15 14:38:52 +09:00
Bobby Holley 3d8a3d0d6d Bug 1436541 - Don't clobber the thread-local arenas when we happen to hit a large allocation. r=glandium
MozReview-Commit-ID: 9i5B76vkNfr
2018-02-07 18:17:48 -08:00
Mike Hommey e483ecaab0 Bug 1424709 - Force disable the OSX system "nano allocator". r=spohl
We're not actually using it, and it messes up with the zone allocator in
mozjemalloc after fork(). See the lengthy analysis in
https://bugzilla.mozilla.org/show_bug.cgi?id=1424709#c34 and following.

--HG--
extra : rebase_source : c58e13b897dde7b32d83c43fbb2a04a0db3a5dc9
2018-01-31 17:18:01 +09:00
Kris Maglione 918ed6c474 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
extra : intermediate-source : 34c999fa006bffe8705cf50c54708aa21a962e62
extra : histedit_source : b2be2c5e5d226e6c347312456a6ae339c1e634b0
2018-01-29 15:20:18 -08:00
Cosmin Sabou 9a65a40178 Backed out 3 changesets (bug 1431533) for Android mochitest failures on testEventDispatcher on a CLOSED TREE
Backed out changeset a1eca62826a1 (bug 1431533)
Backed out changeset 34c999fa006b (bug 1431533)
Backed out changeset e2674287e57f (bug 1431533)
2018-01-30 07:17:48 +02:00
Kris Maglione 6476f95b13 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
2018-01-29 15:20:18 -08:00
Brindusan Cristian af8879d1eb Backed out 2 changesets (bug 1431533) for ESlint failures on a CLOSED TREE
Backed out changeset 6e56f4c8843e (bug 1431533)
Backed out changeset 12fc4dee861c (bug 1431533)
2018-01-30 02:32:43 +02:00
Kris Maglione c276bb9375 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : rebase_source : c004a023389f1f6bf3d2f3efe93c13d423b23ccd
2018-01-29 15:20:18 -08:00
Marco Castelluccio 871dbb2b23 Bug 1403005 - Don't run memory/replace/logalloc/replay in coverage builds. r=glandium
--HG--
extra : rebase_source : b2f451d764f8efb92082d8b987e74744091bfe4c
2018-01-16 15:45:40 +01:00
Chris Peterson 37efe4d0e6 Bug 1428535 - Add missing override specifiers to overridden virtual functions. r=froydnj
MozReview-Commit-ID: DCPTnyBooIe

--HG--
extra : rebase_source : cfec2d96faeb11656d86d760a34e0a04cacddb13
extra : intermediate-source : 6176724d63788b0fe8caa3f91607c2d93dbaa7ec
extra : source : eebbb0600447f9b64aae3bcd47b4be66c02a51ea
2017-11-05 19:37:28 -08:00
Mike Hommey 3e46ee7dc9 Bug 1417504 - Also wrap Heap{Alloc,ReAlloc,Free} when building without our allocator. r=njn
Bug 1280578 added some wrapping for the Win32 Heap* functions, mainly
for the rust static libraries that use them. Because pointer ownership
might cross the C++/Rust boundary, and because about:memory uses
malloc_usable_size/msize, we need both C++ and Rust to still use the
same heap on builds where our allocator is not enabled.

--HG--
extra : rebase_source : 37a25b376a02ea07c187fb161d2005141e783820
2017-12-19 14:46:23 +09:00
Mike Hommey 2fc6190633 Bug 1423802 - Remove the dummy fallible library. r=nalexander
Bug 1423803 was attempting to remove the fallible library but didn't do
so on Android because of this bug. We can now fully retire it.

--HG--
extra : rebase_source : de38872a08d24768eadfbe81652cfcd6aa7aa041
2017-12-07 12:16:50 +09:00
Gurzau Raul 91d3bc0100 Merge inbound to mozilla-central r=merge a=merge 2017-12-09 00:36:15 +02:00
Ryan VanderMeulen 01e424a4bc Bug 1423649 - Fix compiler errors that happen when building with VS2017 15.5. r=rillian 2017-12-08 10:40:08 -05:00
Sylvestre Ledru 5de63ef061 Bug 1394734 - Replace CONFIG['MSVC'] by CONFIG['CC_TYPE'] r=glandium
MozReview-Commit-ID: 5orfnoude7h

--HG--
extra : rebase_source : 1ed9a6b56e1d27221a07624767a7fb0e6147117f
2017-12-08 13:46:13 +01:00
Sylvestre Ledru 9bfe27d903 Bug 1394734 - Replace CONFIG['GNU_C*'] by CONFIG['CC_TYPE'] r=glandium
MozReview-Commit-ID: 7duJk2gSd4m

--HG--
extra : rebase_source : 7312fe276e561e8c034a5f6749774ae812727f9c
2017-12-07 22:09:15 +01:00
Mike Hommey 154fd9c9ad Bug 1424116 - Change the definition of mozilla::fallible again. r=njn
In bug 1423803, mozilla::fallible was made an "alias" of std::nothrow.
Except C++ doesn't allow compilers to be too smart, and in many cases,
they would actually create data fields to hold a copy of std::nothrow,
even creating a static initializer on non-optimized builds to do so.

By turning it into a reference, we allow compilers to just use
std::nothrow directly, as if it were passed directly, but they can still
create unused data fields. Turning it into a static allows compilers to
skip the data fields altogether.

On a local linux64 build, this saves 242 bytes of .bss.

Note this does change a `lea` (address calculation) into a `mov` (read),
but it shouldn't matter too much.

--HG--
extra : rebase_source : 9c08e8263aef267b8ad5962b0248c7effcb67796
2017-12-08 11:51:59 +09:00
Mike Hommey cd4d96f039 Bug 1424114 - Remove the string.h/cstring include in mozalloc.h. r=njn
While here, change the string.h include to cstring in mozalloc.cpp.

--HG--
extra : rebase_source : d60eac8b5fdb358b43eb32978d5d40a426d50648
2017-12-08 11:47:15 +09:00
Mike Hommey abab5abf88 Bug 1423803 - Turn mozilla::fallible into an alias for std::nothrow. r=njn
The std::nothrow variant of operator new is effectively a fallible
operator new. It is used in third party code.

The duplication with our own fallible operator new is unfortunate, and
we can reduce it by making one an alias of the other.

We keep the fallible library as a dummy on Android because bug 1423802
induces some linking problems.

--HG--
extra : rebase_source : d7b915aaafde40057e87b7ad4bbd82d348e4f12d
2017-12-07 11:32:29 +09:00
Mike Hommey c6b6415a7b Bug 1423512 - Remove unnecessary XPCOM_GLUE define in DMD. r=njn
This was added in bug 1122337 back when the stackwalker was still
in XPCOM, which it isn't anymore, so XPCOM_GLUE is not necessary
anymore.

--HG--
extra : rebase_source : e550671c26e250843d34cb2b83497c861225883f
2017-12-06 09:52:55 +09:00
Dorel Luca ed8dc2034d Merge inbound to mozilla-central r=merge a=merge 2017-12-07 00:01:19 +02:00
Mike Hommey 627d9acca4 Bug 1423461 - Report the right size to the OOM handler for moz_xcalloc. r=njn
--HG--
extra : rebase_source : 536f6504394b14a4968b24fbc719017111a428cf
2017-12-06 16:10:30 +09:00
Mike Hommey 33ca8ff779 Bug 1423461 - Use mozilla/Likely.h in mozalloc.cpp. r=njn
Back when mozalloc.cpp was written, mozilla/Likely.h didn't exist.

--HG--
extra : rebase_source : da3b4c8839a97e3ac2d40da158905ac38c088683
2017-12-06 16:05:08 +09:00
Mike Hommey a646756fb7 Bug 1423461 - Use noexcept in mozalloc.h on android. r=njn
Bug 1163171 removed support for building for android with GCC, and we
don't need to use throw() anymore. We can use the same code as for other
non-Windows platforms.

--HG--
extra : rebase_source : 9c2c2179a6d214096619ff0ae1d1a42912beda79
2017-12-06 11:38:59 +09:00
Mike Hommey 41a56e83c2 Bug 1423461 - Remove MOZALLOC_INLINE, and always use MOZ_ALWAYS_INLINE_EVEN_DEBUG. r=njn
MOZ_ALWAYS_INLINE_EVEN_DEBUG is always defined through
mozilla/Attributes.h, so the fallbacks are never used in practice. They
are just there from the old days when mozalloc.h didn't use
mozilla/Attributes.h.

--HG--
extra : rebase_source : 0d55068ab5fcec3f4bcafecd8c3ce371597f8cfe
2017-12-06 11:31:48 +09:00
Mike Hommey 3f1f5c9fc2 Bug 1423114 - Remove moz_xposix_memalign and moz_xvalloc. r=njn
They are both infallible wrappers of posix_memalign and valloc.
There is also moz_xmemalign, which wraps memalign, which is mostly
always available as of bug 1402647.

None of them are actually used, but it's still desirable to at least
have one infallible variant, so keep moz_xmemalign and remove the other
two.

While here, we actually make both memalign and moz_xmemalign always
available.

--HG--
extra : rebase_source : 1c3ca4b3e3310543145f3181dfa4e764be1d6ff8
2017-12-05 17:34:19 +09:00
Mike Hommey 4c95537eeb Bug 1423094 - Remove USE_STATIC_LIBS=True-related code in mozalloc. r=gps
--HG--
extra : rebase_source : 52a4df6d15f9aa5eb0479cef4e98e9e41eb5164c
2017-12-05 16:30:21 +09:00
Mike Hommey 8aa92edf03 Bug 1423094 - Remove mozalloc_staticruntime. r=gps
--HG--
extra : rebase_source : 3b6678d4b36e405b2acc18b8fd75b5db7d45bf4c
2017-12-05 15:39:39 +09:00
David Major ad7ff3a791 Bug 1423287 - Simplify NtCurrentTeb() handling. r=njn 2017-12-06 09:36:00 -05:00
Narcis Beleuzu dfd58840d1 Backed out changeset 8a4050c7e0fd (bug 1423114) for bustages on memory/mozalloc/mozalloc.cpp r=backout on a CLOSED TREE 2017-12-06 00:27:11 +02:00
Mike Hommey a1947c3098 Bug 1423119 - Remove the sole use of MOZALLOC_HAVE_XMALLOC. r=erahm
When this was added, the xpcom glue was still a thing, and there was a
distinction between things that would build with mozalloc available and
others. There is no such distinction anymore. Anything that has access
to xpcom has access to infallible allocator functions.

--HG--
extra : rebase_source : 04bce114e940c53709275d0354ea7240df4a051e
2017-12-05 17:45:20 +09:00
Mike Hommey 5f1f0bbdc4 Bug 1423114 - Remove moz_xposix_memalign and moz_xvalloc. r=njn
They are both infallible wrappers of posix_memalign and valloc.
There is also moz_xmemalign, which wraps memalign, which is always
available as of bug 1402647.

None of them are actually used, but it's still desirable to at least
have one infallible variant, so keep moz_xmemalign and remove the other
two.

While here, we actually make moz_xmemalign always available, since
memalign is always available.

--HG--
extra : rebase_source : 17300bc03a715e5d36b4b687f22050622c1c70c8
2017-12-05 17:34:19 +09:00
Mike Hommey a5aef799e1 Bug 1423109 - Use MOZ_{BEGIN,END}_EXTERN_C in mozalloc.h. r=njn
--HG--
extra : rebase_source : 9d1c8c59b58273c1efe9a124e41eccc254600346
2017-12-05 17:04:45 +09:00
Mike Hommey 660ec9e47b Bug 1423109 - Remove Sun Pro compiler specific preprocessor directives from mozalloc.h. r=njn
As of bug 1255813, compiling with Sun Pro compiler is not supported.

--HG--
extra : rebase_source : 3c925ec389a5607047330f743d45f3c5eca7b7f8
2017-12-05 17:00:02 +09:00
Mike Hommey 1b2c8764a2 Bug 1423107 - Remove moz_posix_memalign. r=njn
--HG--
extra : rebase_source : 47e9db8d98082fbccdb80c5ac0ca21fff0c5c888
2017-12-05 16:52:34 +09:00
Mike Hommey d7c4757af3 Bug 1423107 - Replace uses of moz_posix_memalign with posix_memalign. r=njn
moz_posix_memalign is a wrapper for posix_memalign that only exists if
posix_memalign exists.

On OSX, it has a fallback for an under-specified bug where it
purportedly returns a pointer that doesn't have the requested alignment.
That fallback was added in bug 414946, over 6 years ago, before jemalloc
was even enabled on OSX.

Considering posix_memalign is used directly in many other places in
Gecko, that we almost always use mozjemalloc, which doesn't have these
problems, and that in all likeliness, the bug was in some old version of
OSX that is not supported anymore, the fallback does not seem all that
useful.

So, just use posix_memalign directly.

--HG--
extra : rebase_source : b2151b5fb598dc20cbd70308555059f7545b18b2
2017-12-05 16:46:17 +09:00
Mike Hommey b796bc0e6d Bug 1423000 - Run clang-format in memory/replace/logalloc. r=njn
--HG--
extra : rebase_source : 6372d6eb88bad9da824e6a2a99380554e1ae04f5
2017-12-05 08:28:32 +09:00
Mike Hommey 3dc24c3f35 Bug 1423000 - Re-run clang-format on memory/build. r=njn
Most adjustements come from some recent .clang-format changes. A few
were overlooked from changes to the code.

--HG--
extra : rebase_source : c397762ea739fec05256a8c0132541bf4c727c32
2017-12-03 14:22:05 +09:00
Mike Hommey 55b2629bb8 Bug 1423000 - Always log allocator function calls. r=njn
So far, logalloc has avoided logging calls that e.g. return null
pointers, but both to make the code more generic and to enable logging
of error conditions, we now log every call.

--HG--
extra : rebase_source : 5e41914552f44e330f8f9c12b34fd6d30fdf30a7
2017-11-30 07:55:12 +09:00
Mike Hommey c617c4a119 Bug 1423000 - Don't use a separate replace-malloc library for the minimal-logalloc test. r=njn
Instead, only register a minimal set of functions when an environment
variable is set.

--HG--
extra : rebase_source : 94f2403ed9afe2acab1f56714d60fb32401076dc
2017-12-03 13:59:16 +09:00
Mike Hommey 2ff212b9f9 Bug 1423000 - Use mozjemalloc mutexes in logalloc. r=njn
Instead of the chromium one, which required some tricks.

--HG--
extra : rebase_source : f2918c33ff5263f50b81ac4606aa0ab3059cdc36
2017-12-03 14:23:23 +09:00
Mike Hommey ab9b4f676d Bug 1423000 - Move mozjemalloc mutexes to a separate header. r=njn
Also change the definition of the StaticMutex constructor to unconfuse clang-format.

--HG--
extra : rebase_source : aa2aa07c8c324e1253c20b34d850230579d45632
2017-12-03 14:21:19 +09:00
Mike Hommey 938618a5e1 Bug 1423000 - Reject some more invalid logalloc replay logs. r=njn
For functions with no result, such as free, it's invalid for some string
to appear after the closing parenthesis.

--HG--
extra : rebase_source : d7a72c064c408ba9c4a8722ebbaafb878633e857
2017-11-30 10:33:18 +09:00
Mike Hommey c142d8c12f Bug 1423000 - Move MemSlot lookup for replay results into the Replay methods. r=njn
This allows all methods to have the same signature.

--HG--
extra : rebase_source : 6c6e952d00ba5f92c2cf368fa871e8979f640780
2017-11-30 10:31:25 +09:00
Mike Hommey 94fe24fd79 Bug 1423000 - Count jemalloc_stats as an operation. r=njn
While jemalloc_stats is not actively doing anything, it can be
cumbersome to not have it count as an operation, because the operation
count shown on jemalloc_stats doesn't match the line number in the input
replay log, and the offset grows as the number of jemalloc_stats
operations grows.

While here, also update a comment about the replay log format.

--HG--
extra : rebase_source : da0ad9a990487ebdfadae7f8fcfad85e82b482fc
2017-11-30 10:18:39 +09:00
Mike Hommey ddec58883e Bug 1423000 - Remove Replay::Commit. r=njn
It adds an uncompressible and noticeable time overhead to replaying
logs, even when one is not interested in measuring RSS. This has caused
me to clear the method body on multiple occasions.

If necessary, it is possible to enable zero or junk at the allocator
level for the same effect.

--HG--
extra : rebase_source : a4c44e97986668e712b500266d7fffe985e85881
2017-11-30 10:48:41 +09:00
Mike Hommey 2b2a874b47 Bug 1420355 - Statically link DMD. r=njn
--HG--
extra : rebase_source : 8e7cf975d096116b666532f3fe8aa5a7f61b5725
2017-11-28 08:10:48 +09:00
Mike Hommey 50d09b60b0 Bug 1420355 - Allow to statically link replace-malloc libraries. r=njn
And statically link logalloc.

Statically linking is the default, except when building with
--enable-project=memory, allowing to use the generated libraries from
such builds with Firefox.

--HG--
extra : rebase_source : efe9edce8db6a6264703e0105c2192edc5ca8415
2017-11-23 17:24:19 +09:00
Mike Hommey 1e631092c5 Bug 1420355 - Don't initialize DMD if the DMD environment variable is not given. r=njn
This makes things slightly more inconvenient (having to set two
environment variables instead of one for the simplest case) until a few
patches down the line, when DMD is statically linked, at which point it
will get down to one environment variable every time.

--HG--
extra : rebase_source : 08dc3c05318b572ae1026227d0369fa8bf21b20f
2017-11-28 08:10:07 +09:00
Mike Hommey 7c59f18de8 Bug 1420355 - Don't initialize logalloc if MALLOC_LOG is not given. r=njn
Now that replace_init can opt-out of registering the replace-malloc
functions, don't do so when MALLOC_LOG was not set in the environment.

While one would normally set MALLOC_LOG alongside one of the environment
variable necessary to load the replace-malloc library, we're also going,
in a subsequent change, to allow statically linking replace-malloc
libraries, taking full advantage of this change.

--HG--
extra : rebase_source : 944a9d7af33f88f793ee0104bd5e58ec508e4f58
2017-11-23 13:54:16 +09:00
Mike Hommey 8b50bbe85b Bug 1420355 - Remove fallbacks when DMD is initializing. r=njn
As of bug 1420353, DMD's replace_* functions can't be called before
replace_init places them in the malloc function table, which only
happens after DMD::Init has run, meaning DMD is always initialized
by the time any of its replace_* function can be called.

--HG--
extra : rebase_source : 96bf4d01b6fac5cbb4712f56c572791cc4972f77
2017-11-28 08:05:58 +09:00
Mike Hommey 449973411b Bug 1420355 - Don't declare replace_* functions in replace_malloc.h. r=njn
The original purpose of those declarations was to avoid the function
definitions being wrong, as well as forcing them being exported
properly (as extern "C", as weak symbols when necessary, etc.), but:

- The implementations being C++, function overloads simply allowed
  functions with the same name to have a different signature.

- As of bug 1420353, the functions don't need to be exported anymore,
  nor do we care whether their symbols are mangled. Furthermore, they're
  now being assigned to function table fields, meaning there is type
  checking in place, now.

So all in all, these declarations can be removed.

Also, as further down the line we're going to statically link the
replace-malloc libraries, avoid symbol conflicts by making those
functions static.

--HG--
extra : rebase_source : 0dbb15f2c85bc873e7eb662b8d757f99b0732270
2017-11-28 07:18:15 +09:00
Mike Hommey 2b959b7c6e Bug 1420355 - Don't link logalloc against the static runtime on Windows. r=njn
This was never strictly required (for instance, DMD doesn't do that),
and would make things harder with the subsequent changes.

--HG--
extra : rebase_source : 29ea08d41f54da7f99120f9fe9af4017f61d8a4b
2017-11-28 17:11:40 +09:00
Csoregi Natalia 4ce8d0124c Backed out 7 changesets (bug 1420355) for mass failures on OS X and Android. r=backout on a CLOSED TREE
Backed out changeset a7ed89e13a4c (bug 1420355)
Backed out changeset fd6702e6e0a0 (bug 1420355)
Backed out changeset 0479dda078a2 (bug 1420355)
Backed out changeset e69357ccca9e (bug 1420355)
Backed out changeset 3742a4b69ba2 (bug 1420355)
Backed out changeset 451cd087922f (bug 1420355)
Backed out changeset d80b5c4e1dd0 (bug 1420355)
2017-11-29 03:08:46 +02:00
Mike Hommey 7c62087a43 Bug 1420355 - Statically link DMD. r=njn
--HG--
extra : rebase_source : 46800c9c0c5006a5a32f11abc209da27e65ae0f5
2017-11-28 08:10:48 +09:00
Mike Hommey d60e80991e Bug 1420355 - Allow to statically link replace-malloc libraries. r=njn
And statically link logalloc.

Statically linking is the default, except when building with
--enable-project=memory, allowing to use the generated libraries from
such builds with Firefox.

--HG--
extra : rebase_source : efe9edce8db6a6264703e0105c2192edc5ca8415
2017-11-23 17:24:19 +09:00
Mike Hommey 0a3b6c9813 Bug 1420355 - Don't initialize DMD if the DMD environment variable is not given. r=njn
This makes things slightly more inconvenient (having to set two
environment variables instead of one for the simplest case) until a few
patches down the line, when DMD is statically linked, at which point it
will get down to one environment variable every time.

--HG--
extra : rebase_source : 08dc3c05318b572ae1026227d0369fa8bf21b20f
2017-11-28 08:10:07 +09:00
Mike Hommey e38859b199 Bug 1420355 - Don't initialize logalloc if MALLOC_LOG is not given. r=njn
Now that replace_init can opt-out of registering the replace-malloc
functions, don't do so when MALLOC_LOG was not set in the environment.

While one would normally set MALLOC_LOG alongside one of the environment
variable necessary to load the replace-malloc library, we're also going,
in a subsequent change, to allow statically linking replace-malloc
libraries, taking full advantage of this change.

--HG--
extra : rebase_source : 944a9d7af33f88f793ee0104bd5e58ec508e4f58
2017-11-23 13:54:16 +09:00
Mike Hommey 3e3dbe9627 Bug 1420355 - Remove fallbacks when DMD is initializing. r=njn
As of bug 1420353, DMD's replace_* functions can't be called before
replace_init places them in the malloc function table, which only
happens after DMD::Init has run, meaning DMD is always initialized
by the time any of its replace_* function can be called.

--HG--
extra : rebase_source : 96bf4d01b6fac5cbb4712f56c572791cc4972f77
2017-11-28 08:05:58 +09:00
Mike Hommey ef6af827be Bug 1420355 - Don't declare replace_* functions in replace_malloc.h. r=njn
The original purpose of those declarations was to avoid the function
definitions being wrong, as well as forcing them being exported
properly (as extern "C", as weak symbols when necessary, etc.), but:

- The implementations being C++, function overloads simply allowed
  functions with the same name to have a different signature.

- As of bug 1420353, the functions don't need to be exported anymore,
  nor do we care whether their symbols are mangled. Furthermore, they're
  now being assigned to function table fields, meaning there is type
  checking in place, now.

So all in all, these declarations can be removed.

Also, as further down the line we're going to statically link the
replace-malloc libraries, avoid symbol conflicts by making those
functions static.

--HG--
extra : rebase_source : 0dbb15f2c85bc873e7eb662b8d757f99b0732270
2017-11-28 07:18:15 +09:00
Mike Hommey 8771ae803b Bug 1420355 - Don't link logalloc against the static runtime on Windows. r=njn
This was never strictly required (for instance, DMD doesn't do that),
and would make things harder with the subsequent changes.

--HG--
extra : rebase_source : 29ea08d41f54da7f99120f9fe9af4017f61d8a4b
2017-11-28 17:11:40 +09:00
Mike Hommey feda5d4e15 Bug 1420353 - Don't define replace_init through malloc_decls.h. r=njn
The definition for replace_init is only used in two places:
replace_malloc.h and mozjemalloc.cpp. Invoking the malloc_decls.h
machinery for just that one function is a lot of overhead, and things
are actually simpler doing the declaration directly, especially thanks
to the use of C++11 decltype to avoid duplication of the function
type.

This has the additional advantage that now malloc_decls.h only contains
the allocator API.

While here, replace the MOZ_WIDGET_ANDROID ifdef with ANDROID.

--HG--
extra : rebase_source : 50ddf044f43904575598f17bd4c3477fc1a1155f
2017-11-24 16:36:29 +09:00
Mike Hommey 32ecc64ada Bug 1420353 - Change how replace-malloc initializes, part 2. r=njn
Because one entry point is simpler than two, we make replace_init fulfil
both the roles of replace_init and replace_get_bridge.

Note this should be binary compatible with older replace-malloc
libraries, albeit not detecting their bridge (and with the
previous change, they do not register anyways). So loading older
replace-malloc libraries should do nothing, but not crash in awful ways.

--HG--
extra : rebase_source : aaf83e706ee34f45cfa75551a2f0998e5c5b8726
2017-11-24 16:02:05 +09:00
Mike Hommey 845f9c5d82 Bug 1420353 - Change how replace-malloc initializes, part 1. r=njn
The allocator API is a moving target, and every time we change it, the
surface for replace-malloc libraries grows. This causes some build
system problems, because of the tricks in replace_malloc.mk, which
require the full list of symbols.

Considering the above and the goal of moving some of the replace-malloc
libraries into mozglue, it becomes simpler to reduce the replace-malloc
exposure to the initialization functions.

So instead of the allocator poking into replace-malloc libraries for all
the functions, we expect their replace_init function to alter the table
of allocator functions it's passed to register its own functions.

This means replace-malloc implementations now need to copy the original
table, which is not a bad thing, as it allows function calls with one
level of indirection less. It also replace_init functions to not
actually register the replace-malloc functions in some cases, which will
be useful when linking some replace-malloc libraries into mozglue.

Note this is binary compatible with previously built replace-malloc
libraries, but because those libraries wouldn't update the function
table, they would stay disabled.

--HG--
extra : rebase_source : 2518f6ebe76b4c82359e98369de6a5a8c3ca9967
2017-11-22 17:24:29 +09:00
Gurzau Raul 21905d169e Merge mozilla-central to mozilla-inbound. r=merge a=merge CLOSED TREE 2017-11-24 00:38:13 +02:00
Mike Hommey 1b044f7203 Bug 1416170 - Don't use long double constants. r=njn
Some platforms (at least powerpc64) apparently can't handle long double
constants. So use double constants instead.

--HG--
extra : rebase_source : dd7f87cfff13f63566845e03a0bd6f4a8146f421
2017-11-23 11:58:14 +09:00
Mike Hommey c2346512fd Bug 1418389 - Partially revert bug 1417234. r=njn
Bug 1417234 replaced all uses of CRITICAL_SECTION with SRWLocks in the
allocator on Windows, and this seems to have incurred performance
regressions on speedometer.

OTOH, there is a real benefit from not having to manually initialize the
allocator.

So we restore the use of CRITICAL_SECTIONs for Mutexes in the allocator,
except for the initialization lock, which is remaining as a SRWLock.

Talos indicates this solves the regression in large part, but is not
definitive as whether it has the same effect as a pure backout of bug
1417234. We'll see how things go over time.

--HG--
extra : rebase_source : a52b8d08159f6fce8286578114af84e55851a86b
2017-11-23 07:25:08 +09:00
Gabriele Svelto 5ff191810d Bug 1402519 - When the crash reporter code is disabled at configure time replace it with a dummy implementation; r=ted.mielczarek
MozReview-Commit-ID: F5QbaI1LlmZ

--HG--
extra : rebase_source : f05c929911d27dc1598bc040df54022cd90aa06a
2017-11-14 14:49:33 +01:00
Mike Hommey e760c78ddc Bug 1419217 - Change comparison functions for red-black trees. r=njn
- This makes all of them return an enum, quite similar to rust.
- This makes all of them derive from a single implementation of an
  integer comparison.
- This implements that integer comparison in terms of simple operations,
  rather than "smart" computation, which turns out to allow compilers
  to do better optimizations.
  See https://blogs.msdn.microsoft.com/oldnewthing/20171117-00/?p=97416

--HG--
extra : rebase_source : 89710d7954f445d43e6da55aaf171b1f57dce5fc
2017-11-21 09:11:54 +09:00
Mike Hommey b20067214e Bug 1418123 - Apply junk on huge and large reallocations. r=njn
Zero and junk should have the same scope, but currently huge and large
reallocs are zeroed when zeroing is enabled, but are not junked when
junking is enabled. This makes things straight, leaning on the side of
filling the added bytes, rather than not.

This has an actual effect on debug builds, where junk is enabled by
default.

--HG--
extra : rebase_source : f409cae7ea720f69239d896d155b653efc648feb
2017-11-16 16:34:31 +09:00
Mike Hommey a6bafc7783 Bug 1418123 - Factor out the zero/junk logic. r=njn
--HG--
extra : rebase_source : fe8f184e072982b1995b4059f799a0b6c22af668
2017-11-10 16:59:21 +09:00
Mike Hommey 7e4604b23d Bug 1418153 - Move arena_ralloc/huge_ralloc to methods of arena_t. r=njn
This also creates a new arena_t::Ralloc function replacing parts of
iralloc, the other part being inlined in the unique caller.

--HG--
extra : rebase_source : 76a9ca77e651c99641d8906faea8e469d8eea041
2017-11-17 09:50:27 +09:00
Mike Hommey 960f44ef3e Bug 1418153 - Add Large to SizeClass::ClassType. r=njn
And refactor arena_ralloc as a consequence.

--HG--
extra : rebase_source : a5f72e5f1b6a56b165baf5103e83410580a035d3
2017-11-15 14:50:33 +09:00
Mike Hommey ef84807f38 Bug 1418153 - Remove impossible condition. r=njn
Since the old size arena_ralloc is given is already a size class, when
the size class for the new size is the same as the old size, the new
size can't be larger than the old size, so there's never anything to
zero.

--HG--
extra : rebase_source : dd468de60b2ed87718ec4e26f13d3b0c8932f455
2017-11-16 15:35:37 +09:00
Mike Hommey b73d32f806 Bug 1418153 - Fold imalloc into arena_t::Malloc. r=njn
--HG--
extra : rebase_source : 796fdd6f5147eed29ff359ca7b35e7f70985eda1
2017-11-14 08:31:53 +09:00
Mike Hommey ef76658bce Bug 1418153 - Move huge_malloc/huge_palloc to methods of arena_t. r=njn
--HG--
extra : rebase_source : 20db86c1c87854aceda07323a48d077341d84547
2017-11-14 08:29:39 +09:00
Mike Hommey 68fc08c5af Bug 1418153 - Move ipalloc to a method of arena_t. r=njn
--HG--
extra : rebase_source : fff27ddebdbed11de05e11a93f8cd9edca6e2660
2017-11-14 08:21:09 +09:00
Mike Hommey 93f3b706b5 Bug 1418153 - Rename arena_t::Palloc to arena_t::PallocLarge. r=njn
--HG--
extra : rebase_source : 7fbe7f4883ddea9f13c2567fa76e675621c79bb2
2017-11-14 08:16:28 +09:00
Mike Hommey 3ac39f1599 Bug 1418153 - Move arena selection one level up the call stack. r=njn
We intend to move some functions to methods of the arena_t class. Moving
the arena selection out of them is the first step towards that.

--HG--
extra : rebase_source : b8380c3a0c90ed817a1dbbe8d60e6107b78ec677
2017-11-14 08:00:17 +09:00
Mike Hommey 161d7afcbd Bug 1418104 - Add various realloc, junk and poisoning unit tests. r=njn
--HG--
extra : rebase_source : c79887f72197e5308a74fb5e68a94565ca6464a8
2017-11-16 16:41:41 +09:00
Mike Hommey 2c84ef6b8a Bug 1418104 - Allow to pass parameters when creating arenas. r=njn
The immediate goal for this is to allow determinism in an arena used for
an upcoming test, by essentially disabling purge on that specific arena.
We do that by allowing arenas to be created with a specific setting for
mMaxDirty.

Incidentally, this allows to cleanup the mMaxDirty initialization for
thread-local arenas.

Longer term, this would allow to tweak arenas with more parameters, on
a per arena basis.

--HG--
extra : rebase_source : e4b844185d132aca9ee10224fc626f8293be0a34
2017-11-17 07:27:35 +09:00
Mike Hommey c4587b9a17 Bug 1418104 - Initialize the allocator in jemalloc_stats. r=njn
Some unit tests rely on jemalloc_stats to get information such as chunk
size or page size. They can do so before any allocation happens, when
using gtest filters. So it is preferable for jemalloc_stats to
initialize the allocator.

--HG--
extra : rebase_source : 6696ec1cdaa3b121a3d12cb7b6049b79c656d271
2017-11-16 16:35:03 +09:00
Mike Hommey 398c8e8356 Bug 1417309 - Add the necessary bits to support a --enable-project=memory option. r=nalexander
The option allows to iterate on the allocator code without requiring a
complete setup to build Firefox.
2017-11-16 08:37:36 +09:00
Nathan Froyd f51359bd19 Bug 1325632 - part 5 - ensure that we compile with -fno-sized-deallocation when possible; r=chmanchester
We currently turn off the C++14 sized-deallocation facility on MSVC, and
we'd like to ensure we do the same thing for clang and gcc.  To do so,
we add new functionality to moz.configure for checking and adding
compilation flags, similar to the facility for checking and adding
warning flags.  The newly added facility is then used to add
-fno-sized-deallocation to the compilation flags, when the option is
supported.

Once we do this, we can't define the sized deallocation functions in
mozalloc.h; the compiler will complain that we are using
-fno-sized-deallocation, yet defining these special functions that we'll
never use.  These functions were added for MinGW, where we needed to
compile with C++14 ahead of other platforms to be compatible with MSVC
headers.  But they're no longer necessary, though they would be if we
removed -fno-sized-deallocation; the compiler will complain if we do
that and we'll add them back at that point.
2017-11-15 14:53:16 -04:00
Mike Hommey 1f75d81c1c Bug 1417234 - Use SRWLock as Mutex for mozjemalloc on Windows. r=njn
SRWLock is more lightweight than CriticalSection, but is only available
on Windows Vista and more. So until we actually dropped support Windows
XP, we had to use CriticalSection.

Now that all supported Windows versions do have SRWLock, this is a
switch we can make, and not only because SRWLock is more lightweight,
but because it can be statically initialized like on other platforms,
allowing to use the same initialization code as on other platforms,
and removing the requirement for a DllMain, which in turn can allow
to statically link mozjemalloc in some cases, instead of requiring a
shared library (DllMain only works on shared libraries), or manually
call the initialization function soon enough.

There is a downside, though: SRWLock, as opposed to CriticalSection, is
not fair, meaning it can have thread scheduling implications, and can
theoretically increase latency on some threads. However, it is the
default used by Rust Mutex, meaning it's at least good enough there.
Let's see how things go with this.

--HG--
extra : rebase_source : 337dc4e245e461fd0ea23a2b6b53981346a545c6
2017-11-14 12:58:33 +09:00
Ryan VanderMeulen 6c84e6c823 Bug 1402283 - Fix typo. r+a=RyanVM 2017-11-10 17:07:27 -05:00
Mike Hommey 1e661e8113 Bug 1402283 - Fix non-Nightly build bustage. r+a=RyanVM 2017-11-10 16:55:37 -05:00
Mike Hommey 41ede31cd3 Bug 1402283 - Enforce arena matching on moz_arena_{realloc,free}. r=njn
This enforces the API contract as described in memory/build/malloc_decls.h.
2017-11-10 16:05:24 +09:00
Mike Hommey 1dbfb30e4e Bug 1402283 - Associate an arena to each huge allocation. r=njn
Currently, huge allocations are completely independent from arenas. But
in order to ensure that e.g. moz_arena_realloc can't reallocate huge
allocations from another arena, we need to track which arena was
responsible for the huge allocation. We do that in the corresponding
extent_node_t.
2017-11-10 16:05:22 +09:00
Mike Hommey 60238a717e Bug 1402283 - Replace isalloc/isalloc_validate with static methods of a new AllocInfo class. r=njn
Both functions do essentially the same thing, one having more validation
than the other. We can use a template with a boolean parameter to avoid
the duplication.

Furthermore, we're soon going to require, in some cases, more
information than just the size of the allocation, so we wrap their
result in a helper class that gives information about an active
allocation.
2017-11-10 16:05:21 +09:00
Mike Hommey a6f4d02c4c Bug 1402283 - Make arena_ralloc use the same arena as the original pointer when none is provided. r=njn
When using plain realloc() on a pointer that was allocated with
moz_arena_malloc, we want the resulting pointer to still belong to the
same arena.
2017-11-10 16:05:19 +09:00
Mike Hommey e9f49d03b4 Bug 1402283 - Rename extent_node_t fields. r=njn 2017-11-10 16:05:17 +09:00
Mike Hommey e68ddaa1c2 Bug 1415454 - Replace log2 lookup table with FloorLog2. r=njn
FloorLog2 expands to, essentially, a compiler builtin/intrinsic, that,
in turn, expands to a single machine instruction on tier 1 and other
platforms. On platforms where that's not the case, we can expect the
compiler to generate fast code anyways. So overall, this is all better
than manually using a log2 lookup table.

Also replace a manual power-of-two check with mozilla::IsPowerOfTwo,
which does the same test.

--HG--
extra : rebase_source : e8164c254723c74ef83e798073327ec6afa6f1fb
2017-11-08 16:20:40 +09:00
Mike Hommey 3a2a081a07 Bug 1415454 - Remove the unused arena_bin_t* argument to arena_t::AllocRun. r=njn
--HG--
extra : rebase_source : 6c01dad41bc348237f1ee099bc4bd8138738dfde
2017-11-03 15:54:20 +09:00
Mike Hommey 2b7e3e93bd Bug 1415454 - Inline MallocBinEasy and MallocBinHard. r=njn
They are both only used once, are trivial wrappers, and even repeat the
same assertions.

--HG--
extra : rebase_source : b40b26e303cb69a451e63937efd8a666053954e5
2017-11-03 15:48:40 +09:00
Mike Hommey 80c65dc086 Bug 1414168 - Rename arena_run_t fields. r=njn
--HG--
extra : rebase_source : 2d80b0a7e3634a84f8b7b6dd229d6cd42d59d290
2017-11-03 15:23:44 +09:00
Mike Hommey b6fb21eb81 Bug 1414168 - Move bin initialization to a method of the arena_bin_t class. r=njn
--HG--
extra : rebase_source : f21ff1f44bf8b47185b08652f10d9b77e29dcd64
2017-11-08 15:53:24 +09:00
Mike Hommey 2489970e52 Bug 1414168 - Change how run sizes are calculated. r=njn
There are multiple flaws to the current code:
- The loop calculating the right parameters for a given run size is
  repeated.
- The loop trying different run sizes doesn't actually work to fulfil
  the overhead constraint: while it stops when the constraint is
  fulfilled, the values that are kept are those from the previous
  iteration, which may well be well over the constraint.

In practice, the latter resulted in a few surprising results:
- most size classes had an overhead slightly over the constraint
  (1.562%), which, while not terribly bad, doesn't match the set
  expectations.
- some size classes ended up with relatively good overheads only because
  of the additional constraint that run sizes had to be larger than the
  run size of smaller size classes. Without this constraint, some size
  classes would end up with overheads well over 2% just because that
  happens to be the last overhead value before reaching below the 1.5%
  constraint.

Furthermore, for higher-level fragmentation concerns, smaller run sizes
are better than larger run sizes, and in many cases, smaller run sizes
can yield the same (or even sometimes, better) overhead as larger run
sizes. For example, the current code choses 8KiB for runs of size 112,
but using 4KiB runs would actually yield the same number of regions, and
the same overhead.

We thus change the calculation to:
- not force runs to be smaller than those of smaller classes.
- avoid the code repetition.
- actually enforce its overhead constraint, but make it 1.6%.
- for especially small size classes, relax the overhead constraint to
  2.4%.

This leads to an uneven set of run sizes:
 size class    before   after
   4            4 KiB    4 KiB
   8            4 KiB    4 KiB
   16           4 KiB    4 KiB
   32           4 KiB    4 KiB
   48           4 KiB    4 KiB
   64           4 KiB    4 KiB
   80           4 KiB    4 KiB
   96           4 KiB    4 KiB
   112          8 KiB    4 KiB
   128          8 KiB    8 KiB
   144          8 KiB    4 KiB
   160          8 KiB    8 KiB
   176          8 KiB    4 KiB
   192         12 KiB    4 KiB
   208         12 KiB    8 KiB
   224         12 KiB    4 KiB
   240         12 KiB    4 KiB
   256         16 KiB   16 KiB
   272         16 KiB    4 KiB
   288         16 KiB    4 KiB
   304         16 KiB   12 KiB
   320         20 KiB   12 KiB
   336         20 KiB    4 KiB
   352         20 KiB    8 KiB
   368         20 KiB    4 KiB
   384         24 KiB    8 KiB
   400         24 KiB   20 KiB
   416         24 KiB   16 KiB
   432         24 KiB   12 KiB
   448         28 KiB    4 KiB
   464         28 KiB   16 KiB
   480         28 KiB    8 KiB
   496         28 KiB   20 KiB
   512         32 KiB   32 KiB
   1024        64 KiB   64 KiB
   2048       132 KiB  128 KiB

* Note: before is before this change only, not before the set of changes
  from this bug; before that, the run size for 96 could be 8 KiB in some
  configurations.

In most cases, the overhead hasn't changed, with a few exceptions:
- Improvements:
 size class   before   after
   208         1.823%   0.977%
   304         1.660%   1.042%
   320         1.562%   1.042%
   400         0.716%   0.391%
   464         1.283%   0.879%
   480         1.228%   0.391%
   496         1.395%   0.703%
- Regressions:
   352         0.312%   1.172%
   416         0.130%   0.977%
   2048        1.515%   1.562%

For the regressions, the values are either still well within the
constraint or very close to the previous value, that I don't feel like
it's worth trying to avoid them, with the risk of making things worse
for other size classes.

--HG--
extra : rebase_source : fdff18df8a0a35c24162313d4adb1a1c24fb6e82
2017-11-08 14:04:10 +09:00
Mike Hommey 16459608dd Bug 1414168 - Base run offset calculations on the fixed header size, excluding regs_mask. r=njn
On 64-bit platforms, sizeof(arena_run_t) includes a padding at the end
of the struct to align to 64-bit, since the last field, regs_mask, is
32-bit, and its offset can be a multiple of 64-bit depending on the
configuration. But we're doing size calculations for a dynamically-sized
regs_mask based on sizeof(arena_run_t), completely ignoring that
padding.

Instead, we use the offset of regs_mask as a base for the calculation.

Practically speaking, this doesn't change much with the current set of
values, but could affect the overheads when we squeeze run sizes more.

--HG--
extra : rebase_source : a3bdf10a507b81aa0b2b437031b884e18499dc8f
2017-11-08 10:08:37 +09:00
Mike Hommey f3daece337 Bug 1414168 - Avoid padding near the beginning of arena_run_t. r=njn
This makes the run header larger than necessary, which happens to make
the current arena_bin_run_calc_size pick 8KiB runs for size class 96
when MOZ_DIAGNOSTIC_ASSERT_ENABLED is set. This change makes it pick
4KiB runs, making MOZ_DIAGNOSTIC_ASSERT_ENABLED builds use the same set
of run sizes as non-MOZ_DIAGNOSTIC_ASSERT_ENABLED builds.

--HG--
extra : rebase_source : fd7ef2d58ec601186647799e9dcf8146e723241c
2017-11-08 09:56:08 +09:00
Mike Hommey 87faa92489 Bug 1414168 - Change and move the relaxed calculation rule for small size classes. r=njn
First and foremost, the code and corresponding comment weren't in
agreement on what's going on.

The code checks:
  RUN_MAX_OVRHD * (bin->mSizeClass << 3) <= RUN_MAX_OVRHD_RELAX
which is equivalent to:
  (bin->mSizeClass << 3) <= RUN_MAX_OVRHD_RELAX / RUN_MAX_OVRHD
replacing constants:
  (bin->mSizeClass << 3) <= 0x1800 / 0x3d

The left hand side is just bin->mSizeClass * 8, and the right hand side
is about 100, so this can be roughly summarized as:
  bin->mSizeClass <= 12

The comment says the overhead constraint is relaxed for runs with a
per-region overhead greater than RUN_MAX_OVRHD / (mSizeClass << (3+RUN_BFP)).
Which, on itself, doesn't make sense, because it translates to
61 / (mSizeClass * 32768), which, even for a size class of 1 would mean
less than 0.2%, and this value would be even smaller for bigger classes.
The comment would make more sense with RUN_MAX_OVRHD_RELAX, but would
still not match what the code was doing.

So we change how the relaxed rule works, as per the comment in the new
code, and make it happen after the standard run overhead constraint has
been checked.

--HG--
extra : rebase_source : cec35b5bfec416761fbfbcffdc2b39f0098af849
2017-11-07 14:36:07 +09:00
Mike Hommey 1117bc02f4 Bug 1414168 - Demystify the last test in the main arena_bin_run_size_calc loop. r=njn
The description above the RUN_* constant definitions talks about binary
fixed point math, which is one way to look at the problem, but a clearer
one is to look at it as comparing ratios in a way that doesn't use
divisions.

So, starting from the current expression:
  (try_reg0_offset << RUN_BFP) <= RUN_MAX_OVRHD * try_run_size

This can be rewritten as
  try_reg0_offset * (1 << RUN_BFP) <= RUN_MAX_OVRHD * try_run_size

Dividing both sides with ((1 << RUN_BFP) * try_run_size), and
simplifying, gives us:
  try_reg0_offset / try_run_size <= RUN_MAX_OVRHD / (1 << RUN_BFP)

Replacing the constants:
  try_reg0_offset / try_run_size <= 0x3d / (1 << 12)
or
  try_reg0_offset / try_run_size <= 61 / 4096

61 / 4096 is roughly 1.5%.

So what the check really intends to do is check that the overhead is
below 1.5%.

So we introduce a helper class and a user-defined literal that makes the
test more self-descriptive, while producing identical machine code.

This is a lot of code to add, but I think it's one of those cases where
abstraction can help make the code clearer.

--HG--
extra : rebase_source : 3d4a94f524a60e40ba75859c4f761f59d689e81a
2017-11-07 08:55:37 +09:00
Mike Hommey 1329eac959 Bug 1414168 - Split the condition for the main arena_bin_run_size_calc loop into pieces. r=njn
This is, practically speaking, a no-op, and will hopefully help make the
following changes clearer.

--HG--
extra : rebase_source : b704bdf2ae46c2408e0061363822b9744ef449cb
2017-11-07 07:42:21 +09:00
Mike Hommey 5a60492a53 Bug 1414155 - Define AddressRadixTree node size as a size rather than a power of 2. r=njn
--HG--
extra : rebase_source : 03799ccb0d5ba7c627cd3652777b56b7ae26b942
2017-11-03 13:50:44 +09:00
Mike Hommey 020ff16947 Bug 1414155 - Replace constants describing size class numbers. r=njn
--HG--
extra : rebase_source : 11b479c2928a236ecea94b1bc76497dee717a0b3
2017-11-03 12:21:53 +09:00
Mike Hommey a079c13bb9 Bug 1414155 - Rename chunk related constants. r=njn
--HG--
extra : rebase_source : f458cecab13bc2c9c78685eee670f76e2908d3dc
2017-11-03 12:16:11 +09:00
Mike Hommey 0cd74597a7 Bug 1414155 - Rename page size related constants. r=njn
--HG--
extra : rebase_source : db6b040ca046e350284f6a2aece2c1d1fa3c4ee4
2017-11-03 12:13:17 +09:00
Mike Hommey 89805eb175 Bug 1414155 - Replace chunk size related macros and constants. r=njn
--HG--
extra : rebase_source : 4e445e489148873f141de71d3a6ffd701e14f340
2017-11-03 12:07:16 +09:00
Mike Hommey 91ec9d43c0 Bug 1414155 - Replace size class related macros and constants. r=njn
Hopefully, this makes things a little clearer.

--HG--
extra : rebase_source : cc36c52bfb00bf1b46488e496eb524a9dc46a3e5
2017-11-03 10:10:50 +09:00
Mike Hommey 18e7756799 Bug 1414155 - Remove SIZE_INV values for QUANTUM_2POW_MIN < 4. r=njn
QUANTUM_2POW_MIN is exactly 4, and we are unlikely to ever make it
smaller. Also turn a MOZ_ASSERT into a static_assert, because it only
uses constants, and will fail if QUANTUM_2POW_MIN is lowered without
touching size_invs.

--HG--
extra : rebase_source : 7c8ee3c0ea30a88bddba816c41c6f63914f7a03c
2017-11-03 11:41:30 +09:00
Mike Hommey b4b9a5993f Bug 1414155 - Replace the cacheline-related macros with a constant. r=njn
--HG--
extra : rebase_source : 571145f154478b1703be44b73b8562de7973d788
2017-11-01 19:34:41 +09:00
Mike Hommey 26674ebcb7 Bug 1414155 - Consolidate "constant/globals". r=njn
There is a set of "constants" that are actually globals that depend on
the page size that we get at runtime, when compiling without
MALLOC_STATIC_PAGESIZE, but that are actual constants when compiling
with it. Their value was unfortunately duplicated.

We setup a set of macros allowing to make the declarations unique.

--HG--
extra : rebase_source : 56557b7ba01ee60fe85f2cd3c2a0aa910c4c93c6
2017-11-01 18:33:24 +09:00
Mike Hommey 6b7f782847 Bug 1414155 - Define pagesize_2pow in terms of pagesize, not the opposite. r=njn
At the same time, add user-defined literals to make those constants more
legible.

--HG--
extra : rebase_source : ce143ad9d8a6603179042d8cf432f00c815156c5
2017-11-01 18:07:06 +09:00
Mike Hommey 273538b95c Bug 1414155 - Move arena_chunk_map_t and arena_chunk_t around. r=njn
At the moment, while they are used before their declaration, it's from a
macro. It is desirable to replace the macros with C++ constants, which
will require the structures being defined first.

--HG--
extra : rebase_source : 7a351dafea04a7d75b6eec50fa52fb49c135e569
2017-11-01 17:54:31 +09:00
Mike Hommey 1c4a4f48fa Bug 1414155 - Factor out size classes logic for tiny, quantum and sub-page classes. r=njn
We create a new helper class that rounds up allocations sizes and
categorizes them. Compilers are smart enough to elide what they don't
need, like in malloc_good_size, they elide the code related to the
class type enum.

--HG--
extra : rebase_source : 61381e600587b045e720a85a7b46673edeb691b9
2017-11-03 08:53:34 +09:00
Mike Hommey 161c7d7841 Bug 1414155 - Move a few things around. r=njn
--HG--
extra : rebase_source : 11049459c8318e1a9f1cf535dfbce115bf57f918
2017-11-01 19:29:36 +09:00
Mike Hommey 66867e7f34 Bug 1414073 - Rename arena_bin_t fields. r=njn
At the same time, fold malloc_bin_stats_t into it.

--HG--
extra : rebase_source : 38c6a194d100783ecd0f769952de7bb4f71f17b0
2017-11-03 09:26:07 +09:00
Mike Hommey 8f8239d7bf Bug 1413570 - Disable SSE2 when building mozjemalloc on x86 during PGO profile gen phase. r=froydnj
Because of alignment issues due to the system glibc when running the
SSE2 gcov code generated during the PGO profile gen phase, Firefox
crashes when running the PGO profile. We work around the issue by
disabling SSE2 when building mozjemalloc during that phase. That
shouldn't affect the coverage data anyways, which is bound to the
original C++ code, and the profile-use code generation will still emit
SSE2 based on the coverage data if it needs to.

--HG--
extra : rebase_source : 3596fdc795cdef0789f3a2dd8f10b42cde00430f
2017-11-02 10:26:49 +09:00
Mike Hommey eab43e4a6c Bug 1413475 - Run clang-format on all files in memory/build/. r=njn
--HG--
extra : rebase_source : a0a7ebff22c2387389d2f1dc75f8a5084f76ebb7
2017-11-01 17:20:54 +09:00
Mike Hommey af14262e54 Bug 1413475 - Change comments to use C++ style // instead of /* */ in memory/build/. r=njn
--HG--
extra : rebase_source : 8d8b85e8123f414cb1e0e1eb067e0d198b3ebb8f
2017-11-01 17:15:12 +09:00
Mike Hommey 1de1ed32d0 Bug 1413475 - Normalize license boilerplates in memory/build/. r=njn
--HG--
extra : rebase_source : 9689f766211fbe1476c5e6d4774f1e95bb8e0208
2017-11-01 16:56:27 +09:00
Mike Hommey f081d2458b Bug 1413475 - Replace SIZEOF_INT_2POW with LOG2(sizeof(int)). r=njn
--HG--
extra : rebase_source : f1add73810649c8b12e2ee139528fad9186fc20b
2017-11-01 16:47:59 +09:00
Mike Hommey d07b1b083f Bug 1413475 - Inline STRERROR_BUF in mozjemalloc.cpp. r=njn
It is only used once.

--HG--
extra : rebase_source : 044e7d8ac3e6db834702ab8aedae9b44112d2932
2017-11-01 16:46:44 +09:00
Mike Hommey 7b9d775493 Bug 1413475 - Remove unused MAP_NOSYNC definition in mozjemalloc.cpp. r=njn
--HG--
extra : rebase_source : 95c760647b1c97accfb044961aae6ae1f2113f8e
2017-11-01 16:45:40 +09:00
Mike Hommey a71adf8fd9 Bug 1413475 - Move MALLOC_DECOMMIT definition closer to that of MALLOC_DOUBLE_PURGE. r=njn
--HG--
extra : rebase_source : 41e4dc84269dfa47c9b7daf4ab587dd41c7eb290
2017-11-01 16:45:24 +09:00
Mike Hommey 485f23d7b1 Bug 1413475 - Reorganize #includes in mozjemalloc.cpp. r=njn
--HG--
extra : rebase_source : 8b03bba78544e1980802c5c7e92ecead738e0408
2017-11-01 16:10:24 +09:00
Mike Hommey 66579f53a7 Bug 1413475 - Inline _CRT_SPINCOUNT in mozjemalloc.cpp. r=njn
It is only used once.

--HG--
extra : rebase_source : 589c078fac563f7e7f057e3a2904970126b6a4b9
2017-11-01 16:06:28 +09:00
Mike Hommey 36809628ea Bug 1413475 - Remove ssize_t definition from mozjemalloc.cpp. r=njn
The only use of ssize_t in mozjemalloc was removed in bug 1403444.

--HG--
extra : rebase_source : 98dde18a08a9a64b2b61698c43cbf3fc7eb74b5d
2017-11-01 15:51:06 +09:00
Mike Hommey 673c2f9373 Bug 1402284 - Separate arenas created from moz_arena_* functions from others. r=njn
We introduce the notion of private arenas, separate from other arenas
(main and thread-local). They are kept in a separate arena tree, and
arena lookups from moz_arena_* functions only access the tree of
private arenas. Iteration still goes through all arenas, private and
non-private.

--HG--
extra : rebase_source : 86c43c7c920b01eb6fa1fa214d612fd9220eac3e
2017-10-31 07:13:39 +09:00
Mike Hommey 4092f53e8a Bug 1402284 - Move arena tree related globals to a static singleton of a new class. r=njn
We create the ArenaCollection class to handle operations on the
arena tree. Ideally, iter() would trigger locking, but the
prefork/postfork code complicates things, so we leave this for later.

--HG--
extra : rebase_source : bd7021098baf0ec01c14063294098edea4473d36
2017-10-28 07:13:58 +09:00
Mike Hommey e23a5782c2 Bug 1402284 - Initialize arena_t objects via a constructor instead of manually with an Init method. r=njn
Note we use a local variable for fallible allocator because using plain
`new (fallible)` would require some figuring out for non-Firefox builds
(e.g.  standalone js).

--HG--
extra : rebase_source : 2132f98ebc7e37a139b673f80631e672bcf8ed15
2017-10-28 08:42:59 +09:00
Mike Hommey b4a43c8f3a Bug 1402284 - Make RedBlackTree::{Insert,Remove} work when the type has a constructor. r=njn
RedBlackTree::{Insert,Remove} allocate an object on the stack for its
RedBlackTreeNode, and that shouldn't have side effects if the type
happens to have a constructor. This will allow to add constructors to
some of the mozjemalloc types.

--HG--
extra : rebase_source : 14dbb7d73c86921701d83156186df5d645530dda
2017-10-30 09:55:18 +09:00