gecko-dev/xpcom
Nicholas Nethercote bac452f9ad Bug 1411469 - Statically allocate static atoms. r=froydnj
Currently static atoms are stored on the heap, but their char buffers are
stored in read-only static memory.

This patch changes the representation of nsStaticAtom (thus making it a
non-trivial subclass of nsAtom). Instead of a pointer to the string, it now has
an mStringOffset field which is a 32-bit offset to the string. (This requires
placement of the string and the atom within the same object so that the offset
is known to be small. The docs and macros in nsStaticAtom.h handle that.)

Static and dynamic atoms now store their chars in different ways: nsStaticAtom
stores them inline, nsDynamicAtom has a pointer to separate storage. So
`mString` and GetStringBuffer() move from nsAtom to nsDynamicAtom.

The change to static atoms means they can be made constexpr and stored in
read-only memory instead of on the heap. On 64-bit this reduces the per-process
overhead by 16 bytes; on 32-bit the saving is 12 bytes. (Further reductions
will be possible in follow-up patches.)

The increased use of constexpr required multiple workarounds for MSVC.
- Multiple uses of MOZ_{PUSH,POP}_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING to
  disable warnings about (well-defined!) overflow of unsigned integer
  arithmetic.
- The use of -Zc:externConstexpr on all files defining static atoms, to make
  MSVC follow the C++ standard(!) and let constexpr variables have external
  linkage.
- The use of -constexpr:steps300000 to increase the number of operations
  allowed in a constexpr value, in order to handle gGkAtoms, which requires
  hashing ~2,500 atom strings.

The patch also changes how HTML5 atoms are handled. They are now treated as
dynamic atoms, i.e. we have "dynamic normal" atoms and "dynamic HTML5 atoms",
and "dynamic atoms" covers both cases, and both are represented via
nsDynamicAtom. The main difference between the two kinds is that dynamic HTML5
atoms still aren't allowed to be used in various operations, most notably
AddRef()/Release(). All this also required moving nsDynamicAtom into the header
file.

There is a slight performance cost to all these changes: now that nsStaticAtom
and nsDynamicAtom store their chars in different ways, a conditional branch is
required in the following functions: Equals(), GetUTF16String(),
WeakAtom::as_slice().

Finally, in about:memory the "explicit/atoms/static/atom-objects" value is no
longer needed, because that memory is static instead of heap-allocated.

MozReview-Commit-ID: 4AxPv05ngZy
2018-03-26 11:18:31 +02:00
..
base Bug 1411469 - Statically allocate static atoms. r=froydnj 2018-03-26 11:18:31 +02:00
build Bug 1447742: Understand movups in 32-bit DLL interceptor. r=handyman 2018-03-22 14:20:36 -04:00
components Bug 1446585: Remove support for resource entries in bootstrapped chrome.manifest files. r=aswan,MattN,k88hudson 2018-03-16 20:18:46 -07:00
doc
ds Bug 1411469 - Statically allocate static atoms. r=froydnj 2018-03-26 11:18:31 +02:00
glue Bug 1428557 - Implement wrappers in FileUtils. r=froydnj 2018-02-02 23:25:10 +09:00
idl-parser Bug 1293362 - Part 5: Allow implementing xpcom interfaces from rust code with a custom derive, r=froydnj 2018-01-23 17:27:28 -05:00
io Bug 1411469 - Statically allocate static atoms. r=froydnj 2018-03-26 11:18:31 +02:00
libxpt/xptcall Bug 1403959, part 2 - Automatically generated eslint fixes. r=froydnj 2017-09-28 15:49:04 -07:00
reflect Bug 1444143 part 13. Remove nsIFrameLoader. r=mystor 2018-03-21 22:43:17 -04:00
rust Bug 1448138 - Rename string DataFlags::SHARED to REFCOUNTED to make it clearer to those reading the code. r=erahm 2018-03-23 17:31:37 -07:00
string Bug 1448472 - Remove a C5037 warning suppression xpcom/string/moz.build that is no longer needed. r=xidorn 2018-03-24 12:19:44 -04:00
system Backed out changeset 3b82709eca8a (bug 1445990) for xpcshell failures at js/xpconnect/tests/unit/test_defineModuleGetter.js on a CLOSED TREE 2018-03-16 04:27:22 +02:00
tests Bug 1448138 - Rename string DataFlags::SHARED to REFCOUNTED to make it clearer to those reading the code. r=erahm 2018-03-23 17:31:37 -07:00
threads Bug 1447744 - don't implement nsINamed for mozilla::Runnable when it's unused; r=erahm 2018-03-23 14:53:55 -04:00
typelib Bug 1447849 - Eliminate the anonymous union from XPTTypeDescriptor. r=njn 2018-03-21 16:35:55 -07:00
windbgdlg
xpidl Bug 1390916 - Always use --track instead of --no-remove for install manifests; r=gps 2017-08-08 17:07:07 -04:00
moz.build Bug 1403213 - Move nsstring into servo/support/gecko/nsstring, r=froydnj 2017-10-23 15:37:25 -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