Commit Graph

2612 Commits

Author SHA1 Message Date
Nicholas Nethercote
9ea93c4f7b Bug 1449395 - Remove nsStaticAtomSetup. r=froydnj
Each nsStaticAtomSetup contains a pointer to a static atom, and also a pointer
to the canonical pointer to that static atom. Which is pretty weird! The
notable thing thing about it is that these structs are in an array, and that
gives us the only way to iterate over all static atoms in a single class, for
registration and lookups.

But thanks to various other recent changes to the implementation of static
atoms, we can now put the static atoms themselves into an array, which can be
iterated over. So this patch does that. With that done, nsStaticAtomSetup is no
longer necessary.

According to the `size` utility, on Linux64 this reduces the size of libxul.so
by the following amounts:

> text:  62008 bytes
> data:  20992 bytes
> bss:   21040 bytes
> total: 104040 bytes

- The bss reduction is one word per atom, because the canonical static atom
  pointers (e.g. nsGkAtoms::foo) have moved from .bss to .data, because they're
  now initialized at compile time instead of runtime.

- The data reduction is one word per atom, because we remove two words per atom
  for the nsStaticAtomSetup removal, but gain one word per atom from the
  previous bullet point.

- I'm not sure about the text reduction. It's three words per atom. Maybe
  because there is one less relocation per atom?

Other notable things in the patch:

- nsICSSAnonBoxPseudo and nsICSSPseudoElement now inherit from nsStaticAtom,
  not nsAtom, because that's more precise.

- Each static atoms array now has an enum associated with it, which is used in
  various ways.

- In the big comment about the macros at the top of nsStaticAtom.h, the pre-
  and post-expansion forms are now shown interleaved. The interleaving reduces
  duplication and makes the comment much easier to read and maintain. The
  comment also has an introduction that explains the constraints and goals of
  the implementation.

- The SUBCLASS macro variations are gone. There are few enough users of these
  macros now that always passing the atom type has become simpler.

MozReview-Commit-ID: 1GmfKidLjaU

--HG--
extra : rebase_source : 2352590101fc6693ba388f885ca4714a42963943
2018-03-29 11:48:18 +11:00
Nicholas Nethercote
4b941e22d0 Bug 1449395 - Remove unnecessary nsStaticAtom.h includes. r=froydnj
For nsCSSAnonBoxes.cpp, nsCSSPseudoElements.cpp, nsDirectoryService.cpp, the
corresponding .h file includes nsStaticAtom.h. For the other files in this
patch, nsStaticAtom.h is not needed at all.

MozReview-Commit-ID: IpMmbXwZHhu

--HG--
extra : rebase_source : 46d0a6b40a41ee233adad7c205cf907fa27de34a
2018-03-29 09:08:54 +11:00
Nicholas Nethercote
89d3ee0001 Bug 1449491 - Remove the "Strt" and "CmStrt" directories. r=froydnj
On Windows there are some duplicate keys in nsDirectoryService:

- NS_WIN_STARTUP_DIR is "Strt", and maps to Win_Startup.
- NS_WIN_STARTMENU_DIR is also "Strt", and is meant to map to Win_Startmenu,
  but actually maps to Win_Startup because of the key duplication.

- NS_WIN_COMMON_STARTMENU_DIR is "CmStrt", and maps to Win_Common_Startmenu.
- NS_WIN_COMMON_STARTUP_DIR is also "CmStrt", and is meant to map to
  Win_Common_Startup, but actually maps to Win_Common_Startmenu because of
  the key duplication.

Given the bugginess, it's unsurprising that they aren't used.

This patch removes them. This gets rid of two duplicate static atoms, helping
with bug 1445113.

MozReview-Commit-ID: 9Yx6M0VUaH4

--HG--
extra : rebase_source : 887cb2f2b907a6f3a7b796b6032b385291862323
2018-03-28 19:06:43 +11:00
Nicholas Nethercote
c453ae7ce6 Bug 1449491 - Remove the unused HOME_DIR macro. r=froydnj
MozReview-Commit-ID: LSdJgmIWy4l

--HG--
extra : rebase_source : 85420290d283b62af5d8e7a0bb0500f68873ac4f
2018-03-28 19:06:16 +11: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
Henri Sivonen
21af10d5f4 Bug 1445692 - Remove UTF8InputStream. r=froydnj
MozReview-Commit-ID: 1az5nkKTkru

--HG--
extra : rebase_source : 6a21b4dad71ea351a51c741977b36dfb562c608b
2018-03-14 20:53:18 +02:00
Nicholas Nethercote
d81eb773d4 Bug 1445892 - Remove nsDirectoryService::sOS_HomeDirectory atom. r=froydnj
nsGkAtoms::Home and nsDirectoryAtoms::sOS_HomeDirectory are duplicate static
atoms. This patch comments out the latter to remove the duplication.

MozReview-Commit-ID: LGkjZn0zaoz
2018-03-22 19:07:40 +11:00
Andreea Pavel
7d4b5748e1 Backed out 2 changesets (bug 1435899) for failing android at modules/libpref/test/unit/test_defaultValues.js pn a CLOSED TREE
Backed out changeset 925adb267211 (bug 1435899)
Backed out changeset f22f1ab67c5a (bug 1435899)
2018-03-09 23:14:32 +02:00
Andrea Marchesini
3c1d84b33c Bug 1435899 - Close underlying stream in NonBlockingAsyncInputStream sooner. r=froydnj
--HG--
extra : rebase_source : 64473e8f71f826e7d6a3fd2324cbef98b60b133d
2018-02-27 02:03:00 -05:00
Kris Maglione
afc3918d22 Bug 1443651: Don't return failure for access denied from createUnique() if file exists. r=Mossop
There are ways for Create() to return access denied for files which already
exist, particularly in the case of locked files. When it does, createUnique()
should check whether the file exists before considering the attempt a failure.

MozReview-Commit-ID: FyJTghk04jH

--HG--
extra : rebase_source : 10e6f2cb7da18e8e6d410b52a593b7455f0d76fa
2018-03-06 14:32:40 -08:00
Jeff Walden
8622941e2a Bug 375259 - The directory service shouldn't return an uninitialized (safely) nsILocalFile for the "Drivs" key. r=bsmedberg 11 years ago
--HG--
extra : rebase_source : efbcadc2e034bad91f1525d0c12ca9f81dedaf33
2018-03-05 13:02:25 -08:00
Masatoshi Kimura
5588ef80d1 Bug 1440630 - Reduce nsIFile::ResolveAndStat() calls. r=froydnj
--HG--
extra : source : 3dc9a957980918d125d7d3872c4f86bea31da437
extra : amend_source : 1dc4c1b50fe94370abab6d2ece930803fc02bcb5
2018-02-23 21:45:41 +09:00
Masatoshi Kimura
dc4e17ea95 Bug 1428258 - Disallow nsIFile::GetNativePath on Windows. r=froydnj
MozReview-Commit-ID: JDryRqHcVw2

--HG--
extra : rebase_source : 228d0436c372d76d066affe9657a57bd4cda4dca
extra : source : 1dff63e6a2bb6b3190ded0c8fa748545f5d9f116
2018-01-11 22:38:33 +09:00
Nathan Froyd
65cbfc8247 Bug 1439355 - use static_assert instead of NS_ASSERTION in nsBinaryStream.cpp; r=mystor
The intention is a little more clear with static_assert, as well as
failing sooner.  (The code is probably the same, since the compiler will
optimize out the checks as dead code, but meh.)
2018-02-20 16:34:42 -05:00
Nathan Froyd
af81af55cb Bug 1439593 - micro-optimize read/write of nsIID to binary streams; r=mystor
Reading nsIIDs to binary streams requires 1 + 1 + 1 + 8 calls to Read
for the underlying stream.  With the assumption that reading to the
underlying stream for a binary stream is relatively expensive, we should
be able to do better by reading the byte array in an nsIID in a single
Read() request.  The same logic applies to writing nsIIDs.  Performing a
single operation here should not change the actual bytes read or
written.  Performing a single operation also has the virtue of
performing fewer error checks and whatnot.
2018-02-20 16:34:42 -05:00
Nathan Froyd
29ed461192 Bug 1437932 - fix unused variable error in non-diagnostic assertion builds; r=baku 2018-02-14 12:01:57 -05:00
Masatoshi Kimura
4872102e9d Bug 1428557 - Stop using GetNativePath in xpcom/. r=froydnj
MozReview-Commit-ID: GnSFQ1wprzb

--HG--
extra : rebase_source : 7c25e0361d7f4e8aea730672a931cf78a581e062
extra : intermediate-source : e055aee7306b6636d27abe6fc0b02012b0075260
extra : source : d0831f473c8f85996c106693c9a4ce3783dd9447
2017-12-15 06:53:37 +09:00
Andrea Marchesini
1f4b9d7e56 Bug 1437011 - NonBlockingAsyncInputStream::Close() should return NS_OK if already closed, r=froydnj 2018-02-09 21:15:15 +01:00
Andrea Marchesini
6bfb120a59 Bug 1371699 - Correct canceling of the AsyncWait() callback in NonBlockingAsyncInputStream, r=froydnj 2018-01-31 16:45:21 +01:00
Andrea Marchesini
1126b00aed Bug 1405974 - NonBlockingAsyncInputStream must take the ownership of the underlying stream, r=qdot 2018-01-31 16:45:20 +01:00
Andrea Marchesini
5fb7a2ddb1 Bug 1371699 - NonBlockingAsyncInputStream::ReadSegments passes the correct stream to the writer callback, r=froydnj 2018-01-31 16:45:20 +01:00
Andrea Marchesini
67fac604a1 Bug 1371699 - Use of NonBlockingAsyncInputStream in our code base, r=froydnj 2018-01-31 16:45:20 +01:00
Andrea Marchesini
890628437c Bug 1371699 - Implement NonBlockingAsyncInputStream - nsIAsyncInputStream wrapper for non-blocking non-async streams, r=froydnj 2018-01-31 16:45:20 +01:00
Eric Rahm
465336e99f Bug 1333899 - Part 1: Add a fallible NS_UnescapeURL. r=froydnj
This adds a fallible version of |NS_UnescapeURL| that can be used to
gracefully handle allocation failures when the string needs to be unescaped.

--HG--
extra : rebase_source : 8d10ca98fb372afe8219d744b147703254e02830
2018-02-02 10:42:42 -08:00
Alex Gaynor
7d9591ccdc Bug 1434911 - when creating temporary files, don't set the executable bit; r=froydnj
MozReview-Commit-ID: HxD5z7hm3ra

--HG--
extra : rebase_source : 3bf62b3943e64dca33f79299dd79dbd63dcfdba3
2018-02-01 09:52:01 -05:00
Gian-Carlo Pascutto
6520179659 Bug 1386404 - Enable content-process specific tmpdir on Linux. r=jld
MozReview-Commit-ID: 6Hijq0to9MG

--HG--
extra : rebase_source : 8435b8e39d9723c52b0176a7686895185136aa6e
extra : histedit_source : 50c41172788fddead6357f1d566d0e48de8c90d6
2018-01-09 16:29:40 +01:00
Masatoshi Kimura
a321c5d13e Bug 1433265 - Remove ShortcutResolver from nsLocalFileWin.cpp. r=froydnj
MozReview-Commit-ID: GeFCZI3OkuQ

--HG--
extra : rebase_source : 4a9868f82ae1143e7a31853641f5b5625ac21327
2018-01-31 20:56:17 +09:00
Masatoshi Kimura
410788f63d Bug 1428543 - Add nsIFile::HumanReadablePath. r=froydnj
This method is used to replace some GetNativePath usage for logging.

MozReview-Commit-ID: 9nWf2r4oviA

--HG--
extra : rebase_source : b58e45ab38621179cd802979131fdddbfe65079e
extra : intermediate-source : b4ded2247082f98fe18eb640c5fafeb9bc107ac0
extra : source : 21a82c1faeffc7c0d7b3a5ef0ae4c5243c81a586
2017-12-30 23:32:27 +09:00
Masatoshi Kimura
51d70c873f Bug 1428543 - Implement FileDescriptorFile::GetPersistentDescriptor. r=froydnj
This method is used by some subsequent patches when unique opaque identifiers are necessary.

MozReview-Commit-ID: AreqK4MHdJP

--HG--
extra : rebase_source : d5b85c2c9212618f54a6ac2f5199651b01c99510
extra : intermediate-source : 67c3c7a1012b9fdd628928bec61472c6ce580616
extra : source : c9a67330c600dbe454fd2ce5025247171e0c0e22
2017-12-17 13:37:03 +09:00
Masatoshi Kimura
17fb30182d Bug 1428543 - Add mozilla::filesystem::Path and use it in nsIFile. r=froydnj
Currently only |value_type| is implemented.

MozReview-Commit-ID: 1mejzvkuako

--HG--
extra : rebase_source : 69e08073adbb9a866db26e515702a0659ece0a70
extra : intermediate-source : 3696381ddfdc19ab2f901ca4247e1cb4efb27731
extra : source : 35d760da1d73dd51614f434c26e5ce80ff690829
2017-12-28 03:03:35 +09: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
Masatoshi Kimura
8b05ff3704 Bug 1427023 - Remove nsCRT::strncmp. r=erahm 2018-01-09 23:49:37 +09:00
Swapnil
f42233b3e8 Bug 1396601 - Removed all instances of MOZ_ENABLE_CONTENTACTION from .cpp files and moz.build file. r=paolo
MozReview-Commit-ID: 467SgoTlsFJ

--HG--
extra : rebase_source : dadd8c2a2cad6f96605390d7aac2512714bf58c1
2018-01-08 23:48:56 +05:30
Andrea Marchesini
79f7b767db Bug 1426888 - Get rid of nsIMultiplexInputStream::RemoveStream, r=smaug 2017-12-30 12:47:12 +01:00
Valentin Gosu
d1cae23d3b Bug 1426996 - Use fallible assign in NS_EscapeAndFilterURL r=kershaw
MozReview-Commit-ID: EKVeQb3cboU

--HG--
extra : rebase_source : f06b3c6f4e8e68a2a56ac39ef4261a669d99adaa
2017-12-26 21:47:22 +01:00
Andrea Marchesini
f6f7ecd4e3 Bug 1426684 - Get rid of nsIMultiplexInputStream::InsertStream, r=smaug 2017-12-21 17:21:14 +01:00
Philippe Normand
110d9af7af Bug 1425877 - Non-unified build fixes for xpcom/io/nsLocalFileCommon.cpp r=cpearce
nsArray was used within the compilation unit without prior include.
2017-12-18 09:08:00 +02:00
Andrea Marchesini
fbb63ae853 Bug 1424183 - nsMultiplexInputStream must call OnInputStreamReady only when there is data available, r=smaug 2017-12-13 05:11:12 -06:00
Andrea Marchesini
de5ec36de8 Bug 1424183 - nsMultiplexInputStream must move to the following stream if the current one doesn't have data to read, r=smaug 2017-12-13 05:11:12 -06:00
Andrea Marchesini
11fc30c324 Bug 1424183 - nsMultiplexInputStream must call OnInputStreamReady when closed, r=smaug 2017-12-13 05:11:11 -06:00
Andrea Marchesini
ef2a2db56a Bug 1424183 - nsMultiplexInputStream must not call AsyncOpen on more than the current stream, r=smaug 2017-12-13 05:11:11 -06:00
Andrea Marchesini
badd489870 Bug 1424808 - Get rid of isFileStream in nsHttpChannel.cpp, r=valentin 2017-12-12 06:01:18 -06: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
Cosmin Sabou
c191e25cf5 Merge mozilla-inbound to mozilla-central r=merge a=merge 2017-12-08 11:56:44 +02: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
Henri Sivonen
089449f86b Bug 960957 - Drop nsIFile support for non-UTF-8 file path encodings on non-Windows platforms. r=emk,m_kato
OS.File already only supports UTF-8 paths on non-Windows systems, so this
change makes our different ways of accessing file paths consistent with each
other.

MozReview-Commit-ID: 8HiC5xC8tJN

--HG--
extra : rebase_source : 24c77a2e9b4003694e8e96cffab301e7adc0b4e6
2017-12-05 13:33:52 +02:00
Andrea Marchesini
88be477d67 Bug 1421176 - nsMultiplexInputStream::Available() sanitize - r=smaug
1. nsMultiplexInputStream::Available() should not return CLOSED if one of the
   streams returns this error value. Instead it must check the following
   streams.
2. If a substream is async, available() should not check following streams
   until that is closed.
2017-11-30 20:00:23 +01:00
Cosmin Sabou
4fdf797aca Backed out 3 changesets (bug 1421176) for build bustages on xpcom/tests/gtest/TestMultiplexInputStream.cpp:266:3 r=backout on a CLOSED TREE
Backed out changeset e5dd080198e6 (bug 1421176)
Backed out changeset 83964057e1b2 (bug 1421176)
Backed out changeset 3ef41e230c5e (bug 1421176)
2017-11-30 21:31:55 +02:00
Andrea Marchesini
a0251157e0 Bug 1421176 - nsMultiplexInputStream::Available() sanitize - r=smaug
1. nsMultiplexInputStream::Available() should not return CLOSED if one of the
   streams returns this error value. Instead it must check the following
   streams.
2. If a substream is async, available() should not check following streams
   until that is closed.
2017-11-30 20:00:23 +01:00
Noemi Erli
d96f41a437 Merge inbound to mozilla-central r=merge a=merge 2017-11-18 00:01:46 +02:00