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

20 Коммитов

Автор SHA1 Сообщение Дата
Boris Zbarsky 8f7c90d6be Bug 1473149. Add an external string variant that keeps a DynamicAtom alive. r=njn,rwood
The change to call AsStatic() in SetKnownLiveAtom is drive-by performance cleanup.
2018-07-10 11:21:42 -07:00
Nicholas Nethercote 60b1f563cb Bug 1447951 - Store nsDynamicAtom's chars after the end of the object. r=froydnj
This reduces memory usage because we only need one allocation instead of two
for the dynamic atom and its chars, and because we don't need to store a
refcount and a size. It precludes sharing of chars between dynamic atoms, but
we weren't benefiting much from that anyway.

This reduces per-process memory usage by up to several hundred KiB on my
Linux64 box.

One consequence of this change is that we need to allocate + copy in
DOMString::SetKnownLiveAtom(), which could make some things slower.

--HG--
extra : rebase_source : ba4065ea31e509dd985c003614199f73def0596c
2018-06-22 09:38:42 +10:00
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
Nicholas Nethercote 8ac9830be0 Bug 1444031 - Rename Is{Static,Dynamic,HTML5}Atom. r=froydnj
By removing the "Atom" suffix, which is redundant.

MozReview-Commit-ID: 4MCX9Icfjrw

--HG--
extra : rebase_source : c3c759a508a8938b59d36dbb20448d2964b98c91
2018-03-07 15:17:34 +11:00
Boris Zbarsky 0b411e80c7 Bug 1407858 part 3. Add a literal string state to DOMString. r=smaug
MozReview-Commit-ID: JOuoLoZ2tcR
2017-12-22 13:02:51 -05:00
Boris Zbarsky ca6aad3847 Bug 1407858 part 2. Make DOMString's data model clearer and update various documentation. r=smaug
MozReview-Commit-ID: AaTeI1e7Qnk
2017-12-22 13:02:51 -05:00
Boris Zbarsky 06a6d6e207 Bug 1407858 part 1. Give DOMString setter APIs clearer names. r=smaug
The renaming here is like this:

  SetStringBuffer -> SetKnownLiveStringBuffer
  SetEphemeralStringBuffer -> SetStringBuffer
  SetOwnedString -> SetKnownLiveString
  SetOwnedAtom -> SetKnownLiveAtom

This should make it clearer what the lifetime expectations are on the caller side.

MozReview-Commit-ID: ERHbB3r6paN
2017-12-22 13:02:51 -05:00
Eric Rahm 07c97a5afe Bug 1423773 - Part 1: Remove usage of nsStringGlue.h. r=glandium
This removes an unnecessary level of indirection by replacing all
nsStringGlue.h instances with just nsString.h.

--HG--
extra : rebase_source : 340989240af4018f3ebfd92826ae11b0cb46d019
2017-12-06 16:52:51 -08:00
Nicholas Nethercote f2d1f3b005 Bug 1407117 - Simplify static atom representation. r=froydnj,bz.
Currently nsAtom::mString points to the interior of an nsStringBuffer. For
static atoms this requires the use of nsFakeStringBuffer, which is pretty
gross.

This patch changes things so that nsAtom::mString points to a static char
buffer for static atoms. This simplifies a number of things:

- nsFakeStringBuffer and CheckStaticAtomSizes are no longer needed.

- FakeBufferRefCountHelper is no longer needed.

- nsAtom's constructor for static atoms is simpler.

- RegisterStaticAtoms() is simpler.

On the flip-side, a couple of things get more complicated.

- nsAtom::ToString() treats static and dynamic atoms differently.

- nsAtom::GetStringBuffer() is now only valid for dynamic atoms. This
  function is only used in two places, both involving DOMString, so those
  locations are updated appropriately. This also requires updating some other
  code assigning nsStrings to DOMStrings, because we can't assume that
  nsStrings are shared.

On Linux64 this change reduces the size of the binary by 8752 B, and moves
81968 B from the .data to the .rodata section, where it can be shared between
processes.

--HG--
extra : rebase_source : 0f6fcdec1c525aa66222e208b66a9f9026f69bcb
2017-10-12 10:52:17 +11:00
Nicholas Nethercote d225f7151b Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro.
(Path is actually r=froydnj.)

Bug 1400459 devirtualized nsIAtom so that it is no longer a subclass of
nsISupports. This means that nsAtom is now a better name for it than nsIAtom.

MozReview-Commit-ID: 91U22X2NydP

--HG--
rename : xpcom/ds/nsIAtom.h => xpcom/ds/nsAtom.h
extra : rebase_source : ac3e904a21b8b48e74534fff964f1623ee937c67
2017-10-03 09:05:19 +11:00
Boris Zbarsky 3293a4cd98 Bug 1330759 part 3. Add a "stringbuffer we own" mode to DOMString. r=froydnj
We're going to need it because we're going to add a consumer that cannot in fact
promise that its stringbuffer reference will outlive the DOMString.
2017-01-18 22:20:14 -05:00
Boris Zbarsky 10ac0b56b4 Bug 1330759 part 1. Change various bits of DOMString code to work better when it has a stringbuffer which is effectively not null-terminated (in the sense that indexing into it at the DOMString's length doesn't yield '\0'). r=froydnj 2017-01-18 22:20:14 -05:00
Andrew McCreight 9e8f4b219e Bug 1152551, part 2 - Fix mode lines in dom/. r=jst 2015-05-03 15:32:37 -04:00
Boris Zbarsky 436b43b3ce Bug 1132655. Don't allow conversions from DOMString to const XPCOM string references, since it's meant to be an outparam only. r=smaug 2015-02-12 18:39:26 -05:00
Ehsan Akhgari c2a18b5a9a Bug 1123114 - Mark DOMString::mStringBuffer as unsafe; r=smaug 2015-01-18 18:43:02 -05:00
Seth Fowler 0fd6e994ae Bug 913586 (Part 4) - Update Maybe users in dom. r=bz
--HG--
extra : rebase_source : 7b6159b00b3bf4f919b30f1bccc8939cc04fe526
2014-08-13 15:39:41 -07:00
Olli Pettay 8950709e0c Bug 976302 - MutationRecord should use mozilla::dom::DOMString, r=bz
--HG--
extra : rebase_source : 20188f6025d24c4ee109aefaa2642fb586147223
2014-02-26 02:45:08 +02:00
Boris Zbarsky 5e0f2169f4 Bug 925495 part 1. Move DOMString out to a separate header. r=smaug 2013-10-11 12:28:23 -04:00
Ryan VanderMeulen dbc95f00f4 Backed out changesets 46029c9fbfe4 and 6114164c3d1b (bug 925495) for OSX (at least) crashes. 2013-10-11 13:38:28 -04:00
Boris Zbarsky a78b0cc424 Bug 925495 part 1. Move DOMString out to a separate header. r=smaug 2013-10-11 12:28:23 -04:00