зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1400435 - Use a more precise check in the nsCSSValue destructor. r=xidorn
MozReview-Commit-ID: KFdgtxyOZ01
This commit is contained in:
Родитель
284ba5cb95
Коммит
8d10314a67
|
@ -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()
|
||||
|
|
Загрузка…
Ссылка в новой задаче