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

6684 Коммитов

Автор SHA1 Сообщение Дата
Henri Sivonen 3edc601325 Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj.
Correctness improvements:

 * UTF errors are handled safely per spec instead of dangerously truncating
   strings.

 * There are fewer converter implementations.

Performance improvements:

 * The old code did exact buffer length math, which meant doing UTF math twice
   on each input string (once for length calculation and another time for
   conversion). Exact length math is more complicated when handling errors
   properly, which the old code didn't do. The new code does UTF math on the
   string content only once (when converting) but risks allocating more than
   once. There are heuristics in place to lower the probability of
   reallocation in cases where the double math avoidance isn't enough of a
   saving to absorb an allocation and memcpy.

 * Previously, in UTF-16 <-> UTF-8 conversions, an ASCII prefix was optimized
   but a single non-ASCII code point pessimized the rest of the string. The
   new code tries to get back on the fast ASCII path.

 * UTF-16 to Latin1 conversion guarantees less about handling of out-of-range
   input to eliminate an operation from the inner loop on x86/x86_64.

 * When assigning to a pre-existing string, the new code tries to reuse the
   old buffer instead of first releasing the old buffer and then allocating a
   new one.

 * When reallocating from the new code, the memcpy covers only the data that
   is part of the logical length of the old string instead of memcpying the
   whole capacity. (For old callers old excess memcpy behavior is preserved
   due to bogus callers. See bug 1472113.)

 * UTF-8 strings in XPConnect that are in the Latin1 range are passed to
   SpiderMonkey as Latin1.

New features:

 * Conversion between UTF-8 and Latin1 is added in order to enable faster
   future interop between Rust code (or otherwise UTF-8-using code) and text
   node and SpiderMonkey code that uses Latin1.

MozReview-Commit-ID: JaJuExfILM9
2018-08-14 14:43:42 +03:00
Steve Fink 22ee12770e Bug 1480843 - Avoid hazard by controlling order of operations so that we GC before using any GC heap pointers, r=bz
--HG--
extra : topic : gcstats.thresh
extra : rebase_source : b9e31b5b0da9924bee110b689f16989cf578cb2e
2018-08-03 10:47:21 -07:00
Logan F Smyth 4abb1e0558 Bug 1378808 - Use ::Arguments or ::PropertyName location for method call column offsets. r=jorendorff, r=ckerschb
--HG--
extra : rebase_source : 69612b61b1cfbfd26856e285d63600ce56e95ec3
extra : source : 6c6a609463ab5d71e475354cab8c3ff323d0571d
2018-07-12 11:51:17 -07:00
Nicholas Nethercote b9e071e2e8 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 b3d493f06a Bug 1482423 part 2 - Use js::IsSystemCompartment in xpc::AccessCheck::isChrome. r=mrbkap
--HG--
extra : rebase_source : 7998deb57b0fd8fddcc822bb726a29d3942d3601
2018-08-11 13:12:49 +02:00
Jan de Mooij 17094cb561 Bug 1472976 part 6 - Remove unused xpc::AccessCheck::getPrincipal method. r=mrbkap 2018-08-10 11:57:40 +02:00
Jan de Mooij 0fdef26898 Bug 1472976 part 5 - Use xpc::GetRealmPrincipal instead of xpc::GetCompartmentPrincipal in xpc::GetObjectPrincipal. r=mrbkap 2018-08-10 11:57:40 +02:00
Jan de Mooij 90d9694728 Bug 1472976 part 4 - Use JS::GetRealmPrincipals instead of JS_GetCompartmentPrincipals in XPCWrappedNativeScope::GetPrincipal. r=mrbkap 2018-08-10 11:57:40 +02:00
Gabriele Svelto 15adf94f4d Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.

All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.

--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 15:42:11 +02:00
Tooru Fujisawa f3ffec503c Bug 1478936 - Fix the comment for JS_GetFunctionArity, and add JS_GetFunctionLength which matches to the original comment, and fixed consumer. r=jandem 2018-08-10 07:49:17 +09:00
Jan de Mooij 6b5c6b10aa Bug 1481772 - Remove unnecessary JSAutoRealm in mozJSComponentLoader::ImportInto. r=kmag 2018-08-09 10:48:29 +02:00
Mike Hommey 6d197a0707 Bug 1481719 - Disable profile-instr-out-of-date warnings explicitly rather than allowing all warnings where they appear. r=dmajor 2018-08-09 06:07:33 +09:00
Jan de Mooij 1b991ab653 Bug 1481467 part 3 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in XrayTraits::attachExpandoObject. r=bz
Because XrayTraits::attachExpandoObject operates in the Xray target realm/compartment and we cannot use the Xray wrapper with JSAutoRealm, we pass the caller's global as exclusiveWrapperGlobal and use that.

This also changes XrayWrapper<Base, Traits>::defineProperty to call ensureExpandoObject in the wrapper (instead of target) realm. This didn't matter before, because ensureExpandoObject immediately entered the target realm anyway.
2018-08-08 15:14:02 +02:00
Jan de Mooij 48b99bc1f0 Bug 1481467 part 2 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in JSXrayTraits::getOwnPropertyFromTargetIfSafe. r=bz
Because getOwnPropertyFromTargetIfSafe operates in the Xray target realm/compartment and we cannot use the Xray wrapper with JSAutoRealm, we pass the caller's global as wrapperGlobal and use that.
2018-08-08 15:12:16 +02:00
Jan de Mooij 21af7a61b0 Bug 1481467 part 1 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in mozJSComponentLoader::ImportInto. r=kmag
The targetVal argument is always same-compartment with the JSContext, so we only need to use JSAutoRealm in the FindTargetObject case.
2018-08-08 15:07:41 +02:00
Jon Coppeard 9d6255073d Bug 1481196 - Compile module scripts to a JSScript like we do for classic scripts r=jandem r=baku 2018-08-08 10:40:03 +01:00
agashlin@mozilla.com a03dfcbd42 bug 1397297, make SnowWhite freeing more incremental, r=smaug
--HG--
extra : rebase_source : 0772adabddb6cee33d83184d32c981d3920ea6e6
2018-08-08 09:14:58 +03:00
Brindusan Cristian 37bf8a10b0 Backed out 3 changesets (bug 1378808) for wpt failures on /content-security-policy/securitypolicyviolation/targeting.html.
Backed out changeset 6c6a609463ab (bug 1378808)
Backed out changeset 6dd9c641346a (bug 1378808)
Backed out changeset e732697778c2 (bug 1378808)
2018-08-08 04:40:19 +03:00
Kris Maglione 25c94b46d8 Bug 1481021: Part 1 - Fix tests that rely on permissive COWs or SpecialPowers side-effects in frame script scopes. r=bz
Right now, a lot of test code relies on side-effects of SpecialPowers being
loaded into frame script globals. In particular:

- It forces permissive COWs from those scopes, which allows frame scripts to
  pass objects from those scopes to unprivileged content that they otherwise
  wouldn't.
- It imports a bunch of helper modules and WebIDL globals which would
  otherwise not be available.

Fortunately, this seems to only impact test code at this point. But there's a
real down-the-road risk of it impacting shipping code, which ends up working
in automation due to the side-effects of SpecialPowers, but failing in real
world use.

MozReview-Commit-ID: G27eSSOHymX

--HG--
extra : rebase_source : 1702e63fed719fc92def2bdbbb8a7c53572432db
extra : source : 41bedc526dd6ec6b7e8c7be1c832ac60c81d6263
2018-08-07 14:13:06 -07:00
Brindusan Cristian 16ec846afc Backed out 2 changesets (bug 1481021) for bc failures on security/sandbox/test/browser_bug1393259.js.
Backed out changeset c53c7b0249ad (bug 1481021)
Backed out changeset 41bedc526dd6 (bug 1481021)
2018-08-08 03:22:16 +03:00
Logan F Smyth 96dd9699d1 Bug 1378808 - Use ::Arguments or ::PropertyName location for method call column offsets. r=jorendorff
MozReview-Commit-ID: G8mG1qsIO21

--HG--
extra : rebase_source : b5a72b239156617319fc6dabe111c02c13f621c9
2018-07-12 11:51:17 -07:00
Kris Maglione c1969dbca2 Bug 1481021: Part 1 - Fix tests that rely on permissive COWs or SpecialPowers side-effects in frame script scopes. r=bz
Right now, a lot of test code relies on side-effects of SpecialPowers being
loaded into frame script globals. In particular:

- It forces permissive COWs from those scopes, which allows frame scripts to
  pass objects from those scopes to unprivileged content that they otherwise
  wouldn't.
- It imports a bunch of helper modules and WebIDL globals which would
  otherwise not be available.

Fortunately, this seems to only impact test code at this point. But there's a
real down-the-road risk of it impacting shipping code, which ends up working
in automation due to the side-effects of SpecialPowers, but failing in real
world use.

MozReview-Commit-ID: G27eSSOHymX

--HG--
extra : rebase_source : c528dffe3a54eec75ad6cb358980b783b00eb4a4
2018-08-07 14:13:06 -07:00
Jan de Mooij 5824a03a39 Bug 1478359 - Store a global object in nsXPCWrappedJS and use it for realm-entering. r=mccr8
The problem we're solving here: getting/entering the realm/global of a cross-compartment wrapper doesn't make sense once there are multiple realms in a compartment and the CCW will be shared by all of them. Because nsXPCWrappedJS can store a CCW, we will no longer be able to use this JSObject to enter the target realm.

What this patch does: we pass a JSContext* to nsXPCWrappedJS::GetNewOrUsed and we use this to store a global object in nsXPCWrappedJS (with the invariant that the object and global stored in nsXPCWrappedJS are same-compartment). Then when we want to enter the nsXPCWrappedJS's target realm, we use this global object instead of the maybe-CCW object. Because we currently still have one realm per compartment and the objects are same-compartment, this is guaranteed to preserve behavior for now.

nsXPCWrappedJS has some code to deal with weak pointers. Fortunately this applies only to root wrappers and root wrappers always store an unwrapped JSObject, so the extra global we store is guaranteed to be marked by the GC in that case (a global object is never collected when there are live JSObjects belonging to the same realm).
2018-08-07 11:57:41 +02:00
Masatoshi Kimura 3b21b7868b Bug 1090497 - Re-enable warnings as errors on clang-cl. r=froydnj
--HG--
extra : rebase_source : c09366fb93e5b0f72abe1e99d3094e3d96a934fb
extra : intermediate-source : 5950c9d63c3b4fd63a25464a7b50944aaec7079f
extra : source : ca1b9a2bcc4381795f556fea2fb59066567c30f3
2018-07-31 22:10:07 +09:00
Brian Hackett 8eb62dd065 Bug 1479058 Part 8 - Store time warp target on nsIScriptError, r=smaug.
--HG--
extra : rebase_source : 1faf5a0c0ead57f5dfb24c7450873977bf41a022
2018-08-02 23:31:29 +00:00
Noemi Erli 23c8a3a9f3 Backed out changeset 1e9ecba54e7b (bug 1348273) for failing on widget/tests/test_bug1123480.xul 2018-08-04 12:39:40 +03:00
Dorel Luca 33b000ddd1 Merge mozilla-central to mozilla-inbound 2018-08-04 01:31:40 +03:00
Dorel Luca 5c509fd70a Backed out changeset 8c763e66ba84 (bug 1397297) for frequent mochitest failures. a=backout 2018-08-04 01:27:15 +03:00
Bogdan Tara f2cb75b28c Merge inbound to mozilla-central. a=merge 2018-08-03 13:16:27 +03:00
Kristen Wright fbf7880ab6 Bug 1478942 - Convert UniquePtr<SimpleEdgeRange> back to UniquePtr<EdgeRange> to return an EdgeRange. r=erahm 2018-07-27 11:00:40 -07:00
Boris Zbarsky d4993da381 Bug 1476142 part 4. Remove some unnecessary QIs on window in various parts of the tree. r=kmag
The crashtest was not testing anything useful, because getInterface is no longer exposed to web content.
2018-08-02 15:26:48 -04:00
Brian Hackett 51e310f29a Bug 1479547 Part 1 - Remove instrumentation related to non-deterministic GCs, r=mccr8.
--HG--
extra : rebase_source : 6dfc65ab83e770da6e1f64003379156c3b863050
2018-07-31 19:34:50 +00:00
Brian Hackett f43431cd1c Bug 1479651 - Use correct pointer for registering deferred finalization thing for SandboxPrivate, r=smaug.
--HG--
extra : rebase_source : 88e76371da6ba2c75c1bc88c380d1498a603183d
2018-07-31 19:33:04 +00:00
Boris Zbarsky 357b6b1348 Bug 1479570. Get Add a getter to get a docshell from nsIWindowlessBrowser. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D2669

--HG--
extra : moz-landing-system : lando
2018-08-03 00:05:07 +00:00
Gabriele Svelto 50ba13cce4 Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant functions are updated to take a typed enum (in C++) and an
integer constant (in JavaScript). A JavaScript wrapper around the crash
reporter service is provided to hold the constants. The existing whitelists
and blacklists of annotations are also generated from the YAML file and the
existing duplicate code has been consolidated. Once written out to the .extra
file the annotations are converted in string form and are no different than
the existing ones.

All existing annotations have been included (and some obsolete ones removed)
and all call sites have been updated including tests.

--HG--
extra : rebase_source : b4f0d4bf83c64851028c271d3fab3ebcb6fbcd3e
2018-07-05 15:42:11 +02:00
Nika Layzell 051eb6dcbd Bug 1480624 - Part 2: Add a DestructValue method to XPConnect to run XPT Type destructors, r=mccr8
Summary:
DestructValue acts a lot like CleanupValue, however in addition to normal
cleanup work, it invokes the destructor of complex data types. This is important
to ensure that constructors and destructors are matched for these complex data
types.

CleanupValue is also used to clean up a value without destructing it, so cannot
be modified in-place.

Depends On D2689

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1480624

Differential Revision: https://phabricator.services.mozilla.com/D2690
2018-08-03 15:55:13 -04:00
Nika Layzell f1902ff595 Bug 1480624 - Part 1: Add XPT_FOR_EACH_*_TYPE macros to xptinfo.h, r=mccr8
Summary:
This macro simplifies code which allows performing an operation on or
extracting information from a particular nsXPTType's native representation.

It is also used in part 2 to implement xpc::DestructValue.

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1480624

Differential Revision: https://phabricator.services.mozilla.com/D2689
2018-08-03 15:55:13 -04:00
Coroiu Cristina 1ba19a32ac Backed out changeset 86471a18672f (bug 1348273) for ESlint failure at toolkit/modules/WebNavigationChild.jsm
--HG--
extra : rebase_source : e0c94f49ddc1f1b119b72c06fccc1b4363b9d340
2018-08-03 22:48:51 +03:00
Gabriele Svelto eff24befbd Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant functions are updated to take a typed enum (in C++) and an
integer constant (in JavaScript). A JavaScript wrapper around the crash
reporter service is provided to hold the constants. The existing whitelists
and blacklists of annotations are also generated from the YAML file and the
existing duplicate code has been consolidated. Once written out to the .extra
file the annotations are converted in string form and are no different than
the existing ones.

All existing annotations have been included (and some obsolete ones removed)
and all call sites have been updated including tests.

--HG--
extra : rebase_source : f0e8d229581ac5c0daa0e0454cb258746108e28d
2018-07-05 15:42:11 +02:00
Jan de Mooij 741c3a4130 Bug 1479712 part 5 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in xpc::StackScopedClone. r=bholley 2018-08-02 09:15:42 +02:00
Jan de Mooij 4cda94fb7d Bug 1479712 part 4 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in NativeInterface2JSObject. r=bholley
Also fixes some callers to not pass a potential CCW.
2018-08-02 09:15:42 +02:00
Jan de Mooij 1d54f66140 Bug 1479712 part 3 - Remove unnecessary AutoJSContext and JSAutoRealmAllowCCW in JSObject2NativeInterface and nsXPConnect::WrapJS. r=bholley 2018-08-02 09:15:42 +02:00
Jan de Mooij af31466131 Bug 1479712 part 2 - Remove unused nsIXPConnect.getWrappedNativePrototype. r=bholley 2018-08-02 09:15:41 +02:00
Jan de Mooij f672f4f7b6 Bug 1479712 part 1 - Require a plain function in xpcshell setInterruptCallback. r=bholley
The head_watchdog.js test always calls this with a function argument. This lets us use JSAutoRealm instead of JSAutoRealmAllowCCW.
2018-08-02 09:15:41 +02:00
Jan de Mooij 51c1609621 Bug 1479363 part 6 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in js/xpconnect/loader. r=kmag 2018-08-02 08:49:10 +02:00
Nicholas Nethercote 6f95417fb4 Bug 1478879 - Remove Range/Enum use in XPConnect. r=mccr8
--HG--
extra : rebase_source : 2117904e70e05e318e2b13a5653f029dfdbed851
2018-07-31 10:31:00 +10:00
Nicholas Nethercote 6141e31ef4 Bug 1479954 - Rename Hash{Set,Map}::sizeOf{In,Ex}cludingThis(). r=luke
In PLDHashTable the equivalent functions have a "Shallow" prefix, which makes
it clear that they don't measure things hanging off the table. This patch makes
mozilla::Hash{Set,Map} do likewise.

MozReview-Commit-ID: 3kwCJynhW7d

--HG--
extra : rebase_source : 9c03d11f376a9fd4cfd5cfcdc0c446c00633b210
2018-08-01 09:57:52 +10:00
Jon Coppeard 827b83bae3 Bug 1475228 - Allow construction of a SourceBufferHolder from a UniquePtr r=jandem r=kmag 2018-07-17 14:30:23 +01:00
Jon Coppeard 4ff436874c Bug 1475228 - Make asynchronous compile APIs take SourceBufferHolders r=jandem 2018-07-17 14:30:23 +01:00
Jon Coppeard ec2af16383 Bug 1475228 - Make synchronous compile APIs take SourceBufferHolders exclusively r=jandem r=fitzgen 2018-07-17 14:30:22 +01:00