feat(libSceNKWebKit): implement WTF::PrintStream and StringPrintStream #14946
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14946"
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 w4rc0n on 2026-11-02T03:14:48Z.
What
WTF's printing layer was all
NotImplementedstubs, so guest code that printed through aPrintStreamthrew:dataLog,out.print(...), andtoString()on aStringPrintStream. 34 exports now follow the pinned PS5 WebKit 11.xPrintStream.cppandStringPrintStream.cpp:StringPrintStream:vprintf, which measures the formatted length first and grows the buffer once to fit, starting from the 128-byte inline buffer;reset,toCString,toString,toStringWithLatin1FallbackandtryToString.PrintStream::printf,printfVariableFormatandbegin.printInternalforconst char*,String,CString,StringImpl*,RawPointer,ClockType,booland every integer and floating-point type, anddumpCharacter.Guest code reaches these through the object's vtable, so the layout follows
PrintStream.handStringPrintStream.h:StringPrintStreamgets a vtable in Itanium order (D1, D0,vprintf,flush,begin,end).-fno-rtti(WebKitCompilerFlags.cmake).APS5_VABIfunction.static_assert).printfandprintInternalcall the stream's ownvprintfslot with a System Vva_list, so a guest subclass ofPrintStreamworks too.boolandClockTypego throughout.print, so they also callbeginandend, as in the source.vsnprintfexport (vsnprintf_nid_postfix) on every host, so conversions follow libc's guest rules, not the host's.%pprints bare lowercase hex with no0x, as measured on a PS5 (#7549, recorded indocs/dev/debt/libc.md).tryToString: returns anExpected<String, …>, 16 bytes through the return buffer. It fails only aboveString::MaxLength. Invalid UTF-8 is a success holding a nullString, as in the source.The internal vtable functions end in
_nid_no_patch, sotools/progress.pycounts only the 34 exports.PrintStream::endis left as it is, because #13930 implements it. Thedump(PrintStream&)methods of other classes are a follow-up.tools/pr_overlap.pyon this head, withmainat0eba5db30d: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge withmain, GitHub's file lists show none of them changing these exports either. #13992, #14172 and #15241 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14947 and #14948, in the same stack.Tested
Debian 12, GCC 12.2, Linux 6.18, Release, at the head
59a53bbfcbd5eadd60fe1711a5157d57ca5bb3b2, no local changes:guest_nkwebkit_dates,guest_nkwebkit_numbers,nkwebkit_base,nkwebkit_config,nkwebkit_constants,nkwebkit_fastbitvector,nkwebkit_jsc,nkwebkit_palsessionid,nkwebkit_preferences,nkwebkit_resourceresponse,nkwebkit_webcoregeometry,nkwebkit_wtf,guest_nkwebkit_urlsandpublic_headerspass. The newnkwebkit_wtfcases cover:printInternaltype;reset, and aCStringcopy that outlives the stream;RawPointerprinting as bare hex (1234), including after growth past the inline buffer within one call;tryToStringsucceeding on invalid UTF-8 and failing when oversized, and the Latin-1 fallback;vprintf,beginandendare called, including a redirectedbegin.tools/progress.py: the 34 exports count as implemented (libSceNKWebKit 1346, 1312 onmain).tools/check_conventions.pypasses.feat/nkwebkit-wtf-dumpsat its previous headce247d6dbe042c0616a02eb8117efe060b1cda2fand run 41385242010 builtfeat/nkwebkit-utf8-for-charactersat its previous heada3b0234339d1e891d111f410cf9a3e7dd30d9ca6, which both contain this PR's commit. It is AnyPS5'sBuildworkflow, dispatched in the author's fork withselect=true: the branch merged intomainat926f7dd492b0b432d9287f4d6faaaf1c9d3c86c5, built onwindows-latestwith WinLibs GCC 15.2 (MinGW-w64, UCRT). None of the 672 selected tests failed; 6 AGC tests were skipped, whichcheck_skips.pyaccepts. That includes the nine NKWebKit tests,public_headersandpatched_libraries. The later rebases ontomain(now0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #14479, #13766, #14925 and #15911) changed onlydocs/dev/debt/libSceNKWebKit.md, sogit range-diffshows the code and tests under test are the same as at that run. A fork-internal pull request existed only to give the workflow a number.Not built or run: macOS. The stream layouts and the vtable without RTTI come from the pinned source and build flags, not from console binaries. No title or homebrew was run.
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)Pull request closed