Changeset 255112 in webkit
- Timestamp:
- Jan 24, 2020, 5:35:58 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r255110 r255112 1 2020-01-24 Mark Lam <mark.lam@apple.com> 2 3 IntlObject's cached strings should be immortal and safe for concurrent access. 4 https://bugs.webkit.org/show_bug.cgi?id=206779 5 <rdar://problem/58831763> 6 7 Reviewed by Yusuke Suzuki. 8 9 * stress/numberingSystemsForLocale-cached-strings-should-be-immortal-and-safe-for-concurrent-access.js: Added. 10 1 11 2020-01-24 Yusuke Suzuki <ysuzuki@apple.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r255088 r255112 1 2020-01-24 Mark Lam <mark.lam@apple.com> 2 3 IntlObject's cached strings should be immortal and safe for concurrent access. 4 https://bugs.webkit.org/show_bug.cgi?id=206779 5 <rdar://problem/58831763> 6 7 Reviewed by Yusuke Suzuki. 8 9 In IntlObject's numberingSystemsForLocale(), we have a never destroyed 10 cachedNumberingSystems which is a singleton vector of Strings which are shared 11 multiple VMs. Hence, the strings in this vector should be a StaticStringImpl 12 so that it will be immortal, and can be access concurrently from multiple VMs 13 on different threads without any ref/deref'ing race issues. 14 15 * runtime/IntlObject.cpp: 16 (JSC::numberingSystemsForLocale): 17 1 18 2020-01-24 Caio Lima <ticaiolima@gmail.com> 2 19 -
trunk/Source/JavaScriptCore/runtime/IntlObject.cpp
r251882 r255112 2 2 * Copyright (C) 2015 Andy VanWagoner (andy@vanwagoner.family) 3 3 * Copyright (C) 2015 Sukolsak Sakshuwong (sukolsak@gmail.com) 4 * Copyright (C) 2016-20 19Apple Inc. All rights reserved.4 * Copyright (C) 2016-2020 Apple Inc. All rights reserved. 5 5 * 6 6 * Redistribution and use in source and binary forms, with or without … … 892 892 Vector<String>& availableNumberingSystems = cachedNumberingSystems.get(); 893 893 894 if (UNLIKELY(availableNumberingSystems.isEmpty())) { 895 static Lock cachedNumberingSystemsMutex; 896 std::lock_guard<Lock> lock(cachedNumberingSystemsMutex); 897 if (availableNumberingSystems.isEmpty()) { 898 UErrorCode status = U_ZERO_ERROR; 899 UEnumeration* numberingSystemNames = unumsys_openAvailableNames(&status); 894 static std::once_flag initializeOnce; 895 std::call_once(initializeOnce, [&] { 896 ASSERT(availableNumberingSystems.isEmpty()); 897 UErrorCode status = U_ZERO_ERROR; 898 UEnumeration* numberingSystemNames = unumsys_openAvailableNames(&status); 899 ASSERT(U_SUCCESS(status)); 900 901 int32_t resultLength; 902 // Numbering system names are always ASCII, so use char[]. 903 while (const char* result = uenum_next(numberingSystemNames, &resultLength, &status)) { 900 904 ASSERT(U_SUCCESS(status)); 901 902 int32_t resultLength; 903 // Numbering system names are always ASCII, so use char[]. 904 while (const char* result = uenum_next(numberingSystemNames, &resultLength, &status)) { 905 ASSERT(U_SUCCESS(status)); 906 auto numsys = unumsys_openByName(result, &status); 907 ASSERT(U_SUCCESS(status)); 908 // Only support algorithmic if it is the default fot the locale, handled below. 909 if (!unumsys_isAlgorithmic(numsys)) 910 availableNumberingSystems.append(String(result, resultLength)); 911 unumsys_close(numsys); 912 } 913 uenum_close(numberingSystemNames); 914 } 915 } 905 auto numsys = unumsys_openByName(result, &status); 906 ASSERT(U_SUCCESS(status)); 907 // Only support algorithmic if it is the default fot the locale, handled below. 908 if (!unumsys_isAlgorithmic(numsys)) 909 availableNumberingSystems.append(String(StringImpl::createStaticStringImpl(result, resultLength))); 910 unumsys_close(numsys); 911 } 912 uenum_close(numberingSystemNames); 913 }); 916 914 917 915 UErrorCode status = U_ZERO_ERROR; -
trunk/Source/WTF/ChangeLog
r255087 r255112 1 2020-01-24 Mark Lam <mark.lam@apple.com> 2 3 IntlObject's cached strings should be immortal and safe for concurrent access. 4 https://bugs.webkit.org/show_bug.cgi?id=206779 5 <rdar://problem/58831763> 6 7 Reviewed by Yusuke Suzuki. 8 9 Add a factory for creating a dynamically allocated StaticStringImpl. 10 11 Note: StaticStringImpl is guaranteed to have the same shape as StringImpl. 12 The only difference is that s_refCountFlagIsStaticString is set on the refCount 13 for StaticStringImpl. Since the client will use the StaticStringImpl as a 14 StringImpl, we implement the factory by using StringImpl::createInternal() for 15 simplicity, and set the s_refCountFlagIsStaticString flag thereafter. 16 17 * wtf/text/StringImpl.cpp: 18 (WTF::StringImpl::createStaticStringImpl): 19 * wtf/text/StringImpl.h: 20 1 21 2020-01-24 Keith Rollin <krollin@apple.com> 2 22 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r253987 r255112 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) 5 * Copyright (C) 2003-20 18Apple Inc. All rights reserved.5 * Copyright (C) 2003-2020 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 7 7 * … … 280 280 { 281 281 return createInternal(characters, length); 282 } 283 284 Ref<StringImpl> StringImpl::createStaticStringImpl(const char* characters, unsigned length) 285 { 286 ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(characters), length)); 287 Ref<StringImpl> result = createInternal(reinterpret_cast<const LChar*>(characters), length); 288 result->m_refCount |= s_refCountFlagIsStaticString; 289 return result; 282 290 } 283 291 -
trunk/Source/WTF/wtf/text/StringImpl.h
r254881 r255112 1 1 /* 2 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 2005-20 19Apple Inc. All rights reserved.3 * Copyright (C) 2005-2020 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2009 Google Inc. All rights reserved. 5 5 * … … 255 255 WTF_EXPORT_PRIVATE static Ref<StringImpl> createUninitialized(unsigned length, UChar*&); 256 256 template<typename CharacterType> static RefPtr<StringImpl> tryCreateUninitialized(unsigned length, CharacterType*&); 257 258 WTF_EXPORT_PRIVATE static Ref<StringImpl> createStaticStringImpl(const char*, unsigned length); 257 259 258 260 // Reallocate the StringImpl. The originalString must be only owned by the Ref,
Note:
See TracChangeset
for help on using the changeset viewer.