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

2382 Коммитов

Автор SHA1 Сообщение Дата
Ehsan Akhgari 43091e2839 Bug 1379282 - Improve XPCOM's pointer hashing functions for pointers to neighboring memory locations; r=erahm
The simplistic shift-based hashing function creates a lot of collisions
for pointers pointing to arrays as it doesn't do a great job at distributing
the data randomly based on the input bytes.
2017-07-19 14:16:35 -04:00
Ehsan Akhgari 3df4db262f Backout changeset 06f92d065a85 (bug 1377333) because we don't need keys that are that big 2017-07-18 23:06:00 -04:00
Andrew McCreight d6f0453414 Bug 1350729 - Implement fake refcount logging for nsFakeStringBuffer. r=dbaron
Running with XPCOM_MEM_LOG_CLASSES=nsStringBuffer triggers an
assertion in refcount logging for nsFakeStringBuffers. These are given
an initial refcount of 1, without calling NS_LOG_ADDREF. Then,
AddRef() is called on these objects in StaticAtom::StaticAtom(), and
we tell the refcount logging system about the fake buffer, and that it
has a refcount of 0, triggering the assertion.

The first part of the fix is to call NS_LOG_ADDREF for this initial
refcount, in StaticAtom().

This first fix causes refcount logging to start reporting that the
fake string buffers leak, when XPCOM_MEM_LOG_CLASSES is not set. This
is because refcount logging is now getting told about these objects
being AddRefed at 1, which it takes to mean that an object is created.

To work around this issue, I add an array gFakeBuffers that contains
every fake string buffer we create, and tell the refcount logging
system that these objects are all being destroyed, when the atom table
is being shut down. This could result in some bogosity if the fake
buffers are "leaked" but hopefully this is still an improvement over
the current state.

MozReview-Commit-ID: 5AxoBYAlYRU

--HG--
extra : rebase_source : ba0763cb494894918141774025db525cea9f9c75
2017-07-14 10:20:23 -07:00
Wes Kocher 4ff7648fb6 Backed out changeset 9033647b9a51 (bug 1350729) for build failures in nsAtomTable.cpp a=backout CLOSED TREE
MozReview-Commit-ID: 9wb9Z6tlEar
2017-07-17 11:47:50 -07:00
Andrew McCreight e762779c3b Bug 1350729 - Implement fake refcount logging for nsFakeStringBuffer. r=dbaron
Running with XPCOM_MEM_LOG_CLASSES=nsStringBuffer triggers an
assertion in refcount logging for nsFakeStringBuffers. These are given
an initial refcount of 1, without calling NS_LOG_ADDREF. Then,
AddRef() is called on these objects in StaticAtom::StaticAtom(), and
we tell the refcount logging system about the fake buffer, and that it
has a refcount of 0, triggering the assertion.

The first part of the fix is to call NS_LOG_ADDREF for this initial
refcount, in StaticAtom().

This first fix causes refcount logging to start reporting that the
fake string buffers leak, when XPCOM_MEM_LOG_CLASSES is not set. This
is because refcount logging is now getting told about these objects
being AddRefed at 1, which it takes to mean that an object is created.

To work around this issue, I add an array gFakeBuffers that contains
every fake string buffer we create, and tell the refcount logging
system that these objects are all being destroyed, when the atom table
is being shut down. This could result in some bogosity if the fake
buffers are "leaked" but hopefully this is still an improvement over
the current state.

MozReview-Commit-ID: 5AxoBYAlYRU

--HG--
extra : rebase_source : 967520e825d26c369a11acc478d223d190137a43
2017-07-14 10:20:23 -07:00
Sylvestre Ledru 4e9cf83ee8 Bug 1378712 - Remove all trailing whitespaces r=Ehsan
MozReview-Commit-ID: Kdz2xtTF9EG

--HG--
extra : rebase_source : 7235b3802f25bab29a8c6ba40a181a722f3df0ce
2017-07-06 14:00:35 +02:00
Mats Palmgren 9a66affd7f Bug 1376498 part 5 - Remove nsClassHashtable::RemoveAndForget(). r=froydnj
MozReview-Commit-ID: 2VVgViNhruj
2017-07-05 02:01:45 +02:00
Mats Palmgren fae81013c9 Bug 1376498 part 3 - Make nsClassHashtable inherit Remove() for API consistency with ns[Base|Interface|RefPtr]Hashtable. r=froydnj
MozReview-Commit-ID: LQMaamZhkM4
2017-07-05 02:01:44 +02:00
Mats Palmgren 9542d00e58 Bug 1376498 part 2 - Use plain Remove(key) in some places instead of Lookup(key).Remove() for simplicity. r=froydnj
MozReview-Commit-ID: 7GlCL1jyGAz
2017-07-05 02:01:44 +02:00
Mats Palmgren f88bb52a9e Bug 1376498 part 1 - Unify the ns[Base|Interface|RefPtr]Hashtable::Remove() signatures for consistency. Make it return true if an entry was removed, with an optional out param to move the value. r=froydnj
MozReview-Commit-ID: JVciibiSPL5
2017-07-05 02:01:44 +02:00
Ehsan Akhgari ec3d589e4f Bug 1377333 - Make PLDHashNumber 64-bit on x86-64; r=froydnj 2017-07-04 11:05:21 -04:00
Sebastian Hengst 51f7ac9c81 Backed out changeset 3009a0b538da (bug 1377333) on suspicion of causing frequent failures in test_general.html. r=backout 2017-07-04 00:37:24 +02:00
Ehsan Akhgari de718c51ec Bug 1377333 - Make PLDHashNumber 64-bit on x86-64; r=froydnj 2017-07-03 13:21:11 -04:00
Mats Palmgren 30c6d6295a Bug 1376477 - Use Lookup instead of Get+Remove to avoid unnecessary hashtable lookups. Replace Get with Contains to avoid ref-counting. r=froydnj
MozReview-Commit-ID: G4F2pAnNA73
2017-06-28 01:03:17 +02:00
Mats Palmgren 59d3163a68 Bug 1376473 - Use Lookup instead of Get+Remove to avoid unnecessary hashtable lookups. r=froydnj
MozReview-Commit-ID: lWNPPBDNh7
2017-06-28 01:03:17 +02:00
Ehsan Akhgari 04f49b5fc2 Bug 1376563 - Improve the hash key generation for hashtables containing pointers on 64-bit platforms by using 2 more bits of the original pointer in calculating the hash key; r=froydnj 2017-06-27 18:18:32 -04:00
Bill McCloskey f115503a0b Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-26 14:19:58 -07:00
Nicholas Nethercote 58786e1ea7 Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.

- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
  classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
  mostly misused.

- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
  universally available now anyway.

- Combines the first two string literal arguments of PROFILER_LABEL and
  PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
  them to be separate, and it forced a '::' in the label, which isn't always
  appropriate. Also, the meaning of the "name_space" argument was interpreted
  in an interesting variety of ways.

- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
  it clearer they construct RAII objects rather than just being function calls.
  (I myself have screwed up the scoping because of this in the past.)

- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
  the caller doesn't need to. This makes a *lot* more of the uses fit onto a
  single line.

The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).

- Fixes a bunch of labels that had gotten out of sync with the name of the
  class and/or function that encloses them.

- Removes a useless PROFILER_LABEL use within a trivial scope in
  EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
  any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
  a good idea.

- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
  done within them, instead of at their callsites, because that's a more
  standard way of doing things.

--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 17:08:53 +10:00
Nicholas Nethercote f1364a75ea Bug 1374580 (part 3) - Remove ns{,C}Substring typedefs. r=froydnj.
All the instances are converted as follows.

- nsSubstring  --> nsAString
- nsCSubstring --> nsACString

--HG--
extra : rebase_source : cfd2238c52e3cb4d13e3bd5ddb80ba6584ab6d91
2017-06-20 19:19:52 +10:00
Nicholas Nethercote fe9268c4cd Bug 1374580 (part 2) - Remove nsAFlat{,C}String typedefs. r=froydnj.
All the instances are converted as follows.

- nsAFlatString  --> nsString
- nsAFlatCString --> nsCString

--HG--
extra : rebase_source : b37350642c58a85a08363df2e7c610873faa6e41
2017-06-20 19:19:05 +10:00
Carsten "Tomcat" Book 8a1350b5a6 Backed out changeset 4f6302a98ae4 (bug 1372405)
--HG--
extra : rebase_source : 41632f3158e88e692809731394a683d065a73dfb
2017-06-21 13:59:26 +02:00
Bill McCloskey 6b3e84ed5f Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-20 21:44:11 -07:00
Carsten "Tomcat" Book ea1b86680c Backed out changeset 9846de3bd954 (bug 1372405)
--HG--
extra : rebase_source : 5d4a48e8ec394c329994689d938d2a6e9b2752b0
2017-06-20 08:27:02 +02:00
Bill McCloskey 4592152411 Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-19 22:25:47 -07:00
Ehsan Akhgari c342914631 Bug 1373996 - Make nsTObserverArray::RemoveElementsBy() take a template argument; r=froydnj
This avoids a dynamic allocation in EventListenerManager::HandleEventInternal().
2017-06-19 14:27:39 -04:00
Ehsan Akhgari 5ad8772be5 Bug 1374033 - Remove double bounds checking from the next accessors of the iterator classes of nsTObserverArray; r=froydnj 2017-06-19 14:13:32 -04:00
Mats Palmgren e4f9fc369e Bug 1372317 part 3 - Remove nsBaseHashtable::LookupRemoveIf() since it's not used anymore. r=froydnj
Also, change the gtest to test Lookup() and Lookup().Remove()
in various forms.

MozReview-Commit-ID: 6AguNDhcR5W
2017-06-18 17:07:54 +02:00
Mats Palmgren a57cd6c138 Bug 1372317 part 1 - Introduce a nsBaseHashtable::Lookup() method that allows modifying the value and optionally remove the entry. r=froydnj
MozReview-Commit-ID: AcNBQvTMnX8
2017-06-18 17:07:54 +02:00
Mats Palmgren 95f7896de5 Bug 1371928 - Add a new EnsureInserted() method that return true if a new entry was created, and EnsureRemoved() that return true if an existing entry was removed. r=froydnj
As opposed to PutEntry/RemoveEntry which do not indicate what happened.

MozReview-Commit-ID: LeNKDqpSksR
2017-06-17 00:06:04 +02:00
Florian Quèze 65e6947718 Bug 1373053 - nsObserverService::NotifyObservers should add a pseudo stack frame showing the topic of the notification, r=mstange. 2017-06-15 00:58:25 +02:00
Mats Palmgren a4d601d6c4 Bug 1371094 part 1 - Move the nsClassHashtable::LookupForAdd() method to nsBaseHashtable. r=froydnj
Also change nsClassHashtable::LookupOrAdd to not regard existing entries with
a nullptr value as non-existent.  This is to make it consistent with
nsBaseHashtable::LookupForAdd() and other methods.

MozReview-Commit-ID: 1wYqK8XQbyW
2017-06-14 01:03:38 +02:00
Eric Rahm ab9516d40d Bug 1353593 - Part 2: Remove wwc functions. r=froydnj
This removes the use of |wwc| functions in favor of char16ptr_t's implicit
conversion operators.

MozReview-Commit-ID: GHONYieMPla
2017-06-12 16:20:49 -07:00
Michael Layzell e8c6bd15df Bug 1368524 - Add a telemetry probe for how long we spend processing NotifyObservers callbacks, dr=bsmedberg, r=ehsan
MozReview-Commit-ID: KWypjvFscVu
2017-06-08 13:58:31 -04:00
Mats Palmgren c4730f96bb Bug 1371061 - Optimize nsBaseHashtable::GetOrInsert() to only do a single hashtable lookup. r=froydnj
MozReview-Commit-ID: 6muOorLplG1
2017-06-08 12:48:32 +02:00
Mats Palmgren 6467c38383 Bug 1370632 - Move LookupRemoveIf() to nsBaseHashtable instead so that it can be used on more hashtables types. r=froydnj
MozReview-Commit-ID: 9kQSytPWok5
2017-06-07 15:22:41 +02:00
Mats Palmgren 0630f5b2bf Bug 1367207 part 3 - Introduce nsClassHashtable::LookupRemoveIf() for consumers that wants to do a Get() then inspect/modify the value then, maybe, Remove() the entry. This is to avoid a second hashtable lookup for the Remove(). r=froydnj
Also, make RemoveAndForget() use RemoveEntry(), not Remove(), to remove
the entry to avoid a second hashtable lookup.

MozReview-Commit-ID: Bj5Heo8YLFJ
2017-06-07 15:22:41 +02:00
Nathan Froyd cee39716e5 Bug 1370606 - fix fallible nsRefPtrHashtable::Put to really be fallible; r=erahm
Calling the infallible PutEntry effectively makes this function
infallible, despite Put taking a fallible_t argument.
2017-06-06 21:06:17 -04:00
Nathan Froyd cb5ef308b6 Bug 1370593 - avoid redundant lookups in nsRefPtrHashtable::Remove; r=mats
We already have a handle to the entry in the hashtable, we can remove
that directly, rather than implicitly looking up the entry to remove in
Remove().
2017-06-06 21:06:17 -04:00
Daniel Holbert 4564af3454 Bug 1368326: Don't bother calling Clear() in destructor for empty nsTArrays. r=froydnj
MozReview-Commit-ID: 7mi2Os52JfJ

--HG--
extra : rebase_source : 4c7296fd84509f71b680a55f513574285e754481
2017-06-01 14:38:13 -07:00
L. David Baron 07c2f2dc49 Bug 1352889 - Ensure that PLDHashTable's second hash doesn't have padding with 0 bits for tables with capacity larger than 2^16. r=njn
PLDHashTable takes the result of the hash function and multiplies it by
kGoldenRatio to ensure that it has a good distribution of bits across
the 32-bit hash value, and then zeroes out the low bit so that it can be
used for the collision flag.  This result is called hash0.  From hash0
it computes two different numbers used to find entries in the table
storage:  hash1 is used to find an initial position in the table to
begin searching for an entry; hash2 is then used to repeatedly offset
that position (mod the size of the table) to build a chain of positions
to search.

In a table with capacity 2^c entries, hash1 is simply the upper c bits
of hash0.  This patch does not change this.

Prior to this patch, hash2 was the c bits below hash1, padded at the low
end with zeroes when c > 16.  (Note that bug 927705, changeset
1a02bec165e16f370cace3da21bb2b377a0a7242, increased the maximum capacity
from 2^23 to 2^26 since 2^23 was sometimes insufficient!)  This manner
of computing hash2 is problematic because it increases the risk of long
chains for very large tables, since there is less variation in the hash2
result due to the zero padding.

So this patch changes the hash2 computation by using the low bits of
hash0 instead of shifting it around, thus avoiding 0 bits in parts of
the hash2 value that are significant.

Note that this changes what hash2 is in all cases except when the table
capacity is exactly 2^16, so it does change our hashing characteristics.
For tables with capacity less than 2^16, it should be using a different
second hash, but with the same amount of random-ish data.  For tables
with capacity greater than 2^16, it should be using more random-ish
data.

Note that this patch depends on the patch for bug 1353458 in order to
avoid causing test failures.

MozReview-Commit-ID: JvnxAMBY711

--HG--
extra : transplant_source : 2%D2%C2%CE%E1%92%C8%F8H%D7%15%A4%86%5B%3Ac%0B%08%3DA
2017-05-31 13:44:02 -07:00
L. David Baron f22aab91c2 Bug 1352888 - Don't set the collision flag when adding to PLDHashTable if we've already found the entry we're going to add. r=njn
PLDHashTable's entry store has two types of unoccupied entries:  free
entries and removed entries.  The search of a chain of entries
(determined by the hash value) in the entry store to search for an entry
can stop at free entries, but it continues across removed entries,
because removed entries are entries that may have been skipped over when
we were adding the value we're searching for to the hash, but have since
been removed.  For live entries, we also maintain this distinction by
using one bit of storage for a collision flag, which notes that if the
hashtable entry is removed, its place in the entry store must become a
removed entry rather than a free entry.

When we add a new entry to the table, Add's semantics require that we
return an existing entry if there is one, and only create a new entry if
no existing entry exists.  (Bug 1352198 suggests the possibility of a
faster alternative Add API where the caller guarantees that the key is
not already in the hashtable.)  When we search for the existing entry,
we must thus continue the search across removed entries, even though we
record the first removed entry found to return if the search for an
existing entry fails.

The existing code adds the collision flag through the entire table
search during an Add.  This patch changes that behavior so that we only
add the collision flag prior to finding the first removed entry.  Adding
it after we find the first removed entry is unnecessary, since we are
not making that entry part of a path to a new entry.  If it is part of a
path to an existing entry, it will already have the collision flag set.

This patch effectively puts an if (!firstRemoved) around the else branch
of the if (MOZ_UNLIKELY(EntryIsRemoved(entry))), and then refactors that
condition outwards since it is now around the contents of both the if
and else branches.

MozReview-Commit-ID: CsXnMYttHVy

--HG--
extra : transplant_source : %80%9E%83%EC%CCY%B4%B0%86%86%18%99%B6U%21o%5D%29%AD%04
2017-05-31 13:44:02 -07:00
Andreas Farre 1cf93d7962 Bug 1311425 - Avoid expiration timers when scheduling idle runnables, r=froydnj
--HG--
extra : rebase_source : b20edf82a69a24965b4bb6300ff9b1be39ad7b8a
2017-05-24 21:17:06 -04:00
Samael Wang ecbe18e933 Bug 1363036 - Part 1: Remove MOZ_DIAGNOSTIC_ASSERTs previously added for bug hunting. r=smaug
MozReview-Commit-ID: BAkuRlHtMcP

--HG--
extra : rebase_source : 5e708d0dacec9a673851d689d1f5274a0f1b69aa
2017-05-22 11:25:54 +08:00
L. David Baron f2c24eea94 Backed out changeset e4ac2148c920 (bug 1352888) to see if it is responsible for input latency regression bug 1362094.
--HG--
extra : rebase_source : bfb451e911058496c2a6498d658cb6ab777da8e6
2017-05-24 11:42:19 -04:00
L. David Baron 34315c4eee Backed out changeset 52fff3b1e209 (bug 1352889) to see if it is responsible for input latency regressions in bug 1365334 or bug 1366156.
--HG--
extra : rebase_source : 387401d1417a29c19e5dbc1ee7413d9d6f810d23
2017-05-24 11:41:02 -04:00
Samael Wang da20faa46e Bug 1363036 - Add MOZ_DIAGNOSTIC_ASSERTs for bug hunting. r=smaug
MozReview-Commit-ID: JPnkkJlkwDY
2017-05-16 10:54:01 +08:00
Ehsan Akhgari 5de2ecd325 Bug 1361745 - Part 1: Improve the nsClassHashtable::LookupForAdd() API; r=froydnj
The OrInsert() method adds the new entry to the hashtable if needed, and
returns the newly added entry or the pre-existing one.  It allows for a
more concise syntax at the call site.
2017-05-08 10:02:04 -04:00
L. David Baron 5191ef7b3b Bug 1352889 - Ensure that PLDHashTable's second hash doesn't have padding with 0 bits for tables with capacity larger than 2^16. r=njn
PLDHashTable takes the result of the hash function and multiplies it by
kGoldenRatio to ensure that it has a good distribution of bits across
the 32-bit hash value, and then zeroes out the low bit so that it can be
used for the collision flag.  This result is called hash0.  From hash0
it computes two different numbers used to find entries in the table
storage:  hash1 is used to find an initial position in the table to
begin searching for an entry; hash2 is then used to repeatedly offset
that position (mod the size of the table) to build a chain of positions
to search.

In a table with capacity 2^c entries, hash1 is simply the upper c bits
of hash0.  This patch does not change this.

Prior to this patch, hash2 was the c bits below hash1, padded at the low
end with zeroes when c > 16.  (Note that bug 927705, changeset
1a02bec165e16f370cace3da21bb2b377a0a7242, increased the maximum capacity
from 2^23 to 2^26 since 2^23 was sometimes insufficient!)  This manner
of computing hash2 is problematic because it increases the risk of long
chains for very large tables, since there is less variation in the hash2
result due to the zero padding.

So this patch changes the hash2 computation by using the low bits of
hash0 instead of shifting it around, thus avoiding 0 bits in parts of
the hash2 value that are significant.

Note that this changes what hash2 is in all cases except when the table
capacity is exactly 2^16, so it does change our hashing characteristics.
For tables with capacity less than 2^16, it should be using a different
second hash, but with the same amount of random-ish data.  For tables
with capacity greater than 2^16, it should be using more random-ish
data.

Note that this patch depends on the patch for bug 1353458 in order to
avoid causing test failures.

MozReview-Commit-ID: JvnxAMBY711

--HG--
extra : rebase_source : dbde93b9312dd10fb3a549ee4098b57e1df5cadf
2017-05-04 15:17:50 -07:00
Ehsan Akhgari 49ea4e277a Bug 1359848 - Part 1: Add the nsClassHashtable::LookupForAdd() API to allow consumers to lookup and add an entry to a class hashtable if it doesn't exist already with a single lookup; r=froydnj 2017-05-03 08:59:48 -04:00
Tom Tromey bd012d9546 Bug 1334318 - remove last uses of PR_smprintf; r=froydnj
This removes the last uses of PR_smprintf from the tree (excluding the
security and nsprpub directories).  It also fixes a related latent bug
in nsAppRunner.cpp (which was incorrectly freeing the pointer passed to
PR_SetEnv).

MozReview-Commit-ID: GynP2PhuWWO

--HG--
extra : rebase_source : c3b83c7bd08b1c222e137a00323caf5481352845
2017-04-28 10:13:26 -06:00