On Sat, Sep 26, 2015 at 5:44 AM, Jakob Kummerow <[email protected]> wrote:
> Different discussion...
>
> On Fri, Sep 25, 2015 at 11:13 PM, 'Daniel Ehrenberg' via v8-dev
> <[email protected]> wrote:
>>
>> On Fri, Sep 25, 2015 at 2:58 AM, Jakob Kummerow <[email protected]>
>> wrote:
>> > As we have discussed at various occasions recently, we generally want to
>> > move in the direction of having C++ implementations of spec-defined
>> > behavior.
>>
>> Was that the conclusion of the discussion? My understanding was that
>> *some* things would be in C++ and we would try to minimize the bad
>> parts of the previous approach, especially where it jumps back and
>> forth, but that some things still make sense in JavaScript. But
>> correct me if I'm wrong. I'm asking because I do work on JS natives
>> and I don't want to write code in the wrong form such that it has to
>> be rewritten some time soon.
>
>
> Apologies if that summary was misleading. "we generally want to move in the
> direction" doesn't imply that everything must be C++, just that more
> implementations should be done in (or moved to) C++. Personally I'm working
> on Object.definePropert{y,ies} currently, but a lot of the code I see in
> v8natives.js as it exists today is just horribly inefficient.
>
> My rule of thumb is: "if a function calls the runtime anyway (and not just
> on a rare, slow fallback path), then it's probably better to implement all
> of it in C++".

Things like Object.defineProperty and ToLength sound great candidates
to move into C++. Maybe most of v8natives.js is like that. But there's
another large amount of natives code which I'm not sure fits the
pattern.

Here are a couple cases of code that I've worked on or might work on
in the near future:
- TypedArray code. I implemented some methods like map in JavaScript.
These currently call out to the same underlying code as Arrays, which
saves us a lot of effort. These functions do need to call special
compiler intrinsics that we added just to support them, to efficiently
identify them as TypedArrays and get their length.  If I were
implementing it today, would i do it in C++ instead?
- Promises. These currently need some changes for spec compliance,
which might be done by us or might be provided by external
contributors. They need special runtime calls for interacting with the
job queue (in the main path) and debugging (in a slow path). In the
midst of correctness and performance work on promises, should they be
rewritten in C++?

Dan

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