gecko-dev/xpcom
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
..
base Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov 2018-07-05 15:42:11 +02:00
build Bug 1479641 - Don't record counting allocator amount, r=froydnj. 2018-07-31 19:22:54 +00:00
components Bug 1479945: Part 5 - Remove the 'allowbootstrap' directive flag. r=froydnj 2018-07-31 16:44:52 -07:00
doc
ds Bug 1416328 - Part 2. Expose decoding attribute for img elements. r=bz,tnikkel 2018-08-08 07:56:01 -04:00
glue Bug 1090497 - Re-enable warnings as errors on clang-cl. r=froydnj 2018-07-31 22:10:07 +09:00
idl-parser Bug 1474739 - Part 3: Linting fixes on a CLOSED TREE, a=bustage 2018-08-01 18:23:21 -04:00
io Bug 1090497 - Re-enable warnings as errors on clang-cl. r=froydnj 2018-07-31 22:10:07 +09:00
libxpt/xptcall Bug 1403959, part 2 - Automatically generated eslint fixes. r=froydnj 2017-09-28 15:49:04 -07:00
reflect Bug 1480624 - Part 1: Add XPT_FOR_EACH_*_TYPE macros to xptinfo.h, r=mccr8 2018-08-03 15:55:13 -04:00
rust Bug 1481998 - Make mozilla::Hash{Map,Set}'s entry storage allocation lazy. r=luke,sfink 2018-08-10 18:00:29 +10:00
string Bug 1481097 - xpcom: Remove nsTString literal string workaround for gcc 4.9 bug. r=nika 2018-07-22 00:02:34 -07:00
system Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov 2018-07-05 15:42:11 +02:00
tests Bug 1479484 - Part 1: Add make_dafsa.py to the virtualenv's python path, r=froydnj 2018-08-01 17:54:41 -04:00
threads Bug 1090497 - Re-enable warnings as errors on clang-cl. r=froydnj 2018-07-31 22:10:07 +09:00
typelib Bug 1471620 - Skip python-tests locally that don't run with python 3 in CI r=davehunt 2018-06-27 11:10:02 -04:00
windbgdlg Bug 1090497 - Re-enable warnings as errors on clang-cl. r=froydnj 2018-07-31 22:10:07 +09:00
xpidl Bug 1459721 - part 7 - remove dist_idl install manifest; r=chmanchester 2018-05-15 10:05:23 -04:00
moz.build Bug 1444745 - Part 1: Clear out xptinfo and typelib to make way for the this patch, r=mccr8 2018-04-17 19:20:50 -04:00
xpcom-config.h.in
xpcom-private.h.in Bug 1423846 - Remove configure script checks for iconv and mbrtowc/tcrtomb. r=glandium 2017-12-07 14:06:53 +02:00