On 2015/03/04 15:43:00, caitp wrote:
On 2015/03/04 15:24:09, Dmitry Lomov (chromium) wrote:
> On 2015/03/04 14:44:11, caitp wrote:
> > So Runtime_NewObjectHelper creates an object using the initial map of
whatever
> > the constructor was, and then __maybe__ sets __proto__ to the
prototype of
the
> > original constructor. That doesn't seem right to me, but I'm sure
there
are
> good
> > reasons for doing this, maybe it's okay to leave it as-is for now?
>
> This is absolutely correct.
>
> Reflect.construct(Array, [], C)
>
> invokes Array.[[Construct]] trap with [] for argumentsList and C for new
Target.
> For Arrays this constructs an exotic object (Array) with __proto__ being
> C.prototype.
>
> This is what your CL does
Right, but the actual behaviour is not quite correct.
Here's a sample run:
```
(lldb) r --harmony-reflect
Process 17689 launched: '/Users/caitp/google/v8/out/x64.debug/d8' (x86_64)
V8 version 4.3.0 (candidate) [console: dumb]
d8> function A() {}
undefined
d8> function B() {}
undefined
d8> B.prototype.name = "B"
"B"
d8> Reflect.construct(A, [], B).name
"B"
d8> Reflect.construct(A, [], B) instanceof B
true
d8> Reflect.construct(A, [], B) instanceof A
false
d8> function C() {}
undefined
d8> Reflect.construct(A, [], C) instanceof A
true
d8> Reflect.construct(A, [], C) instanceof C
false
d8>
```
Notice that if I add a property to B's prototype, then we take the path
where
we
do set the prototype to the right value. However, when newTarget is `C`,
which
has not touched its prototype at all, the prototype is incorrect.
Ah, I see. It is indeed a bug (can be fixed later; you cannot repro that
with
classes since for classes we always set .prototype)
https://codereview.chromium.org/913073003/
--
--
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.