feat(libSceJsc): implement WTF URL, time and StringBuilder read-only helpers #19104
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19104"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-11-12T19:43:18Z.
What
Implements nine read-only WTF helpers in
libSceJscthat threw throughNotImplemented_nid_no_patch. They are ported from WebKitc55364d53f97, the revision that the module'sWtfStringSearch.cppand its debt entry already follow.URL::port() constAxbrDa89hBsURL::query() const0CB7Dz8pEuAURL::isLocalFile() const2awTIdIwODIURL::protocolIsAbout() constYeskHF2qK4IURL::stringWithoutQueryOrFragmentIdentifier() constQlcy3AKepzUWTF::defaultPortForProtocol(StringView)8stlbyGspnETimeWithDynamicClockType::operator<(const TimeWithDynamicClockType&) const-tPqziuAbt0Seconds::operator+(const TimeWithDynamicClockType&) const-oW-aAeCPs4StringBuilder::isAllASCII() constR5rWHiU8BF4New
src/WtfUrlAbi.hppadds layouts to the 24-byteStringImpland 16-byteStringViewthat the module already uses. These are the same layoutslibSceNKWebKitmodels inWtfStringAbi.hppandWtfTextAbi.hpp, all pinned withstatic_assert:URL: string, bit field with valid bit 0, port length in bits 3-5 and scheme end from bit 6, then seven offsets;StringBuilder;SecondsandTimeWithDynamicClockType.WtfStringAbi.hppis not touched, so this does not collide with theStringlayout that #18430 and #18442 add there.Optional<uint16_t>is returned indirectly, with the flag at byte 0 and the value at byte 2.WTF::Optionalat this revision has a user-provided copy constructor, so the Itanium ABI returns it through a hidden pointer. The same reasoning backsResponseOptionalTimeinlibSceNKWebKit.portparses the substring afterhostEndwithparseUInt16/toIntegralType<uint16_t>. It skips leading and trailingisSpaceOrNewlinecharacters: Latin-1 ASCII spaces, and above U+00FF the Unicode bidi class WS set. It accepts an optional+and decimal digits only, and gives no value above 65535.StringView::substringclamping is kept, includingempty()(a non-null zero-length view) when the start is past the end.queryreturns a null view whenqueryEnd == pathEnd.stringWithoutQueryOrFragmentIdentifierreturns the whole string for an invalid URL, and otherwise the string up topathEnd.isLocalFileandprotocolIsAboutareprotocolIs(const char*): false for an invalid URL, otherwise an ASCII-case-insensitive (| 0x20) match of the scheme againstfileorabout.defaultPortForProtocolisURLParser::defaultPortForProtocol. It is case-sensitive:ws/httpgive 80,wss/httpsgive 443,ftpgives 21. One quirk of this revision is reproduced: a scheme starting withwwhose length is not 2 or 3 returnsfalseconverted to an engaged port 0. The testing override map that WebKit checks first stays empty, because this module exports neitherregisterDefaultPortForProtocolForTestingnorclearDefaultPortForProtocolMapForTesting.TimeWithDynamicClockType::operator<compares the raw seconds. Different clock types hit aRELEASE_ASSERTin WebKit, and here they throwstd::invalid_argument.Seconds::operator+returnsother + *thiswith the time's clock.StringBuilder::isAllASCIIreturns true for length 0. Otherwise it reads the characters ofm_string, orm_bufferwhen the string is null, in the builder's width, and checks that no unit is above 0x7F. An overflowed builder (RELEASE_ASSERTinlength()), a negative length, a nonzero length with no string or buffer, and null pointers throw.Debt: two entries are added under Functional. The six
InventoryExports.hpprows leave the NID table. The inventory counts in the prose are left as they are; the generated progress report gives current totals.Left out of this PR:
pageMask(),SHA1::hexDigestand the random/UUID helpers, which need a device page size orCStringallocation.Source of the behaviour (WebKit
c55364d53f97; no public reimplementation of these exports was found, so this is the only source)port, #L278-L288defaultPortForProtocol, #L300-L317protocolIs(const char*), #L337-L343query, #L650-L656stringWithoutQueryOrFragmentIdentifier, #L795-L802isLocalFile, #L843-L846protocolIsAbout; layout URL.h#L204-L222return falseat L595), StringView.cpp#L316-L323, StringToIntegerConversion.h#L48-L122, StringImpl.h#L770-L774 (isSpaceOrNewline)empty()), #L480-L500 (substring);Optionalcopy constructor Optional.h#L414-L424Tested
Linux x86-64 (Ubuntu 24.04, GCC 14), on
main09ab49de9649. The newjsc_wtf_urltest covers:portandqueryon a parsed-style URL. A port of 65535, 65536,+80,-1,8a,8\t, empty and00042; U+3000 around a digit; U+00A0 and a full-width digit.queryandstringWithoutQueryOrFragmentIdentifier, and a null URL string.file/about, a longer scheme, an invalid URL and a 16-bit URL.defaultPortForProtocolbranch, includingwandwebcalgiving an engaged 0, a 16-bit scheme and a null view with a length.operator<with NaN and with mismatched clocks;Seconds::operator+keeping the clock.isAllASCIIfor an empty builder, string before buffer, 8-bit and 16-bit buffers, an overflowed builder, no storage and a nullthis.Results:
ctest -R '^jsc_wtf_(url|string_search)$'passed in 2 of 2 runs.NotImplemented_nid_no_patch,jsc_wtf_urlaborts.tools/progress.py --compare: +9 implemented (libSceJsc 55/737 -> 64/737).tools/check_conventions.py --base origin/mainpasses.Not tested on a device or with a title.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)libSceJscExport.cpp,CMakeLists.txtand the debt file but implement none of these nine)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T00:31:38Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c754d9b33d:tools/check_conventions.pypassed;git diff --checkclean.jsc_wtf_url_testsbuilt cleanly.jsc_wtf_url):core/libs/prx/libSceJsc/Export.cpp,core/libs/prx/libSceJsc/include/Api.hpp,core/libs/prx/libSceJsc/include/InventoryExports.hpp,core/libs/prx/libSceJsc/libSceJsc.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me