Bug 1400435 - Use a more precise check in the nsCSSValue destructor. r=xidorn

MozReview-Commit-ID: KFdgtxyOZ01
This commit is contained in:
Bobby Holley 2017-09-18 18:26:29 -07:00
Родитель 284ba5cb95
Коммит 8d10314a67
4 изменённых файлов: 23 добавлений и 4 удалений

Просмотреть файл

@ -615,6 +615,9 @@ SERVO_BINDING_FUNC(Servo_TraverseSubtree,
// Assert that the tree has no pending or unconsumed restyles.
SERVO_BINDING_FUNC(Servo_AssertTreeIsClean, void, RawGeckoElementBorrowed root)
// Returns true if the current thread is a Servo parallel worker thread.
SERVO_BINDING_FUNC(Servo_IsWorkerThread, bool, )
// Checks whether the rule tree has crossed its threshold for unused rule nodes,
// and if so, frees them.
SERVO_BINDING_FUNC(Servo_MaybeGCRuleTree, void, RawServoStyleSetBorrowed set)

Просмотреть файл

@ -40,6 +40,14 @@ using namespace mozilla::dom;
ServoStyleSet* ServoStyleSet::sInServoTraversal = nullptr;
#ifdef DEBUG
bool
ServoStyleSet::IsCurrentThreadInServoTraversal()
{
return sInServoTraversal && (NS_IsMainThread() || Servo_IsWorkerThread());
}
#endif
namespace mozilla {
// On construction, sets sInServoTraversal to the given ServoStyleSet.
// On destruction, clears sInServoTraversal and calls RunPostTraversalTasks.

Просмотреть файл

@ -97,6 +97,13 @@ public:
return sInServoTraversal;
}
#ifdef DEBUG
// Used for debug assertions. We make this debug-only to prevent callers from
// accidentally using it instead of IsInServoTraversal, which is cheaper. We
// can change this if a use-case arises.
static bool IsCurrentThreadInServoTraversal();
#endif
static ServoStyleSet* Current()
{
return sInServoTraversal;

Просмотреть файл

@ -417,10 +417,11 @@ nscoord nsCSSValue::GetPixelLength() const
// traversal, since the refcounts aren't thread-safe.
// Note that the caller might be an OMTA thread, which is allowed to operate off
// main thread because it owns all of the corresponding nsCSSValues and any that
// they might be sharing members with.
#define DO_RELEASE(member) { \
MOZ_ASSERT(NS_IsInCompositorThread() || !ServoStyleSet::IsInServoTraversal()); \
mValue.member->Release(); \
// they might be sharing members with. Since this can happen concurrently with
// the servo traversal, we have to use a more-precise (but slower) test.
#define DO_RELEASE(member) { \
MOZ_ASSERT(!ServoStyleSet::IsCurrentThreadInServoTraversal()); \
mValue.member->Release(); \
}
void nsCSSValue::DoReset()