The window
object is very different from the GSR (and less "global" of course).
No, the GSR is not represented as an object that is accessible to JS code, with properties for key-value pairs or so (or as a Map
maybe). It cannot be enumerated, if that is what you are looking for. The only ways to access it are Symbol.for
and Symbol.keyFor
, which suffices to expose the bijective property of the relation.
This was probably (read: my speculation) done to simplify the implementation. The GSR needs to handle symbol references weakly, they should get garbage-collected when all realms that used them are terminated. Also, the multiple realms that access it might run in different threads, which adds complexity. Exposing the mapping directly to code might introduce race conditions (similar to the reason why WeakMap
s are not enumerable).