Commit Graph

486 Commits

Author SHA1 Message Date
Nicholas Nethercote
439d31614d Bug 1481998 - Make mozilla::Hash{Map,Set}'s entry storage allocation lazy. r=luke,sfink
Entry storage allocation now occurs on the first lookupForAdd()/put()/putNew().
This removes the need for init() and initialized(), and matches how
PLDHashTable/nsTHashtable work. It also removes the need for init() functions
in a lot of types that are built on top of mozilla::Hash{Map,Set}.

Pros:

- No need for init() calls and subsequent checks.

- No memory allocated for empty tables, which are not that uncommon.

Cons:

- An extra branch in lookup() and lookupForAdd(), but not in put()/putNew(),
  because the existing checkOverloaded() can handle it.

Specifics:

- Construction now can take a length parameter.

- init() is removed. Explicit length-setting, when necessary, now occurs in the
  constructors.

- initialized() is removed.

- capacity() now returns zero when the entry storage is absent.

- lookupForAdd() is no longer `const`, because it can instantiate the storage,
  which requires modifications.

- lookupForAdd() can now return an invalid AddPtr in two cases:

  - old: hashing failure (due to OOM in the hasher)

  - new: OOM while instantiating entry storage

  The existing failure handling paths for the old case work for the new case.

- clear(), finish(), and clearAndShrink() are replaced by clear(), compact(),
  and reserve(). The old compactIfUnderloaded() is also removed.

- Capacity computation code is now in its own functions, bestCapacity() and
  hashShift(). setTableSizeLog2() is removed.

- uint32_t is used throughout for capacities, instead of size_t, for
  consistency with other similar values.

- changeTableSize() now takes a capacity instead of a deltaLog2, and it can now
  handle !mTable.

Measurements:

- Total source code size is reduced by over 900 lines. Also, lots of existing
  lines got shorter (i.e. two checks were reduced to one).

- Executable size barely changed, down by 2 KiB on Linux64. The extra branches
  are compensated for by the lack of init() calls.

- Speed changed negligibly. The instruction count for Bench_Cpp_MozHash
  increased from 2.84 billion to 2.89 billion but any execution time change was
  well below noise.
2018-08-10 18:00:29 +10:00
Jan de Mooij
cafd7c75e4 Bug 1481229 part 2 - Always use the unwrapped object in Logging::formatObject. r=evilpie 2018-08-07 14:06:45 +02:00
Jan de Mooij
57f5c11f9a Bug 1481229 part 1 - Remove unnecessary realm entering in JavaScriptShared::findObjectById. r=evilpie
ToWindowProxyIfWindow does not rely on the current realm in any way.
2018-08-07 14:06:45 +02:00
Jan de Mooij
9d3bc542f6 Bug 1479363 part 10 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in other directories. r=mrbkap 2018-08-02 19:30:17 +02:00
Brian Hackett
9155e432f9 Bug 1479645 - Don't unwrap CPOWs in middleman processes, r=mccr8. 2018-07-31 19:30:02 +00:00
Tom Schuster
050d853e33 Bug 1468774 - Remove getPropertyDescriptor from CPOWs. r=mrbkap r=mccr8 2018-04-03 18:21:40 +02:00
Jan de Mooij
fddc23c346 Bug 1478955 part 1 - Rename JSAutoRealm to JSAutoRealmAllowCCW. r=luke 2018-07-28 12:12:26 +02:00
Alex Gaynor
717ac53588 Bug 1470890 - handle deserialization failure gracefully in JS IPC; r=evilpie
Summary: This primarily affects the efficiency of fuzzing.

Reviewers: evilpie

Reviewed By: evilpie

Bug #: 1470890

Differential Revision: https://phabricator.services.mozilla.com/D1797
2018-06-27 16:10:41 +03:00
Tom Schuster
1167d8b8a5 Bug 1465911 - Disable CPOWs also when receiving message from the child. r=mrbkap 2018-06-21 16:00:04 +02:00
Tom Schuster
f5de305bda Bug 1465911 - Disable CPOWs outside of test mode. r=mrbkap 2018-06-08 00:00:54 +02:00
Alex Gaynor
ea7d08f175 Bug 1470181 - handle deserialization failure gracefully in JS IPC; r=evilpie
This primarily effects the efficiency of fuzzing.

Differential Revision: https://phabricator.services.mozilla.com/D1751
2018-06-21 18:47:08 +00:00
Alex Gaynor
687ce91a32 Bug 1465860 - Don't crash in JS IPC on invalid object id. r=evilpie
Instead, return an error up to the caller, who can return an IPC error, which
will kill the child. This is significantly friendlier to fuzzing.

MozReview-Commit-ID: C67xSqUeN1i
2018-05-31 16:29:03 -04:00
Emilio Cobos Álvarez
4b8b5e1717 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
Steve Fink
551f65ca28 Bug 1464266 - Rename GCForReason to NonIncrementalGC, r=jonco 2018-05-24 16:19:18 -07:00
Jan de Mooij
e5f8a28c84 Bug 1461292 part 1 - Rename JSAutoCompartment to JSAutoRealm. r=bz,luke 2018-05-16 10:53:16 +02:00
Adrian Wielgosik
93eb294385 Bug 1460940 - Clean up most remaining C++-side uses of nsIDOMDocument. r=bz
MozReview-Commit-ID: LKRnyDPNlle
2018-05-11 19:46:15 +02:00
Kris Maglione
2f66e87f0b Bug 1445551: Part 3 - Remove AllowCPOWsInAddon machinery. r=mccr8
This is all dead code now that the add-on manager support for shimmed add-ons
has been removed.

MozReview-Commit-ID: J6aRQDqEahs
2018-03-13 19:20:17 -07:00
Andrea Marchesini
cdb15164d7 Bug 1443079 - nsScriptError.isFromPrivateWindow must match the correct value also in e10s mode, r=smaug 2018-03-13 06:40:38 +01:00
Jason Orendorff
d640df5146 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
2018-02-21 10:30:19 -06:00
Chris Peterson
677bf4030c Bug 1428535 - Add missing override specifiers to overridden virtual functions. r=froydnj
MozReview-Commit-ID: DCPTnyBooIe
2017-11-05 19:37:28 -08:00
Sylvestre Ledru
37064ac043 Bug 1394734 - Replace CONFIG['GNU_C*'] by CONFIG['CC_TYPE'] r=glandium
MozReview-Commit-ID: 7duJk2gSd4m
2017-12-07 22:09:15 +01:00
Jan de Mooij
37b8f5c8c3 Bug 1413867 - Remove StopIteration object. r=evilpie 2017-11-05 19:01:04 +01:00
Steve Fink
cb2dda1273 Bug 1406570 - Rooting improvements, r=jonco,bz 2017-10-09 10:59:02 -07:00
Jan de Mooij
325f2ebe3b Bug 1403136 - Clean up JSSetterOp code now that slotful setters are gone. r=evilpie 2017-09-26 22:26:40 +02:00
Jon Coppeard
92628b5345 Bug 1396613 - Update the object moved hook to allow it to be called when tenuring nursery objects r=sfink r=mccr8 2017-09-19 12:31:30 +01:00
Jason Orendorff
f5235a8008 Bug 1363200 - JSAPI for realms: Split xpc::RealmPrivate from xpc::CompartmentPrivate. r=mrbkap 2017-06-08 11:07:10 -05:00
Jan de Mooij
9e74eb50a5 Bug 1393790 part 2 - Remove JS_PropertyStub and JS_StrictPropertyStub. r=jorendorff 2017-08-28 10:40:19 +02:00
Nicholas Nethercote
09493fcbcf Bug 1384835 (part 3, attempt 2) - Remove the Preferences::Get*CString() variants that return nsAdoptingCString. r=froydnj. 2017-07-31 14:28:48 +10:00
Ehsan Akhgari
7ee3166230 Bug 1382339 - Improve SpiderMonkey hashing functions by using MFBT's HashGeneric more; r=jandem 2017-07-20 12:59:09 -04:00
Jan de Mooij
e959a1182a Bug 1379461 - Refactor code to return RegExpShared* directly instead of using bool + outparam. r=evilpie,sfink 2017-07-11 11:31:12 +02:00
Carsten "Tomcat" Book
0603cbc370 Backed out changeset 3a0a2ffe803b (bug 1379461) for hazard failure 2017-07-11 12:59:09 +02:00
Jan de Mooij
a2a13185d4 Bug 1379461 - Refactor code to return RegExpShared* directly instead of using bool + outparam. r=evilpie 2017-07-11 11:31:12 +02:00
Jan de Mooij
4afba77787 Bug 1375505 part 1 - Change iterator code to return JSObject* instead of returning bool + outparam. r=evilpie 2017-06-28 21:00:43 -07:00
Nicholas Nethercote
a58025002f 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.
2017-06-22 17:08:53 +10:00
Jan de Mooij
6ad0a86b42 Bug 1237504 - Refactor proxy slot layout to allow proxies to have more than 2 slots. r=bz,jonco
The patch makes the following proxy changes:

* The number of slots in ProxyValueArray is now dynamic and depends on the number of reserved slots we get from the Class.
* "Extra slots" was renamed to "Reserved slots" to make this clearer.
* All proxy Classes now have 2 reserved slots, but it should be easy to change that for proxy Classes that need more than 2 slots.
* Proxies now store a pointer to these slots and this means GetReservedSlot and SetReservedSlot can be used on proxies as well. We no longer need GetReservedOrProxyPrivateSlot and SetReservedOrProxyPrivateSlot.

And some changes to make DOM Proxies work with this:

* We now store the C++ object in the first reserved slot (DOM_OBJECT_SLOT) instead of in the proxy's private slot. This is pretty nice because it matches what we do for non-proxy DOM objects.
* We now store the expando in the proxy's private slot so I removed GetDOMProxyExpandoSlot and changed the IC code to get the expando from the private slot instead.
2017-04-28 14:12:28 +02:00
Bill McCloskey
f32234a94e Bug 1359245 - Eliminate nsXPConnect::GetContextInstance() (r=mccr8)
This method assumes there is one global XPCJSContext. This patch eliminates
uses of it.

MozReview-Commit-ID: L2AkBGh5TnC
2017-04-27 15:34:46 -07:00
Jon Coppeard
d60b70fa01 Bug 1352430 - Add barrier to CPOWs table to remove dying objects r=billm 2017-04-26 11:18:53 +01:00
Jon Coppeard
1690b0506c Bug 1345177 - Remove use of RegExpGuard r=sfink 2017-03-27 10:38:29 +01:00
Jon Coppeard
f2dc766532 Backed out changesets e66f564d9749 and 0380d914ad39 (bug 1345177) for rooting hazards 2017-03-27 11:09:54 +01:00
Jon Coppeard
08352c6c76 Bug 1345177 - Remove use of RegExpGuard r=sfink 2017-03-27 10:38:29 +01:00
Jon Coppeard
b0a63f7241 Bug 1341044 - Rename the GC's 'zone group' concept to 'sweep group' r=sfink 2017-03-22 17:30:50 +00:00
Tom Tromey
e90d95a3f9 Bug 1060419 - make AppendPrintf and nsPrintfCString use Printf.h, r=froydnj
MozReview-Commit-ID: 2E8FoiNxU8L
2016-12-14 09:32:21 -07:00
Tom Schuster
932e8ca649 Bug 1339036 - Rename JSTYPE_VOID to JSTYPE_UNDEFINED. r=arai 2017-02-13 17:26:16 +01:00
Boris Zbarsky
b0f35c60e3 Bug 1335368 part 8. Stop using IsCallerChrome in UnwrapArgImpl. r=bholley 2017-02-01 15:43:37 -05:00
Tooru Fujisawa
4b595b32f4 Bug 1332245 - Move nsScriptError from js/xpconnect to dom/bindings. r=bz 2017-01-28 00:42:47 +09:00
Andrew McCreight
1bde316c56 Bug 1331809 - Remove unused variable in WrapperOwner::hasInstance(). r=kanru
MozReview-Commit-ID: 3de6HDTVpU0
2017-01-17 16:34:16 -08:00
Andrew McCreight
40df076a4a Bug 1330018 - Ensure we always unwrap CpowEntries. r=bholley,billm
We can drop async messages that contain CPOWs, which can cause us to
leak them either until we successfully send a CPOW or forever,
depending on the direction of the message. This is causing
intermittent leaks until shutdown with e10s-multi.

MozReview-Commit-ID: 3iIaIBZKZR2
2017-01-13 13:50:35 -08:00
Andrew McCreight
4f6b7d8ac4 Bug 1331115 - Fix two typos in CPOW code. r=billm
MozReview-Commit-ID: FAh7O1U9hGP
2017-01-13 09:49:17 -08:00
Steve Fink
ba86250240 Bug 1308236 - Don't trigger read barriers when comparing wrapped pointers types r=sfink r=mccr8 2016-10-28 15:11:56 -07:00
Jon Coppeard
1bf98927a2 Bug 1318384 - Don't trigger pre barrier in WrapperAnswer::RecvDropObject r=billm 2016-11-18 13:18:09 +00:00