On Mon, Feb 15, 2016 at 9:19 AM, <[email protected]> wrote:

> I've been frustrated by v8::Object::New not accepting a prototype object
> as a parameter and it's been hinted strongly that using
> v8::Object::SetPrototype after object creation is a bad idea.
>

Well, rule #1 of performance optimizations is to start by measuring what
you care about. Have you tried simply using SetPrototype? Do you have a
performance problem?

Now I'm left wondering if it would be reasonable to implement (and if it
> would be accepted if it worked) to add that functionality to v8::Object::New
>

The warning that has you so scared mostly just says that dynamically
modifying prototype chains is bad. Adding a new API function with a
different name that still changes prototypes under the hood isn't going to
change that.

That said, setting up an object's prototype initially is often unavoidable.
If the object hasn't been seen/mucked with by other code, it's probably
going to be fine. Again, please measure before you obsess about it.

Specifically:
>
> static Local<Object> New(Isolate *isolate, Local<Object> prototype =
> Local<Object>, Local<Object>() propertiesObject=Local<Object>());
>
> To line up with:
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
> and not change the functionality of existing calls.
>

I'm not the right person to give a final "yes" or "no" to this question,
but my gut feeling is that instead of overloading Object::New to have
several different behaviors, it's probably better to introduce a new
function (maybe "Object::Create"?) that does exactly what JS-side
Object.create would do, nothing more, nothing less. That said, I'm not
convinced any new API call is required at all, see above.


> Also, while asking related questions earlier in the week, I was pointed at
> ObjectCreate in builtins.cc
>
> https://github.com/v8/v8/blob/master/src/builtins.cc#L1705
>
> I looked at it a bit and tried to move the code into v8.h/api.cc but I was
> quickly stymied by not understanding the relationship between v8::Object
> and v8::i::Object.  Is the code in builtins.cc the right path for this?
> Also, is this a reasonable project for someone not intimately familiar with
> the v8 codebase and willing to put in a week's worth of time into learning
> and making the change or is this somehow much harder than it appears?
>
>
> Thank you.
>
> --Zac
>
> --
> --
> 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.
>

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