Changeset 281788 in webkit
- Timestamp:
- Aug 30, 2021 6:56:19 PM (11 months ago)
- Location:
- trunk
- Files:
-
- 7 added
- 20 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/temporal-calendar.js (added)
-
Source/JavaScriptCore/CMakeLists.txt (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/DerivedSources-input.xcfilelist (modified) (1 diff)
-
Source/JavaScriptCore/DerivedSources-output.xcfilelist (modified) (1 diff)
-
Source/JavaScriptCore/DerivedSources.make (modified) (1 diff)
-
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (modified) (7 diffs)
-
Source/JavaScriptCore/Sources.txt (modified) (1 diff)
-
Source/JavaScriptCore/runtime/CommonIdentifiers.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/IntlObject.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/IntlObject.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/IntlObjectInlines.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSGlobalObject.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/JSGlobalObject.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/TemporalCalendar.cpp (added)
-
Source/JavaScriptCore/runtime/TemporalCalendar.h (added)
-
Source/JavaScriptCore/runtime/TemporalCalendarConstructor.cpp (added)
-
Source/JavaScriptCore/runtime/TemporalCalendarConstructor.h (added)
-
Source/JavaScriptCore/runtime/TemporalCalendarPrototype.cpp (added)
-
Source/JavaScriptCore/runtime/TemporalCalendarPrototype.h (added)
-
Source/JavaScriptCore/runtime/TemporalObject.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/VM.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/VM.h (modified) (2 diffs)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/text/StringImpl.cpp (modified) (1 diff)
-
Source/WTF/wtf/text/StringImpl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r281748 r281788 1 2021-08-30 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Implement Temporal.Calendar 4 https://bugs.webkit.org/show_bug.cgi?id=229651 5 6 Reviewed by Ross Kirsling. 7 8 * stress/temporal-calendar.js: Added. 9 (shouldBe): 10 (shouldThrow): 11 (new.Temporal.Calendar): 12 1 13 2021-08-29 Yusuke Suzuki <ysuzuki@apple.com> 2 14 -
trunk/Source/JavaScriptCore/CMakeLists.txt
r281757 r281788 108 108 runtime/SymbolConstructor.cpp 109 109 runtime/SymbolPrototype.cpp 110 runtime/TemporalCalendarConstructor.cpp 111 runtime/TemporalCalendarPrototype.cpp 110 112 runtime/TemporalObject.cpp 111 113 -
trunk/Source/JavaScriptCore/ChangeLog
r281776 r281788 1 2021-08-30 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Implement Temporal.Calendar 4 https://bugs.webkit.org/show_bug.cgi?id=229651 5 6 Reviewed by Ross Kirsling. 7 8 This patch implements Temporal.Calendar's simple part. Currently, we do not implement many part of Temporal.Calendar since 9 we do not have Temporal Date-like structures yet, but this patch implemented core part of Temporal.Calendar: keeping calendar 10 identifier. 11 12 We also defer implementing Temporal.Calendar.from's calendar ID parsing part since it requires full-fledged ISO 8601 parser, 13 which will be implemented in a separate patch. 14 15 We use `unsigned` for CalendarID, and this id corresponds to the array index of intlAvailableCalendars, which returns array 16 of String from ICU. 17 18 * CMakeLists.txt: 19 * DerivedSources-input.xcfilelist: 20 * DerivedSources-output.xcfilelist: 21 * DerivedSources.make: 22 * JavaScriptCore.xcodeproj/project.pbxproj: 23 * Sources.txt: 24 * runtime/CommonIdentifiers.h: 25 * runtime/IntlObject.cpp: 26 (JSC::intlAvailableCalendars): 27 (JSC::iso8601CalendarIDSlow): 28 (JSC::availableCalendars): 29 (JSC::createArrayFromStringVector): Deleted. 30 * runtime/IntlObject.h: 31 (JSC::iso8601CalendarID): 32 * runtime/IntlObjectInlines.h: 33 (JSC::createArrayFromStringVector): 34 * runtime/JSGlobalObject.cpp: 35 (JSC::JSGlobalObject::init): 36 (JSC::JSGlobalObject::visitChildrenImpl): 37 * runtime/JSGlobalObject.h: 38 (JSC::JSGlobalObject::calendarStructure): 39 * runtime/TemporalCalendar.cpp: Added. 40 (JSC::TemporalCalendar::create): 41 (JSC::TemporalCalendar::createStructure): 42 (JSC::TemporalCalendar::TemporalCalendar): 43 (JSC::TemporalCalendar::isBuiltinCalendar): 44 (JSC::parseTemporalCalendarString): 45 (JSC::TemporalCalendar::from): 46 * runtime/TemporalCalendar.h: Added. 47 * runtime/TemporalCalendarConstructor.cpp: Added. 48 (JSC::TemporalCalendarConstructor::create): 49 (JSC::TemporalCalendarConstructor::createStructure): 50 (JSC::TemporalCalendarConstructor::TemporalCalendarConstructor): 51 (JSC::TemporalCalendarConstructor::finishCreation): 52 (JSC::JSC_DEFINE_HOST_FUNCTION): 53 * runtime/TemporalCalendarConstructor.h: Added. 54 * runtime/TemporalCalendarPrototype.cpp: Added. 55 (JSC::TemporalCalendarPrototype::create): 56 (JSC::TemporalCalendarPrototype::createStructure): 57 (JSC::TemporalCalendarPrototype::TemporalCalendarPrototype): 58 (JSC::TemporalCalendarPrototype::finishCreation): 59 (JSC::JSC_DEFINE_CUSTOM_GETTER): 60 (JSC::JSC_DEFINE_HOST_FUNCTION): 61 (JSC::defaultMergeFields): 62 * runtime/TemporalCalendarPrototype.h: Added. 63 * runtime/TemporalObject.cpp: 64 (JSC::createCalendarConstructor): 65 * runtime/VM.cpp: 66 * runtime/VM.h: 67 1 68 2021-08-30 Ross Kirsling <ross.kirsling@sony.com> 2 69 -
trunk/Source/JavaScriptCore/DerivedSources-input.xcfilelist
r279638 r281788 170 170 $(PROJECT_DIR)/runtime/SymbolConstructor.cpp 171 171 $(PROJECT_DIR)/runtime/SymbolPrototype.cpp 172 $(PROJECT_DIR)/runtime/TemporalCalendarConstructor.cpp 173 $(PROJECT_DIR)/runtime/TemporalCalendarPrototype.cpp 172 174 $(PROJECT_DIR)/runtime/TemporalObject.cpp 173 175 $(PROJECT_DIR)/ucd/CaseFolding.txt -
trunk/Source/JavaScriptCore/DerivedSources-output.xcfilelist
r279638 r281788 67 67 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/SymbolConstructor.lut.h 68 68 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/SymbolPrototype.lut.h 69 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalCalendarConstructor.lut.h 70 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalCalendarPrototype.lut.h 69 71 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalObject.lut.h 70 72 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/UnicodePatternTables.h -
trunk/Source/JavaScriptCore/DerivedSources.make
r279630 r281788 192 192 SymbolConstructor.lut.h \ 193 193 SymbolPrototype.lut.h \ 194 TemporalCalendarConstructor.lut.h \ 195 TemporalCalendarPrototype.lut.h \ 194 196 TemporalObject.lut.h \ 195 197 WebAssemblyCompileErrorConstructor.lut.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r281684 r281788 1848 1848 E32AB2441DCD75F400D7533A /* MacroAssemblerHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = E380A76B1DCD7195000F89E6 /* MacroAssemblerHelpers.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1849 1849 E32C3C6923E94C1E00BC97C0 /* UnlinkedCodeBlockGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = E32C3C6823E94C1E00BC97C0 /* UnlinkedCodeBlockGenerator.h */; }; 1850 E32D4DE726DAFD4300D4533A /* TemporalCalendarPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = E32D4DE126DAFD4200D4533A /* TemporalCalendarPrototype.h */; }; 1851 E32D4DE926DAFD4300D4533A /* TemporalCalendar.h in Headers */ = {isa = PBXBuildFile; fileRef = E32D4DE326DAFD4300D4533A /* TemporalCalendar.h */; }; 1852 E32D4DEA26DAFD4300D4533A /* TemporalCalendarConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = E32D4DE426DAFD4300D4533A /* TemporalCalendarConstructor.h */; }; 1850 1853 E33095DD23210A1B00EB7856 /* JSInternalFieldObjectImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = E33095DC23210A1400EB7856 /* JSInternalFieldObjectImpl.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1851 1854 E334CBB521FD96A9000EB178 /* RegExpGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E334CBB321FD96A9000EB178 /* RegExpGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1903 1906 E39D45F51D39005600B3B377 /* InterpreterInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E39D9D841D39000600667282 /* InterpreterInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1904 1907 E39D8B2E23021E2600265852 /* WasmOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = E39D8B2D23021E1E00265852 /* WasmOperations.h */; }; 1908 E39DA1DA26DB5E4C00100437 /* TemporalCalendarPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C4630626DB5DE900896336 /* TemporalCalendarPrototype.lut.h */; }; 1909 E39DA1DB26DB5E5100100437 /* TemporalCalendarConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C4630526DB5DE900896336 /* TemporalCalendarConstructor.lut.h */; }; 1905 1910 E39DA4A71B7E8B7C0084F33A /* JSModuleRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = E39DA4A51B7E8B7C0084F33A /* JSModuleRecord.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1906 1911 E39EEAF322812450008474F4 /* CachedSpecialPropertyAdaptiveStructureWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = E39EEAF22281244C008474F4 /* CachedSpecialPropertyAdaptiveStructureWatchpoint.h */; }; … … 5088 5093 E3282BBA1FE930A400EDAF71 /* YarrErrorCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YarrErrorCode.h; path = yarr/YarrErrorCode.h; sourceTree = "<group>"; }; 5089 5094 E32C3C6823E94C1E00BC97C0 /* UnlinkedCodeBlockGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedCodeBlockGenerator.h; sourceTree = "<group>"; }; 5095 E32D4DE026DAFD4200D4533A /* TemporalCalendar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalCalendar.cpp; sourceTree = "<group>"; }; 5096 E32D4DE126DAFD4200D4533A /* TemporalCalendarPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalCalendarPrototype.h; sourceTree = "<group>"; }; 5097 E32D4DE226DAFD4200D4533A /* TemporalCalendarPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalCalendarPrototype.cpp; sourceTree = "<group>"; }; 5098 E32D4DE326DAFD4300D4533A /* TemporalCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalCalendar.h; sourceTree = "<group>"; }; 5099 E32D4DE426DAFD4300D4533A /* TemporalCalendarConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalCalendarConstructor.h; sourceTree = "<group>"; }; 5100 E32D4DE526DAFD4300D4533A /* TemporalCalendarConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalCalendarConstructor.cpp; sourceTree = "<group>"; }; 5090 5101 E3305FB020B0F78700CEB82B /* InByVariant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InByVariant.cpp; sourceTree = "<group>"; }; 5091 5102 E3305FB120B0F78800CEB82B /* InByVariant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InByVariant.h; sourceTree = "<group>"; }; … … 5203 5214 E3BFD0BA1DAF807C0065DEA2 /* AccessCaseSnippetParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessCaseSnippetParams.h; sourceTree = "<group>"; }; 5204 5215 E3C295DC1ED2CBAA00D3016F /* ObjectPropertyChangeAdaptiveWatchpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectPropertyChangeAdaptiveWatchpoint.h; sourceTree = "<group>"; }; 5216 E3C4630526DB5DE900896336 /* TemporalCalendarConstructor.lut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TemporalCalendarConstructor.lut.h; sourceTree = "<group>"; }; 5217 E3C4630626DB5DE900896336 /* TemporalCalendarPrototype.lut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TemporalCalendarPrototype.lut.h; sourceTree = "<group>"; }; 5205 5218 E3C694B123026873006FBE42 /* WasmOSREntryData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WasmOSREntryData.h; sourceTree = "<group>"; }; 5206 5219 E3C694B223026874006FBE42 /* WasmTierUpCount.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WasmTierUpCount.cpp; sourceTree = "<group>"; }; … … 7010 7023 996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */, 7011 7024 996B73141BD9FA2C00331B84 /* SymbolPrototype.lut.h */, 7025 E3C4630526DB5DE900896336 /* TemporalCalendarConstructor.lut.h */, 7026 E3C4630626DB5DE900896336 /* TemporalCalendarPrototype.lut.h */, 7012 7027 F6F150202693D450004B98EF /* TemporalObject.lut.h */, 7013 7028 533B15DE1DC7F463004D500A /* WasmOps.h */, … … 7954 7969 BDB4B5E099CD4C1BB3C1CF05 /* TemplateObjectDescriptor.cpp */, 7955 7970 70ECA6041AFDBEA200449739 /* TemplateObjectDescriptor.h */, 7971 E32D4DE026DAFD4200D4533A /* TemporalCalendar.cpp */, 7972 E32D4DE326DAFD4300D4533A /* TemporalCalendar.h */, 7973 E32D4DE526DAFD4300D4533A /* TemporalCalendarConstructor.cpp */, 7974 E32D4DE426DAFD4300D4533A /* TemporalCalendarConstructor.h */, 7975 E32D4DE226DAFD4200D4533A /* TemporalCalendarPrototype.cpp */, 7976 E32D4DE126DAFD4200D4533A /* TemporalCalendarPrototype.h */, 7956 7977 F6F1501B2693D33E004B98EF /* TemporalNow.cpp */, 7957 7978 F6F150182693D33D004B98EF /* TemporalNow.h */, … … 10650 10671 DC7997831CDE9FA0004D4A09 /* TagRegistersMode.h in Headers */, 10651 10672 70ECA6091AFDBEA200449739 /* TemplateObjectDescriptor.h in Headers */, 10673 E32D4DE926DAFD4300D4533A /* TemporalCalendar.h in Headers */, 10674 E32D4DEA26DAFD4300D4533A /* TemporalCalendarConstructor.h in Headers */, 10675 E39DA1DB26DB5E5100100437 /* TemporalCalendarConstructor.lut.h in Headers */, 10676 E32D4DE726DAFD4300D4533A /* TemporalCalendarPrototype.h in Headers */, 10677 E39DA1DA26DB5E4C00100437 /* TemporalCalendarPrototype.lut.h in Headers */, 10652 10678 F6F150212693D450004B98EF /* TemporalObject.lut.h in Headers */, 10653 10679 0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */, -
trunk/Source/JavaScriptCore/Sources.txt
r281757 r281788 1011 1011 runtime/SymbolTable.cpp 1012 1012 runtime/TemplateObjectDescriptor.cpp 1013 runtime/TemporalCalendar.cpp 1014 runtime/TemporalCalendarConstructor.cpp 1015 runtime/TemporalCalendarPrototype.cpp 1013 1016 runtime/TemporalNow.cpp 1014 1017 runtime/TemporalObject.cpp -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r281375 r281788 111 111 macro(enumerable) \ 112 112 macro(era) \ 113 macro(eraYear) \ 113 114 macro(errors) \ 114 115 macro(eval) \ … … 170 171 macro(minute) \ 171 172 macro(month) \ 173 macro(monthCode) \ 172 174 macro(multiline) \ 173 175 macro(name) \ -
trunk/Source/JavaScriptCore/runtime/IntlObject.cpp
r281776 r281788 1576 1576 } 1577 1577 1578 const Vector<String>& intlAvailableCalendars() 1579 { 1580 static LazyNeverDestroyed<Vector<String>> availableCalendars; 1581 static std::once_flag initializeOnce; 1582 std::call_once(initializeOnce, [&] { 1583 availableCalendars.construct(); 1584 ASSERT(availableCalendars->isEmpty()); 1585 1586 UErrorCode status = U_ZERO_ERROR; 1587 auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucal_getKeywordValuesForLocale("calendars", "und", false, &status)); 1588 ASSERT(U_SUCCESS(status)); 1589 1590 int32_t count = uenum_count(enumeration.get(), &status); 1591 ASSERT(U_SUCCESS(status)); 1592 availableCalendars->reserveInitialCapacity(count); 1593 1594 auto createImmortalThreadSafeString = [&](String&& string) { 1595 if (string.is8Bit()) 1596 return StringImpl::createStaticStringImpl(string.characters8(), string.length()); 1597 return StringImpl::createStaticStringImpl(string.characters16(), string.length()); 1598 }; 1599 1600 for (int32_t index = 0; index < count; ++index) { 1601 int32_t length = 0; 1602 const char* pointer = uenum_next(enumeration.get(), &length, &status); 1603 ASSERT(U_SUCCESS(status)); 1604 String calendar(pointer, length); 1605 if (auto mapped = mapICUCalendarKeywordToBCP47(calendar)) 1606 availableCalendars->append(createImmortalThreadSafeString(WTFMove(mapped.value()))); 1607 else 1608 availableCalendars->append(createImmortalThreadSafeString(WTFMove(calendar))); 1609 } 1610 1611 // The AvailableCalendars abstract operation returns a List, ordered as if an Array of the same 1612 // values had been sorted using %Array.prototype.sort% using undefined as comparefn 1613 std::sort(availableCalendars->begin(), availableCalendars->end(), 1614 [](const String& a, const String& b) { 1615 return WTF::codePointCompare(a, b) < 0; 1616 }); 1617 }); 1618 return availableCalendars; 1619 } 1620 1621 CalendarID iso8601CalendarIDStorage { std::numeric_limits<CalendarID>::max() }; 1622 CalendarID iso8601CalendarIDSlow() 1623 { 1624 static std::once_flag initializeOnce; 1625 std::call_once(initializeOnce, [&] { 1626 const auto& calendars = intlAvailableCalendars(); 1627 for (unsigned index = 0; index < calendars.size(); ++index) { 1628 if (calendars[index] == "iso8601"_s) { 1629 iso8601CalendarIDStorage = index; 1630 return; 1631 } 1632 } 1633 RELEASE_ASSERT_NOT_REACHED(); 1634 }); 1635 return iso8601CalendarIDStorage; 1636 } 1637 1578 1638 // https://tc39.es/proposal-intl-enumeration/#sec-availablecalendars 1579 1639 static JSArray* availableCalendars(JSGlobalObject* globalObject) 1580 1640 { 1581 VM& vm = globalObject->vm(); 1582 auto scope = DECLARE_THROW_SCOPE(vm); 1583 1584 UErrorCode status = U_ZERO_ERROR; 1585 auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucal_getKeywordValuesForLocale("calendars", "und", false, &status)); 1586 if (U_FAILURE(status)) { 1587 throwTypeError(globalObject, scope, "failed to enumerate available calendars"_s); 1588 return { }; 1589 } 1590 1591 int32_t count = uenum_count(enumeration.get(), &status); 1592 if (U_FAILURE(status)) { 1593 throwTypeError(globalObject, scope, "failed to enumerate available calendars"_s); 1594 return { }; 1595 } 1596 1597 Vector<String, 1> elements; 1598 elements.reserveInitialCapacity(count); 1599 for (int32_t index = 0; index < count; ++index) { 1600 int32_t length = 0; 1601 const char* pointer = uenum_next(enumeration.get(), &length, &status); 1602 if (U_FAILURE(status)) { 1603 throwTypeError(globalObject, scope, "failed to enumerate available calendars"_s); 1604 return { }; 1605 } 1606 String calendar(pointer, length); 1607 if (auto mapped = mapICUCalendarKeywordToBCP47(calendar)) 1608 elements.append(WTFMove(mapped.value())); 1609 else 1610 elements.append(WTFMove(calendar)); 1611 } 1612 1613 // The AvailableCalendars abstract operation returns a List, ordered as if an Array of the same 1614 // values had been sorted using %Array.prototype.sort% using undefined as comparefn 1615 std::sort(elements.begin(), elements.end(), 1616 [](const String& a, const String& b) { 1617 return WTF::codePointCompare(a, b) < 0; 1618 }); 1619 1620 RELEASE_AND_RETURN(scope, createArrayFromStringVector(globalObject, WTFMove(elements))); 1641 return createArrayFromStringVector(globalObject, intlAvailableCalendars()); 1621 1642 } 1622 1643 … … 1866 1887 } 1867 1888 1868 JSArray* createArrayFromStringVector(JSGlobalObject* globalObject, Vector<String, 1>&& elements)1869 {1870 VM& vm = globalObject->vm();1871 auto scope = DECLARE_THROW_SCOPE(vm);1872 1873 JSArray* result = JSArray::tryCreate(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), elements.size());1874 if (!result) {1875 throwOutOfMemoryError(globalObject, scope);1876 return nullptr;1877 }1878 for (unsigned index = 0; index < elements.size(); ++index) {1879 result->putDirectIndex(globalObject, index, jsString(vm, WTFMove(elements[index])));1880 RETURN_IF_EXCEPTION(scope, { });1881 }1882 return result;1883 }1884 1885 1889 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/IntlObject.h
r281513 r281788 102 102 inline const LocaleSet& intlListFormatAvailableLocales() { return intlAvailableLocales(); } 103 103 104 using CalendarID = unsigned; 105 const Vector<String>& intlAvailableCalendars(); 106 107 extern CalendarID iso8601CalendarIDStorage; 108 CalendarID iso8601CalendarIDSlow(); 109 inline CalendarID iso8601CalendarID() 110 { 111 unsigned value = iso8601CalendarIDStorage; 112 if (value == std::numeric_limits<CalendarID>::max()) 113 return iso8601CalendarIDSlow(); 114 return value; 115 } 116 104 117 TriState intlBooleanOption(JSGlobalObject*, JSObject* options, PropertyName); 105 118 String intlStringOption(JSGlobalObject*, JSObject* options, PropertyName, std::initializer_list<const char*> values, const char* notFound, const char* fallback); … … 149 162 std::optional<String> mapBCP47ToICUCalendarKeyword(const String&); 150 163 151 JSArray* createArrayFromStringVector(JSGlobalObject*, Vector<String, 1>&&);152 153 164 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/IntlObjectInlines.h
r278035 r281788 226 226 } 227 227 228 template<typename Container> 229 JSArray* createArrayFromStringVector(JSGlobalObject* globalObject, const Container& elements) 230 { 231 VM& vm = globalObject->vm(); 232 auto scope = DECLARE_THROW_SCOPE(vm); 233 234 JSArray* result = JSArray::tryCreate(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), elements.size()); 235 if (!result) { 236 throwOutOfMemoryError(globalObject, scope); 237 return nullptr; 238 } 239 for (unsigned index = 0; index < elements.size(); ++index) { 240 result->putDirectIndex(globalObject, index, jsString(vm, elements[index])); 241 RETURN_IF_EXCEPTION(scope, { }); 242 } 243 return result; 244 } 245 228 246 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r280760 r281788 202 202 #include "SymbolObject.h" 203 203 #include "SymbolPrototype.h" 204 #include "TemporalCalendar.h" 205 #include "TemporalCalendarConstructor.h" 206 #include "TemporalCalendarPrototype.h" 204 207 #include "TemporalObject.h" 205 208 #include "VMTrapsInlines.h" … … 1213 1216 1214 1217 if (Options::useTemporal()) { 1218 m_calendarStructure.initLater( 1219 [] (const Initializer<Structure>& init) { 1220 JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(init.owner); 1221 TemporalCalendarPrototype* calendarPrototype = TemporalCalendarPrototype::create(init.vm, globalObject, TemporalCalendarPrototype::createStructure(init.vm, globalObject, globalObject->objectPrototype())); 1222 init.set(TemporalCalendar::createStructure(init.vm, globalObject, calendarPrototype)); 1223 }); 1224 1215 1225 TemporalObject* temporal = TemporalObject::create(vm, TemporalObject::createStructure(vm, this)); 1216 1226 putDirectWithoutTransition(vm, vm.propertyNames->Temporal, temporal, static_cast<unsigned>(PropertyAttribute::DontEnum)); … … 2091 2101 thisObject->m_numberFormatStructure.visit(visitor); 2092 2102 2103 thisObject->m_calendarStructure.visit(visitor); 2104 2093 2105 visitor.append(thisObject->m_nullGetterFunction); 2094 2106 visitor.append(thisObject->m_nullSetterFunction); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r281429 r281788 325 325 LazyClassStructure m_numberFormatStructure; 326 326 327 LazyProperty<JSGlobalObject, Structure> m_calendarStructure; 328 327 329 WriteBarrier<NullGetterFunction> m_nullGetterFunction; 328 330 WriteBarrier<NullSetterFunction> m_nullSetterFunction; … … 871 873 JSObject* numberFormatPrototype() { return m_numberFormatStructure.prototype(this); } 872 874 875 Structure* calendarStructure() { return m_calendarStructure.get(this); } 876 873 877 JS_EXPORT_PRIVATE void setRemoteDebuggingEnabled(bool); 874 878 JS_EXPORT_PRIVATE bool remoteDebuggingEnabled() const; -
trunk/Source/JavaScriptCore/runtime/TemporalObject.cpp
r280506 r281788 1 1 /* 2 2 * Copyright (C) 2021 Igalia S.L. All rights reserved. 3 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 21 22 #include "TemporalObject.h" 22 23 24 #include "FunctionPrototype.h" 23 25 #include "JSCJSValueInlines.h" 24 26 #include "JSGlobalObject.h" 25 27 #include "JSObjectInlines.h" 26 28 #include "ObjectPrototype.h" 29 #include "TemporalCalendarConstructor.h" 30 #include "TemporalCalendarPrototype.h" 27 31 #include "TemporalNow.h" 28 32 … … 30 34 31 35 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(TemporalObject); 36 37 static JSValue createCalendarConstructor(VM& vm, JSObject* object) 38 { 39 TemporalObject* temporalObject = jsCast<TemporalObject*>(object); 40 JSGlobalObject* globalObject = temporalObject->globalObject(vm); 41 return TemporalCalendarConstructor::create(vm, TemporalCalendarConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<TemporalCalendarPrototype*>(globalObject->calendarStructure()->storedPrototypeObject())); 42 } 32 43 33 44 static JSValue createNowObject(VM& vm, JSObject* object) … … 46 57 /* Source for TemporalObject.lut.h 47 58 @begin temporalObjectTable 59 Calendar createCalendarConstructor DontEnum|PropertyCallback 48 60 Now createNowObject DontEnum|PropertyCallback 49 61 @end -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r279216 r281788 163 163 #include "StructureInlines.h" 164 164 #include "SymbolObject.h" 165 #include "TemporalCalendar.h" 165 166 #include "TestRunnerUtils.h" 166 167 #include "ThunkGenerators.h" … … 1585 1586 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(symbolObjectSpace, cellHeapCellType.get(), SymbolObject) 1586 1587 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(templateObjectDescriptorSpace, destructibleCellHeapCellType.get(), JSTemplateObjectDescriptor) 1588 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(temporalCalendarSpace, cellHeapCellType.get(), TemporalCalendar) 1587 1589 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(uint8ArraySpace, cellHeapCellType.get(), JSUint8Array) 1588 1590 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(uint8ClampedArraySpace, cellHeapCellType.get(), JSUint8ClampedArray) -
trunk/Source/JavaScriptCore/runtime/VM.h
r279976 r281788 194 194 class VirtualRegister; 195 195 class VMEntryScope; 196 class TemporalCalendar; 196 197 class TopLevelGlobalObjectScope; 197 198 class TypeProfiler; … … 592 593 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(symbolObjectSpace) 593 594 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(templateObjectDescriptorSpace) 595 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(temporalCalendarSpace) 594 596 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(uint8ArraySpace) 595 597 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(uint8ClampedArraySpace) -
trunk/Source/WTF/ChangeLog
r281771 r281788 1 2021-08-30 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Implement Temporal.Calendar 4 https://bugs.webkit.org/show_bug.cgi?id=229651 5 6 Reviewed by Ross Kirsling. 7 8 Add UChar version of createStaticStringImpl to make immortal thread-safe StringImpl with UChar. 9 10 * wtf/text/StringImpl.cpp: 11 (WTF::StringImpl::createStaticStringImpl): 12 * wtf/text/StringImpl.h: 13 (WTF::StringImpl::createStaticStringImpl): 14 1 15 2021-08-30 Sihui Liu <sihui_liu@apple.com> 2 16 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r281513 r281788 285 285 } 286 286 287 Ref<StringImpl> StringImpl::createStaticStringImpl(const char* characters, unsigned length) 288 { 289 const LChar* lcharCharacters = reinterpret_cast<const LChar*>(characters); 290 ASSERT(charactersAreAllASCII(lcharCharacters, length)); 291 Ref<StringImpl> result = createInternal(lcharCharacters, length); 292 result->setHash(StringHasher::computeHashAndMaskTop8Bits(lcharCharacters, length)); 287 Ref<StringImpl> StringImpl::createStaticStringImpl(const LChar* characters, unsigned length) 288 { 289 if (!length) 290 return *empty(); 291 Ref<StringImpl> result = createInternal(characters, length); 292 result->hash(); 293 result->m_refCount |= s_refCountFlagIsStaticString; 294 return result; 295 } 296 297 Ref<StringImpl> StringImpl::createStaticStringImpl(const UChar* characters, unsigned length) 298 { 299 if (!length) 300 return *empty(); 301 Ref<StringImpl> result = create8BitIfPossible(characters, length); 302 result->hash(); 293 303 result->m_refCount |= s_refCountFlagIsStaticString; 294 304 return result; -
trunk/Source/WTF/wtf/text/StringImpl.h
r281737 r281788 260 260 template<typename CharacterType> static RefPtr<StringImpl> tryCreateUninitialized(unsigned length, CharacterType*&); 261 261 262 WTF_EXPORT_PRIVATE static Ref<StringImpl> createStaticStringImpl(const char*, unsigned length); 262 static Ref<StringImpl> createStaticStringImpl(const char* characters, unsigned length) 263 { 264 ASSERT(charactersAreAllASCII(bitwise_cast<const LChar*>(characters), length)); 265 return createStaticStringImpl(bitwise_cast<const LChar*>(characters), length); 266 } 267 WTF_EXPORT_PRIVATE static Ref<StringImpl> createStaticStringImpl(const LChar*, unsigned length); 268 WTF_EXPORT_PRIVATE static Ref<StringImpl> createStaticStringImpl(const UChar*, unsigned length); 263 269 264 270 // Reallocate the StringImpl. The originalString must be only owned by the Ref,
Note: See TracChangeset
for help on using the changeset viewer.