On 2015/06/03 08:26:06, Michael Starzinger wrote:
On 2015/06/03 08:03:04, rossberg wrote:
> On 2015/06/03 07:54:53, Michael Starzinger wrote:
> > On 2015/06/03 06:28:44, rossberg wrote:
> > > Does this also work correctly if the (direct, sloppy) eval contains a
'var'
> > > declaration?
> > >
> > >   () => eval("var x = 666"), x
> > >
> > > should return 666. Wouldn't the x still go to the wrong context, or am I
> > > misunderstanding the CL?
> >
> > Just to clarify, did you mean the following arrow?
> >
> >   () => (eval("var x = 666"), x)
>
> Right.
>
> > This one work correctly after my fix.
>
> Then I'm obviously confused. :) Why does this work?

Since the arrow function is marked as calling a sloppy eval, it will allocate
a
context in the prologue (because the scope's heap count is set to
MIN_CONTEXT_SLOTS instead of 0). The eval will then install an extension
object
on said context containing the dynamic declaration of "x". Any optimistic
binding to a local "x" surrounding the arrow will not hit, because said
context
contains an extension object.

Before my fix, the arrow function wouldn't allocate a context (because the
scope's heap count of MIN_CONTEXT_SLOTS was still interpreted as "don't need a context"). I guess (didn't verify) that the extension object would have been
placed on the wrong context.

> Can we have a test for that?

I added this to the regression test.

Cool, thanks. LGTM

https://codereview.chromium.org/1146063006/

--
--
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.

Reply via email to