Title: [212731] branches/safari-603-branch/Source

Diff

Modified: branches/safari-603-branch/Source/_javascript_Core/ChangeLog (212730 => 212731)


--- branches/safari-603-branch/Source/_javascript_Core/ChangeLog	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/_javascript_Core/ChangeLog	2017-02-21 19:27:02 UTC (rev 212731)
@@ -1,3 +1,21 @@
+2017-02-17  JF Bastien  <[email protected]>
+
+        A/B test concurrent GC
+        https://bugs.webkit.org/show_bug.cgi?id=168453
+        <rdar://problem/30553220>
+
+        Reviewed by Phil Pizlo.
+
+        The concurrent GC may be causing more crashes, but it's hard to
+        tell. A/B test this by setting it off for 50% of users, based on
+        the UUID which crash tracer generates. From this we can look at
+        crashes and figure out whether the concurrent GC was on or off,
+        and derive whether fewer crashes occur when it's off.
+
+        * runtime/Options.cpp:
+        (JSC::recomputeDependentOptions):
+        * runtime/Options.h:
+
 2017-02-21  Matthew Hanson  <[email protected]>
 
         Merge r212692. rdar://problem/30475767

Modified: branches/safari-603-branch/Source/_javascript_Core/runtime/Options.cpp (212730 => 212731)


--- branches/safari-603-branch/Source/_javascript_Core/runtime/Options.cpp	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/_javascript_Core/runtime/Options.cpp	2017-02-21 19:27:02 UTC (rev 212731)
@@ -39,6 +39,7 @@
 #include <wtf/Compiler.h>
 #include <wtf/DataLog.h>
 #include <wtf/NumberOfCores.h>
+#include <wtf/SplitTest.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/StringExtras.h>
 #include <wtf/text/StringBuilder.h>
@@ -319,6 +320,17 @@
         Options::concurrentGCPeriodMS() = 10;
     } else
         Options::useStochasticMutatorScheduler() = true;
+
+    if (Options::useConcurrentGCSplitTesting()) {
+        if (Options::useConcurrentGC()) {
+            // Run an A/B split test on concurrent GC: if it was going to be on,
+            // turn it off with some probability. Do this deterministically per
+            // unique user identifier so that crashes don't skew statistics, and
+            // do it in a manner which can be reconstructed from a crash trace.
+            std::optional<bool> enableExperiment = SplitTest::singleton().enableBooleanExperiment();
+            Options::useConcurrentGC() = enableExperiment.value_or(true);
+        }
+    }
 }
 
 static void recomputeDependentOptions()

Modified: branches/safari-603-branch/Source/_javascript_Core/runtime/Options.h (212730 => 212731)


--- branches/safari-603-branch/Source/_javascript_Core/runtime/Options.h	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/_javascript_Core/runtime/Options.h	2017-02-21 19:27:02 UTC (rev 212731)
@@ -417,6 +417,8 @@
     v(bool, useCodeCache, true, Normal, "If false, the unlinked byte code cache will not be used.") \
     \
     v(bool, useWebAssembly, false, Normal, "Expose the WebAssembly global object.") \
+    \
+    v(bool, useConcurrentGCSplitTesting, true, Normal, "If true, A/B split testing will be performed on the concurrent GC, yielding a 50% chance that concurrent GC is disabled.") \
 
 enum OptionEquivalence {
     SameOption,

Modified: branches/safari-603-branch/Source/WTF/ChangeLog (212730 => 212731)


--- branches/safari-603-branch/Source/WTF/ChangeLog	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/WTF/ChangeLog	2017-02-21 19:27:02 UTC (rev 212731)
@@ -1,3 +1,25 @@
+2017-02-17  JF Bastien  <[email protected]>
+
+        A/B test concurrent GC
+        https://bugs.webkit.org/show_bug.cgi?id=168453
+        <rdar://problem/30553220>
+
+        Reviewed by Phil Pizlo.
+
+        Add the SplitTest singleton which can be used for A/B split
+        testing of features. It is currently initialized for WebKit2
+        WebContent processes, but the class is usable anywhere WTF can be
+        used (it returns an optional, which is valueless if not
+        initialized).
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/SplitTest.cpp: Added.
+        (WTF::SplitTest::singleton):
+        (WTF::SplitTest::initialize):
+        (WTF::SplitTest::enableBooleanExperiment):
+        * wtf/SplitTest.h: Added.
+
 2017-02-21  Matthew Hanson  <[email protected]>
 
         Merge r212692. rdar://problem/30475767

Modified: branches/safari-603-branch/Source/WTF/WTF.xcodeproj/project.pbxproj (212730 => 212731)


--- branches/safari-603-branch/Source/WTF/WTF.xcodeproj/project.pbxproj	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/WTF/WTF.xcodeproj/project.pbxproj	2017-02-21 19:27:02 UTC (rev 212731)
@@ -335,6 +335,8 @@
 		A8A47486151A825B004123FF /* WTFThreadData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A4737A151A825B004123FF /* WTFThreadData.cpp */; };
 		A8A47487151A825B004123FF /* WTFThreadData.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4737B151A825B004123FF /* WTFThreadData.h */; };
 		A8A4748C151A8264004123FF /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4748B151A8264004123FF /* config.h */; };
+		AD412B201E57BC92008AF157 /* SplitTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD412B1E1E57BC92008AF157 /* SplitTest.cpp */; };
+		AD412B211E57BC92008AF157 /* SplitTest.h in Headers */ = {isa = PBXBuildFile; fileRef = AD412B1F1E57BC92008AF157 /* SplitTest.h */; };
 		AD7C434B1DD2A4A70026888B /* Expected.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7C434A1DD2A4A70026888B /* Expected.h */; };
 		ADF2CE661E39F106006889DB /* MemoryFootprint.h in Headers */ = {isa = PBXBuildFile; fileRef = ADF2CE641E39F106006889DB /* MemoryFootprint.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		ADF2CE671E39F106006889DB /* MemoryFootprint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */; };
@@ -712,6 +714,8 @@
 		A8A4737A151A825B004123FF /* WTFThreadData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WTFThreadData.cpp; sourceTree = "<group>"; };
 		A8A4737B151A825B004123FF /* WTFThreadData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFThreadData.h; sourceTree = "<group>"; };
 		A8A4748B151A8264004123FF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
+		AD412B1E1E57BC92008AF157 /* SplitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SplitTest.cpp; sourceTree = "<group>"; };
+		AD412B1F1E57BC92008AF157 /* SplitTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplitTest.h; sourceTree = "<group>"; };
 		AD7C434A1DD2A4A70026888B /* Expected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Expected.h; sourceTree = "<group>"; };
 		ADF2CE641E39F106006889DB /* MemoryFootprint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryFootprint.h; sourceTree = "<group>"; };
 		ADF2CE651E39F106006889DB /* MemoryFootprint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryFootprint.cpp; sourceTree = "<group>"; };
@@ -870,6 +874,8 @@
 		A876DBD6151816E500DADB95 /* wtf */ = {
 			isa = PBXGroup;
 			children = (
+				AD412B1E1E57BC92008AF157 /* SplitTest.cpp */,
+				AD412B1F1E57BC92008AF157 /* SplitTest.h */,
 				2CDED0F018115C3F004DBA70 /* cf */,
 				E4A0AD3B1A96251900536DF6 /* cocoa */,
 				A8A47281151A825A004123FF /* dtoa */,
@@ -1456,6 +1462,7 @@
 				0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */,
 				143F61201565F0F900DB514A /* RAMSize.h in Headers */,
 				A8A47415151A825B004123FF /* RandomNumber.h in Headers */,
+				AD412B211E57BC92008AF157 /* SplitTest.h in Headers */,
 				A8A47416151A825B004123FF /* RandomNumberSeed.h in Headers */,
 				0F725CAC1C50461600AD943A /* RangeSet.h in Headers */,
 				0F87105A16643F190090B0AD /* RawPointer.h in Headers */,
@@ -1725,6 +1732,7 @@
 				A8A47443151A825B004123FF /* StringStatics.cpp in Sources */,
 				93F1993E19D7958D00C2390B /* StringView.cpp in Sources */,
 				93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */,
+				AD412B201E57BC92008AF157 /* SplitTest.cpp in Sources */,
 				93934BD318A1E8C300D0D6A1 /* StringViewObjC.mm in Sources */,
 				A8A473B7151A825B004123FF /* strtod.cc in Sources */,
 				52183012C99E476A84EEBEA8 /* SymbolImpl.cpp in Sources */,

Modified: branches/safari-603-branch/Source/WTF/wtf/CMakeLists.txt (212730 => 212731)


--- branches/safari-603-branch/Source/WTF/wtf/CMakeLists.txt	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/WTF/wtf/CMakeLists.txt	2017-02-21 19:27:02 UTC (rev 212731)
@@ -110,6 +110,7 @@
     Seconds.h
     SegmentedVector.h
     SmallPtrSet.h
+    SplitTest.h
     StackBounds.h
     StackStats.h
     StaticConstructors.h
@@ -222,6 +223,7 @@
     SHA1.cpp
     Seconds.cpp
     SixCharacterHash.cpp
+    SplitTest.cpp
     StackBounds.cpp
     StackStats.cpp
     StringPrintStream.cpp

Added: branches/safari-603-branch/Source/WTF/wtf/SplitTest.cpp (0 => 212731)


--- branches/safari-603-branch/Source/WTF/wtf/SplitTest.cpp	                        (rev 0)
+++ branches/safari-603-branch/Source/WTF/wtf/SplitTest.cpp	2017-02-21 19:27:02 UTC (rev 212731)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SplitTest.h"
+
+#include <wtf/Assertions.h>
+
+namespace WTF {
+
+SplitTest& SplitTest::singleton()
+{
+    static NeverDestroyed<SplitTest> splitTest;
+    return splitTest;
+}
+
+void SplitTest::initializeSingleton(uint64_t lo, uint64_t hi)
+{
+    // Double initialization with different values would be bad because it would
+    // provide different experiment results.
+    RELEASE_ASSERT(!m_initialized || (m_lo == lo && m_hi == hi));
+    m_lo = lo;
+    m_hi = hi;
+
+    m_initialized = true;
+}
+
+std::optional<bool> SplitTest::enableBooleanExperiment()
+{
+    if (!m_initialized)
+        return std::optional<bool>();
+
+    uint64_t value = m_lo ^ m_hi;
+    value = (value & 0xFFFFFFFFu) ^ (value >> 32);
+    value = (value & 0xFFFFu) ^ (value >> 16);
+    value = (value & 0xFFu) ^ (value >> 8);
+    value = (value & 0xFu) ^ (value >> 4);
+    value = (value & 0x3u) ^ (value >> 2);
+    value = (value & 0x1u) ^ (value >> 1);
+
+    return !!value;
+}
+
+} // namespace WTF

Added: branches/safari-603-branch/Source/WTF/wtf/SplitTest.h (0 => 212731)


--- branches/safari-603-branch/Source/WTF/wtf/SplitTest.h	                        (rev 0)
+++ branches/safari-603-branch/Source/WTF/wtf/SplitTest.h	2017-02-21 19:27:02 UTC (rev 212731)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <limits>
+#include <wtf/ExportMacros.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/Optional.h>
+
+namespace WTF {
+
+class SplitTest {
+    WTF_MAKE_FAST_ALLOCATED;
+    friend class WTF::NeverDestroyed<SplitTest>;
+public:
+    WTF_EXPORT static SplitTest& singleton();
+
+    WTF_EXPORT void initializeSingleton(uint64_t lo, uint64_t hi);
+
+    // FIXME: Query with a per-experiment unique ID to determine which experiment
+    // bucket the user should fall into. It's important to "salt" with unique
+    // experiment IDs so that users don't all fall in the same set of experiments
+    // when there are multiple experiments.
+    // Also add a version which returns a number in a provided [min, max] range,
+    // which is more useful for bucketed experiments.
+    // https://bugs.webkit.org/show_bug.cgi?id=168467
+    WTF_EXPORT std::optional<bool> enableBooleanExperiment();
+
+private:
+    uint64_t m_lo;
+    uint64_t m_hi;
+    bool m_initialized { false };
+};
+
+} // namespace WTF
+
+using WTF::SplitTest;

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (212730 => 212731)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-21 19:27:02 UTC (rev 212731)
@@ -1,3 +1,21 @@
+2017-02-17  JF Bastien  <[email protected]>
+
+        A/B test concurrent GC
+        https://bugs.webkit.org/show_bug.cgi?id=168453
+        <rdar://problem/30553220>
+
+        Reviewed by Phil Pizlo.
+
+        Initialize the WTF::SplitTest singleton using the anonymous UUID
+        from crash reporter. This makes it easy to figure out which A/B
+        split tests were enabled from a particular crash log.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/SplitTestInitializer.cpp: Added.
+        (getUUID):
+        (InitWebCoreSplitTest):
+        * platform/SplitTestInitializer.h: Copied from Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm.
+
 2017-02-21  Matthew Hanson  <[email protected]>
 
         Merge r212667. rdar://problem/29852056

Modified: branches/safari-603-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (212730 => 212731)


--- branches/safari-603-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-02-21 19:27:02 UTC (rev 212731)
@@ -4538,6 +4538,8 @@
 		ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */; };
 		AD03AAFA1468455300A39B5B /* CSSValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD03AAF81468453900A39B5B /* CSSValue.cpp */; };
 		AD20B18D18E9D237005A8083 /* JSNodeListCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		AD412B241E57C766008AF157 /* SplitTestInitializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD412B221E57C6DE008AF157 /* SplitTestInitializer.cpp */; };
+		AD412B251E57C773008AF157 /* SplitTestInitializer.h in Headers */ = {isa = PBXBuildFile; fileRef = AD412B231E57C6DE008AF157 /* SplitTestInitializer.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		AD4495F3141FC08900541EDF /* EventListenerMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4495F1141FC08900541EDF /* EventListenerMap.cpp */; };
 		AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4495F2141FC08900541EDF /* EventListenerMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		AD49914318F0815100BF0092 /* HTMLUnknownElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AD49914118F0815100BF0092 /* HTMLUnknownElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -12291,6 +12293,8 @@
 		ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderMenuList.h; sourceTree = "<group>"; };
 		AD03AAF81468453900A39B5B /* CSSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValue.cpp; sourceTree = "<group>"; };
 		AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNodeListCustom.h; sourceTree = "<group>"; };
+		AD412B221E57C6DE008AF157 /* SplitTestInitializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SplitTestInitializer.cpp; sourceTree = "<group>"; };
+		AD412B231E57C6DE008AF157 /* SplitTestInitializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplitTestInitializer.h; sourceTree = "<group>"; };
 		AD4495F1141FC08900541EDF /* EventListenerMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventListenerMap.cpp; sourceTree = "<group>"; };
 		AD4495F2141FC08900541EDF /* EventListenerMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventListenerMap.h; sourceTree = "<group>"; };
 		AD49914118F0815100BF0092 /* HTMLUnknownElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLUnknownElement.h; sourceTree = "<group>"; };
@@ -22554,6 +22558,8 @@
 		BCF1A5BA097832090061A123 /* platform */ = {
 			isa = PBXGroup;
 			children = (
+				AD412B221E57C6DE008AF157 /* SplitTestInitializer.cpp */,
+				AD412B231E57C6DE008AF157 /* SplitTestInitializer.h */,
 				49E912A40EFAC8E6009D0CAF /* animation */,
 				FD31604012B026A300C1A359 /* audio */,
 				1AE42F670AA4B8CB00C8612D /* cf */,
@@ -28329,6 +28335,7 @@
 				49C7B9CF1042D32F0009D447 /* WebGLFramebuffer.h in Headers */,
 				6E47E66110B7944B00B186C8 /* WebGLGetInfo.h in Headers */,
 				463763091E26FDD7008CD46D /* CPUTime.h in Headers */,
+				AD412B251E57C773008AF157 /* SplitTestInitializer.h in Headers */,
 				49FFBF3F11C93EE3006A7118 /* WebGLLayer.h in Headers */,
 				93F1D5BB12D532C400832BEC /* WebGLLoseContext.h in Headers */,
 				49C7B9D51042D32F0009D447 /* WebGLObject.h in Headers */,
@@ -30924,6 +30931,7 @@
 				1A58E86D1D19E42D00C0EA73 /* PaymentCoordinator.cpp in Sources */,
 				1ADA4A1C1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm in Sources */,
 				1A8A646E1D19FF8700D0E00F /* PaymentMethodCocoa.mm in Sources */,
+				AD412B241E57C766008AF157 /* SplitTestInitializer.cpp in Sources */,
 				1A58E8671D19D80E00C0EA73 /* PaymentRequest.cpp in Sources */,
 				1A8A64671D19FDFF00D0E00F /* PaymentRequestValidator.cpp in Sources */,
 				B27535640B053814002CE64F /* PDFDocumentImage.cpp in Sources */,

Added: branches/safari-603-branch/Source/WebCore/platform/SplitTestInitializer.cpp (0 => 212731)


--- branches/safari-603-branch/Source/WebCore/platform/SplitTestInitializer.cpp	                        (rev 0)
+++ branches/safari-603-branch/Source/WebCore/platform/SplitTestInitializer.cpp	2017-02-21 19:27:02 UTC (rev 212731)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SplitTestInitializer.h"
+
+#if !PLATFORM(IOS) && OS(DARWIN) && USE(APPLE_INTERNAL_SDK)
+
+#include <dlfcn.h>
+#include <mutex>
+#include <WebCore/SoftLinking.h>
+#include <wtf/ASCIICType.h>
+#include <wtf/Optional.h>
+#include <wtf/SplitTest.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK(CrashReporterSupport);
+SOFT_LINK(CrashReporterSupport, CRGetUserUUID, CFStringRef, (void), ());
+
+namespace {
+
+struct UUID {
+    uint64_t lo;
+    uint64_t hi;
+};
+
+std::optional<UUID> getUUID()
+{
+    // The UUID we're about to obtain contains 128-bit of data, encoded as a
+    // hexadecimal ASCII string with the following format:
+    //     FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
+    static constexpr const size_t maxBytes = 37;
+    static bool failed = true;
+    static UUID uuid = { 0, 0 };
+    static std::once_flag once;
+
+    std::call_once(once, [] {
+        // Always soft-fail, which will simply disable split testing.
+
+        char userUUID[maxBytes] = { '\0' };
+        CFStringRef (*softLinkCRGetUserUUID)(void) = (CFStringRef (*)(void)) dlsym(CrashReporterSupportLibrary(), "CRGetUserUUID");
+        if (!softLinkCRGetUserUUID)
+            return;
+
+        CFStringRef userUUIDString = CRGetUserUUID();
+        CFIndex length = CFStringGetLength(userUUIDString);
+        CFRange range = CFRangeMake(0, length);
+        CFIndex numConvertedCharacters = CFStringGetBytes(userUUIDString, range, kCFStringEncodingASCII, 0, false, reinterpret_cast<UInt8*>(userUUID), maxBytes - 1, nullptr);
+        if (numConvertedCharacters <= 0 || static_cast<size_t>(numConvertedCharacters) >= maxBytes)
+            return;
+
+        size_t nibblesDecoded = 0;
+        for (size_t position = 0; position < maxBytes; ++position) {
+            uint64_t nibble;
+            int c = toASCIILowerUnchecked(userUUID[position]);
+
+            if (c >= 'a' && c <= 'f')
+                nibble = c - 'a' + 10;
+            else if (c >= '0' && c <= '9')
+                nibble = c - '0';
+            else
+                continue; // Ignore non-hexdecimal ASCII nibbles.
+
+            if (nibblesDecoded < 64 / 4) {
+                uuid.lo <<= 4;
+                uuid.lo |= nibble;
+            } else {
+                uuid.hi <<= 4;
+                uuid.hi |= nibble;
+            }
+
+            ++nibblesDecoded;
+        }
+
+        failed = false;
+    });
+
+    return failed ? std::optional<UUID>() : uuid;
+}
+
+} // anonymous namespace
+
+void initSplitTest()
+{
+    std::optional<UUID> uuid = getUUID();
+    if (!uuid)
+        return;
+
+    SplitTest::singleton().initializeSingleton(uuid->lo, uuid->hi);
+}
+
+#else
+
+void initSplitTest()
+{
+    // Don't do split testing on other platforms.
+}
+
+#endif

Copied: branches/safari-603-branch/Source/WebCore/platform/SplitTestInitializer.h (from rev 212728, branches/safari-603-branch/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm) (0 => 212731)


--- branches/safari-603-branch/Source/WebCore/platform/SplitTestInitializer.h	                        (rev 0)
+++ branches/safari-603-branch/Source/WebCore/platform/SplitTestInitializer.h	2017-02-21 19:27:02 UTC (rev 212731)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WEBCORE_EXPORT void initSplitTest(void);
+
+#ifdef __cplusplus
+}
+#endif

Modified: branches/safari-603-branch/Source/WebKit2/ChangeLog (212730 => 212731)


--- branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-02-21 19:27:02 UTC (rev 212731)
@@ -1,3 +1,17 @@
+2017-02-17  JF Bastien  <[email protected]>
+
+        A/B test concurrent GC
+        https://bugs.webkit.org/show_bug.cgi?id=168453
+        <rdar://problem/30553220>
+
+        Reviewed by Phil Pizlo.
+
+        Initialize WTF::SplitTest early enough that other initialization
+        can use it.
+
+        * WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
+        (WebContentServiceInitializer):
+
 2017-02-20  Matthew Hanson  <[email protected]>
 
         Rollout r212660. rdar://problem/30553220

Modified: branches/safari-603-branch/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm (212730 => 212731)


--- branches/safari-603-branch/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm	2017-02-21 19:21:31 UTC (rev 212730)
+++ branches/safari-603-branch/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm	2017-02-21 19:27:02 UTC (rev 212731)
@@ -30,6 +30,8 @@
 #import "WebProcess.h"
 #import "XPCServiceEntryPoint.h"
 
+#import <WebCore/SplitTestInitializer.h>
+
 #if PLATFORM(IOS)
 #import <WebCore/GraphicsServicesSPI.h>
 #import <WebCore/WebCoreThreadSystemInterface.h>
@@ -51,5 +53,9 @@
     InitWebCoreThreadSystemInterface();
 #endif // PLATFORM(IOS)
 
+    // Initialize split testing early, so that other initialization can
+    // determine which experiments to run.
+    initSplitTest();
+
     XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(adoptOSObject(connection), initializerMessage, priorityBoostMessage);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to