On 2014/06/12 12:40:10, rossberg wrote:
On 2014/06/12 09:25:55, wingo wrote:
> Hum, this points out a problem in the patch -- before, the set of
properties
in
> an object was statically known, and so you could create a new object
literal
by
> cloning a template and then updating properties that needed to be
computed
at
> runtime. Now with computed property names that isn't the case. In my
patch
we
> still create a template for the first few properties -- the ones that
precede
> any computed property name -- but subsequent properties are not in the
template.
> This of course opens up the possibility of interference from
Object.prototype
> :/
Hm, trying to understand what you mean. As far as the spec is concerned,
all
properties are defined, not set, so the prototype should never interfere.
Are
you saying that it could yet potentially do in the current implementation?
For each object literal in the source, the current implementation lazily
prepares a "boilerplate object" when the code is first reached. In ES5.1,
the
set of properties is known, so the runtime can create a template object
that has
all the properties, and whose map has the properties in the correct
left-to-right insertion order. The only thing that needs to happen at
runtime
is computing those properties that are not constant, and since they are
already
in the object, we just use Runtime_SetProperty to update the object.
However with computed property names we don't know the set of properties
ahead
of time, and so we can't create a boilerplate object that has all of them
defined already. So for ES6 object literals with computed properties --
call it
the dynamic object literal case -- we have to do something like
PutOwnProperty
at runtime, instead of SetProperty.
Computed property names are the only way to get dynamic object literals.
The
current code is fine for ES5.1.
Note that all properties to the right of the first computed property have
to be
added via PutOwnProperty, at least in the baseline case, in order to
preserve
insertion order.
https://codereview.chromium.org/332443002/
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.