Andreas Rossberg於 2013年12月13日星期五UTC+8下午3時38分41秒寫道: > > On 13 December 2013 06:58, Ting-Yu Chou <[email protected] <javascript:>> > wrote: > > Hello, > > > > I am not so sure why it needs to always search the setter in prototypes > when > > setting a property, even there's a transition map: > > > > Handle<Object> JSObject::SetPropertyForResult(Handle<JSObject> object, > > ... > > if (!lookup->IsProperty() && !object->IsJSContextExtensionObject()) > { > > bool done = false; > > Handle<Object> result_object = SetPropertyViaPrototypes( > > object, name, value, attributes, strict_mode, &done); > > if (done) return result_object; > > } > > A transition is an absent property -- all it tells is where to find a > new map if this property ever gets added. So of course search has to > continue up the prototype chain first to look for setters. >
I was just curious that creating a transition means there's no setter found from prototype chain, why bother to search it next time adding the property. > > > Is it possible that both a map and a setter in ancestor existed? > > Yes, why shouldn't it? There are various ways to achieve this in > JavaScript. > Got it, but would you mind to show me a short example? Thank you for responding, Ting > > /Andreas > Andreas Rossberg於 2013年12月13日星期五UTC+8下午3時38分41秒寫道: > > On 13 December 2013 06:58, Ting-Yu Chou <[email protected] <javascript:>> > wrote: > > Hello, > > > > I am not so sure why it needs to always search the setter in prototypes > when > > setting a property, even there's a transition map: > > > > Handle<Object> JSObject::SetPropertyForResult(Handle<JSObject> object, > > ... > > if (!lookup->IsProperty() && !object->IsJSContextExtensionObject()) > { > > bool done = false; > > Handle<Object> result_object = SetPropertyViaPrototypes( > > object, name, value, attributes, strict_mode, &done); > > if (done) return result_object; > > } > > A transition is an absent property -- all it tells is where to find a > new map if this property ever gets added. So of course search has to > continue up the prototype chain first to look for setters. > > > Is it possible that both a map and a setter in ancestor existed? > > Yes, why shouldn't it? There are various ways to achieve this in > JavaScript. > > /Andreas > -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" 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/groups/opt_out.
