[webkit-dev] SharedContext (was: GlobalScript in WebKit)
pmuellr at muellerware.org
Tue Dec 1 10:42:13 PST 2009
Couple of notes:
- the name SharedScriptContext is a big win over GlobalScript - this is
more about sharing things than making them global, and more about
contexts than scripts. It's like if the name SeparateScript was used in
instead of Worker, or something, just because a script is associated
with it - though it's not the important bit. I'd go for the name
SharedContext to make it even shorter (and I use that name below).
- I've been thinking about how you could use SharedContext as a means of
implementing CommonJS modules, or something close: see
http://wiki.commonjs.org/wiki/Modules/1.0 . I suppose you'd end up
creating a SharedContext per module. So I would hope the implementation
could handle lots of modules. Java's OSGi module system wasn't
originally imagined to be used to load 1000's of modules, but is in fact
doing that today (in Eclipse-based products). Specifically, where the
section 1.1 of Worker spec  says "workers are expected to be
long-lived, have a high start-up performance cost, and a high
per-instance memory cost", I'd expect those "highs" to not be high for
In any case, it's interesting to think about users using this facility
- It would probably be useful to engage the CommonJS folks who have been
dealing with some of the same 'shared context' issues as presented in
this proposal. I'm not one of them, I've just been lurking there.
Frankly, I like the CommonJS module system a bit more than this proposal
as it provides a capability of hiding things in the SharedContext - much
Actually, it's not that it provides hiding, it's that it requires
exporting things you want to be visible; same effect.
- Example 1.2.3 of the Worker spec  contains a mini use-case for
SharedContext, specifically the importScripts("io.js"). In this case,
loading "io.js" into every worker isn't much of a hardship. But if you
had to load lots of the same scripts into lots of workers, it would be
not just the cached source).
 Worker spec referenced:
http://www.whatwg.org/specs/web-workers/current-work/ ; the version I'm
looking at is "Draft Recommendation - 1 December 2009"
Patrick Mueller - http://muellerware.org
More information about the webkit-dev