feat(libSceJsc): implement JSValueMakeString and JSObjectHasPropertyForKey #19271
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19271"
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 c1b3r-p3d1a on 2026-11-13T01:26:36Z.
What
Implements
JSValueMakeStringandJSObjectHasPropertyForKey, two JavaScriptCore C API exports thatlibSceJscdeclares among its older (3.20) callable exports and that threw throughNotImplemented_nid_no_patch.libSceJscexports them, but JS contexts and values exist only inlibSceNKWebKit, which builds the C API on QuickJS (JSGlobalContextCreate,JSValueMakeNumber,JSObjectGetPropertyForKeyand the rest).libSceNKWebKitalready linkslibSceJsc, so the two exports cannot call into it directly. The PR uses the patternlibcuses fortimespec_getres:libSceJsc(src/ApiBridge.cpp) defines the exports andRegisterApiBridge_nid_no_patch, which stores a table of two function pointers.libSceNKWebKit(src/JscApiBridge.cpp) registers its QuickJS implementations from a static initializer, aslibkernelregisterssceKernelClockGetreswithlibc.libSceNKWebKit.Behaviour follows the C API in WebKit 73a35b43 (the revision used for other 3.20 exports), JSValueRef.cpp L336-L347 and JSObjectRef.cpp L386-L406:
JSValueMakeStringmakes a JS string from theJSStringRef(a null string makes"") and returns a handle like the otherJSValueMake*functions.JSObjectHasPropertyForKeyconverts the key with QuickJS's property-key conversion (JS_ValueToAtom, the counterpart oftoPropertyKey) and asksJS_HasProperty, so the prototype chain and proxyhastraps count. An exception from the key conversion or from a trap goes toexceptionand the call returns false. A null object or key returns false, as the existinglibSceNKWebKitForKeysiblings do.These are written from WebKit's documented behaviour on top of the existing QuickJS code; no WebKit code is copied. The "throwing JavaScriptCore, Inspector, WTF and bmalloc exports" count in
docs/dev/debt/libSceJsc.mdgoes from 136 to 134.JSWeakObjectMapCreatestays a placeholder.Unverified, as the debt entry says: nothing was compared with a console module.
Tested
Windows 11, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release.
nkwebkit_jscapibridge(in the NKWebKit tests, since onlylibSceNKWebKitcreates contexts). ForJSValueMakeStringit checks non-ASCII text checked from script, empty and null strings, two calls giving strictly equal values, and a null context. ForJSObjectHasPropertyForKeyit checks string, number and symbol keys, inherited properties, a different symbol with the same description, proxyhastraps that answer or throw, a key whosetoStringthrows (with and without anexceptionpointer), and null context, object and key.libSceJsc.prx: each export takes its arguments inrdi,rsi,rdx,rcx, returns 0 for a null context without touching the table, and otherwise calls the registered host function with the Windows host convention.main066b1f8a41: all 146nkwebkit,jscandpublic_headerstests pass;python tools/check_conventions.py --base origin/mainpasses.build/tests(#17895), so I copiedlibSceJsc.prxandlibSceNKWebKit.prxthere before each 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)Note: #19193 also lowers the
libSceJsc"throwing exports" count. Git merges the two edits of that line without a conflict and keeps both lines, so whichever merges second must drop the stale line and recount; I will do that on rebase.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T05:40:28Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
e00126ee6c:tools/check_conventions.pypassed;git diff --checkclean.nkwebkit_jscapibridge_testsbuilt cleanly.nkwebkit_jscapibridge):core/libs/prx/libSceJsc/Export.cpp,core/libs/prx/libSceJsc/include/Api.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