NEW 262059
Provide public C API for getting and setting JavaScriptCore options
https://bugs.webkit.org/show_bug.cgi?id=262059
Summary Provide public C API for getting and setting JavaScriptCore options
Kasper Isager Dalsgarð
Reported 2023-09-25 11:13:29 PDT
The public JavaScriptCore C API is currently missing functions for getting and settings options as defined by https://github.com/WebKit/WebKit/blob/main/Source/JavaScriptCore/runtime/OptionsList.h. This necessitates relying on environment variables instead, such as by using `setenv()`, though one can only set options this way and not get their current value.
Attachments
Mark Lam
Comment 1 2023-09-25 14:37:43 PDT
Why do you need to set these options? The options are designed for platform implementers to tune their system. These are low level options, and it takes intimate knowledge about how the system works in order to set them correctly. They are not intended for app developers to modify. In fact, many of the options are not safe for app developers to modify, and if set incorrectly, may result in performance / correctness / security issues. Can you explain why you are attempting to set these options (via environment variables) or otherwise?
Kasper Isager Dalsgarð
Comment 2 2023-09-25 23:36:16 PDT
I'm working on a JavaScript runtime that binds to several JavaScript engines, JavaScriptCore being one and V8 being another. Mostly for debugging purposes, the C API of the runtime exposes options for disabling or tracing JIT, enabling sampling profiling if available, and more. Through an API independent of the underlying engine, embedders can specify platform options, such as `trace_garbage_collection`, which are then translated to engine specific options behind the scenes, such as `--trace-gc` in V8 or `JSC_logGC=true` in JavaScriptCore. That particular option also happened to be one of the options you asked me to enable in https://bugs.webkit.org/show_bug.cgi?id=251261, and it has proven helpful in other cases as well. To some extent, it might also be true that I shouldn't be using the system JavaScriptCore framework for this; I could just embed it directly and rely on its internal APIs. Using the system JavaScriptCore framework is highly desirable, however, as it allows me to ship a mostly complete runtime, with things like CommonJS and C addon support, to Apple devices in only a few hundred KiB. The other bugs I've filed over the past year asking for additional public API to be exposed relates to the bits I'm missing for it to be fully complete.
Radar WebKit Bug Importer
Comment 3 2023-10-02 11:14:14 PDT
Note You need to log in before you can comment on or make changes to this bug.