typed objects and value types

Andreas Rossberg rossberg at google.com
Thu Apr 3 06:58:52 PDT 2014


On 3 April 2014 15:30, Marius Gundersen <gundersen at gmail.com> wrote:
> On Thu, Apr 3, 2014 at 3:09 PM, Andreas Rossberg <rossberg at google.com>
> wrote:
>>
>> Unfortunately, that only works for primitives because the respective
>> constructor/wrapper class is known to exist in all realms, it is known
>> to be "the same" everywhere, and because the language can hence apply
>> some magic to "rebind" it when primitives cross realm boundaries. For
>> user-defined values, no such guarantees exist. Hence, no similar
>> rebinding magic can be applied, and values have to hold on to their
>> original constructor.
>
> Wouldn't it be a security risk to send the constructor and prototype between
> realms?

Objects could always cross realm boundaries, that is nothing new. In
the browser, the usual access checks apply.

> Since the uvalue only consists of primitives and other uvalues,

They also (necessarily) carry an implicit reference to their type
descriptor (an internal object), which in turn links to the prototype
(or equivalently, the other way round). Otherwise, methods, wrapping,
etc would not work.

> it
> can be serialized to an object consisting of objects and primitives. This
> object could then be passed into the constructor of an equivalent uvalue,
> just like the original uvalue was created. This would unfortunately add an
> extra step in passing uvalues between realms, but it might just be a minor
> inconvenience.

/Andreas


More information about the es-discuss mailing list