Bug 1444296 part 1 - Have servo report traversal statistics to gecko. r=bholley
MozReview-Commit-ID: 52YO9mzvneR
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -63,16 +63,17 @@
#include "mozilla/Mutex.h"
#include "mozilla/Preferences.h"
#include "mozilla/ServoElementSnapshot.h"
#include "mozilla/ServoRestyleManager.h"
#include "mozilla/SizeOfState.h"
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/SystemGroup.h"
#include "mozilla/ServoMediaList.h"
+#include "mozilla/ServoTraversalStatistics.h"
#include "mozilla/Telemetry.h"
#include "mozilla/RWLock.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ElementInlines.h"
#include "mozilla/dom/HTMLTableCellElement.h"
#include "mozilla/dom/HTMLBodyElement.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/URLExtraData.h"
@@ -92,16 +93,20 @@ using namespace mozilla::dom;
RefPtr<type_> result; \
result.swap(mPtr); \
return result.forget(); \
}
#include "mozilla/ServoArcTypeList.h"
SERVO_ARC_TYPE(StyleContext, ServoStyleContext)
#undef SERVO_ARC_TYPE
+// Definitions of the global traversal stats.
+bool ServoTraversalStatistics::sActive = false;
+ServoTraversalStatistics ServoTraversalStatistics::sSingleton;
+
static RWLock* sServoFFILock = nullptr;
static
const nsFont*
ThreadSafeGetDefaultFontHelper(const nsPresContext* aPresContext,
nsAtom* aLanguage, uint8_t aGenericId)
{
bool needsCache = false;
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -71,16 +71,17 @@ headers = [
"mozilla/dom/ChildIterator.h",
"mozilla/dom/NameSpaceConstants.h",
"mozilla/LookAndFeel.h",
"mozilla/StylePrefs.h",
"mozilla/ServoBindings.h",
"mozilla/ServoMediaList.h",
"mozilla/ServoStyleContext.h",
"mozilla/ServoDeclarationBlock.h",
+ "mozilla/ServoTraversalStatistics.h",
"mozilla/SizeOfState.h",
"nsCSSCounterStyleRule.h",
"nsCSSFontFaceRule.h",
"nsContentUtils.h",
"nsNameSpaceManager.h",
"nsMediaFeatures.h",
"nsXBLBinding.h",
]
@@ -225,16 +226,17 @@ whitelist-types = [
"mozilla::ComputedTimingFunction",
"mozilla::ComputedTimingFunction::BeforeFlag",
"mozilla::SeenPtrs",
"mozilla::ServoElementSnapshot.*",
"mozilla::ServoStyleContext",
"mozilla::ServoStyleSheet",
"mozilla::ServoStyleSheetInner",
"mozilla::ServoStyleSetSizes",
+ "mozilla::ServoTraversalStatistics",
"mozilla::CSSPseudoClassType",
"mozilla::css::ErrorReporter",
"mozilla::css::LoaderReusableStyleSheets",
"mozilla::css::SheetLoadData",
"mozilla::css::SheetParsingMode",
"mozilla::css::URLMatchingFunction",
"mozilla::dom::IterationCompositeOperation",
"mozilla::dom::StyleChildrenIterator",
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoTraversalStatistics.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_ServoTraversalStatistics_h
+#define mozilla_ServoTraversalStatistics_h
+
+#include <inttypes.h>
+
+namespace mozilla {
+
+// Traversal statistics for Servo traversal.
+//
+// See style::context::PerThreadTraversalStatistics for
+// meaning of these fields.
+struct ServoTraversalStatistics
+{
+ uint32_t mElementsTraversed = 0;
+ uint32_t mElementsStyled = 0;
+ uint32_t mElementsMatched = 0;
+ uint32_t mStylesShared = 0;
+ uint32_t mStylesReused = 0;
+
+ static bool sActive;
+ static ServoTraversalStatistics sSingleton;
+};
+
+} // namespace mozilla
+
+#endif // mozilla_ServoTraversalStatistics_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -118,16 +118,17 @@ EXPORTS.mozilla += [
'ServoPropPrefList.h',
'ServoSpecifiedValues.h',
'ServoStyleContext.h',
'ServoStyleContextInlines.h',
'ServoStyleRule.h',
'ServoStyleSet.h',
'ServoStyleSheet.h',
'ServoSupportsRule.h',
+ 'ServoTraversalStatistics.h',
'ServoTypes.h',
'ServoUtils.h',
'SheetType.h',
'StyleAnimationValue.h',
'StyleBackendType.h',
'StyleComplexColor.h',
'StylePrefs.h',
'StyleSetHandle.h',