Changeset 216217 in webkit


Ignore:
Timestamp:
May 4, 2017 4:24:13 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

NeverDestroyed<String>(ASCIILiteral(...)) is not thread safe.
https://bugs.webkit.org/show_bug.cgi?id=171586
<rdar://problem/31873190>

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

JavaScriptCore allows multiple VMs to be instantiated, and each of these should
be able to run concurrently on different threads. There is code in the VM that
allocates NeverDestroyed<String>(ASCIILiteral(...)) to defined immortal strings
meant to be shared by all VMs.

However, NeverDestroyed<String>(ASCIILiteral(...)) is not thread-safe because
each thread will ref and deref the underlying StringImpl. Since this ref and
deref is not done in a thread-safe way, the NeverDestroyed<String> may get
destroyed due to the ref/deref races. Additionally, each thread may modify the
StringImpl by setting its hash and also twiddling its flags.

The fix is to use the StaticStringImpl class which is safe for ref/derefing
concurrently from different threads. StaticStringImpl is also pre-set with a
hash on construction, and its flags are set in such a way as to prevent twiddling
at runtime. Hence, we will be able to share a NeverDestroyed<String> between
VMs, as long as it is backed by a StaticStringImpl.

An alternative solution would be to change all the uses of NeverDestroyed<String>
to use per-VM strings. However, this solution is cumbersome, and makes it harder
to allocate the intended shared string. It also uses more memory and takes more
CPU time because it requires allocating the same string for each VM instance.
The StaticStringImpl solution wins out because it is more efficient and is easier
to use.

The StaticStringImpl solution also can be used in WTF without a layer violation.
See Source/WTF/wtf/text/icu/TextBreakIteratorICU.h for an example.

Also added the MultithreadedMultiVMExecutionTest which runs multiple VMs in
multiple threads, all banging on the BuiltinExecutable's baseConstructorCode
NeverDestroyed<String>. The test will manifest the issue reliably (before this
fix) if run on an ASAN build.

  • API/tests/MultithreadedMultiVMExecutionTest.cpp: Added.

(threadsList):
(startMultithreadedMultiVMExecutionTest):
(finalizeMultithreadedMultiVMExecutionTest):

  • API/tests/MultithreadedMultiVMExecutionTest.h: Added.
  • API/tests/testapi.c:

(main):

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::createDefaultConstructor):

  • inspector/agents/InspectorDebuggerAgent.cpp:

(Inspector::objectGroupForBreakpointAction):

  • replay/scripts/CodeGeneratorReplayInputsTemplates.py:
  • replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::SavedMouseButton>::type):

  • replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::SavedMouseButton>::type):

  • replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::HandleWheelEvent>::type):

  • replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::FormCombo>::type):

  • replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::GetCurrentTime>::type):
(JSC::InputTraits<Test::SetRandomSeed>::type):

  • replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::ArrayOfThings>::type):
(JSC::InputTraits<Test::SavedHistory>::type):

  • replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::ScalarInput1>::type):
(JSC::InputTraits<Test::ScalarInput2>::type):

  • replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp:

(JSC::InputTraits<Test::ScalarInput>::type):
(JSC::InputTraits<Test::MapInput>::type):

  • runtime/IntlObject.cpp:

(JSC::numberingSystemsForLocale):

Source/WebCore:

No new tests because we're just converting uses of ASCIILiteral (in the
instantiation of NeverDestroyed<String> and NeverDestroyed<const String>) to
MAKE_STATIC_STRING_IMPL.

The correctness of using MAKE_STATIC_STRING_IMPL is tested in the newly added
API test in this patch.

Also changed "static NeverDestroyed<ASCIILiteral>" instances in
SQLiteIDBBackingStore.cpp to "static const char* const" because they are only
ever used to get the underlying const char*.

  • Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:

(WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::cachedStatementForGetAllObjectStoreRecords):

  • Modules/mediastream/MediaEndpointSessionDescription.cpp:
  • Modules/mediastream/RTCRtpTransceiver.cpp:
  • Modules/mediastream/SDPProcessor.cpp:
  • Modules/navigatorcontentutils/NavigatorContentUtils.cpp:

(WebCore::customHandlersStateString):
(WebCore::NavigatorContentUtils::isProtocolHandlerRegistered):

  • Modules/speech/SpeechSynthesis.cpp:

(WebCore::SpeechSynthesis::boundaryEventOccurred):

  • accessibility/AccessibilityMediaControls.cpp:

(WebCore::AccessibilityMediaControl::controlTypeName):
(WebCore::AccessibilityMediaControl::title):
(WebCore::AccessibilityMediaControlsContainer::elementTypeName):
(WebCore::AccessibilityMediaTimeline::helpText):
(WebCore::AccessibilityMediaTimeDisplay::accessibilityDescription):

  • bindings/js/JSLazyEventListener.cpp:

(WebCore::eventParameterName):

  • contentextensions/ContentExtensionsBackend.cpp:

(WebCore::ContentExtensions::ContentExtensionsBackend::displayNoneCSSRule):

  • css/CSSDefaultStyleSheets.cpp:

(WebCore::screenEval):
(WebCore::printEval):

  • css/MediaList.cpp:

(WebCore::addResolutionWarningMessageToConsole):

  • css/StyleSheetContents.cpp:

(WebCore::StyleSheetContents::parseAuthorStyleSheet):

  • dom/Document.cpp:

(WebCore::Document::readyState):

  • dom/LoadableClassicScript.cpp:

(WebCore::LoadableClassicScript::notifyFinished):

  • dom/PseudoElement.cpp:

(WebCore::PseudoElement::pseudoElementNameForEvents):

  • editing/MarkupAccumulator.cpp:

(WebCore::MarkupAccumulator::shouldAddNamespaceElement):

  • editing/cocoa/DataDetection.mm:

(WebCore::DataDetection::dataDetectorURLProtocol):

  • editing/markup.cpp:

(WebCore::StyledMarkupAccumulator::styleNodeCloseTag):
(WebCore::createMarkupInternal):

  • html/FormController.cpp:

(WebCore::formStateSignature):

  • html/ImageInputType.cpp:

(WebCore::ImageInputType::appendFormData):

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::realizeSaves):
(WebCore::CanvasRenderingContext2D::getImageData):

  • html/parser/XSSAuditor.cpp:

(WebCore::XSSAuditor::init):
(WebCore::XSSAuditor::eraseDangerousAttributesIfInjected):

  • html/track/VTTCue.cpp:

(WebCore::startKeyword):
(WebCore::middleKeyword):
(WebCore::endKeyword):
(WebCore::leftKeyword):
(WebCore::rightKeyword):
(WebCore::verticalGrowingLeftKeyword):
(WebCore::verticalGrowingRightKeyword):
(WebCore::VTTCue::determineTextDirection):
(WebCore::VTTCue::markFutureAndPastNodes):

  • inspector/InspectorCSSAgent.cpp:

(WebCore::computePseudoClassMask):

  • inspector/InspectorIndexedDBAgent.cpp:
  • inspector/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::sourceMapURLForResource):

  • inspector/PageDebuggerAgent.cpp:

(WebCore::PageDebuggerAgent::sourceMapURLForScript):

  • loader/ImageLoader.cpp:

(WebCore::ImageLoader::notifyFinished):

  • loader/TextTrackLoader.cpp:

(WebCore::TextTrackLoader::corsPolicyPreventedLoad):

  • loader/icon/IconDatabase.cpp:

(WebCore::IconDatabase::defaultDatabaseFilename):

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS):

  • page/SecurityOrigin.cpp:

(WebCore::SecurityOrigin::urlWithUniqueSecurityOrigin):

  • page/UserContentURLPattern.cpp:

(WebCore::UserContentURLPattern::parse):

  • platform/MIMETypeRegistry.cpp:

(WebCore::defaultMIMEType):

  • platform/animation/Animation.cpp:

(WebCore::Animation::initialName):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::engineDescription):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::engineDescription):

  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::FontCache::similarFont):

  • platform/gtk/UserAgentGtk.cpp:

(WebCore::platformVersionForUAString):

  • platform/mock/mediasource/MockBox.cpp:

(WebCore::MockTrackBox::type):
(WebCore::MockInitializationBox::type):
(WebCore::MockSampleBox::type):

  • platform/network/HTTPHeaderValues.cpp:

(WebCore::HTTPHeaderValues::textPlainContentType):
(WebCore::HTTPHeaderValues::formURLEncodedContentType):
(WebCore::HTTPHeaderValues::noCache):
(WebCore::HTTPHeaderValues::maxAge0):

  • platform/network/HTTPParsers.cpp:

(WebCore::parseXSSProtectionHeader):

  • replay/MemoizedDOMResult.cpp:

(JSC::InputTraits<MemoizedDOMResultBase>::type):

  • svg/SVGTransformValue.cpp:

(WebCore::SVGTransformValue::transformTypePrefixForParsing):

Source/WebKit2:

  • Shared/API/APIError.cpp:

(API::Error::webKitErrorDomain):
(API::Error::webKitNetworkErrorDomain):
(API::Error::webKitPolicyErrorDomain):
(API::Error::webKitPluginErrorDomain):
(API::Error::webKitDownloadErrorDomain):
(API::Error::webKitPrintErrorDomain):

  • Shared/WebPreferencesKeys.cpp:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::executeEditCommand):

  • WebProcess/WebCoreSupport/WebEditorClient.cpp:

(WebKit::WebEditorClient::didBeginEditing):
(WebKit::WebEditorClient::respondToChangedContents):
(WebKit::WebEditorClient::respondToChangedSelection):
(WebKit::WebEditorClient::didEndEditing):

Source/WTF:

StaticStringImpl is meant to be thread-safe. However, it has a bug: it did not
set the s_hashFlagDidReportCost flag. As a result, if cost() is called on it,
different threads may try to change its flags bits at the same time. This patch
changes StaticStringImpl to always set the s_hashFlagDidReportCost flag.

Also factored out StringImplShape and made StringImpl and StaticStringImpl extend
it. This makes it more clear that the 2 are intended to have the same shape.
Note: there is already a static_assert that the 2 have the same size. This
change also ensures that they both have the same shape, which is a requirement in
order for StaticStringImpl to work.

Introduced the MAKE_STATIC_STRING_IMPL macro as a convenient way to instantiate
StaticStringImpls from literal strings. This allows us to trivially change

NeverDestroyed<String> myString(ASCIILiteral("myString"));

to ...

NeverDestroyed<String> myString(MAKE_STATIC_STRING_IMPL("myString"));

and by so doing, make it thread-safe.

MAKE_STATIC_STRING_IMPL instantiates a lambda function to create the static
StaticStringImpls.

  • wtf/text/StringImpl.h:

(WTF::StringImplShape::StringImplShape):
(WTF::StringImpl::StringImpl):
(WTF::StringImpl::cost):
(WTF::StringImpl::setHash):
(WTF::StringImpl::StaticStringImpl::StaticStringImpl):
(WTF::StringImpl::StaticStringImpl::operator StringImpl&):

  • wtf/text/WTFString.h:

(WTF::String::String):

  • wtf/text/icu/TextBreakIteratorICU.h:

(WTF::caretRules):

Tools:

API test for exercising StaticStringImpl and the MAKE_STATIC_STRING_IMPL macro.

  • TestWebKitAPI/Tests/WTF/StringImpl.cpp:

(TestWebKitAPI::neverDestroyedString):
(TestWebKitAPI::getNeverDestroyedStringAtStackDepth):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
2 added
71 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/tests/testapi.c

    r216109 r216217  
    4848#include "GlobalContextWithFinalizerTest.h"
    4949#include "JSONParseTest.h"
     50#include "MultithreadedMultiVMExecutionTest.h"
    5051#include "PingPongStackOverflowTest.h"
    5152#include "TypedArrayCTest.h"
     
    11911192
    11921193    testCompareAndSwap();
     1194    startMultithreadedMultiVMExecutionTest();
    11931195
    11941196#if JSC_OBJC_API_ENABLED
     
    20092011    globalObjectPrivatePropertyTest();
    20102012
     2013    failed = finalizeMultithreadedMultiVMExecutionTest() || failed;
     2014
    20112015    if (failed) {
    20122016        printf("FAIL: Some tests failed.\n");
  • trunk/Source/JavaScriptCore/ChangeLog

    r216206 r216217  
     12017-05-04  Mark Lam  <mark.lam@apple.com>
     2
     3        NeverDestroyed<String>(ASCIILiteral(...)) is not thread safe.
     4        https://bugs.webkit.org/show_bug.cgi?id=171586
     5        <rdar://problem/31873190>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        JavaScriptCore allows multiple VMs to be instantiated, and each of these should
     10        be able to run concurrently on different threads.  There is code in the VM that
     11        allocates NeverDestroyed<String>(ASCIILiteral(...)) to defined immortal strings
     12        meant to be shared by all VMs.
     13
     14        However, NeverDestroyed<String>(ASCIILiteral(...)) is not thread-safe because
     15        each thread will ref and deref the underlying StringImpl.  Since this ref and
     16        deref is not done in a thread-safe way, the NeverDestroyed<String> may get
     17        destroyed due to the ref/deref races.  Additionally, each thread may modify the
     18        StringImpl by setting its hash and also twiddling its flags.
     19
     20        The fix is to use the StaticStringImpl class which is safe for ref/derefing
     21        concurrently from different threads.  StaticStringImpl is also pre-set with a
     22        hash on construction, and its flags are set in such a way as to prevent twiddling
     23        at runtime.  Hence, we will be able to share a NeverDestroyed<String> between
     24        VMs, as long as it is backed by a StaticStringImpl.
     25
     26        An alternative solution would be to change all the uses of NeverDestroyed<String>
     27        to use per-VM strings.  However, this solution is cumbersome, and makes it harder
     28        to allocate the intended shared string.  It also uses more memory and takes more
     29        CPU time because it requires allocating the same string for each VM instance.
     30        The StaticStringImpl solution wins out because it is more efficient and is easier
     31        to use.
     32
     33        The StaticStringImpl solution also can be used in WTF without a layer violation.
     34        See Source/WTF/wtf/text/icu/TextBreakIteratorICU.h for an example.
     35
     36        Also added the MultithreadedMultiVMExecutionTest which runs multiple VMs in
     37        multiple threads, all banging on the BuiltinExecutable's baseConstructorCode
     38        NeverDestroyed<String>.  The test will manifest the issue reliably (before this
     39        fix) if run on an ASAN build.
     40
     41        * API/tests/MultithreadedMultiVMExecutionTest.cpp: Added.
     42        (threadsList):
     43        (startMultithreadedMultiVMExecutionTest):
     44        (finalizeMultithreadedMultiVMExecutionTest):
     45        * API/tests/MultithreadedMultiVMExecutionTest.h: Added.
     46        * API/tests/testapi.c:
     47        (main):
     48        * JavaScriptCore.xcodeproj/project.pbxproj:
     49        * builtins/BuiltinExecutables.cpp:
     50        (JSC::BuiltinExecutables::createDefaultConstructor):
     51        * inspector/agents/InspectorDebuggerAgent.cpp:
     52        (Inspector::objectGroupForBreakpointAction):
     53        * replay/scripts/CodeGeneratorReplayInputsTemplates.py:
     54        * replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp:
     55        (JSC::InputTraits<Test::SavedMouseButton>::type):
     56        * replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp:
     57        (JSC::InputTraits<Test::SavedMouseButton>::type):
     58        * replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp:
     59        (JSC::InputTraits<Test::HandleWheelEvent>::type):
     60        * replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp:
     61        (JSC::InputTraits<Test::FormCombo>::type):
     62        * replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp:
     63        (JSC::InputTraits<Test::GetCurrentTime>::type):
     64        (JSC::InputTraits<Test::SetRandomSeed>::type):
     65        * replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp:
     66        (JSC::InputTraits<Test::ArrayOfThings>::type):
     67        (JSC::InputTraits<Test::SavedHistory>::type):
     68        * replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp:
     69        (JSC::InputTraits<Test::ScalarInput1>::type):
     70        (JSC::InputTraits<Test::ScalarInput2>::type):
     71        * replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp:
     72        (JSC::InputTraits<Test::ScalarInput>::type):
     73        (JSC::InputTraits<Test::MapInput>::type):
     74        * runtime/IntlObject.cpp:
     75        (JSC::numberingSystemsForLocale):
     76
    1772017-05-04  Sam Weinig  <sam@webkit.org>
    278
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r216078 r216217  
    24932493                FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
    24942494                FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
     2495                FEF49AAB1EB9484B00653BDB /* MultithreadedMultiVMExecutionTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF49AA91EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.cpp */; };
    24952496                FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    24962497/* End PBXBuildFile section */
     
    51435144                FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = "<group>"; };
    51445145                FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = "<group>"; };
     5146                FEF49AA91EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MultithreadedMultiVMExecutionTest.cpp; path = API/tests/MultithreadedMultiVMExecutionTest.cpp; sourceTree = "<group>"; };
     5147                FEF49AAA1EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MultithreadedMultiVMExecutionTest.h; path = API/tests/MultithreadedMultiVMExecutionTest.h; sourceTree = "<group>"; };
    51455148                FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = "<group>"; };
    51465149/* End PBXFileReference section */
     
    57775780                                5C4E8E941DBEBDA20036F1FC /* JSONParseTest.cpp */,
    57785781                                5C4E8E951DBEBDA20036F1FC /* JSONParseTest.h */,
     5782                                FEF49AA91EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.cpp */,
     5783                                FEF49AAA1EB947FE00653BDB /* MultithreadedMultiVMExecutionTest.h */,
    57795784                                144005170A531CB50005F061 /* minidom */,
    57805785                                FEDA50D41B97F442009A3B4F /* PingPongStackOverflowTest.cpp */,
     
    1003610041                                FECB8B271D25BB85006F2463 /* FunctionOverridesTest.cpp in Sources */,
    1003710042                                FE0D4A091ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp in Sources */,
     10043                                FEF49AAB1EB9484B00653BDB /* MultithreadedMultiVMExecutionTest.cpp in Sources */,
    1003810044                                C2181FC218A948FB0025A235 /* JSExportTests.mm in Sources */,
    1003910045                                5C4E8E961DBEBE620036F1FC /* JSONParseTest.cpp in Sources */,
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp

    r210149 r216217  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545UnlinkedFunctionExecutable* BuiltinExecutables::createDefaultConstructor(ConstructorKind constructorKind, const Identifier& name)
    4646{
    47     static NeverDestroyed<const String> baseConstructorCode(ASCIILiteral("(function () { })"));
    48     static NeverDestroyed<const String> derivedConstructorCode(ASCIILiteral("(function (...args) { super(...args); })"));
     47    static NeverDestroyed<const String> baseConstructorCode(MAKE_STATIC_STRING_IMPL("(function () { })"));
     48    static NeverDestroyed<const String> derivedConstructorCode(MAKE_STATIC_STRING_IMPL("(function (...args) { super(...args); })"));
    4949
    5050    switch (constructorKind) {
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp

    r212448 r216217  
    11/*
    2  * Copyright (C) 2010, 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
    44 *
     
    5757static String objectGroupForBreakpointAction(const ScriptBreakpointAction& action)
    5858{
    59     static NeverDestroyed<String> objectGroup(ASCIILiteral("breakpoint-action-"));
     59    static NeverDestroyed<String> objectGroup(MAKE_STATIC_STRING_IMPL("breakpoint-action-"));
    6060    return makeString(objectGroup.get(), String::number(action.identifier));
    6161}
  • trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py

    r206533 r216217  
    22# Copyright (c) 2011 Google Inc. All rights reserved.
    33# Copyright (c) 2012 Intel Corporation. All rights reserved.
    4 # Copyright (c) 2013, 2014, 2016 Apple Inc. All rights reserved.
     4# Copyright (c) 2013-2017 Apple Inc. All rights reserved.
    55#
    66# Redistribution and use in source and binary forms, with or without
     
    151151    """const String& InputTraits<${qualifiedInputName}>::type()
    152152{
    153     static NeverDestroyed<const String> type(ASCIILiteral(${inputNameStringLiteral}));
     153    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL(${inputNameStringLiteral}));
    154154    return type;
    155155}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp

    r178714 r216217  
    5151const String& InputTraits<Test::SavedMouseButton>::type()
    5252{
    53     static NeverDestroyed<const String> type(ASCIILiteral("SavedMouseButton"));
     53    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("SavedMouseButton"));
    5454    return type;
    5555}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp

    r206099 r216217  
    5252const String& InputTraits<Test::SavedMouseButton>::type()
    5353{
    54     static NeverDestroyed<const String> type(ASCIILiteral("SavedMouseButton"));
     54    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("SavedMouseButton"));
    5555    return type;
    5656}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp

    r194496 r216217  
    5353const String& InputTraits<Test::HandleWheelEvent>::type()
    5454{
    55     static NeverDestroyed<const String> type(ASCIILiteral("HandleWheelEvent"));
     55    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("HandleWheelEvent"));
    5656    return type;
    5757}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp

    r178714 r216217  
    5353const String& InputTraits<Test::FormCombo>::type()
    5454{
    55     static NeverDestroyed<const String> type(ASCIILiteral("FormCombo"));
     55    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("FormCombo"));
    5656    return type;
    5757}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-guard.json-TestReplayInputs.cpp

    r174113 r216217  
    6363const String& InputTraits<Test::GetCurrentTime>::type()
    6464{
    65     static NeverDestroyed<const String> type(ASCIILiteral("GetCurrentTime"));
     65    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("GetCurrentTime"));
    6666    return type;
    6767}
     
    8585const String& InputTraits<Test::SetRandomSeed>::type()
    8686{
    87     static NeverDestroyed<const String> type(ASCIILiteral("SetRandomSeed"));
     87    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("SetRandomSeed"));
    8888    return type;
    8989}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-input-with-vector-members.json-TestReplayInputs.cpp

    r174113 r216217  
    6464const String& InputTraits<Test::ArrayOfThings>::type()
    6565{
    66     static NeverDestroyed<const String> type(ASCIILiteral("ArrayOfThings"));
     66    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("ArrayOfThings"));
    6767    return type;
    6868}
     
    9595const String& InputTraits<Test::SavedHistory>::type()
    9696{
    97     static NeverDestroyed<const String> type(ASCIILiteral("SavedHistory"));
     97    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("SavedHistory"));
    9898    return type;
    9999}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-inputs-with-flags.json-TestReplayInputs.cpp

    r174113 r216217  
    6060const String& InputTraits<Test::ScalarInput1>::type()
    6161{
    62     static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput1"));
     62    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("ScalarInput1"));
    6363    return type;
    6464}
     
    8181const String& InputTraits<Test::ScalarInput2>::type()
    8282{
    83     static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput2"));
     83    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("ScalarInput2"));
    8484    return type;
    8585}
  • trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-memoized-type-modes.json-TestReplayInputs.cpp

    r194496 r216217  
    6060const String& InputTraits<Test::ScalarInput>::type()
    6161{
    62     static NeverDestroyed<const String> type(ASCIILiteral("ScalarInput"));
     62    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("ScalarInput"));
    6363    return type;
    6464}
     
    8181const String& InputTraits<Test::MapInput>::type()
    8282{
    83     static NeverDestroyed<const String> type(ASCIILiteral("MapInput"));
     83    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("MapInput"));
    8484    return type;
    8585}
  • trunk/Source/JavaScriptCore/runtime/IntlObject.cpp

    r216122 r216217  
    854854    static NeverDestroyed<Vector<String>> cachedNumberingSystems;
    855855    Vector<String>& availableNumberingSystems = cachedNumberingSystems.get();
    856     if (availableNumberingSystems.isEmpty()) {
    857         UErrorCode status = U_ZERO_ERROR;
    858         UEnumeration* numberingSystemNames = unumsys_openAvailableNames(&status);
    859         ASSERT(U_SUCCESS(status));
    860 
    861         int32_t resultLength;
    862         // Numbering system names are always ASCII, so use char[].
    863         while (const char* result = uenum_next(numberingSystemNames, &resultLength, &status)) {
     856
     857    if (UNLIKELY(availableNumberingSystems.isEmpty())) {
     858        static StaticLock cachedNumberingSystemsMutex;
     859        std::lock_guard<StaticLock> lock(cachedNumberingSystemsMutex);
     860        if (availableNumberingSystems.isEmpty()) {
     861            UErrorCode status = U_ZERO_ERROR;
     862            UEnumeration* numberingSystemNames = unumsys_openAvailableNames(&status);
    864863            ASSERT(U_SUCCESS(status));
    865             availableNumberingSystems.append(String(result, resultLength));
    866         }
    867         uenum_close(numberingSystemNames);
     864
     865            int32_t resultLength;
     866            // Numbering system names are always ASCII, so use char[].
     867            while (const char* result = uenum_next(numberingSystemNames, &resultLength, &status)) {
     868                ASSERT(U_SUCCESS(status));
     869                availableNumberingSystems.append(String(result, resultLength));
     870            }
     871            uenum_close(numberingSystemNames);
     872        }
    868873    }
    869874
  • trunk/Source/WTF/ChangeLog

    r216206 r216217  
     12017-05-04  Mark Lam  <mark.lam@apple.com>
     2
     3        NeverDestroyed<String>(ASCIILiteral(...)) is not thread safe.
     4        https://bugs.webkit.org/show_bug.cgi?id=171586
     5        <rdar://problem/31873190>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        StaticStringImpl is meant to be thread-safe.  However, it has a bug: it did not
     10        set the s_hashFlagDidReportCost flag.  As a result, if cost() is called on it,
     11        different threads may try to change its flags bits at the same time.  This patch
     12        changes StaticStringImpl to always set the s_hashFlagDidReportCost flag.
     13
     14        Also factored out StringImplShape and made StringImpl and StaticStringImpl extend
     15        it.  This makes it more clear that the 2 are intended to have the same shape.
     16        Note: there is already a static_assert that the 2 have the same size.  This
     17        change also ensures that they both have the same shape, which is a requirement in
     18        order for StaticStringImpl to work.
     19
     20        Introduced the MAKE_STATIC_STRING_IMPL macro as a convenient way to instantiate
     21        StaticStringImpls from literal strings.  This allows us to trivially change
     22
     23            NeverDestroyed<String> myString(ASCIILiteral("myString"));
     24
     25        to ...
     26
     27            NeverDestroyed<String> myString(MAKE_STATIC_STRING_IMPL("myString"));
     28
     29        and by so doing, make it thread-safe.
     30
     31        MAKE_STATIC_STRING_IMPL instantiates a lambda function to create the static
     32        StaticStringImpls.
     33
     34        * wtf/text/StringImpl.h:
     35        (WTF::StringImplShape::StringImplShape):
     36        (WTF::StringImpl::StringImpl):
     37        (WTF::StringImpl::cost):
     38        (WTF::StringImpl::setHash):
     39        (WTF::StringImpl::StaticStringImpl::StaticStringImpl):
     40        (WTF::StringImpl::StaticStringImpl::operator StringImpl&):
     41        * wtf/text/WTFString.h:
     42        (WTF::String::String):
     43        * wtf/text/icu/TextBreakIteratorICU.h:
     44        (WTF::caretRules):
     45
    1462017-05-04  Sam Weinig  <sam@webkit.org>
    247
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r215345 r216217  
    11/*
    22 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2005-2010, 2013-2016 Apple Inc. All rights reserved.
     3 * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
    44 * Copyright (C) 2009 Google Inc. All rights reserved.
    55 *
     
    130130#endif
    131131
    132 class StringImpl {
     132class StringImplShape {
     133    WTF_MAKE_NONCOPYABLE(StringImplShape);
     134protected:
     135    StringImplShape(unsigned refCount, unsigned length, const LChar* data8, unsigned hashAndFlags)
     136        : m_refCount(refCount)
     137        , m_length(length)
     138        , m_data8(data8)
     139        , m_hashAndFlags(hashAndFlags)
     140    { }
     141
     142    StringImplShape(unsigned refCount, unsigned length, const UChar* data16, unsigned hashAndFlags)
     143        : m_refCount(refCount)
     144        , m_length(length)
     145        , m_data16(data16)
     146        , m_hashAndFlags(hashAndFlags)
     147    { }
     148
     149    template<unsigned charactersCount>
     150    constexpr StringImplShape(unsigned refCount, unsigned length, const char (&characters)[charactersCount], unsigned hashAndFlags)
     151        : m_refCount(refCount)
     152        , m_length(length)
     153        , m_data8(reinterpret_cast<const LChar*>(characters))
     154        , m_hashAndFlags(hashAndFlags)
     155    { }
     156   
     157    template<unsigned charactersCount>
     158    constexpr StringImplShape(unsigned refCount, unsigned length, const char16_t (&characters)[charactersCount], unsigned hashAndFlags)
     159        : m_refCount(refCount)
     160        , m_length(length)
     161        , m_data16(reinterpret_cast<const UChar*>(characters))
     162        , m_hashAndFlags(hashAndFlags)
     163    { }
     164
     165    unsigned m_refCount;
     166    unsigned m_length;
     167    union {
     168        const LChar* m_data8;
     169        const UChar* m_data16;
     170    };
     171    mutable unsigned m_hashAndFlags;
     172};
     173
     174class StringImpl : private StringImplShape {
    133175    WTF_MAKE_NONCOPYABLE(StringImpl); WTF_MAKE_FAST_ALLOCATED;
    134176    friend struct WTF::CStringTranslator;
     
    175217    // Create a normal 8-bit string with internal storage (BufferInternal)
    176218    StringImpl(unsigned length, Force8Bit)
    177         : m_refCount(s_refCountIncrement)
    178         , m_length(length)
    179         , m_data8(tailPointer<LChar>())
    180         , m_hashAndFlags(s_hashFlag8BitBuffer | StringNormal | BufferInternal)
     219        : StringImplShape(s_refCountIncrement, length, tailPointer<LChar>(), s_hashFlag8BitBuffer | StringNormal | BufferInternal)
    181220    {
    182221        ASSERT(m_data8);
     
    188227    // Create a normal 16-bit string with internal storage (BufferInternal)
    189228    StringImpl(unsigned length)
    190         : m_refCount(s_refCountIncrement)
    191         , m_length(length)
    192         , m_data16(tailPointer<UChar>())
    193         , m_hashAndFlags(StringNormal | BufferInternal)
     229        : StringImplShape(s_refCountIncrement, length, tailPointer<UChar>(), StringNormal | BufferInternal)
    194230    {
    195231        ASSERT(m_data16);
     
    201237    // Create a StringImpl adopting ownership of the provided buffer (BufferOwned)
    202238    StringImpl(MallocPtr<LChar> characters, unsigned length)
    203         : m_refCount(s_refCountIncrement)
    204         , m_length(length)
    205         , m_data8(characters.leakPtr())
    206         , m_hashAndFlags(s_hashFlag8BitBuffer | StringNormal | BufferOwned)
     239        : StringImplShape(s_refCountIncrement, length, characters.leakPtr(), s_hashFlag8BitBuffer | StringNormal | BufferOwned)
    207240    {
    208241        ASSERT(m_data8);
     
    214247    enum ConstructWithoutCopyingTag { ConstructWithoutCopying };
    215248    StringImpl(const UChar* characters, unsigned length, ConstructWithoutCopyingTag)
    216         : m_refCount(s_refCountIncrement)
    217         , m_length(length)
    218         , m_data16(characters)
    219         , m_hashAndFlags(StringNormal | BufferInternal)
     249        : StringImplShape(s_refCountIncrement, length, characters, StringNormal | BufferInternal)
    220250    {
    221251        ASSERT(m_data16);
     
    226256
    227257    StringImpl(const LChar* characters, unsigned length, ConstructWithoutCopyingTag)
    228         : m_refCount(s_refCountIncrement)
    229         , m_length(length)
    230         , m_data8(characters)
    231         , m_hashAndFlags(s_hashFlag8BitBuffer | StringNormal | BufferInternal)
     258        : StringImplShape(s_refCountIncrement, length, characters, s_hashFlag8BitBuffer | StringNormal | BufferInternal)
    232259    {
    233260        ASSERT(m_data8);
     
    239266    // Create a StringImpl adopting ownership of the provided buffer (BufferOwned)
    240267    StringImpl(MallocPtr<UChar> characters, unsigned length)
    241         : m_refCount(s_refCountIncrement)
    242         , m_length(length)
    243         , m_data16(characters.leakPtr())
    244         , m_hashAndFlags(StringNormal | BufferOwned)
     268        : StringImplShape(s_refCountIncrement, length, characters.leakPtr(), StringNormal | BufferOwned)
    245269    {
    246270        ASSERT(m_data16);
     
    252276    // Used to create new strings that are a substring of an existing 8-bit StringImpl (BufferSubstring)
    253277    StringImpl(const LChar* characters, unsigned length, Ref<StringImpl>&& base)
    254         : m_refCount(s_refCountIncrement)
    255         , m_length(length)
    256         , m_data8(characters)
    257         , m_hashAndFlags(s_hashFlag8BitBuffer | StringNormal | BufferSubstring)
     278        : StringImplShape(s_refCountIncrement, length, characters, s_hashFlag8BitBuffer | StringNormal | BufferSubstring)
    258279    {
    259280        ASSERT(is8Bit());
     
    269290    // Used to create new strings that are a substring of an existing 16-bit StringImpl (BufferSubstring)
    270291    StringImpl(const UChar* characters, unsigned length, Ref<StringImpl>&& base)
    271         : m_refCount(s_refCountIncrement)
    272         , m_length(length)
    273         , m_data16(characters)
    274         , m_hashAndFlags(StringNormal | BufferSubstring)
     292        : StringImplShape(s_refCountIncrement, length, characters, StringNormal | BufferSubstring)
    275293    {
    276294        ASSERT(!is8Bit());
     
    400418            return substringBuffer()->cost();
    401419
     420        // Note: we must not alter the m_hashAndFlags field in instances of StaticStringImpl.
     421        // We ensure this by pre-setting the s_hashFlagDidReportCost bit in all instances of
     422        // StaticStringImpl. As a result, StaticStringImpl instances will always return a cost of
     423        // 0 here and avoid modifying m_hashAndFlags.
    402424        if (m_hashAndFlags & s_hashFlagDidReportCost)
    403425            return 0;
     
    461483    {
    462484        ASSERT(!hasHash());
     485        ASSERT(!isStatic());
    463486        // Multiple clients assume that StringHasher is the canonical string hash function.
    464487        ASSERT(hash == (is8Bit() ? StringHasher::computeHashAndMaskTop8Bits(m_data8, m_length) : StringHasher::computeHashAndMaskTop8Bits(m_data16, m_length)));
     
    538561    }
    539562
    540     class StaticStringImpl {
     563    class StaticStringImpl : private StringImplShape {
    541564        WTF_MAKE_NONCOPYABLE(StaticStringImpl);
    542565    public:
     
    544567        // This means that the static string will never be destroyed, which is important because
    545568        // static strings will be shared across threads & ref-counted in a non-threadsafe manner.
     569        //
     570        // In order to make StaticStringImpl thread safe, we also need to ensure that the rest of
     571        // the fields are never mutated by threads. We have this guarantee because:
     572        //
     573        // 1. m_length is only set on construction and never mutated thereafter.
     574        //
     575        // 2. m_data8 and m_data16 are only set on construction and never mutated thereafter.
     576        //    We also know that a StringImpl never changes from 8 bit to 16 bit because there
     577        //    is no way to set/clear the s_hashFlag8BitBuffer flag other than at construction.
     578        //
     579        // 3. m_hashAndFlags will not be mutated by different threads because:
     580        //
     581        //    a. StaticStringImpl's constructor sets the s_hashFlagDidReportCost flag to ensure
     582        //       that StringImpl::cost() returns early.
     583        //       This means StaticStringImpl costs are not counted. But since there should only
     584        //       be a finite set of StaticStringImpls, their cost can be aggregated into a single
     585        //       system cost if needed.
     586        //    b. setIsAtomic() is never called on a StaticStringImpl.
     587        //       setIsAtomic() asserts !isStatic().
     588        //    c. setHash() is never called on a StaticStringImpl.
     589        //       StaticStringImpl's constructor sets the hash on construction.
     590        //       StringImpl::hash() only sets a new hash iff !hasHash().
     591        //       Additionally, StringImpl::setHash() asserts hasHash() and !isStatic().
     592
    546593        template<unsigned charactersCount>
    547594        constexpr StaticStringImpl(const char (&characters)[charactersCount], StringKind stringKind = StringNormal)
    548             : m_refCount(s_refCountFlagIsStaticString)
    549             , m_length(charactersCount - 1)
    550             , m_data8(characters)
    551             , m_hashAndFlags(s_hashFlag8BitBuffer | stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount))
     595            : StringImplShape(s_refCountFlagIsStaticString, charactersCount - 1, characters,
     596                s_hashFlag8BitBuffer | s_hashFlagDidReportCost | stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount))
    552597        {
    553598        }
     
    555600        template<unsigned charactersCount>
    556601        constexpr StaticStringImpl(const char16_t (&characters)[charactersCount], StringKind stringKind = StringNormal)
    557             : m_refCount(s_refCountFlagIsStaticString)
    558             , m_length(charactersCount - 1)
    559             , m_data16(characters)
    560             , m_hashAndFlags(stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount))
     602            : StringImplShape(s_refCountFlagIsStaticString, charactersCount - 1, characters,
     603                s_hashFlagDidReportCost | stringKind | BufferInternal | (StringHasher::computeLiteralHashAndMaskTop8Bits(characters) << s_flagCount))
    561604        {
    562605        }
     
    566609            return *reinterpret_cast<StringImpl*>(this);
    567610        }
    568 
    569         // These member variables must match the layout of StringImpl.
    570         unsigned m_refCount;
    571         unsigned m_length;
    572         union {
    573             const char* m_data8;
    574             const char16_t* m_data16;
    575         };
    576         unsigned m_hashAndFlags;
    577611    };
    578612
     
    740774    // Used to create new symbol strings that holds existing 8-bit [[Description]] string as a substring buffer (BufferSubstring).
    741775    StringImpl(CreateSymbolTag, const LChar* characters, unsigned length)
    742         : m_refCount(s_refCountIncrement)
    743         , m_length(length)
    744         , m_data8(characters)
    745         , m_hashAndFlags(s_hashFlag8BitBuffer | StringSymbol | BufferSubstring)
     776        : StringImplShape(s_refCountIncrement, length, characters, s_hashFlag8BitBuffer | StringSymbol | BufferSubstring)
    746777    {
    747778        ASSERT(is8Bit());
     
    752783    // Used to create new symbol strings that holds existing 16-bit [[Description]] string as a substring buffer (BufferSubstring).
    753784    StringImpl(CreateSymbolTag, const UChar* characters, unsigned length)
    754         : m_refCount(s_refCountIncrement)
    755         , m_length(length)
    756         , m_data16(characters)
    757         , m_hashAndFlags(StringSymbol | BufferSubstring)
     785        : StringImplShape(s_refCountIncrement, length, characters, StringSymbol | BufferSubstring)
    758786    {
    759787        ASSERT(!is8Bit());
     
    764792    // Null symbol.
    765793    StringImpl(CreateSymbolTag)
    766         : m_refCount(s_refCountIncrement)
    767         , m_length(0)
    768         , m_data8(empty()->characters8())
    769         , m_hashAndFlags(s_hashFlag8BitBuffer | StringSymbol | BufferSubstring)
     794        : StringImplShape(s_refCountIncrement, 0, empty()->characters8(), s_hashFlag8BitBuffer | StringSymbol | BufferSubstring)
    770795    {
    771796        ASSERT(is8Bit());
     
    860885    }
    861886#endif
    862 
    863 private:
    864     // These member variables must match the layout of StaticStringImpl.
    865     unsigned m_refCount;
    866     unsigned m_length;
    867     union {
    868         const LChar* m_data8;
    869         const UChar* m_data16;
    870     };
    871     mutable unsigned m_hashAndFlags;
    872887};
    873888
    874 static_assert(sizeof(StringImpl) == sizeof(StringImpl::StaticStringImpl), "");
     889using StaticStringImpl = StringImpl::StaticStringImpl;
     890
     891static_assert(sizeof(StringImpl) == sizeof(StaticStringImpl), "");
    875892
    876893#if !ASSERT_DISABLED
     
    11371154}
    11381155
     1156#define MAKE_STATIC_STRING_IMPL(characters) ([] { \
     1157        static StaticStringImpl impl(characters); \
     1158        return &impl; \
     1159    }())
     1160
     1161
    11391162} // namespace WTF
    11401163
    11411164using WTF::StringImpl;
     1165using WTF::StaticStringImpl;
    11421166using WTF::equal;
    11431167using WTF::TextCaseSensitivity;
  • trunk/Source/WTF/wtf/text/WTFString.h

    r214919 r216217  
    11/*
    22 * (C) 1999 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    115115    String(RefPtr<AtomicStringImpl>&&);
    116116
     117    String(StaticStringImpl&);
     118    String(StaticStringImpl*);
     119
    117120    // Construct a string from a constant string literal.
    118     WTF_EXPORT_STRING_API String(ASCIILiteral characters);
     121    WTF_EXPORT_STRING_API String(ASCIILiteral);
    119122
    120123    // Construct a string from a constant string literal.
     
    490493};
    491494
     495static_assert(sizeof(String) == sizeof(void*), "String should effectively be a pointer to a StringImpl, and efficient to pass by value");
     496
    492497inline bool operator==(const String& a, const String& b) { return equal(a.impl(), b.impl()); }
    493498inline bool operator==(const String& a, const LChar* b) { return equal(a.impl(), b); }
     
    559564}
    560565
     566inline String::String(StaticStringImpl& impl)
     567    : m_impl(reinterpret_cast<StringImpl*>(&impl))
     568{
     569}
     570
     571inline String::String(StaticStringImpl* impl)
     572    : m_impl(reinterpret_cast<StringImpl*>(impl))
     573{
     574}
     575
    561576template<size_t inlineCapacity, typename OverflowHandler>
    562577String::String(const Vector<UChar, inlineCapacity, OverflowHandler>& vector)
     
    729744};
    730745
    731 }
     746} // namespace WTF
    732747
    733748using WTF::CString;
  • trunk/Source/WTF/wtf/text/icu/TextBreakIteratorICU.h

    r213095 r216217  
    3232static String caretRules()
    3333{
    34     return ASCIILiteral(
     34    static StaticStringImpl caretRuleString(
    3535        // This rule set is based on character-break iterator rules of ICU 57
    3636        // <http://source.icu-project.org/repos/icu/icu/tags/release-57-1/source/data/brkitr/>.
     
    129129        "$EmojiForMods [$EmojiVar $EmojiMods]+;"
    130130    );
     131    return caretRuleString;
    131132}
    132133#endif
  • trunk/Source/WebCore/ChangeLog

    r216216 r216217  
     12017-05-04  Mark Lam  <mark.lam@apple.com>
     2
     3        NeverDestroyed<String>(ASCIILiteral(...)) is not thread safe.
     4        https://bugs.webkit.org/show_bug.cgi?id=171586
     5        <rdar://problem/31873190>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        No new tests because we're just converting uses of ASCIILiteral (in the
     10        instantiation of NeverDestroyed<String> and NeverDestroyed<const String>) to
     11        MAKE_STATIC_STRING_IMPL.
     12
     13        The correctness of using MAKE_STATIC_STRING_IMPL is tested in the newly added
     14        API test in this patch.
     15
     16        Also changed "static NeverDestroyed<ASCIILiteral>" instances in
     17        SQLiteIDBBackingStore.cpp to "static const char* const" because they are only
     18        ever used to get the underlying const char*.
     19
     20        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     21        (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
     22        (WebCore::IDBServer::SQLiteIDBBackingStore::cachedStatementForGetAllObjectStoreRecords):
     23        * Modules/mediastream/MediaEndpointSessionDescription.cpp:
     24        * Modules/mediastream/RTCRtpTransceiver.cpp:
     25        * Modules/mediastream/SDPProcessor.cpp:
     26        * Modules/navigatorcontentutils/NavigatorContentUtils.cpp:
     27        (WebCore::customHandlersStateString):
     28        (WebCore::NavigatorContentUtils::isProtocolHandlerRegistered):
     29        * Modules/speech/SpeechSynthesis.cpp:
     30        (WebCore::SpeechSynthesis::boundaryEventOccurred):
     31        * accessibility/AccessibilityMediaControls.cpp:
     32        (WebCore::AccessibilityMediaControl::controlTypeName):
     33        (WebCore::AccessibilityMediaControl::title):
     34        (WebCore::AccessibilityMediaControlsContainer::elementTypeName):
     35        (WebCore::AccessibilityMediaTimeline::helpText):
     36        (WebCore::AccessibilityMediaTimeDisplay::accessibilityDescription):
     37        * bindings/js/JSLazyEventListener.cpp:
     38        (WebCore::eventParameterName):
     39        * contentextensions/ContentExtensionsBackend.cpp:
     40        (WebCore::ContentExtensions::ContentExtensionsBackend::displayNoneCSSRule):
     41        * css/CSSDefaultStyleSheets.cpp:
     42        (WebCore::screenEval):
     43        (WebCore::printEval):
     44        * css/MediaList.cpp:
     45        (WebCore::addResolutionWarningMessageToConsole):
     46        * css/StyleSheetContents.cpp:
     47        (WebCore::StyleSheetContents::parseAuthorStyleSheet):
     48        * dom/Document.cpp:
     49        (WebCore::Document::readyState):
     50        * dom/LoadableClassicScript.cpp:
     51        (WebCore::LoadableClassicScript::notifyFinished):
     52        * dom/PseudoElement.cpp:
     53        (WebCore::PseudoElement::pseudoElementNameForEvents):
     54        * editing/MarkupAccumulator.cpp:
     55        (WebCore::MarkupAccumulator::shouldAddNamespaceElement):
     56        * editing/cocoa/DataDetection.mm:
     57        (WebCore::DataDetection::dataDetectorURLProtocol):
     58        * editing/markup.cpp:
     59        (WebCore::StyledMarkupAccumulator::styleNodeCloseTag):
     60        (WebCore::createMarkupInternal):
     61        * html/FormController.cpp:
     62        (WebCore::formStateSignature):
     63        * html/ImageInputType.cpp:
     64        (WebCore::ImageInputType::appendFormData):
     65        * html/canvas/CanvasRenderingContext2D.cpp:
     66        (WebCore::CanvasRenderingContext2D::realizeSaves):
     67        (WebCore::CanvasRenderingContext2D::getImageData):
     68        * html/parser/XSSAuditor.cpp:
     69        (WebCore::XSSAuditor::init):
     70        (WebCore::XSSAuditor::eraseDangerousAttributesIfInjected):
     71        * html/track/VTTCue.cpp:
     72        (WebCore::startKeyword):
     73        (WebCore::middleKeyword):
     74        (WebCore::endKeyword):
     75        (WebCore::leftKeyword):
     76        (WebCore::rightKeyword):
     77        (WebCore::verticalGrowingLeftKeyword):
     78        (WebCore::verticalGrowingRightKeyword):
     79        (WebCore::VTTCue::determineTextDirection):
     80        (WebCore::VTTCue::markFutureAndPastNodes):
     81        * inspector/InspectorCSSAgent.cpp:
     82        (WebCore::computePseudoClassMask):
     83        * inspector/InspectorIndexedDBAgent.cpp:
     84        * inspector/InspectorPageAgent.cpp:
     85        (WebCore::InspectorPageAgent::sourceMapURLForResource):
     86        * inspector/PageDebuggerAgent.cpp:
     87        (WebCore::PageDebuggerAgent::sourceMapURLForScript):
     88        * loader/ImageLoader.cpp:
     89        (WebCore::ImageLoader::notifyFinished):
     90        * loader/TextTrackLoader.cpp:
     91        (WebCore::TextTrackLoader::corsPolicyPreventedLoad):
     92        * loader/icon/IconDatabase.cpp:
     93        (WebCore::IconDatabase::defaultDatabaseFilename):
     94        * page/CaptionUserPreferencesMediaAF.cpp:
     95        (WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS):
     96        * page/SecurityOrigin.cpp:
     97        (WebCore::SecurityOrigin::urlWithUniqueSecurityOrigin):
     98        * page/UserContentURLPattern.cpp:
     99        (WebCore::UserContentURLPattern::parse):
     100        * platform/MIMETypeRegistry.cpp:
     101        (WebCore::defaultMIMEType):
     102        * platform/animation/Animation.cpp:
     103        (WebCore::Animation::initialName):
     104        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     105        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::engineDescription):
     106        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
     107        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::engineDescription):
     108        * platform/graphics/cocoa/FontCacheCoreText.cpp:
     109        (WebCore::FontCache::similarFont):
     110        * platform/gtk/UserAgentGtk.cpp:
     111        (WebCore::platformVersionForUAString):
     112        * platform/mock/mediasource/MockBox.cpp:
     113        (WebCore::MockTrackBox::type):
     114        (WebCore::MockInitializationBox::type):
     115        (WebCore::MockSampleBox::type):
     116        * platform/network/HTTPHeaderValues.cpp:
     117        (WebCore::HTTPHeaderValues::textPlainContentType):
     118        (WebCore::HTTPHeaderValues::formURLEncodedContentType):
     119        (WebCore::HTTPHeaderValues::noCache):
     120        (WebCore::HTTPHeaderValues::maxAge0):
     121        * platform/network/HTTPParsers.cpp:
     122        (WebCore::parseXSSProtectionHeader):
     123        * replay/MemoizedDOMResult.cpp:
     124        (JSC::InputTraits<MemoizedDOMResultBase>::type):
     125        * svg/SVGTransformValue.cpp:
     126        (WebCore::SVGTransformValue::transformTypePrefixForParsing):
     127
    11282017-05-04  Jeremy Jones  <jeremyj@apple.com>
    2129
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r215601 r216217  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    19001900    ThreadSafeDataBuffer resultBuffer;
    19011901    {
    1902         static NeverDestroyed<ASCIILiteral> lowerOpenUpperOpen("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    1903         static NeverDestroyed<ASCIILiteral> lowerOpenUpperClosed("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
    1904         static NeverDestroyed<ASCIILiteral> lowerClosedUpperOpen("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    1905         static NeverDestroyed<ASCIILiteral> lowerClosedUpperClosed("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
    1906 
    1907         static NeverDestroyed<ASCIILiteral> lowerOpenUpperOpenKeyOnly("SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    1908         static NeverDestroyed<ASCIILiteral> lowerOpenUpperClosedKeyOnly("SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
    1909         static NeverDestroyed<ASCIILiteral> lowerClosedUpperOpenKeyOnly("SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    1910         static NeverDestroyed<ASCIILiteral> lowerClosedUpperClosedKeyOnly("SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
     1902        static const char* const lowerOpenUpperOpen = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     1903        static const char* const lowerOpenUpperClosed = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
     1904        static const char* const lowerClosedUpperOpen = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     1905        static const char* const lowerClosedUpperClosed = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
     1906
     1907        static const char* const lowerOpenUpperOpenKeyOnly = "SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     1908        static const char* const lowerOpenUpperClosedKeyOnly = "SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
     1909        static const char* const lowerClosedUpperOpenKeyOnly = "SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     1910        static const char* const lowerClosedUpperClosedKeyOnly = "SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
    19111911
    19121912        SQLiteStatement* sql = nullptr;
     
    19161916            if (keyRange.lowerOpen) {
    19171917                if (keyRange.upperOpen)
    1918                     sql = cachedStatement(SQL::GetValueRecordsLowerOpenUpperOpen, lowerOpenUpperOpen.get());
     1918                    sql = cachedStatement(SQL::GetValueRecordsLowerOpenUpperOpen, lowerOpenUpperOpen);
    19191919                else
    1920                     sql = cachedStatement(SQL::GetValueRecordsLowerOpenUpperClosed, lowerOpenUpperClosed.get());
     1920                    sql = cachedStatement(SQL::GetValueRecordsLowerOpenUpperClosed, lowerOpenUpperClosed);
    19211921            } else {
    19221922                if (keyRange.upperOpen)
    1923                     sql = cachedStatement(SQL::GetValueRecordsLowerClosedUpperOpen, lowerClosedUpperOpen.get());
     1923                    sql = cachedStatement(SQL::GetValueRecordsLowerClosedUpperOpen, lowerClosedUpperOpen);
    19241924                else
    1925                     sql = cachedStatement(SQL::GetValueRecordsLowerClosedUpperClosed, lowerClosedUpperClosed.get());
     1925                    sql = cachedStatement(SQL::GetValueRecordsLowerClosedUpperClosed, lowerClosedUpperClosed);
    19261926            }
    19271927            break;
     
    19291929            if (keyRange.lowerOpen) {
    19301930                if (keyRange.upperOpen)
    1931                     sql = cachedStatement(SQL::GetKeyRecordsLowerOpenUpperOpen, lowerOpenUpperOpenKeyOnly.get());
     1931                    sql = cachedStatement(SQL::GetKeyRecordsLowerOpenUpperOpen, lowerOpenUpperOpenKeyOnly);
    19321932                else
    1933                     sql = cachedStatement(SQL::GetKeyRecordsLowerOpenUpperClosed, lowerOpenUpperClosedKeyOnly.get());
     1933                    sql = cachedStatement(SQL::GetKeyRecordsLowerOpenUpperClosed, lowerOpenUpperClosedKeyOnly);
    19341934            } else {
    19351935                if (keyRange.upperOpen)
    1936                     sql = cachedStatement(SQL::GetKeyRecordsLowerClosedUpperOpen, lowerClosedUpperOpenKeyOnly.get());
     1936                    sql = cachedStatement(SQL::GetKeyRecordsLowerClosedUpperOpen, lowerClosedUpperOpenKeyOnly);
    19371937                else
    1938                     sql = cachedStatement(SQL::GetKeyRecordsLowerClosedUpperClosed, lowerClosedUpperClosedKeyOnly.get());
     1938                    sql = cachedStatement(SQL::GetKeyRecordsLowerClosedUpperClosed, lowerClosedUpperClosedKeyOnly);
    19391939            }
    19401940        }
     
    20042004SQLiteStatement* SQLiteIDBBackingStore::cachedStatementForGetAllObjectStoreRecords(const IDBGetAllRecordsData& getAllRecordsData)
    20052005{
    2006     static NeverDestroyed<ASCIILiteral> lowerOpenUpperOpenKey("SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    2007     static NeverDestroyed<ASCIILiteral> lowerOpenUpperClosedKey("SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
    2008     static NeverDestroyed<ASCIILiteral> lowerClosedUpperOpenKey("SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    2009     static NeverDestroyed<ASCIILiteral> lowerClosedUpperClosedKey("SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
    2010     static NeverDestroyed<ASCIILiteral> lowerOpenUpperOpenValue("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    2011     static NeverDestroyed<ASCIILiteral> lowerOpenUpperClosedValue("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
    2012     static NeverDestroyed<ASCIILiteral> lowerClosedUpperOpenValue("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;");
    2013     static NeverDestroyed<ASCIILiteral> lowerClosedUpperClosedValue("SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;");
     2006    static const char* const lowerOpenUpperOpenKey ="SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     2007    static const char* const lowerOpenUpperClosedKey = "SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
     2008    static const char* const lowerClosedUpperOpenKey = "SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     2009    static const char* const lowerClosedUpperClosedKey = "SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
     2010    static const char* const lowerOpenUpperOpenValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     2011    static const char* const lowerOpenUpperClosedValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
     2012    static const char* const lowerClosedUpperOpenValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     2013    static const char* const lowerClosedUpperClosedValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";
    20142014
    20152015    if (getAllRecordsData.getAllType == IndexedDB::GetAllType::Keys) {
    20162016        if (getAllRecordsData.keyRangeData.lowerOpen) {
    20172017            if (getAllRecordsData.keyRangeData.upperOpen)
    2018                 return cachedStatement(SQL::GetAllKeyRecordsLowerOpenUpperOpen, lowerOpenUpperOpenKey.get());
    2019             return cachedStatement(SQL::GetAllKeyRecordsLowerOpenUpperClosed, lowerOpenUpperClosedKey.get());
     2018                return cachedStatement(SQL::GetAllKeyRecordsLowerOpenUpperOpen, lowerOpenUpperOpenKey);
     2019            return cachedStatement(SQL::GetAllKeyRecordsLowerOpenUpperClosed, lowerOpenUpperClosedKey);
    20202020        }
    20212021
    20222022        if (getAllRecordsData.keyRangeData.upperOpen)
    2023             return cachedStatement(SQL::GetAllKeyRecordsLowerClosedUpperOpen, lowerClosedUpperOpenKey.get());
    2024         return cachedStatement(SQL::GetAllKeyRecordsLowerClosedUpperClosed, lowerClosedUpperClosedKey.get());
     2023            return cachedStatement(SQL::GetAllKeyRecordsLowerClosedUpperOpen, lowerClosedUpperOpenKey);
     2024        return cachedStatement(SQL::GetAllKeyRecordsLowerClosedUpperClosed, lowerClosedUpperClosedKey);
    20252025    }
    20262026
    20272027    if (getAllRecordsData.keyRangeData.lowerOpen) {
    20282028        if (getAllRecordsData.keyRangeData.upperOpen)
    2029             return cachedStatement(SQL::GetValueRecordsLowerOpenUpperOpen, lowerOpenUpperOpenValue.get());
    2030         return cachedStatement(SQL::GetValueRecordsLowerOpenUpperClosed, lowerOpenUpperClosedValue.get());
     2029            return cachedStatement(SQL::GetValueRecordsLowerOpenUpperOpen, lowerOpenUpperOpenValue);
     2030        return cachedStatement(SQL::GetValueRecordsLowerOpenUpperClosed, lowerOpenUpperClosedValue);
    20312031    }
    20322032
    20332033    if (getAllRecordsData.keyRangeData.upperOpen)
    2034         return cachedStatement(SQL::GetValueRecordsLowerClosedUpperOpen, lowerClosedUpperOpenValue.get());
    2035     return cachedStatement(SQL::GetValueRecordsLowerClosedUpperClosed, lowerClosedUpperClosedValue.get());
     2034        return cachedStatement(SQL::GetValueRecordsLowerClosedUpperOpen, lowerClosedUpperOpenValue);
     2035    return cachedStatement(SQL::GetValueRecordsLowerClosedUpperClosed, lowerClosedUpperClosedValue);
    20362036}
    20372037
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointSessionDescription.cpp

    r214212 r216217  
    4444    static const String& name##String() \
    4545    { \
    46         static NeverDestroyed<const String> name { ASCIILiteral(#name) }; \
     46        static NeverDestroyed<const String> name(MAKE_STATIC_STRING_IMPL(#name)); \
    4747        return name; \
    4848    }
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpTransceiver.cpp

    r214212 r216217  
    4242    static const String& name##String() \
    4343    { \
    44         static NeverDestroyed<const String> name { ASCIILiteral(#name) }; \
     44        static NeverDestroyed<const String> name(MAKE_STATIC_STRING_IMPL(#name)); \
    4545        return name; \
    4646    }
  • trunk/Source/WebCore/Modules/mediastream/SDPProcessor.cpp

    r214960 r216217  
    11/*
    22 * Copyright (C) 2015, 2016 Ericsson AB. All rights reserved.
    3  * Copyright (C) 2016 Apple Inc. All rights reserved.
     3 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    5252    static const String& name##String() \
    5353    { \
    54         static NeverDestroyed<const String> name { ASCIILiteral(#name) }; \
     54        static NeverDestroyed<const String> name(MAKE_STATIC_STRING_IMPL(#name)); \
    5555        return name; \
    5656    }
  • trunk/Source/WebCore/Modules/navigatorcontentutils/NavigatorContentUtils.cpp

    r208118 r216217  
    22 * Copyright (C) 2011, Google Inc. All rights reserved.
    33 * Copyright (C) 2012, Samsung Electronics. All rights reserved.
     4 * Copyright (C) 2017 Apple Inc. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    118119static String customHandlersStateString(const NavigatorContentUtilsClient::CustomHandlersState state)
    119120{
    120     static NeverDestroyed<String> newHandler(ASCIILiteral("new"));
    121     static NeverDestroyed<String> registeredHandler(ASCIILiteral("registered"));
    122     static NeverDestroyed<String> declinedHandler(ASCIILiteral("declined"));
     121    static NeverDestroyed<String> newHandler(MAKE_STATIC_STRING_IMPL("new"));
     122    static NeverDestroyed<String> registeredHandler(MAKE_STATIC_STRING_IMPL("registered"));
     123    static NeverDestroyed<String> declinedHandler(MAKE_STATIC_STRING_IMPL("declined"));
    123124
    124125    switch (state) {
     
    137138ExceptionOr<String> NavigatorContentUtils::isProtocolHandlerRegistered(Navigator& navigator, const String& scheme, const String& url)
    138139{
    139     static NeverDestroyed<String> declined(ASCIILiteral("declined"));
     140    static NeverDestroyed<String> declined(MAKE_STATIC_STRING_IMPL("declined"));
    140141
    141142    if (!navigator.frame())
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp

    r203340 r216217  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    189189void SpeechSynthesis::boundaryEventOccurred(PlatformSpeechSynthesisUtterance& utterance, SpeechBoundary boundary, unsigned charIndex)
    190190{
    191     static NeverDestroyed<const String> wordBoundaryString(ASCIILiteral("word"));
    192     static NeverDestroyed<const String> sentenceBoundaryString(ASCIILiteral("sentence"));
     191    static NeverDestroyed<const String> wordBoundaryString(MAKE_STATIC_STRING_IMPL("word"));
     192    static NeverDestroyed<const String> sentenceBoundaryString(MAKE_STATIC_STRING_IMPL("sentence"));
    193193
    194194    ASSERT(utterance.client());
  • trunk/Source/WebCore/accessibility/AccessibilityMediaControls.cpp

    r177733 r216217  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8484const String& AccessibilityMediaControl::controlTypeName() const
    8585{
    86     static NeverDestroyed<const String> mediaEnterFullscreenButtonName(ASCIILiteral("EnterFullscreenButton"));
    87     static NeverDestroyed<const String> mediaExitFullscreenButtonName(ASCIILiteral("ExitFullscreenButton"));
    88     static NeverDestroyed<const String> mediaMuteButtonName(ASCIILiteral("MuteButton"));
    89     static NeverDestroyed<const String> mediaPlayButtonName(ASCIILiteral("PlayButton"));
    90     static NeverDestroyed<const String> mediaSeekBackButtonName(ASCIILiteral("SeekBackButton"));
    91     static NeverDestroyed<const String> mediaSeekForwardButtonName(ASCIILiteral("SeekForwardButton"));
    92     static NeverDestroyed<const String> mediaRewindButtonName(ASCIILiteral("RewindButton"));
    93     static NeverDestroyed<const String> mediaReturnToRealtimeButtonName(ASCIILiteral("ReturnToRealtimeButton"));
    94     static NeverDestroyed<const String> mediaUnMuteButtonName(ASCIILiteral("UnMuteButton"));
    95     static NeverDestroyed<const String> mediaPauseButtonName(ASCIILiteral("PauseButton"));
    96     static NeverDestroyed<const String> mediaStatusDisplayName(ASCIILiteral("StatusDisplay"));
    97     static NeverDestroyed<const String> mediaCurrentTimeDisplay(ASCIILiteral("CurrentTimeDisplay"));
    98     static NeverDestroyed<const String> mediaTimeRemainingDisplay(ASCIILiteral("TimeRemainingDisplay"));
    99     static NeverDestroyed<const String> mediaShowClosedCaptionsButtonName(ASCIILiteral("ShowClosedCaptionsButton"));
    100     static NeverDestroyed<const String> mediaHideClosedCaptionsButtonName(ASCIILiteral("HideClosedCaptionsButton"));
     86    static NeverDestroyed<const String> mediaEnterFullscreenButtonName(MAKE_STATIC_STRING_IMPL("EnterFullscreenButton"));
     87    static NeverDestroyed<const String> mediaExitFullscreenButtonName(MAKE_STATIC_STRING_IMPL("ExitFullscreenButton"));
     88    static NeverDestroyed<const String> mediaMuteButtonName(MAKE_STATIC_STRING_IMPL("MuteButton"));
     89    static NeverDestroyed<const String> mediaPlayButtonName(MAKE_STATIC_STRING_IMPL("PlayButton"));
     90    static NeverDestroyed<const String> mediaSeekBackButtonName(MAKE_STATIC_STRING_IMPL("SeekBackButton"));
     91    static NeverDestroyed<const String> mediaSeekForwardButtonName(MAKE_STATIC_STRING_IMPL("SeekForwardButton"));
     92    static NeverDestroyed<const String> mediaRewindButtonName(MAKE_STATIC_STRING_IMPL("RewindButton"));
     93    static NeverDestroyed<const String> mediaReturnToRealtimeButtonName(MAKE_STATIC_STRING_IMPL("ReturnToRealtimeButton"));
     94    static NeverDestroyed<const String> mediaUnMuteButtonName(MAKE_STATIC_STRING_IMPL("UnMuteButton"));
     95    static NeverDestroyed<const String> mediaPauseButtonName(MAKE_STATIC_STRING_IMPL("PauseButton"));
     96    static NeverDestroyed<const String> mediaStatusDisplayName(MAKE_STATIC_STRING_IMPL("StatusDisplay"));
     97    static NeverDestroyed<const String> mediaCurrentTimeDisplay(MAKE_STATIC_STRING_IMPL("CurrentTimeDisplay"));
     98    static NeverDestroyed<const String> mediaTimeRemainingDisplay(MAKE_STATIC_STRING_IMPL("TimeRemainingDisplay"));
     99    static NeverDestroyed<const String> mediaShowClosedCaptionsButtonName(MAKE_STATIC_STRING_IMPL("ShowClosedCaptionsButton"));
     100    static NeverDestroyed<const String> mediaHideClosedCaptionsButtonName(MAKE_STATIC_STRING_IMPL("HideClosedCaptionsButton"));
    101101
    102102    switch (controlType()) {
     
    157157String AccessibilityMediaControl::title() const
    158158{
    159     static NeverDestroyed<const String> controlsPanel(ASCIILiteral("ControlsPanel"));
     159    static NeverDestroyed<const String> controlsPanel(MAKE_STATIC_STRING_IMPL("ControlsPanel"));
    160160
    161161    if (controlType() == MediaControlsPanel)
     
    246246const String& AccessibilityMediaControlsContainer::elementTypeName() const
    247247{
    248     static NeverDestroyed<const String> videoElement(ASCIILiteral("VideoElement"));
    249     static NeverDestroyed<const String> audioElement(ASCIILiteral("AudioElement"));
     248    static NeverDestroyed<const String> videoElement(MAKE_STATIC_STRING_IMPL("VideoElement"));
     249    static NeverDestroyed<const String> audioElement(MAKE_STATIC_STRING_IMPL("AudioElement"));
    250250
    251251    if (controllingVideoElement())
     
    284284String AccessibilityMediaTimeline::helpText() const
    285285{
    286     static NeverDestroyed<const String> slider(ASCIILiteral("Slider"));
     286    static NeverDestroyed<const String> slider(MAKE_STATIC_STRING_IMPL("Slider"));
    287287    return localizedMediaControlElementHelpText(slider);
    288288}
     
    315315String AccessibilityMediaTimeDisplay::accessibilityDescription() const
    316316{
    317     static NeverDestroyed<const String> currentTimeDisplay(ASCIILiteral("CurrentTimeDisplay"));
    318     static NeverDestroyed<const String> timeRemainingDisplay(ASCIILiteral("TimeRemainingDisplay"));
     317    static NeverDestroyed<const String> currentTimeDisplay(MAKE_STATIC_STRING_IMPL("CurrentTimeDisplay"));
     318    static NeverDestroyed<const String> timeRemainingDisplay(MAKE_STATIC_STRING_IMPL("TimeRemainingDisplay"));
    319319
    320320    if (controlType() == MediaCurrentTimeDisplay)
  • trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp

    r211280 r216217  
    11/*
    22 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    3  *  Copyright (C) 2003-2016 Apple Inc. All Rights Reserved.
     3 *  Copyright (C) 2003-2017 Apple Inc. All Rights Reserved.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    140140static const String& eventParameterName(bool isSVGEvent)
    141141{
    142     static NeverDestroyed<const String> eventString(ASCIILiteral("event"));
    143     static NeverDestroyed<const String> evtString(ASCIILiteral("evt"));
     142    static NeverDestroyed<const String> eventString(MAKE_STATIC_STRING_IMPL("event"));
     143    static NeverDestroyed<const String> evtString(MAKE_STATIC_STRING_IMPL("evt"));
    144144    return isSVGEvent ? evtString : eventString;
    145145}
  • trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp

    r213669 r216217  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    222222const String& ContentExtensionsBackend::displayNoneCSSRule()
    223223{
    224     static NeverDestroyed<const String> rule(ASCIILiteral("display:none !important;"));
     224    static NeverDestroyed<const String> rule(MAKE_STATIC_STRING_IMPL("display:none !important;"));
    225225    return rule;
    226226}
  • trunk/Source/WebCore/css/CSSDefaultStyleSheets.cpp

    r214305 r216217  
    33 *           (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
    44 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
    5  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
     5 * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
    77 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
     
    8585static const MediaQueryEvaluator& screenEval()
    8686{
    87     static NeverDestroyed<const MediaQueryEvaluator> staticScreenEval(String(ASCIILiteral("screen")));
     87    static NeverDestroyed<const MediaQueryEvaluator> staticScreenEval(String(MAKE_STATIC_STRING_IMPL("screen")));
    8888    return staticScreenEval;
    8989}
     
    9191static const MediaQueryEvaluator& printEval()
    9292{
    93     static NeverDestroyed<const MediaQueryEvaluator> staticPrintEval(String(ASCIILiteral("print")));
     93    static NeverDestroyed<const MediaQueryEvaluator> staticPrintEval(String(MAKE_STATIC_STRING_IMPL("print")));
    9494    return staticPrintEval;
    9595}
  • trunk/Source/WebCore/css/MediaList.cpp

    r209794 r216217  
    11/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004, 2006, 2010, 2012 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    240240static void addResolutionWarningMessageToConsole(Document& document, const String& serializedExpression, const CSSPrimitiveValue& value)
    241241{
    242     static NeverDestroyed<String> mediaQueryMessage(ASCIILiteral("Consider using 'dppx' units instead of '%replacementUnits%', as in CSS '%replacementUnits%' means dots-per-CSS-%lengthUnit%, not dots-per-physical-%lengthUnit%, so does not correspond to the actual '%replacementUnits%' of a screen. In media query expression: "));
    243     static NeverDestroyed<String> mediaValueDPI(ASCIILiteral("dpi"));
    244     static NeverDestroyed<String> mediaValueDPCM(ASCIILiteral("dpcm"));
    245     static NeverDestroyed<String> lengthUnitInch(ASCIILiteral("inch"));
    246     static NeverDestroyed<String> lengthUnitCentimeter(ASCIILiteral("centimeter"));
     242    static NeverDestroyed<String> mediaQueryMessage(MAKE_STATIC_STRING_IMPL("Consider using 'dppx' units instead of '%replacementUnits%', as in CSS '%replacementUnits%' means dots-per-CSS-%lengthUnit%, not dots-per-physical-%lengthUnit%, so does not correspond to the actual '%replacementUnits%' of a screen. In media query expression: "));
     243    static NeverDestroyed<String> mediaValueDPI(MAKE_STATIC_STRING_IMPL("dpi"));
     244    static NeverDestroyed<String> mediaValueDPCM(MAKE_STATIC_STRING_IMPL("dpcm"));
     245    static NeverDestroyed<String> lengthUnitInch(MAKE_STATIC_STRING_IMPL("inch"));
     246    static NeverDestroyed<String> lengthUnitCentimeter(MAKE_STATIC_STRING_IMPL("centimeter"));
    247247
    248248    String message;
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r215753 r216217  
    11/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004, 2006, 2007, 2012, 2013 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    339339    if (m_parserContext.needsSiteSpecificQuirks && isStrictParserMode(m_parserContext.mode)) {
    340340        // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
    341         static NeverDestroyed<const String> mediaWikiKHTMLFixesStyleSheet(ASCIILiteral("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
     341        static NeverDestroyed<const String> mediaWikiKHTMLFixesStyleSheet(MAKE_STATIC_STRING_IMPL("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
    342342        // There are two variants of KHTMLFixes.css. One is equal to mediaWikiKHTMLFixesStyleSheet,
    343343        // while the other lacks the second trailing newline.
  • trunk/Source/WebCore/dom/Document.cpp

    r216197 r216217  
    11381138String Document::readyState() const
    11391139{
    1140     static NeverDestroyed<const String> loading(ASCIILiteral("loading"));
    1141     static NeverDestroyed<const String> interactive(ASCIILiteral("interactive"));
    1142     static NeverDestroyed<const String> complete(ASCIILiteral("complete"));
     1140    static NeverDestroyed<const String> loading(MAKE_STATIC_STRING_IMPL("loading"));
     1141    static NeverDestroyed<const String> interactive(MAKE_STATIC_STRING_IMPL("interactive"));
     1142    static NeverDestroyed<const String> complete(MAKE_STATIC_STRING_IMPL("complete"));
    11431143
    11441144    switch (m_readyState) {
  • trunk/Source/WebCore/dom/LoadableClassicScript.cpp

    r216199 r216217  
    11/*
    2  * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
     2 * Copyright (C) 2016-2017 Apple, Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7373    ASSERT(m_cachedScript);
    7474    if (resource.resourceError().isAccessControl()) {
    75         static NeverDestroyed<String> consoleMessage(ASCIILiteral("Cross-origin script load denied by Cross-Origin Resource Sharing policy."));
     75        static NeverDestroyed<String> consoleMessage(MAKE_STATIC_STRING_IMPL("Cross-origin script load denied by Cross-Origin Resource Sharing policy."));
    7676        m_error = Error {
    7777            ErrorType::CrossOriginLoad,
  • trunk/Source/WebCore/dom/PseudoElement.cpp

    r208985 r216217  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
     3 * Copyright (C) 2017 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    4546String PseudoElement::pseudoElementNameForEvents(PseudoId pseudoId)
    4647{
    47     static NeverDestroyed<const String> after(ASCIILiteral("::after"));
    48     static NeverDestroyed<const String> before(ASCIILiteral("::before"));
     48    static NeverDestroyed<const String> after(MAKE_STATIC_STRING_IMPL("::after"));
     49    static NeverDestroyed<const String> before(MAKE_STATIC_STRING_IMPL("::before"));
    4950    switch (pseudoId) {
    5051    case AFTER:
  • trunk/Source/WebCore/editing/MarkupAccumulator.cpp

    r215648 r216217  
    11/*
    2  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
    44 *
     
    258258        return !element.hasAttribute(xmlnsAtom);
    259259
    260     static NeverDestroyed<String> xmlnsWithColon(ASCIILiteral("xmlns:"));
     260    static NeverDestroyed<String> xmlnsWithColon(MAKE_STATIC_STRING_IMPL("xmlns:"));
    261261    return !element.hasAttribute(xmlnsWithColon.get() + prefix);
    262262}
  • trunk/Source/WebCore/editing/cocoa/DataDetection.mm

    r215849 r216217  
    11/*
    2  * Copyright (C) 2014 Apple, Inc.  All rights reserved.
     2 * Copyright (C) 2014-2017 Apple, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    663663const String& DataDetection::dataDetectorURLProtocol()
    664664{
    665     static NeverDestroyed<String> protocol(ASCIILiteral("x-apple-data-detectors"));
     665    static NeverDestroyed<String> protocol(MAKE_STATIC_STRING_IMPL("x-apple-data-detectors"));
    666666    return protocol;
    667667}
  • trunk/Source/WebCore/editing/markup.cpp

    r216128 r216217  
    11/*
    2  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved.
    44 * Copyright (C) 2011 Igalia S.L.
     
    214214const String& StyledMarkupAccumulator::styleNodeCloseTag(bool isBlock)
    215215{
    216     static NeverDestroyed<const String> divClose(ASCIILiteral("</div>"));
    217     static NeverDestroyed<const String> styleSpanClose(ASCIILiteral("</span>"));
     216    static NeverDestroyed<const String> divClose(MAKE_STATIC_STRING_IMPL("</div>"));
     217    static NeverDestroyed<const String> styleSpanClose(MAKE_STATIC_STRING_IMPL("</span>"));
    218218    return isBlock ? divClose : styleSpanClose;
    219219}
     
    577577    EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs)
    578578{
    579     static NeverDestroyed<const String> interchangeNewlineString(ASCIILiteral("<br class=\"" AppleInterchangeNewline "\">"));
     579    static NeverDestroyed<const String> interchangeNewlineString(MAKE_STATIC_STRING_IMPL("<br class=\"" AppleInterchangeNewline "\">"));
    580580
    581581    bool collapsed = range.collapsed();
  • trunk/Source/WebCore/html/FormController.cpp

    r209399 r216217  
    11/*
    2  * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved.
    44 *
     
    388388    // attribute value of a form control. The following string literal should
    389389    // contain some characters which are rarely used for name attribute values.
    390     static NeverDestroyed<String> signature(ASCIILiteral("\n\r?% WebKit serialized form state version 8 \n\r=&"));
     390    static NeverDestroyed<String> signature(MAKE_STATIC_STRING_IMPL("\n\r?% WebKit serialized form state version 8 \n\r=&"));
    391391    return signature;
    392392}
  • trunk/Source/WebCore/html/ImageInputType.cpp

    r215914 r216217  
    11/*
    2  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010 Google Inc. All rights reserved.
    44 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
     
    6666    }
    6767
    68     static NeverDestroyed<String> dotXString(ASCIILiteral(".x"));
    69     static NeverDestroyed<String> dotYString(ASCIILiteral(".y"));
     68    static NeverDestroyed<String> dotXString(MAKE_STATIC_STRING_IMPL(".x"));
     69    static NeverDestroyed<String> dotYString(MAKE_STATIC_STRING_IMPL(".y"));
    7070    encoding.appendData(name + dotXString.get(), m_clickLocation.x());
    7171    encoding.appendData(name + dotYString.get(), m_clickLocation.y());
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r215900 r216217  
    353353
    354354    if (m_unrealizedSaveCount) {
    355         static NeverDestroyed<String> consoleMessage(ASCIILiteral("CanvasRenderingContext2D.save() has been called without a matching restore() too many times. Ignoring save()."));
     355        static NeverDestroyed<String> consoleMessage(MAKE_STATIC_STRING_IMPL("CanvasRenderingContext2D.save() has been called without a matching restore() too many times. Ignoring save()."));
    356356        canvas().document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, consoleMessage);
    357357    }
     
    19821982{
    19831983    if (!canvas().originClean()) {
    1984         static NeverDestroyed<String> consoleMessage(ASCIILiteral("Unable to get image data from canvas because the canvas has been tainted by cross-origin data."));
     1984        static NeverDestroyed<String> consoleMessage(MAKE_STATIC_STRING_IMPL("Unable to get image data from canvas because the canvas has been tainted by cross-origin data."));
    19851985        canvas().document().addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage);
    19861986        return Exception { SECURITY_ERR };
  • trunk/Source/WebCore/html/parser/XSSAuditor.cpp

    r216102 r216217  
    22 * Copyright (C) 2011 Adam Barth. All Rights Reserved.
    33 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com).
     4 * Copyright (C) 2017 Apple Inc. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    317318    String httpBodyAsString;
    318319    if (DocumentLoader* documentLoader = document->frame()->loader().documentLoader()) {
    319         static NeverDestroyed<String> XSSProtectionHeader(ASCIILiteral("X-XSS-Protection"));
     320        static NeverDestroyed<String> XSSProtectionHeader(MAKE_STATIC_STRING_IMPL("X-XSS-Protection"));
    320321        String headerValue = documentLoader->response().httpHeaderField(XSSProtectionHeader);
    321322        String errorDetails;
     
    564565bool XSSAuditor::eraseDangerousAttributesIfInjected(const FilterTokenRequest& request)
    565566{
    566     static NeverDestroyed<String> safeJavaScriptURL(ASCIILiteral("javascript:void(0)"));
     567    static NeverDestroyed<String> safeJavaScriptURL(MAKE_STATIC_STRING_IMPL("javascript:void(0)"));
    567568
    568569    bool didBlockScript = false;
  • trunk/Source/WebCore/html/track/VTTCue.cpp

    r214340 r216217  
    11/*
    22 * Copyright (C) 2011, 2013 Google Inc.  All rights reserved.
    3  * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
     3 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    7575static const String& startKeyword()
    7676{
    77     static NeverDestroyed<const String> start(ASCIILiteral("start"));
     77    static NeverDestroyed<const String> start(MAKE_STATIC_STRING_IMPL("start"));
    7878    return start;
    7979}
     
    8181static const String& middleKeyword()
    8282{
    83     static NeverDestroyed<const String> middle(ASCIILiteral("middle"));
     83    static NeverDestroyed<const String> middle(MAKE_STATIC_STRING_IMPL("middle"));
    8484    return middle;
    8585}
     
    8787static const String& endKeyword()
    8888{
    89     static NeverDestroyed<const String> end(ASCIILiteral("end"));
     89    static NeverDestroyed<const String> end(MAKE_STATIC_STRING_IMPL("end"));
    9090    return end;
    9191}
     
    9393static const String& leftKeyword()
    9494{
    95     static NeverDestroyed<const String> left("left");
     95    static NeverDestroyed<const String> left(MAKE_STATIC_STRING_IMPL("left"));
    9696    return left;
    9797}
     
    9999static const String& rightKeyword()
    100100{
    101     static NeverDestroyed<const String> right("right");
     101    static NeverDestroyed<const String> right(MAKE_STATIC_STRING_IMPL("right"));
    102102    return right;
    103103}
     
    110110static const String& verticalGrowingLeftKeyword()
    111111{
    112     static NeverDestroyed<const String> verticalrl(ASCIILiteral("rl"));
     112    static NeverDestroyed<const String> verticalrl(MAKE_STATIC_STRING_IMPL("rl"));
    113113    return verticalrl;
    114114}
     
    116116static const String& verticalGrowingRightKeyword()
    117117{
    118     static NeverDestroyed<const String> verticallr(ASCIILiteral("lr"));
     118    static NeverDestroyed<const String> verticallr(MAKE_STATIC_STRING_IMPL("lr"));
    119119    return verticallr;
    120120}
     
    610610void VTTCue::determineTextDirection()
    611611{
    612     static NeverDestroyed<const String> rtTag(ASCIILiteral("rt"));
     612    static NeverDestroyed<const String> rtTag(MAKE_STATIC_STRING_IMPL("rt"));
    613613    createWebVTTNodeTree();
    614614    if (!m_webVTTNodeTree)
     
    754754void VTTCue::markFutureAndPastNodes(ContainerNode* root, const MediaTime& previousTimestamp, const MediaTime& movieTime)
    755755{
    756     static NeverDestroyed<const String> timestampTag(ASCIILiteral("timestamp"));
     756    static NeverDestroyed<const String> timestampTag(MAKE_STATIC_STRING_IMPL("timestamp"));
    757757   
    758758    bool isPastNode = true;
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r215160 r216217  
    11/*
    22 * Copyright (C) 2010 Google Inc. All rights reserved.
    3  * Copyright (C) 2015 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    7878static unsigned computePseudoClassMask(const InspectorArray& pseudoClassArray)
    7979{
    80     static NeverDestroyed<String> active(ASCIILiteral("active"));
    81     static NeverDestroyed<String> hover(ASCIILiteral("hover"));
    82     static NeverDestroyed<String> focus(ASCIILiteral("focus"));
    83     static NeverDestroyed<String> visited(ASCIILiteral("visited"));
     80    static NeverDestroyed<String> active(MAKE_STATIC_STRING_IMPL("active"));
     81    static NeverDestroyed<String> hover(MAKE_STATIC_STRING_IMPL("hover"));
     82    static NeverDestroyed<String> focus(MAKE_STATIC_STRING_IMPL("focus"));
     83    static NeverDestroyed<String> visited(MAKE_STATIC_STRING_IMPL("visited"));
    8484    if (!pseudoClassArray.length())
    8585        return PseudoClassNone;
  • trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

    r210923 r216217  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
    3  * Copyright (C) 2015 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    275275        return nullptr;
    276276
    277     static NeverDestroyed<const String> numberType(ASCIILiteral("number"));
    278     static NeverDestroyed<const String> stringType(ASCIILiteral("string"));
    279     static NeverDestroyed<const String> dateType(ASCIILiteral("date"));
    280     static NeverDestroyed<const String> arrayType(ASCIILiteral("array"));
     277    static NeverDestroyed<const String> numberType(MAKE_STATIC_STRING_IMPL("number"));
     278    static NeverDestroyed<const String> stringType(MAKE_STATIC_STRING_IMPL("string"));
     279    static NeverDestroyed<const String> dateType(MAKE_STATIC_STRING_IMPL("date"));
     280    static NeverDestroyed<const String> arrayType(MAKE_STATIC_STRING_IMPL("array"));
    281281
    282282    RefPtr<IDBKey> idbKey;
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r216215 r216217  
    11/*
    22 * Copyright (C) 2011 Google Inc. All rights reserved.
    3  * Copyright (C) 2015 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    206206String InspectorPageAgent::sourceMapURLForResource(CachedResource* cachedResource)
    207207{
    208     static NeverDestroyed<String> sourceMapHTTPHeader(ASCIILiteral("SourceMap"));
    209     static NeverDestroyed<String> sourceMapHTTPHeaderDeprecated(ASCIILiteral("X-SourceMap"));
     208    static NeverDestroyed<String> sourceMapHTTPHeader(MAKE_STATIC_STRING_IMPL("SourceMap"));
     209    static NeverDestroyed<String> sourceMapHTTPHeaderDeprecated(MAKE_STATIC_STRING_IMPL("X-SourceMap"));
    210210
    211211    if (!cachedResource)
  • trunk/Source/WebCore/inspector/PageDebuggerAgent.cpp

    r201237 r216217  
    11/*
    22 * Copyright (C) 2011 Google Inc. All rights reserved.
    3  * Copyright (C) 2015 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    7474String PageDebuggerAgent::sourceMapURLForScript(const Script& script)
    7575{
    76     static NeverDestroyed<String> sourceMapHTTPHeader(ASCIILiteral("SourceMap"));
    77     static NeverDestroyed<String> sourceMapHTTPHeaderDeprecated(ASCIILiteral("X-SourceMap"));
     76    static NeverDestroyed<String> sourceMapHTTPHeader(MAKE_STATIC_STRING_IMPL("SourceMap"));
     77    static NeverDestroyed<String> sourceMapHTTPHeaderDeprecated(MAKE_STATIC_STRING_IMPL("X-SourceMap"));
    7878
    7979    if (!script.url.isEmpty()) {
  • trunk/Source/WebCore/loader/ImageLoader.cpp

    r215160 r216217  
    22 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    4  * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserved.
     4 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    288288        errorEventSender().dispatchEventSoon(*this);
    289289
    290         static NeverDestroyed<String> consoleMessage(ASCIILiteral("Cross-origin image load denied by Cross-Origin Resource Sharing policy."));
     290        static NeverDestroyed<String> consoleMessage(MAKE_STATIC_STRING_IMPL("Cross-origin image load denied by Cross-Origin Resource Sharing policy."));
    291291        element().document().addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage);
    292292
  • trunk/Source/WebCore/loader/TextTrackLoader.cpp

    r216174 r216217  
    11/*
    22 * Copyright (C) 2011 Google Inc.  All rights reserved.
    3  * Copyright (C) 2014 Apple Inc. All rights reserved.
     3 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    118118void TextTrackLoader::corsPolicyPreventedLoad()
    119119{
    120     static NeverDestroyed<String> consoleMessage(ASCIILiteral("Cross-origin text track load denied by Cross-Origin Resource Sharing policy."));
     120    static NeverDestroyed<String> consoleMessage(MAKE_STATIC_STRING_IMPL("Cross-origin text track load denied by Cross-Origin Resource Sharing policy."));
    121121    Document* document = downcast<Document>(m_scriptExecutionContext);
    122122    document->addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage);
  • trunk/Source/WebCore/loader/icon/IconDatabase.cpp

    r215265 r216217  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
    44 *
     
    881881String IconDatabase::defaultDatabaseFilename()
    882882{
    883     static NeverDestroyed<String> defaultDatabaseFilename(ASCIILiteral("WebpageIcons.db"));
     883    static NeverDestroyed<String> defaultDatabaseFilename(MAKE_STATIC_STRING_IMPL("WebpageIcons.db"));
    884884    return defaultDatabaseFilename.get().isolatedCopy();
    885885}
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r215461 r216217  
    11/*
    2  * Copyright (C) 2012-2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    380380String CaptionUserPreferencesMediaAF::captionsTextEdgeCSS() const
    381381{
    382     static NeverDestroyed<const String> edgeStyleRaised(ASCIILiteral(" -.1em -.1em .16em "));
    383     static NeverDestroyed<const String> edgeStyleDepressed(ASCIILiteral(" .1em .1em .16em "));
    384     static NeverDestroyed<const String> edgeStyleDropShadow(ASCIILiteral(" 0 .1em .16em "));
     382    static NeverDestroyed<const String> edgeStyleRaised(MAKE_STATIC_STRING_IMPL(" -.1em -.1em .16em "));
     383    static NeverDestroyed<const String> edgeStyleDepressed(MAKE_STATIC_STRING_IMPL(" .1em .1em .16em "));
     384    static NeverDestroyed<const String> edgeStyleDropShadow(MAKE_STATIC_STRING_IMPL(" 0 .1em .16em "));
    385385
    386386    MACaptionAppearanceBehavior behavior;
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r211946 r216217  
    536536{
    537537    ASSERT(isMainThread());
    538     static NeverDestroyed<URL> uniqueSecurityOriginURL(ParsedURLString, ASCIILiteral("data:,"));
     538    static NeverDestroyed<URL> uniqueSecurityOriginURL(ParsedURLString, MAKE_STATIC_STRING_IMPL("data:,"));
    539539    return uniqueSecurityOriginURL;
    540540}
  • trunk/Source/WebCore/page/UserContentURLPattern.cpp

    r203250 r216217  
    11/*
    2  * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6464bool UserContentURLPattern::parse(const String& pattern)
    6565{
    66     static NeverDestroyed<const String> schemeSeparator(ASCIILiteral("://"));
     66    static NeverDestroyed<const String> schemeSeparator(MAKE_STATIC_STRING_IMPL("://"));
    6767
    6868    size_t schemeEndPos = pattern.find(schemeSeparator);
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r215706 r216217  
    11/*
    2  * Copyright (C) 2006-2016 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006-2017 Apple Inc.  All rights reserved.
    33 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
    44 *
     
    698698const String& defaultMIMEType()
    699699{
    700     static NeverDestroyed<const String> defaultMIMEType(ASCIILiteral("application/octet-stream"));
     700    static NeverDestroyed<const String> defaultMIMEType(MAKE_STATIC_STRING_IMPL("application/octet-stream"));
    701701    return defaultMIMEType;
    702702}
  • trunk/Source/WebCore/platform/animation/Animation.cpp

    r209352 r216217  
    11/*
    22 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
    3  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    166166const String& Animation::initialName()
    167167{
    168     static NeverDestroyed<String> initialValue(ASCIILiteral("none"));
     168    static NeverDestroyed<String> initialValue(MAKE_STATIC_STRING_IMPL("none"));
    169169    return initialValue;
    170170}
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r215160 r216217  
    11/*
    2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    559559String MediaPlayerPrivateMediaSourceAVFObjC::engineDescription() const
    560560{
    561     static NeverDestroyed<String> description(ASCIILiteral("AVFoundation MediaSource Engine"));
     561    static NeverDestroyed<String> description(MAKE_STATIC_STRING_IMPL("AVFoundation MediaSource Engine"));
    562562    return description;
    563563}
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm

    r216197 r216217  
    10601060String MediaPlayerPrivateMediaStreamAVFObjC::engineDescription() const
    10611061{
    1062     static NeverDestroyed<String> description(ASCIILiteral("AVFoundation MediaStream Engine"));
     1062    static NeverDestroyed<String> description(MAKE_STATIC_STRING_IMPL("AVFoundation MediaStream Engine"));
    10631063    return description;
    10641064}
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r215331 r216217  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    672672#endif
    673673
    674     static NeverDestroyed<String> arabic(ASCIILiteral("Arabic"));
    675     static NeverDestroyed<String> pashto(ASCIILiteral("Pashto"));
    676     static NeverDestroyed<String> urdu(ASCIILiteral("Urdu"));
     674    static NeverDestroyed<String> arabic(MAKE_STATIC_STRING_IMPL("Arabic"));
     675    static NeverDestroyed<String> pashto(MAKE_STATIC_STRING_IMPL("Pashto"));
     676    static NeverDestroyed<String> urdu(MAKE_STATIC_STRING_IMPL("Urdu"));
    677677    static String* matchWords[3] = { &arabic.get(), &pashto.get(), &urdu.get() };
    678678    static NeverDestroyed<AtomicString> geezaPlain("GeezaPro", AtomicString::ConstructFromLiteral);
  • trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp

    r211034 r216217  
    11/*
    22 * Copyright (C) 2012, 2014, 2016 Igalia S.L.
     3 * Copyright (C) 2017 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    6566    //
    6667    // FIXME: The final result should include OS version, e.g. "Intel Mac OS X 10_8_4".
    67     static NeverDestroyed<const String> uaOSVersion(ASCIILiteral("Intel Mac OS X"));
     68    static NeverDestroyed<const String> uaOSVersion(MAKE_STATIC_STRING_IMPL("Intel Mac OS X"));
    6869    return uaOSVersion;
    6970#endif
  • trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp

    r205462 r216217  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8181const String& MockTrackBox::type()
    8282{
    83     static NeverDestroyed<String> trak(ASCIILiteral("trak"));
     83    static NeverDestroyed<String> trak(MAKE_STATIC_STRING_IMPL("trak"));
    8484    return trak;
    8585}
     
    110110const String& MockInitializationBox::type()
    111111{
    112     static NeverDestroyed<String> init(ASCIILiteral("init"));
     112    static NeverDestroyed<String> init(MAKE_STATIC_STRING_IMPL("init"));
    113113    return init;
    114114}
     
    138138const String& MockSampleBox::type()
    139139{
    140     static NeverDestroyed<String> smpl(ASCIILiteral("smpl"));
     140    static NeverDestroyed<String> smpl(MAKE_STATIC_STRING_IMPL("smpl"));
    141141    return smpl;
    142142}
  • trunk/Source/WebCore/platform/network/HTTPHeaderValues.cpp

    r207086 r216217  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535const String& textPlainContentType()
    3636{
    37     static NeverDestroyed<const String> contentType(ASCIILiteral("text/plain;charset=UTF-8"));
     37    static NeverDestroyed<const String> contentType(MAKE_STATIC_STRING_IMPL("text/plain;charset=UTF-8"));
    3838    return contentType;
    3939}
     
    4141const String& formURLEncodedContentType()
    4242{
    43     static NeverDestroyed<const String> contentType(ASCIILiteral("application/x-www-form-urlencoded;charset=UTF-8"));
     43    static NeverDestroyed<const String> contentType(MAKE_STATIC_STRING_IMPL("application/x-www-form-urlencoded;charset=UTF-8"));
    4444    return contentType;
    4545}
     
    4747const String& noCache()
    4848{
    49     static NeverDestroyed<const String> value(ASCIILiteral("no-cache"));
     49    static NeverDestroyed<const String> value(MAKE_STATIC_STRING_IMPL("no-cache"));
    5050    return value;
    5151}
     
    5353const String& maxAge0()
    5454{
    55     static NeverDestroyed<const String> value(ASCIILiteral("max-age=0"));
     55    static NeverDestroyed<const String> value(MAKE_STATIC_STRING_IMPL("max-age=0"));
    5656    return value;
    5757}
  • trunk/Source/WebCore/platform/network/HTTPParsers.cpp

    r210077 r216217  
    11/*
    22 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
    3  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     3 * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
    44 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
    55 * Copyright (C) 2009 Google Inc. All rights reserved.
     
    385385XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL)
    386386{
    387     static NeverDestroyed<String> failureReasonInvalidToggle(ASCIILiteral("expected 0 or 1"));
    388     static NeverDestroyed<String> failureReasonInvalidSeparator(ASCIILiteral("expected semicolon"));
    389     static NeverDestroyed<String> failureReasonInvalidEquals(ASCIILiteral("expected equals sign"));
    390     static NeverDestroyed<String> failureReasonInvalidMode(ASCIILiteral("invalid mode directive"));
    391     static NeverDestroyed<String> failureReasonInvalidReport(ASCIILiteral("invalid report directive"));
    392     static NeverDestroyed<String> failureReasonDuplicateMode(ASCIILiteral("duplicate mode directive"));
    393     static NeverDestroyed<String> failureReasonDuplicateReport(ASCIILiteral("duplicate report directive"));
    394     static NeverDestroyed<String> failureReasonInvalidDirective(ASCIILiteral("unrecognized directive"));
     387    static NeverDestroyed<String> failureReasonInvalidToggle(MAKE_STATIC_STRING_IMPL("expected 0 or 1"));
     388    static NeverDestroyed<String> failureReasonInvalidSeparator(MAKE_STATIC_STRING_IMPL("expected semicolon"));
     389    static NeverDestroyed<String> failureReasonInvalidEquals(MAKE_STATIC_STRING_IMPL("expected equals sign"));
     390    static NeverDestroyed<String> failureReasonInvalidMode(MAKE_STATIC_STRING_IMPL("invalid mode directive"));
     391    static NeverDestroyed<String> failureReasonInvalidReport(MAKE_STATIC_STRING_IMPL("invalid report directive"));
     392    static NeverDestroyed<String> failureReasonDuplicateMode(MAKE_STATIC_STRING_IMPL("duplicate mode directive"));
     393    static NeverDestroyed<String> failureReasonDuplicateReport(MAKE_STATIC_STRING_IMPL("duplicate report directive"));
     394    static NeverDestroyed<String> failureReasonInvalidDirective(MAKE_STATIC_STRING_IMPL("unrecognized directive"));
    395395
    396396    unsigned pos = 0;
  • trunk/Source/WebCore/replay/MemoizedDOMResult.cpp

    r194496 r216217  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7272const String& InputTraits<MemoizedDOMResultBase>::type()
    7373{
    74     static NeverDestroyed<const String> type(ASCIILiteral("MemoizedDOMResult"));
     74    static NeverDestroyed<const String> type(MAKE_STATIC_STRING_IMPL("MemoizedDOMResult"));
    7575    return type;
    7676}
  • trunk/Source/WebCore/svg/SVGTransformValue.cpp

    r208705 r216217  
    22 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
     4 * Copyright (C) 2017 Apple Inc. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    131132        return emptyString();
    132133    case SVG_TRANSFORM_MATRIX: {
    133         static NeverDestroyed<String> matrixString(ASCIILiteral("matrix("));
     134        static NeverDestroyed<String> matrixString(MAKE_STATIC_STRING_IMPL("matrix("));
    134135        return matrixString;
    135136    }
    136137    case SVG_TRANSFORM_TRANSLATE: {
    137         static NeverDestroyed<String> translateString(ASCIILiteral("translate("));
     138        static NeverDestroyed<String> translateString(MAKE_STATIC_STRING_IMPL("translate("));
    138139        return translateString;
    139140    }
    140141    case SVG_TRANSFORM_SCALE: {
    141         static NeverDestroyed<String> scaleString(ASCIILiteral("scale("));
     142        static NeverDestroyed<String> scaleString(MAKE_STATIC_STRING_IMPL("scale("));
    142143        return scaleString;
    143144    }
    144145    case SVG_TRANSFORM_ROTATE: {
    145         static NeverDestroyed<String> rotateString(ASCIILiteral("rotate("));
     146        static NeverDestroyed<String> rotateString(MAKE_STATIC_STRING_IMPL("rotate("));
    146147        return rotateString;
    147148    }   
    148149    case SVG_TRANSFORM_SKEWX: {
    149         static NeverDestroyed<String> skewXString(ASCIILiteral("skewX("));
     150        static NeverDestroyed<String> skewXString(MAKE_STATIC_STRING_IMPL("skewX("));
    150151        return skewXString;
    151152    }
    152153    case SVG_TRANSFORM_SKEWY: {
    153         static NeverDestroyed<String> skewYString(ASCIILiteral("skewY("));
     154        static NeverDestroyed<String> skewYString(MAKE_STATIC_STRING_IMPL("skewY("));
    154155        return skewYString;
    155156    }
  • trunk/Source/WebKit2/ChangeLog

    r216216 r216217  
     12017-05-04  Mark Lam  <mark.lam@apple.com>
     2
     3        NeverDestroyed<String>(ASCIILiteral(...)) is not thread safe.
     4        https://bugs.webkit.org/show_bug.cgi?id=171586
     5        <rdar://problem/31873190>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * Shared/API/APIError.cpp:
     10        (API::Error::webKitErrorDomain):
     11        (API::Error::webKitNetworkErrorDomain):
     12        (API::Error::webKitPolicyErrorDomain):
     13        (API::Error::webKitPluginErrorDomain):
     14        (API::Error::webKitDownloadErrorDomain):
     15        (API::Error::webKitPrintErrorDomain):
     16        * Shared/WebPreferencesKeys.cpp:
     17        * UIProcess/WebPageProxy.cpp:
     18        (WebKit::WebPageProxy::executeEditCommand):
     19        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
     20        (WebKit::WebEditorClient::didBeginEditing):
     21        (WebKit::WebEditorClient::respondToChangedContents):
     22        (WebKit::WebEditorClient::respondToChangedSelection):
     23        (WebKit::WebEditorClient::didEndEditing):
     24
    1252017-05-04  Jeremy Jones  <jeremyj@apple.com>
    226
  • trunk/Source/WebKit2/Shared/API/APIError.cpp

    r214934 r216217  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535const WTF::String& Error::webKitErrorDomain()
    3636{
    37     static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitErrorDomain"));
     37    static NeverDestroyed<WTF::String> webKitErrorDomainString(MAKE_STATIC_STRING_IMPL("WebKitErrorDomain"));
    3838    return webKitErrorDomainString;
    3939}
     
    4242{
    4343#if USE(GLIB)
    44     static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitNetworkError"));
     44    static NeverDestroyed<WTF::String> webKitErrorDomainString(MAKE_STATIC_STRING_IMPL("WebKitNetworkError"));
    4545    return webKitErrorDomainString;
    4646#else
     
    5252{
    5353#if USE(GLIB)
    54     static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitPolicyError"));
     54    static NeverDestroyed<WTF::String> webKitErrorDomainString(MAKE_STATIC_STRING_IMPL("WebKitPolicyError"));
    5555    return webKitErrorDomainString;
    5656#else
     
    6262{
    6363#if USE(GLIB)
    64     static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitPluginError"));
     64    static NeverDestroyed<WTF::String> webKitErrorDomainString(MAKE_STATIC_STRING_IMPL("WebKitPluginError"));
    6565    return webKitErrorDomainString;
    6666#else
     
    7272const WTF::String& Error::webKitDownloadErrorDomain()
    7373{
    74     static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitDownloadError"));
     74    static NeverDestroyed<WTF::String> webKitErrorDomainString(MAKE_STATIC_STRING_IMPL("WebKitDownloadError"));
    7575    return webKitErrorDomainString;
    7676}
     
    8080const WTF::String& Error::webKitPrintErrorDomain()
    8181{
    82     static NeverDestroyed<WTF::String> webKitErrorDomainString(ASCIILiteral("WebKitPrintError"));
     82    static NeverDestroyed<WTF::String> webKitErrorDomainString(MAKE_STATIC_STRING_IMPL("WebKitPrintError"));
    8383    return webKitErrorDomainString;
    8484}
  • trunk/Source/WebKit2/Shared/WebPreferencesKeys.cpp

    r199700 r216217  
    11/*
    2  * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535        const String& KeyLower##Key() \
    3636        { \
    37             static NeverDestroyed<String> key(ASCIILiteral(#KeyUpper)); \
     37            static NeverDestroyed<String> key(MAKE_STATIC_STRING_IMPL(#KeyUpper)); \
    3838            return key; \
    3939        }
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r216212 r216217  
    11/*
    2  * Copyright (C) 2010, 2011, 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2012 Intel Corporation. All rights reserved.
    44 *
     
    17231723void WebPageProxy::executeEditCommand(const String& commandName, const String& argument)
    17241724{
    1725     static NeverDestroyed<String> ignoreSpellingCommandName(ASCIILiteral("ignoreSpelling"));
     1725    static NeverDestroyed<String> ignoreSpellingCommandName(MAKE_STATIC_STRING_IMPL("ignoreSpelling"));
    17261726
    17271727    if (!isValid())
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

    r215872 r216217  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    171171{
    172172    // FIXME: What good is a notification name, if it's always the same?
    173     static NeverDestroyed<String> WebViewDidBeginEditingNotification(ASCIILiteral("WebViewDidBeginEditingNotification"));
     173    static NeverDestroyed<String> WebViewDidBeginEditingNotification(MAKE_STATIC_STRING_IMPL("WebViewDidBeginEditingNotification"));
    174174    m_page->injectedBundleEditorClient().didBeginEditing(*m_page, WebViewDidBeginEditingNotification.get().impl());
    175175    notImplemented();
     
    178178void WebEditorClient::respondToChangedContents()
    179179{
    180     static NeverDestroyed<String> WebViewDidChangeNotification(ASCIILiteral("WebViewDidChangeNotification"));
     180    static NeverDestroyed<String> WebViewDidChangeNotification(MAKE_STATIC_STRING_IMPL("WebViewDidChangeNotification"));
    181181    m_page->injectedBundleEditorClient().didChange(*m_page, WebViewDidChangeNotification.get().impl());
    182182    notImplemented();
     
    185185void WebEditorClient::respondToChangedSelection(Frame* frame)
    186186{
    187     static NeverDestroyed<String> WebViewDidChangeSelectionNotification(ASCIILiteral("WebViewDidChangeSelectionNotification"));
     187    static NeverDestroyed<String> WebViewDidChangeSelectionNotification(MAKE_STATIC_STRING_IMPL("WebViewDidChangeSelectionNotification"));
    188188    m_page->injectedBundleEditorClient().didChangeSelection(*m_page, WebViewDidChangeSelectionNotification.get().impl());
    189189    if (!frame)
     
    219219void WebEditorClient::didEndEditing()
    220220{
    221     static NeverDestroyed<String> WebViewDidEndEditingNotification(ASCIILiteral("WebViewDidEndEditingNotification"));
     221    static NeverDestroyed<String> WebViewDidEndEditingNotification(MAKE_STATIC_STRING_IMPL("WebViewDidEndEditingNotification"));
    222222    m_page->injectedBundleEditorClient().didEndEditing(*m_page, WebViewDidEndEditingNotification.get().impl());
    223223    notImplemented();
  • trunk/Tools/ChangeLog

    r216212 r216217  
     12017-05-04  Mark Lam  <mark.lam@apple.com>
     2
     3        NeverDestroyed<String>(ASCIILiteral(...)) is not thread safe.
     4        https://bugs.webkit.org/show_bug.cgi?id=171586
     5        <rdar://problem/31873190>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        API test for exercising StaticStringImpl and the MAKE_STATIC_STRING_IMPL macro.
     10
     11        * TestWebKitAPI/Tests/WTF/StringImpl.cpp:
     12        (TestWebKitAPI::neverDestroyedString):
     13        (TestWebKitAPI::getNeverDestroyedStringAtStackDepth):
     14        (TestWebKitAPI::TEST):
     15
    1162017-05-04  Wenson Hsieh  <wenson_hsieh@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp

    r210230 r216217  
    2727
    2828#include <wtf/Hasher.h>
     29#include <wtf/NeverDestroyed.h>
    2930#include <wtf/text/SymbolImpl.h>
    3031#include <wtf/text/WTFString.h>
     
    627628}
    628629
     630static const String& neverDestroyedString()
     631{
     632    static NeverDestroyed<String> str(StaticStringImpl("NeverDestroyedString"));
     633    return str;
     634};
     635
     636static const String& getNeverDestroyedStringAtStackDepth(int i)
     637{
     638    if (--i)
     639        return getNeverDestroyedStringAtStackDepth(i);
     640    return neverDestroyedString();
     641};
     642
     643TEST(WTF, StaticStringImpl)
     644{
     645    // Construct using MAKE_STATIC_STRING_IMPL.
     646    String hello(MAKE_STATIC_STRING_IMPL("hello"));
     647    String world(MAKE_STATIC_STRING_IMPL("world"));
     648    String longer(MAKE_STATIC_STRING_IMPL("longer"));
     649    String hello2(MAKE_STATIC_STRING_IMPL("hello"));
     650
     651    ASSERT_EQ(strlen("hello"), hello.length());
     652    ASSERT_EQ(strlen("world"), world.length());
     653    ASSERT_EQ(strlen("longer"), longer.length());
     654    ASSERT_EQ(strlen("hello"), hello2.length());
     655
     656    ASSERT_TRUE(equal(hello, "hello"));
     657    ASSERT_TRUE(equal(world, "world"));
     658    ASSERT_TRUE(equal(longer, "longer"));
     659    ASSERT_TRUE(equal(hello2, "hello"));
     660
     661    // Each StaticStringImpl* returned by MAKE_STATIC_STRING_IMPL should be unique.
     662    ASSERT_NE(hello.impl(), hello2.impl());
     663
     664    // Test that MAKE_STATIC_STRING_IMPL isn't allocating a StaticStringImpl on the stack.
     665    const String& str1 = getNeverDestroyedStringAtStackDepth(10);
     666    ASSERT_EQ(strlen("NeverDestroyedString"), str1.length());
     667    ASSERT_TRUE(equal(str1, "NeverDestroyedString"));
     668
     669    const String& str2 = getNeverDestroyedStringAtStackDepth(20);
     670    ASSERT_EQ(strlen("NeverDestroyedString"), str2.length());
     671    ASSERT_TRUE(equal(str2, "NeverDestroyedString"));
     672
     673    ASSERT_TRUE(equal(str1, str2));
     674    ASSERT_EQ(&str1, &str2);
     675    ASSERT_EQ(str1.impl(), str2.impl());
     676}
     677
    629678} // namespace TestWebKitAPI
Note: See TracChangeset for help on using the changeset viewer.