GNOME Bugzilla – Bug 691109
Remove support for multiple contexts within a runtime
Last modified: 2013-01-07 18:36:24 UTC
This has always been a very hacky, weird situation, and I've thought about just sort of scrapping the weird stack situation we have here. After some eavesdropping on #jsapi talking about merging JSContext and JSRuntime, I felt validated, and wrote this patch set.
Created attachment 232701 [details] [review] context: Don't allow users to pass external runtimes to GjsContext Upstream wants to merge JSContext and JSRuntime, because the distinction has been a constant source and confusion and pain as they rearrange the runtime. As a first step towards making this shift on the gjs side, we need to discourage external consumers of gjs from making the distinction. Remove support for the "runtime" property which allows consumers of gjs to specify their own JS runtime.
Created attachment 232702 [details] [review] Remove support for multiple contexts within a runtime Remove code and support code to allow for multiple contexts, and simply store one context. In a thread-safe world, we'd put each context in thread-local storage, but gjs is not thread-safe, nor do we expect it will be in the future.
Created attachment 232703 [details] [review] context: Remove RuntimeData and gjs_runtime_init/gjs_runtime_destroy Now that RuntimeData only contains one pointer, we can just swap out the allocation with a direct reference to the pointer instead. The leftover initialization functions, not needing to do memory management, become one-liners and we can simply squash them where used.
Depends on bug #691108 only for some reindenting changes that confuse diff/patch. Can easily rebase without it, if wanted.
(In reply to comment #0) > This has always been a very hacky, weird situation, and I've thought > about just sort of scrapping the weird stack situation we have here. > > After some eavesdropping on #jsapi talking about merging JSContext > and JSRuntime, I felt validated, and wrote this patch set. I think the main reason the JSContext/JSRuntime distinction is basically obsolete is because they have compartments now, which maps *much* better to the web browser model (domains). We don't have anything analogous to that situation in GNOME apps because we use multiple operating system processes, so for us runtime == context == compartment.
Review of attachment 232701 [details] [review]: Looks correct to me.
Review of attachment 232702 [details] [review]: Looks great.
Review of attachment 232703 [details] [review]: Also looks great.
Attachment 232701 [details] pushed as d9f8e52 - context: Don't allow users to pass external runtimes to GjsContext Attachment 232702 [details] pushed as 244f186 - Remove support for multiple contexts within a runtime Attachment 232703 [details] pushed as baf096b - context: Remove RuntimeData and gjs_runtime_init/gjs_runtime_destroy