Comment #1 on issue 398 by ernst.matthias: Overwriting function-valued  
property of first ObjectTemplate instance gives "undefined" on clones
http://code.google.com/p/v8/issues/detail?id=398

The reproducer is even easier, it has nothing to do with templates:

   v8::Handle<v8::Object> o = v8::Object::New();
   o->Set(v8::String::New("method"),  
v8::FunctionTemplate::New()->GetFunction());
   o->Clone()->Set(v8::String::New("method"), v8::String::New("new value"));
   cerr << *v8::String::AsciiValue(o->Get(v8::String::New("method"))) <<  
endl;

I've tracked it down to JSObject::ConvertDescriptorToFieldAndMapTransition  
which
overwrites the original CONSTANT_FUNCTION descriptor with a  
MAP_TRANSITION . Objects
that share the same original map (only possible through Clone?) will see  
their
function disappear.

I cannot judge what is the right fix. Maybe the MAP_TRANSITION should copy  
the
function constant? Maybe a different type of Descriptor needs to be  
inserted that
does so? Maybe Clone() cannot re-use the map if it contain a function  
constants?
Maybe we cannot leave a MAP_TRANSITION when overriding a function constant.

Interestingly, function constants are only used if the property is new.  
After that, a
CONSTANT_TRANSITION is left in the original map with the specific purpose  
to trigger creation of fields for reasons I don't understand.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to