On Tue, Jun 24, 2014 at 12:54 PM, <da...@chromium.org> wrote:

>
>> Ah. I think I know what's going on.
>

This only tests Map.prototype.forEach which does not need any iterator
result object or any array holding the entry.

The code on master creates an iterator result object and an entry array.
The code on my two branches does not.


>
> The reason your new Map iterator is slow--granted, this is speculation not
> having seen your code--is that I suspect now you pass in the entry object
> all
> the way down to NewIteratorResultObject (or some new equivalent), and then
> you
> call SetProperty on that object, which has to do expensive property
> lookups each
> time you set the property.
>

Kind of. The object is passed into MapIteratorNextWithEntry which does a
JSReciever::SetProperty for the key and the value

I also upload my branches to github:

https://github.com/arv/v8/tree/for-each-opt
https://github.com/arv/v8/tree/map-set-for-each-reuse-object

which allows you to see the diffs if you want to see the nitty gritty
details.


> Looking at the code, however, I am confused why the Map iterator needs to
> be any
> different than the Set iterator with respect to optimizations, since the
> ValueForKind utility called by Next works in exactly the same way. It
> looks like
> for both the Set and Map iterators, the entry is still always of the form {
> value: XXXX, done: XXXX }, but values has a different form depending on
> whether
> one is iterating keys, values or entries. if you are iterating entries,
> then the
> entry takes the form { value: [key, actual_value], done: XXX }. Which
> means that
> I don't understand why you can't use the trick that I originally proposed,
> i.e.
> the %SetIteratorNextObject/%MapIteratorNextObject return the "value"
> property
> from the runtime function, either the key, the value, the array [key,
> value] or
> the done sentinel.
>

This CL only involves forEach which does not need the iterator result
object or the entry array.


>
> This will avoid all the property lookups in the native code that you are
> currently doing on entry objects: the value store to the entry object in
> JS will
> use an IC and therefore will be quite fast.
>

There needs to be 2 SetProperty calls from the C++ code since we  need to
set the key and value (there are conceptually three out params, key, value
and done)

-- 
erik

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to