feat(libSceJsc): implement the WTF StringImpl and StringView search queries #18420
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18420"
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 SHOnnay on 2026-11-11T13:46:25Z.
What
Implements 20 libSceJsc exports that threw: WTF string search queries.
WTF::StringImpl(18):startsWith(const*/&),startsWithIgnoringASCIICase(*/&)endsWith(*/&),endsWithIgnoringASCIICase(*/&)hasInfixStartingAt,hasInfixEndingAtfind(bool(*)(char16_t), unsigned),find(StringImpl*),find(StringImpl*, unsigned)reverseFind(StringImpl*, unsigned)findIgnoringASCIICaseoverloadsOthers (2):
WTF::StringView::contains(const char*)andWTF::protocolIs(StringView, const char*).Source. Ported from pinned WebKit
c55364d53f97:Source/WTF/wtf/text/StringImpl.{h,cpp},StringCommon.h,StringView.{h,cpp}andSource/WTF/wtf/URL.cpp. Every parameter list matches its mangled name. The PS5-WebKit-11.x overloads takeStringViewand do not match.Layout.
src/WtfStringAbi.hppmodels the 24-byteStringImpl(8-bit flag1 << 2) and the 16-byteStringViewwith static asserts. This is the layout libSceNKWebKit'sWtfStringAbialready uses.Behaviour.
findmatch function is called as a guestAPS5_VABIfunction, asWtfLanguage.cppdoes.this, reference, function or C-string arguments throw where WebKit faults.Files.
src/WtfStringSearch.cpp,src/WtfStringAbi.hpp,include/WtfStringSearchExports.hpp,tests/WtfStringSearch.cpp.jsc_placement_new.Left throwing:
WTF::Unicode::convert*: depends on version-specific ICUU8_NEXTsemantics.StringImpl.Tested
macOS 27 on Apple M1. The new registered test is a full-build test and was not run: the full build does not run on macOS. A Linux or Windows run is needed.
Harness. A temporary host harness, not committed, built the unchanged
WtfStringSearch.cppwith the test copied verbatim. It runs 140 hand-derived checks covering:All passed on x86-64 under Rosetta (ad-hoc signed) and on arm64.
Mutation check. All 5 hand mutations failed the harness on both architectures:
startsWithsemanticsreverseFindempty-needle clampprotocolIstab/newline skipFindCommonstart boundA sixth mutation survived; it is behaviour-equivalent. It drops the Latin-1 check in the single-character find, which changes nothing because an 8-bit unit can never equal a character above 0xFF.
Syntax.
clang++ -arch x86_64 -fsyntax-onlypasses onExport.cpp,LegacyExports.cpp,PlacementNew.cpp,GuestJscString.cpp, and the new source and test.Overlap. No open PR implements these exports.
gh pr listsearches found only #15708 touching libSceJsc, with no hits for these names.pr_overlap.pymerged the 2 PRs sharing files cleanly.docs/dev/debt/libSceJsc.mdis possible.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T16:04:23Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
8f3c62b483:tools/check_conventions.pypassed;git diff --checkclean.jsc_wtf_string_search_testsbuilt cleanly.jsc_wtf_string_search):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.!prefix || StartsWith(...), which evaluates totruewhenprefix == nullptr. In WebKit (StringImpl.h),startsWith(const StringImpl* prefix)returnsprefix && startsWith(*prefix)(returningfalsewhenprefixis null), consistent withstartsWithIgnoringASCIICaseEPKS0_andendsWithEPS0_. Furthermore, tests/WtfStringSearch.cpp:68 codifies this inverted logic by assertingCheck(_ZNK3WTF10StringImpl10startsWithEPKS0_(&hello, nullptr), __LINE__).IsASCIIAlphaCaselessEqualreturnsstatic_cast<int>(codeUnit | 0x20) == static_cast<int>(expected). Because bit 5 (0x20) is unconditionally set oncodeUnitwhileexpectedis unmasked, any uppercase ASCII letter inexpected('A'-'Z', values 0x41 to 0x5A) has bit 5 clear and can never match, causingprotocolIsto fail for protocols containing uppercase characters (e.g. 'HTTP'). Additionally, non-alpha characters with bit 5 clear (e.g. '@' 0x40) will spuriously match punctuation with bit 5 set (e.g. '`' 0x60). Both operands must be validated as ASCII alpha and folded.FindCommon, the checkif (start > haystack.length) return NotFound;precedesif (!needle.length) return start;. When searching for an empty needle (needle.length == 0) withstart > haystack.length, WebKit'sStringImpl::findreturnsstd::min(start, length())(clamped tohaystack.length).FindCommoninstead returnsNotFound, contradicting WebKit semantics as well asFindIgnoringASCIICase(line 203) andReverseFind(line 225) which correctly clamp empty needles. Unit test tests/WtfStringSearch.cpp:188 asserts this incorrect failure._ZN3WTF10protocolIsENS_10StringViewEPKc, the null checkif (!protocol) throw std::invalid_argument(__func__);is located inside the loop after skipping leading whitespace. Ifstringis empty or composed exclusively of whitespace characters (<= ' '), the loop finishes without executing line 353 and returnsfalse, bypassing the required null check onprotocol. The null check must occur at function entry before parsingstring, and tests/WtfStringSearch.cpp:310 improperly asserts thatprotocolIs(View(\" \"), nullptr)returnsfalsewithout throwing.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T18:36:21Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
8f3c62b483:tools/check_conventions.pypassed;git diff --checkclean.jsc_wtf_string_search_testsbuilt cleanly.jsc_wtf_string_search):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.Generated withfooter from the description; the AI-assisted checkbox can stay.Looks Good To Me