Commit Graph

195 Commits

Author SHA1 Message Date
Nicholas Nethercote
b85493f609 Bug 1477626 - Move js::Hash{Set,Map} into MFBT. r=Waldo
The main change is that the patch copies js/public/HashTable.h to
mfbt/HashTable.h, and then changes it as follows.

- Changes `js` namespaces to `mozilla` (and removes some now-unnecessary
  `mozilla::` qualifiers).

- Changes the default AllocPolicy from the SpiderMonkey-specific
  `TempAllocPolicy` to the generic `MallocAllocPolicy`.

- Adds `#include "AllocPolicy.h"` (like mfbt/Vector.h).

- Changes `JS_DEBUG` use to `DEBUG`.

- Minor comment updates, as necessary.

js/public/HashTable.h is now tiny, holding just a few renamings of things from
the `mozilla` namespace into the `js` namespace to minimize churn elsewhere.
(Those renamings keep `TempAllocPolicy` as the default AllocPolicy for
js::Hash{Set,Map}.)

Also, various template specializations had to be moved from the `js` namespace
to the `mozilla` namespace to avoid compile errors.

MozReview-Commit-ID: GS9Qn9YeYDA

--HG--
rename : js/public/HashTable.h => mfbt/HashTable.h
2018-07-26 20:15:49 +10:00
Nicholas Nethercote
faa9066821 Bug 1477626 - Remove use of JS_BIT in js/src/HashTable.h. r=Waldo
MozReview-Commit-ID: DRba0Z0Olo0

--HG--
extra : rebase_source : a9b48c986cd09c37039bd81e054f129afce48171
2018-07-26 20:12:55 +10:00
Nicholas Nethercote
0f205a7ce0 Bug 1477626 - Move ScrambleHashCode() from js/src/Utility.h to mfbt/HashFunctions.h. r=Waldo
And use it in PLDHashTable.cpp.

MozReview-Commit-ID: BqwEkE0p5AG

--HG--
extra : rebase_source : bd9118e24b82add6ad1fdcb067a5f25b25e90201
2018-07-26 18:52:47 +10:00
Nicholas Nethercote
25a1140207 Bug 1477626 - Introduce mozilla::HashNumber and use it in various places. r=Waldo
Currently we have three ways of representing hash values.

- uint32_t: used in HashFunctions.h.

- PLDHashNumber: defined in PLDHashTable.{h,cpp}.

- js::HashNumber: defined in js/public/Utility.h.

Functions that create hash values with functions from HashFunctions.h use a mix
of these three types. It's a bit of a mess.

This patch introduces mozilla::HashNumber, and redefines PLDHashNumber and
js::HashNumber as synonyms. It also changes HashFunctions.h to use
mozilla::HashNumber throughout instead of uint32_t.

This leaves plenty of places that still use uint32_t that should use
mozilla::HashNumber or one of its synonyms, but I didn't want to tackle that
now.

The patch also:

- Does similar things for the constants defining the number of bits in each
  hash number type.

- Moves js::HashNumber from Utility.h to HashTable.h, which is a better spot
  for it. (This required changing the signature of ScrambleHashCode(); that's
  ok, it'll get moved by the next patch anyway.)

MozReview-Commit-ID: EdoWlCm7OUC

--HG--
extra : rebase_source : 5b92c0c3560eb56850cd8832f8ee514d25e3c16f
2018-07-26 18:52:46 +10:00
Nicholas Nethercote
e683e03e60 Bug 1477626 - Use uint32_t instead of unsigned in HashTable.h. r=Waldo
Because it's more precise, and gives us more consistency.

MozReview-Commit-ID: BLYXYSHgZ7v

--HG--
extra : rebase_source : 527379499a7f2868e032982d7967005df6599bf1
2018-07-26 18:52:46 +10:00
Nicholas Nethercote
049d8130b0 Bug 1477626 - Replace some bespoke code with a call to CeilingLog2(). r=Waldo
After all, bug 543034 was fixed 9 years ago.

MozReview-Commit-ID: HDPO3gGuQMx

--HG--
extra : rebase_source : 6a1410c30e63f2ea5a4f918ba932b814d50c34dd
2018-07-26 18:52:46 +10:00
Brian Hackett
f6b8e6f81c Bug 1309552 - Specify buffer size when freeing data in AllocPolicy, r=waldo.
--HG--
extra : rebase_source : f4e2d9f8831cf41c19d592ce252e87161f32250b
2018-07-20 23:58:34 +00:00
Emilio Cobos Álvarez
1e9c395548 Bug 1466168: Remove mozilla::Forward in favor of std::forward. r=froydnj
Same approach as the other bug, mostly replacing automatically by removing
'using mozilla::Forward;' and then:

  s/mozilla::Forward/std::forward/
  s/Forward</std::forward</

The only file that required manual fixup was TestTreeTraversal.cpp, which had
a class called TestNodeForward with template parameters :)

MozReview-Commit-ID: A88qFG5AccP
2018-06-02 09:33:26 +02:00
Emilio Cobos Álvarez
fffb25b74f Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
This was done automatically replacing:

  s/mozilla::Move/std::move/
  s/ Move(/ std::move(/
  s/(Move(/(std::move(/

Removing the 'using mozilla::Move;' lines.

And then with a few manual fixups, see the bug for the split series..

MozReview-Commit-ID: Jxze3adipUh
2018-06-01 10:45:27 +02:00
Jeff Walden
0128813edd Bug 1462261 - Abandon the idea of HashTableEntry being "POD", make its constructor explicitly initialize HashTableEntry::keyHash, give it a destructor that destroys the stored T if the entry is live, and call both constructor and destructor in the necessary places. r=jandem
--HG--
extra : rebase_source : 99c72ac86fa32d683397c8060d58872617153976
2018-05-16 14:18:11 -07:00
Jeff Walden
5bd2e61e1d Bug 1462261 - Don't use AlignedStorage2 to implement HashTableEntry. r=jandem
--HG--
extra : rebase_source : 79e9c2287f8e443ff5da1c96f3707b8d066099fc
2018-05-16 13:29:52 -07:00
Jeff Walden
c079a4b0d4 Use more-normal formatting of HashTableEntry member functions, now that the prior consistent pattern is no longer consistent. No bug, r=me as trivial
--HG--
extra : rebase_source : 3b31ce414354ff457b1abe23d43da6655419824a
2018-05-08 14:48:11 -07:00
Andi-Bogdan Postelnicu
c4f2c57166 Bug 1416666 - Avoid doing a memset on a non-POD structure. r=jwalden
--HG--
extra : rebase_source : c1e3c4fb42693e552e037a35a489d4bbff6d5f98
2018-05-08 15:35:29 +03:00
André Bargull
afefc69f03 Bug 1447442 - Part 10: Remove ifdefs for unsupported compiler versions. r=jorendorff
--HG--
extra : rebase_source : dcafe84ca4b492ab3e91289d5d0a78a816feb343
2018-04-13 02:26:01 -07:00
Sebastian Hengst
ec371d68d4 Bug 525063 - Backing out js/public/ for violation of committing guidelines. a=backout 2018-04-12 22:15:26 +03:00
Tristan Bourvon
a3a77c0312 Bug 525063 - Initialize uninitialized class attributes in m-c. r=ehsan 2018-04-10 21:11:02 +02:00
Jason Orendorff
e7c94fff59 Bug 1439063 - Part 1: Move several public headers from js/src to js/public. r=jandem.
js/src/jsalloc.h -> js/public/AllocPolicy.h
jsalloc.cpp -> js/src/util/AllocPolicy.cpp
jsbytecode.h -> merge into js/public/TypeDecls.h
jsprf.h -> js/public/Printf.h
jsprf.cpp -> js/src/util/Printf.cpp
jsprototypes.h -> public/ProtoKey.h
jswrapper.h -> js/Wrapper.h

--HG--
rename : js/src/jsalloc.h => js/public/AllocPolicy.h
rename : js/src/jsprf.h => js/public/Printf.h
rename : js/src/jsprototypes.h => js/public/ProtoKey.h
rename : js/src/jswrapper.h => js/public/Wrapper.h
rename : js/src/jsalloc.cpp => js/src/util/AllocPolicy.cpp
rename : js/src/jsprf.cpp => js/src/util/Printf.cpp
extra : rebase_source : 98b16d94c469202eab0303a8da844f1d0b6aa809
extra : amend_source : e0b16c1077226d6fe240f4d7096537f93b43f2b8
extra : histedit_source : d94e0ba7904a7d66742c7fac43f638aaec4fa4e5
2018-02-21 10:30:19 -06:00
Jon Coppeard
ff4f5d0483 Backed out changesets 115d70e6c818 and 1938afc34193 for memory and performance regressions (bug 1422575) 2017-12-12 16:29:19 -06:00
Jon Coppeard
0228e51379 Bug 1422575 - Give hash tables a minimum capacity based on the parameter passed to init() r=sfink 2017-12-07 18:28:42 +00:00
Philippe Normand
6e9c2ed9f4 Bug 1402824 - Ensure mutationCount in HashTable.h is only used inside an JS_DEBUG ifdef. r=luke
This member variable is declared only in debug builds. This fixes the build
when this header is imported into non-unified builds.

This header is included in the build when xpcom/threads is built.

MozReview-Commit-ID: AF3YUqvVqET

--HG--
extra : rebase_source : f0065f0d326af069dc6c8a255fefbc0d2e2e9fe9
2017-09-25 10:32:01 +01:00
Sebastian Hengst
3aab3b9ea3 Backed out changeset 2d59a91b2f2d (bug 1402824) for build bustage (mozilla/LabeledEventQueue.h not found). r=backout on a CLOSED TREE 2017-09-26 10:39:27 +02:00
Philippe Normand
26c7f9ba16 Bug 1402824 - Ensure mutationCount in HashTable.h is only used inside an JS_DEBUG ifdef. r=luke
This member variable is declared only in debug builds. This fixes the build
when this header is imported into non-unified builds.

This header is included in the build when xpcom/threads is built.

MozReview-Commit-ID: AF3YUqvVqET

--HG--
extra : rebase_source : 7366e3b1044174ac635246ec8f2e5ee982e6eb5e
2017-09-25 10:32:01 +01:00
Ting-Yu Chou
fe98b4e219 Bug 1385181 - Avoid excess copying when return from HashTable::lookupForAdd(). r=luke
MozReview-Commit-ID: F95DCc1wvkE

--HG--
extra : rebase_source : 42edaf41d53e9c7646206cc6ea9c9ce976846eb1
2017-08-01 17:00:39 +08:00
Wes Kocher
cb83ca733e Backed out changeset e94dceac8090 (bug 1385181) for causing bug 1386011 (CCov build bustage) a=bustage
MozReview-Commit-ID: BK2XP0pcoE8
2017-07-31 22:12:03 -07:00
Ting-Yu Chou
54070eee06 Bug 1385181 - Alter HashTable::lookupForAdd() to remove a redundant copy when return. r=luke
MozReview-Commit-ID: 9XnlC0JXETX
2017-07-28 14:05:40 +08:00
Ehsan Akhgari
33114ba370 Bug 1382324 - Improve SpiderMonkey's pointer hashing function for pointers to neighboring memory locations; r=jandem
This is very similar to the fix to bug 1379282 for the XPCOM hashtables.
2017-07-20 12:23:07 -04:00
Jon Coppeard
52665ac9e7 Bug 1372875 - Add more assertions for hash table pointer generation and mutation count r=luke 2017-06-16 10:05:55 +01:00
Jon Coppeard
422260f4ea Bug 1341367 - Make the sense of HashTable::Ptr::isValid match its name r=luke 2017-06-06 11:25:57 +01:00
Jon Coppeard
bcbfa5c7e9 Bug 1370069 - Fix several issues with incremental atom sweeping r=sfink 2017-06-06 09:46:15 +01:00
Jon Coppeard
e85f5ed76c Bug 1365654 - Add a move constructor to HashTable::Enum r=luke 2017-05-18 16:22:00 +01:00
Jan de Mooij
1ad92e7cc7 Bug 1350760 part 6 - Add a Zone cache for recently atomized strings. r=jonco 2017-03-31 10:54:16 +02:00
Jan de Mooij
35bd8c0bf9 Bug 1350760 part 5 - Make sure various hashtable lookups get inlined when atomizing strings. r=luke 2017-03-31 10:53:39 +02:00
Jeff Walden
176f2f5a05 Bug 1246061 - Add some comments. r=luke
--HG--
extra : rebase_source : 6577e0ab9834fa00f3f0fe2893a6b039bb70f5f3
2016-03-23 13:21:02 -07:00
Jon Coppeard
17af524d85 Bug 1260785 - Make hashcode generation fallible for cell pointers that can be moved by GC r=terrence 2016-07-13 10:20:00 +01:00
Jan de Mooij
d54ca15369 Bug 1269319 followup - Don't swap an entry with itself to avoid Variant self assignment. r=bustage
--HG--
extra : rebase_source : 0bf8331f4aba57502bbff07df478c1aeb91c2fc6
2016-05-21 18:08:30 +02:00
Jan de Mooij
eb2ea5c544 Bug 1269319 - Make AlignedStorage/AlignedStorage2 non-copyable to fix strict aliasing issues. r=Waldo 2016-05-19 20:57:36 +02:00
Nicholas Nethercote
2511b2c327 Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj.
It's an annotation that is used a lot, and should be used even more, so a
shorter name is better.

MozReview-Commit-ID: 1VS4Dney4WX

--HG--
extra : rebase_source : b26919c1b0fcb32e5339adeef5be5becae6032cf
2016-04-27 14:16:50 +10:00
Shu-yu Guo
a58fd08178 Bug 1265956 - Assert that no entry is found in HashTable::putNew. (r=terrence) 2016-04-20 14:52:12 -07:00
Jeff Walden
1dd8dbc3f7 Bug 1246061. r=jandem, r=bz, r=luke, r=froydnj
--HG--
extra : rebase_source : 5b314d4c4c6e0b553290884be7338f8e79c22f71
2016-03-09 00:37:20 -08:00
Luke Wagner
b4d7059241 Bug 1234985 - Hoist CStringHasher (r=sfink)
--HG--
extra : commitid : KxwfOhuDfeq
extra : rebase_source : 1a38c30bea5b324ca913a7688c2febd834873d49
2016-01-20 12:00:21 -06:00
Luke Wagner
6ebd19920f Bug 1239601 - improve the UniquePtr situation (r=jorendorff)
--HG--
extra : commitid : FwqWNSZ3SKY
extra : rebase_source : 75ed67bfadcbdaeb5bf89a57ad6ca9ef75b7f1f0
2016-01-15 18:26:06 -06:00
Terrence Cole
3c0b63c8e8 Bug 1239515 - Simplify HashSet's key-overwriting interface; r=sunfish 2016-01-14 09:43:30 -08:00
Jim Blandy
9aba54fc4f Bug 1236801: Don't check for simulated OOM in a way that invalidates AddPtrs for no discernable reason. (Revised to fix uninitialized var, r=sfink) r=jonco
--HG--
extra : rebase_source : 23222e831fb516bc3cc2672b4c6807564d56bce1
2016-01-12 16:49:45 -08:00
Wes Kocher
0439338087 Backed out changeset 7111837e42b9 (bug 1236801) for SM wError bustage
--HG--
extra : commitid : EZ9x68Sn1qG
2016-01-12 16:55:12 -08:00
Jim Blandy
637fbf70ae Bug 1236801: Don't check for simulated OOM in a way that invalidates AddPtrs for no discernable reason. r=jonco
--HG--
extra : rebase_source : 12fd6cb6969733355581d7cd28876a7b46097c45
extra : amend_source : 04430312d8175c746139a85b0f8062b408c82192
2016-01-08 10:01:53 -08:00
Jon Coppeard
498b421261 Bug 1232672 - Use MOZ_WARN_UNUSED_RESULT to make hash table clients check for failure r=luke r=billm r=njn 2015-12-22 13:29:43 +00:00
Jon Coppeard
204777d13d Bug 1207519 - Prevent HashTable shrink from ignoring allocation failures that may have been reported r=Waldo 2015-09-30 11:34:49 +01:00
Jon Coppeard
3616fbd00c Bug 1200642 - Add OOM simulation to hastables r=terrence 2015-09-30 11:34:49 +01:00
Terrence Cole
a6855649ac Bug 1196847 - Part 2: Implement a cell hasher that uses unique id based hashes; r=jonco
--HG--
extra : rebase_source : 4d33add708a491e27492f9cdb63d98e76a7af94e
2015-08-26 14:51:35 -07:00
Terrence Cole
01fd1cc898 Bug 1196847 - Part 1: Allow storage of a unique id for a cell independent of address; r=jonco
* * *
imported patch rewrite_uid_on_ht_with_zone_sweeping

--HG--
extra : rebase_source : fc3a37b4ea6bbf32f8f55f56a1c4846be92c0164
2015-08-20 10:35:22 -07:00