Commit Graph

5292 Commits

Author SHA1 Message Date
Andrew McCreight
b9fe49e715 Bug 1290614, part 7 - Further refactor XPCNativeSetKey::Hash. r=mrbkap
Now we can see what is really happening in Hash: first hash the
interfaces from the base set, if any, then hash the additional
interface, if any.

Note that this function is wrong when mBaseSet is null. This will be
fixed in bug 1290239.

MozReview-Commit-ID: KaxQ57ofO1D

--HG--
extra : rebase_source : 42012878839adb2e36580480abce7d9708288db4
2016-07-31 14:19:31 -07:00
Andrew McCreight
bcc1ce175d Bug 1290614, part 6 - Hoist out the common loop over all interfaces in XPCNativeSetKey::Hash(). r=mrbkap
Both cases first hash together all of the existing interfaces.

MozReview-Commit-ID: AnUF5uPSPpN

--HG--
extra : rebase_source : 43ac016974d3ee4dfbd92361348aeeae5b6a793c
2016-07-31 14:16:52 -07:00
Andrew McCreight
c2ef63a1b9 Bug 1290614, part 5 - Split out the last iteration of the XPCNativeSetKey loops. r=mrbkap
Now I take advantage of knowing that any new interface is always being
added to the end of the set.

Further cleanup of Hash() will happen in the next patch.

MozReview-Commit-ID: EoESTOfIOr

--HG--
extra : rebase_source : 8471391d23e3ff27a27156f55badbef3d1a4118b
2016-07-31 14:11:01 -07:00
Andrew McCreight
c597939d49 Bug 1290614, part 4 - Stop storing mPosition in XPCNativeSetKey. r=mrbkap
There are three cases for a key, represented by the three ctors:
1. mBaseSet is non-null, mAddition is null.
2. mBaseSet is null, mAddition is non-null.
3. Both mBaseSet and mAddition are non-null.

In the three places that use the value of mPosition, condition 3
holds, so the key must have been constructed using the third ctor. For
this ctor, mPosition is equal to mBaseSet->GetInterfaceCount(), so I
substitute the value and eliminate the field.

This makes a check in NewInstanceMutate() trivially false, so I
eliminated that, too.

MozReview-Commit-ID: 1SOF6GyccU7

--HG--
extra : rebase_source : e215da19d77d6f88c216a48a07b9450c4d0e12bb
2016-07-31 13:50:11 -07:00
Andrew McCreight
d01e63e95e Bug 1290614, part 3 - The last argument to the third XPCNativeSetKey ctor is always the interface count. r=mrbkap
The mPosition field will be eliminated in a later patch.

MozReview-Commit-ID: EyVYZGgUWrH

--HG--
extra : rebase_source : 229ec989485bdd3ef86670a7c7db4149281a8d79
2016-07-31 13:36:39 -07:00
Andrew McCreight
d55f0d4d23 Bug 1290614, part 2 - Split XPCNativeSetKey into three constructors. r=mrbkap
This explicitly represents the three types of keys that are used:

1. A key for an existing set.
2. A key for a new set with one interface added.
3. A key for an existing set with one new interface added at a
specified position.

MozReview-Commit-ID: Ctw41EymHbd

--HG--
extra : rebase_source : d7ce7d608a3d09df752313116c99bc2079d15a13
2016-07-31 13:25:05 -07:00
Andrew McCreight
e453d61e92 Bug 1290614, part 1 - Pass around XPCNativeSetKeys to better encapsulate argument invariants. r=mrbkap
XPCNativeSet::GetNewOrUsed() and ::NewInstanceMutate() essentially
take XPCNativeSetKeys as arguments, but pass them around
unboxed. Passing around the keys explicitly will allow later changes
to enforce stronger invariants on keys.

MozReview-Commit-ID: CyQU3bUGinq

--HG--
extra : rebase_source : 5cdc651c1e4b9566dccd61b66de5e2bb8d6f33f5
2016-07-31 13:00:02 -07:00
Jon Coppeard
d1435a2a8c Bug 1296688 - Add JSCLASS_FOREGROUND_FINALIZE flag r=sfink r=smaug 2016-08-24 14:18:10 +01:00
Kan-Ru Chen
b6d880aca1 Bug 1297276 - Rename mfbt/unused.h to mfbt/Unused.h for consistency. r=froydnj
The patch is generated from following command:

  rgrep -l unused.h|xargs sed -i -e s,mozilla/unused.h,mozilla/Unused.h,

MozReview-Commit-ID: AtLcWApZfES


--HG--
rename : mfbt/unused.h => mfbt/Unused.h
2016-08-24 14:47:04 +08:00
Phil Ringnalda
b25ad4c181 Back out changeset bba47d5c2583 (bug 1296484) for isNurseryAllocAllowed() assertion failures in devtools tests
CLOSED TREE
2016-08-23 22:37:03 -07:00
Terrence Cole
d00af19508 Bug 1296484 - Automatically CycleCollect if COMPARTMENT_REVIVED GC ends mostly gray; r=mccr8,r=jonco
--HG--
extra : rebase_source : d8df564fb782c4d8cfa4a5b153e5cda00e6343a2
2016-08-18 13:30:32 -07:00
Ryan VanderMeulen
cd2e02c188 Merge m-c to inbound. a=merge 2016-08-23 10:06:36 -04:00
Andrew McCreight
8fcd1d9885 Bug 1288870, part 5 - Remove the now-vestigial Mark code for XPCNativeInterface. r=billm
XPCNativeInterface::Mark(), Unmark() and IsMarked() don't do anything
any more, so anything that calls them can be deleted. This removes the
only use of XPCCallContext::CanGetInterface(), so delete that, too.

MozReview-Commit-ID: 4w3aPTVXNDI
2016-08-23 05:59:57 -07:00
Andrew McCreight
f1d540176d Bug 1288870, part 4 - Make XPCNativeInterface refcounted. r=billm
There are four classes that call Root() on XPCNativeInterface, and
thus keep interfaces alive. Each of these gets converted to use a
RefPtr:

1. XPCCallContext. This could be on some kind of hot path, but the
FindMemberCall involves various string operations and hashtable
lookups, so adding a single AddRef shouldn't matter. One weirdness
here is that the context only roots the interface when |mState >=
HAVE_NAME|. With a RefPtr<>, this requires nulling out
mInterface. Fortunately, in most cases where it moves from rooting to
non-rooting, it already does this. The one case it does not is in
SystemIsBeingShutDown(), so my patch adds that.

2. XPCNativeSet. This holds an array of interfaces in a weird
placement new array at the end of the object. I wasn't sure how a
non-POD class would interact with the way the array is handled with
casting, so I manually AddRef and Release things put into or removed
from the array.

3. AutoMarkingNativeInterfacePtr simply becomes RefPtr<>. This is the
bulk of the patch, in terms of number of lines changed.

4. Similarly, the one AutoMarkingNativeInterfacePtrArrayPtr becomes
nsTArray<RefPtr<>>. This is the last use of the auto marking array
class, so I deleted it.

Here are some other notes on what the patch does:

- XPCNativeInterfaces are created with placement new. This requires a
special version of refcounting that calls DestroyInstance, defined in
the previous patch. The GetNewOrUsed methods used to explicitly call
DestroyInstance(), but with refcounting this is no longer needed.

- The Mark() etc. methods are gutted so they don't do anything and
mMarked is removed because it is no longer used. The methods will be
cleaned up in later patches in this bug.

- Interfaces are removed from mIID2NativeInterfaceMap in the dtor
instead of during sweeping, requiring an extra hash table lookup.

- All of the methods that can create a new interface (NewInstance,
GetISupports, GetNewOrUsed) now return an already_AddRefed<>, which
gives some static checking that we don't accidentally fail to hold
onto a newly created interface.

MozReview-Commit-ID: CrlH1ENAzvr
2016-08-23 05:59:57 -07:00
Andrew McCreight
e410eeed77 Bug 1288870, part 3 - Root the return value of the prewrap callback. r=mrbkap,terrence
Like part 2, this patch is to work around a false GC hazard in
~XPCNativeInterface in part 4. This hazard is around the return value
of WrapperFactory::PrepareForWrapping(), because ~XPCCallContext might
call ~XPCNativeInterface. The fix is to pass the return value into a
mutable handle. Unfortunately, this function is used in the JSAPI, so
JS minor engine changes are also needed.

MozReview-Commit-ID: GwFxmrXFXmb
2016-08-23 05:59:57 -07:00
Andrew McCreight
f487fbbfce Bug 1288870, part 2 - Handlify the argument to XPCNativeSet::FindMember(). r=mrbkap
This is to work around false GC hazards in ~XPCNativeInterface in part
4 of this bug. Putting RefPtr<XPCNativeInterface> on the stack means
that ~XPCNativeInterface can get called in various places, and the GC
hazard analysis does not understand the virtual methods involved, so
it assumes they might possibly GC.

This fixes one hazard by taking a jsid handle argument. The callers
already pass in handles, so no other changes are needed.

MozReview-Commit-ID: LpNpTlujpkm
2016-08-23 05:59:56 -07:00
Wes Kocher
b38dbd1378 Backed out 2 changesets (bug 1279086) for causing painting issues a=backout
Backed out changeset b1c893387fdd (bug 1279086)
Backed out changeset 277c54118c8a (bug 1279086)
2016-08-22 16:00:34 -07:00
Jan de Mooij
d8047f2b2f Bug 1295967 - Share Shapes and BaseShapes across compartments. r=jonco,fitzgen,njn 2016-08-23 11:25:54 +02:00
Bill McCloskey
1613c2cbc9 Bug 1279086 - Allow multiple interrupt callbacks (r=dvander) 2016-08-19 14:40:52 -07:00
Wes Kocher
3a31be9c17 Backed out 2 changesets (bug 1279086) for failures in browser_menu_item_01.js a=backout
Backed out changeset 00bb53b58e96 (bug 1279086)
Backed out changeset cff59fe2b933 (bug 1279086)
2016-08-19 12:31:55 -07:00
Bill McCloskey
95c5d71549 Bug 1279086 - Allow multiple interrupt callbacks (r=dvander) 2016-08-19 09:59:39 -07:00
Wes Kocher
55897634c1 Backed out 3 changesets (bug 1288870) for hazards a=backout
Backed out changeset 83bbd356da97 (bug 1288870)
Backed out changeset 4f0ab1a0d8dd (bug 1288870)
Backed out changeset 8d71aba5c1e7 (bug 1288870)
2016-08-18 16:50:13 -07:00
Andrew McCreight
e5e0b12c27 Bug 1288870, part 3 - Remove the now-vestigial Mark code for XPCNativeInterface. r=billm
XPCNativeInterface::Mark(), Unmark() and IsMarked() don't do anything
any more, so anything that calls them can be deleted. This removes the
only use of XPCCallContext::CanGetInterface(), so delete that, too.

MozReview-Commit-ID: 4w3aPTVXNDI
2016-08-18 15:20:48 -07:00
Andrew McCreight
f8d14c904a Bug 1288870, part 2 - Make XPCNativeInterface refcounted. r=billm
There are four classes that call Root() on XPCNativeInterface, and
thus keep interfaces alive. Each of these gets converted to use a
RefPtr:

1. XPCCallContext. This could be on some kind of hot path, but the
FindMemberCall involves various string operations and hashtable
lookups, so adding a single AddRef shouldn't matter. One weirdness
here is that the context only roots the interface when |mState >=
HAVE_NAME|. With a RefPtr<>, this requires nulling out
mInterface. Fortunately, in most cases where it moves from rooting to
non-rooting, it already does this. The one case it does not is in
SystemIsBeingShutDown(), so my patch adds that.

2. XPCNativeSet. This holds an array of interfaces in a weird
placement new array at the end of the object. I wasn't sure how a
non-POD class would interact with the way the array is handled with
casting, so I manually AddRef and Release things put into or removed
from the array.

3. AutoMarkingNativeInterfacePtr simply becomes RefPtr<>. This is the
bulk of the patch, in terms of number of lines changed.

4. Similarly, the one AutoMarkingNativeInterfacePtrArrayPtr becomes
nsTArray<RefPtr<>>. This is the last use of the auto marking array
class, so I deleted it.

Here are some other notes on what the patch does:

- XPCNativeInterfaces are created with placement new. This requires a
special version of refcounting that calls DestroyInstance, defined in
the previous patch. The GetNewOrUsed methods used to explicitly call
DestroyInstance(), but with refcounting this is no longer needed.

- The Mark() etc. methods are gutted so they don't do anything and
mMarked is removed because it is no longer used. The methods will be
cleaned up in later patches in this bug.

- Interfaces are removed from mIID2NativeInterfaceMap in the dtor
instead of during sweeping, requiring an extra hash table lookup.

- All of the methods that can create a new interface (NewInstance,
GetISupports, GetNewOrUsed) now return an already_AddRefed<>, which
gives some static checking that we don't accidentally fail to hold
onto a newly created interface.

MozReview-Commit-ID: CrlH1ENAzvr
2016-08-18 15:20:48 -07:00
Tom Schuster
92024846c1 Bug 1114580 - Define getBuiltinClass on Xray. r=peterv 2016-08-18 10:59:36 +02:00
Chris Manchester
b0b84a1928 Bug 1240134 - Incorporate the interfaces.xpt from downloaded artifacts instead of building XPIDL during an artifact build. r=glandium
MozReview-Commit-ID: 8oEyS1xLOwV
2016-08-17 15:02:31 -07:00
Bob Clary
faa4e6f42c Bug 1295138 - remove expected assertion from test_chrometoSource.xul, r=nfroyd 2016-08-16 22:26:40 -07:00
Nicholas Nethercote
e0229c761e Bug 1295053 (part 5) - Remove an unnecessary use of NS_CALLBACK in ClassInfoData. r=froydnj.
--HG--
extra : rebase_source : 6b14b91e8cd4c056e40148064b396a55c6f451a3
2016-08-16 07:56:26 +10:00
Andrew McCreight
b42d29f1f8 Bug 1288817, part 3 - Stop calling XPCNativeScriptableInfo::Mark() from various places because it doesn't do anything. r=billm
MozReview-Commit-ID: IcjcFti2k7A
2016-08-16 14:29:51 -07:00
Andrew McCreight
323130b5ec Bug 1288817, part 2 - Remove marking methods from XPCNativeScriptableShared and XPCNativeScriptableFlags. r=billm
Nothing depends on the value of the mark bit now.

MozReview-Commit-ID: 9k06XdtR9KB
2016-08-16 14:29:51 -07:00
Andrew McCreight
821b59184e Bug 1288817, part 1 - Make XPCNativeScriptableShared refcounted. r=billm
This adds a heap allocation in
XPCNativeScriptableSharedMap::GetNewOrUsed() on the fast
path. Hopefully that code is not hot enough for it to matter. I could
work around this if needed, but it would be ugly.

mNativeScriptableSharedMap has a weak pointer to
XPCNativeScriptableShared. I moved this removal from
XPCJSRuntime::FinalizeCallback() to the dtor.

There are two types of scriptable: one is a dummy one created in
GetNewOrUsed() to do a lookup, and the other is a fully filled out
one. The dummy one is not added to the hashtable, and may have had its
name stolen if we created a new scriptable. The latter makes it so
that you crash if you try to look it up in the hashtable anyways, so
this patch only looks up fully filled out scriptables.

This patch also removes MOZ_COUNT_CTOR/DTOR because they are not
needed for refcounted classes.

Stop destroying mScriptableInfo in XPCWrappedNative's
SystemIsBeingShutDown(), because that will end up destroying
XPCNativeScriptableShared, while their js::ClassOps are still in use
by JS objects. This matches the existing behavior, which does not
sweep these ScriptableShared during shutdown. (This came up in opt
xpcshell tests.)

MozReview-Commit-ID: GeG0pAYqXpR
2016-08-16 14:29:51 -07:00
Jon Coppeard
17304689a2 Bug 1291292 - Use dynamic chunk allocation for the nursery r=terrence 2016-08-11 17:14:56 +01:00
Jan de Mooij
c33bac8363 Bug 1292892 part 5 - Replace most nsContentUtils::RootingCx calls with dom::RootingCx. r=bz,terrence 2016-08-11 14:39:23 +02:00
Jan de Mooij
4ec9b6fc7e Bug 1292892 part 4 - Pass RootingContext to ModuleEntry. r=bz 2016-08-11 14:39:22 +02:00
Jan de Mooij
da9820d563 Bug 1292892 part 3 - Pass RootingContext to ScriptErrorEvent, DispatchScriptErrorEvent. r=bz 2016-08-11 14:39:22 +02:00
Jan de Mooij
0ad12515f4 Bug 1292892 part 1 - Stop using JSRuntime outside SpiderMonkey. r=bz,terrence,fitzgen,kanru 2016-08-11 14:39:22 +02:00
Jon Coppeard
5e361d2da5 Bug 1293262 - Refactor pretenuring after minor GC and add telemetry r=terrence 2016-08-11 10:41:06 +01:00
Nicholas Nethercote
4d2f91d5f5 Bug 1293117 (part 6) - Fix a comment and return type in XPCComponents.cpp. r=froydnj.
The comment is wrong. NS_METHOD is the appropriate thing to use here.

--HG--
extra : rebase_source : 68ada96c01f7941d5266298356ba5f493bcda67c
2016-08-09 14:03:12 +10:00
Wes Kocher
565cdb97f5 Backed out changeset 3fbb8651a171 (bug 1121938) for breaking encrypted-media-syntax.html CLOSED TREE 2016-08-10 13:17:39 -07:00
André Bargull
878648c8cf Bug 1121938 - Implement TypedArray.prototype.toString and .toLocaleString. r=waldo, r=froydnj 2016-07-29 09:04:06 -07:00
Shih-Chiang Chien
a8326d97ea Bug 1288600 - reject promise with NotFoundError while no device, and NotAllowedError while canceled by user. r=smaug.
MozReview-Commit-ID: ArQHhdIpQjg
2016-08-09 09:58:14 +08:00
Carsten "Tomcat" Book
553a2da922 merge mozilla-inbound to mozilla-central a=merge 2016-08-10 15:54:26 +02:00
Nicholas Nethercote
e7f10a07fd Bug 1293603 (part 2) - Make Run() declarations consistent. r=erahm.
This patch makes most Run() declarations in subclasses of nsIRunnable have the
same form: |NS_IMETHOD Run() override|.

As a result of these changes, I had to add |override| to a couple of other
functions to satisfy clang's -Winconsistent-missing-override warning.

--HG--
extra : rebase_source : 815d0018b0b13329bb5698c410f500dddcc3ee12
2016-08-08 12:18:10 +10:00
Andrew McCreight
b22f612021 Bug 1289137 - Make XPCNativeSet::NewInstance() take an nsTArray argument. r=billm
I could clean up ArrayAutoMarkingPtr more, but it is going to be
removed entirely in bug 1288870.

MozReview-Commit-ID: Jyjc2ZfvF3i

--HG--
extra : rebase_source : d7954ab821722b26fe5fc4f5ddc319dd824c6879
2016-07-27 16:36:48 -07:00
Andrew McCreight
d2be3b7515 Bug 1292289, part 1 - Stop unnecessarily using xpcprivate in XPCWrapper.h. r=mrbkap
This file is included in caps/, but it only uses generic JS things,
aside from a macro.

AccessCheck.cpp was bootlegging xpcprivate.h.

MozReview-Commit-ID: C6fGOFxsTvg

--HG--
extra : rebase_source : bd5e7bf9010acf83ccab8ce6cce77a557ad76196
2016-08-04 11:14:35 -07:00
Alexandre Lissy
0af5b943b6 Bug 1284674 - Remove NUWA r=cyu
MozReview-Commit-ID: GyMRNzOBKw6

--HG--
extra : rebase_source : 293af1cd55f2035ce6a99f4ebf144059c32a2b8f
2016-08-02 14:54:00 +02:00
Tooru Fujisawa
f9e30f8e42 Bug 1284099 - Part 2: Assert nsIScriptError.*Flags constants match to JSREPORT_*. r=baku 2016-08-03 18:09:42 +09:00
Tom Schuster
c955774058 Bug 1251364 - Remove our custom printf implementation (jsprf.cpp). r=tromey 2016-08-02 22:16:15 +02:00
Boris Zbarsky
7ad35e1f86 Bug 1289428. Make sure JSCompartment::wrap never returns a gray object, except when it returns "existing". r=bholley,jonco
The basic idea is that we assume the invariant that the "obj" argument is never
gray if "existing" is null (and add asserts to that effect).  Starting from that
assumption, terrence and I audited all the return paths to ensure that gray
objects are never returned.  We found a few places, generally after crossing
compartments with UncheckedUnwrap, where we could have gray things and inserted
corresponding calls to ExposeObjectToActiveJS.

If "existing" is passed in, all bets are off: both "obj" and "existing" can be
gray and can get returned from here.  But the only caller that passes "existing"
doesn't allow the return value to escape, so it's actually safe to do this.
2016-08-02 11:10:58 -07:00
Boris Zbarsky
599897e926 Bug 1291142. Ensure that we don't return gray objects when getting child windows by name or index. r=bholley 2016-08-02 11:06:25 -07:00