Bug 1335308 - Proxy mSpecifiedTransform releases that occur during the servo traversal to the main thread. r=heycam

This commit is contained in:
Bobby Holley 2017-02-07 19:25:45 -08:00
parent 02e0614b63
commit 8a7297e161
2 changed files with 27 additions and 3 deletions

View File

@ -3306,6 +3306,31 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
MOZ_COUNT_CTOR(nsStyleDisplay);
}
nsStyleDisplay::~nsStyleDisplay()
{
// We don't allow releasing nsCSSValues with refcounted data in the Servo
// traversal, since the refcounts aren't threadsafe. Since Servo may trigger
// the deallocation of style structs during styling, we need to handle it
// here.
if (mSpecifiedTransform && ServoStyleSet::IsInServoTraversal()) {
// The default behavior of NS_ReleaseOnMainThread is to only proxy the
// release if we're not already on the main thread. This is a nice
// optimization for the cases we happen to be doing a sequential traversal
// (i.e. a single-core machine), but it trips our assertions which check
// whether we're in a Servo traversal, parallel or not. So we
// unconditionally proxy in debug builds.
bool alwaysProxy =
#ifdef DEBUG
true;
#else
false;
#endif
NS_ReleaseOnMainThread(mSpecifiedTransform.forget(), alwaysProxy);
}
MOZ_COUNT_DTOR(nsStyleDisplay);
}
nsChangeHint
nsStyleDisplay::CalcDifference(const nsStyleDisplay& aNewData) const
{

View File

@ -2794,9 +2794,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
{
explicit nsStyleDisplay(const nsPresContext* aContext);
nsStyleDisplay(const nsStyleDisplay& aOther);
~nsStyleDisplay() {
MOZ_COUNT_DTOR(nsStyleDisplay);
}
~nsStyleDisplay();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleDisplay* aSelf) { return aSelf; }