Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Issue 240323003: ES6: Add support for Map/Set forEach (Closed)

Created:
6 years, 8 months ago by arv (Not doing code reviews)
Modified:
6 years, 8 months ago
CC:
v8-dev
Visibility:
Public.

Description

ES6: Add support for Map/Set forEach This implements MapIterator and SetIterator which matches the same constructs in the ES6 spec. However, these 2 iterators are not exposed to user code yet. They are only used internally to implement Map.prototype.forEach and Set.prototype.forEach. Each iterator has a reference to the OrderedHashTable where it directly accesses the hash table's entries. The OrderedHashTable has a reference to the newest iterator and each iterator has a reference to the next and previous iterator, effectively creating a double linked list. When the OrderedHashTable is mutated (or replaced) all the iterators are updated. When the iterator iterates passed the end of the data table it closes itself. Closed iterators no longer have a reference to the OrderedHashTable and they are removed from the double linked list. In the case of Map/Set forEach, we manually call Close on the iterator in case an exception was thrown so that the iterator never reached the end. At this point the OrderedHashTable keeps all the non finished iterators alive but since the only thing we currently expose is forEach there are no unfinished iterators outside a forEach call. Once we expose the iterators to user code we will need to make the references from the OrderedHashTable to the iterators weak and have some mechanism to close an iterator when it is garbage collected. BUG=1793, 2323 LOG=Y TBR=mstarzinger@chromium.org Committed: https://code.google.com/p/v8/source/detail?r=20823

Patch Set 1 #

Total comments: 6

Patch Set 2 : Moar template instantiations #

Patch Set 3 : Inline Create functions #

Patch Set 4 : Explicit instantiate the functions instead #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1341 lines, -71 lines) Patch
M src/arm/full-codegen-arm.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/arm64/full-codegen-arm64.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/array-iterator.js View 2 chunks +5 lines, -10 lines 0 comments Download
M src/bootstrapper.cc View 2 chunks +27 lines, -16 lines 0 comments Download
M src/collection.js View 5 chunks +54 lines, -6 lines 0 comments Download
M src/contexts.h View 2 chunks +6 lines, -2 lines 0 comments Download
M src/factory.h View 1 chunk +2 lines, -0 lines 0 comments Download
M src/factory.cc View 2 chunks +13 lines, -0 lines 0 comments Download
M src/ia32/full-codegen-ia32.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/macros.py View 1 chunk +5 lines, -0 lines 0 comments Download
M src/mips/full-codegen-mips.cc View 1 chunk +1 line, -1 line 0 comments Download
M src/objects.h View 1 2 14 chunks +181 lines, -9 lines 0 comments Download
M src/objects.cc View 1 2 3 11 chunks +379 lines, -20 lines 0 comments Download
M src/objects-debug.cc View 3 chunks +40 lines, -0 lines 0 comments Download
M src/objects-inl.h View 1 2 5 chunks +48 lines, -0 lines 0 comments Download
M src/objects-printer.cc View 1 2 3 4 chunks +51 lines, -3 lines 0 comments Download
M src/objects-visiting.cc View 1 chunk +2 lines, -0 lines 0 comments Download
M src/runtime.h View 1 chunk +10 lines, -0 lines 0 comments Download
M src/runtime.cc View 4 chunks +85 lines, -0 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 1 chunk +1 line, -1 line 0 comments Download
M test/cctest/test-ordered-hash-table.cc View 8 chunks +84 lines, -0 lines 0 comments Download
M test/mjsunit/harmony/collections.js View 1 chunk +344 lines, -0 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
adamk
https://codereview.chromium.org/240323003/diff/1/src/objects.cc File src/objects.cc (right): https://codereview.chromium.org/240323003/diff/1/src/objects.cc#newcode16493 src/objects.cc:16493: template class OrderedHashTable<OrderedHashMap, JSMapIterator, 2>; Based on the Windows ...
6 years, 8 months ago (2014-04-16 18:35:10 UTC) #1
arv (Not doing code reviews)
Moar template instantiations
6 years, 8 months ago (2014-04-16 18:49:48 UTC) #2
arv (Not doing code reviews)
https://codereview.chromium.org/240323003/diff/1/src/objects.cc File src/objects.cc (right): https://codereview.chromium.org/240323003/diff/1/src/objects.cc#newcode16493 src/objects.cc:16493: template class OrderedHashTable<OrderedHashMap, JSMapIterator, 2>; On 2014/04/16 18:35:11, adamk ...
6 years, 8 months ago (2014-04-16 18:49:54 UTC) #3
arv (Not doing code reviews)
Inline Create functions
6 years, 8 months ago (2014-04-16 20:37:56 UTC) #4
adamk
Committed patchset #3 manually as r20823 (presubmit successful).
6 years, 8 months ago (2014-04-16 21:12:39 UTC) #5
arv (Not doing code reviews)
Explicit instantiate the functions instead
6 years, 8 months ago (2014-04-16 21:47:02 UTC) #6
Jakob Kummerow
This hits unreachable code in types.cc: out/ia32.debug/d8 --allow-natives-syntax --harmony -e "var s = new Set(); ...
6 years, 8 months ago (2014-04-22 14:50:40 UTC) #7
arv (Not doing code reviews)
On 2014/04/22 14:50:40, Jakob wrote: > This hits unreachable code in types.cc: > > out/ia32.debug/d8 ...
6 years, 8 months ago (2014-04-22 15:06:56 UTC) #8
Jakob Kummerow
Likely: diff --git a/src/types.cc b/src/types.cc index 394f772..13ab324 100644 --- a/src/types.cc +++ b/src/types.cc @@ -225,7 +225,9 ...
6 years, 8 months ago (2014-04-22 15:08:13 UTC) #9
arv (Not doing code reviews)
6 years, 8 months ago (2014-04-22 15:23:10 UTC) #10
Message was sent while issue was closed.
On 2014/04/22 15:06:56, arv wrote:
> On 2014/04/22 14:50:40, Jakob wrote:
> > This hits unreachable code in types.cc:
> > 
> > out/ia32.debug/d8 --allow-natives-syntax --harmony -e "var s = new Set();
var
> it
> > = %SetCreateIterator(s, 2);"
> 
> Looking

Fix at https://codereview.chromium.org/246993003/

Powered by Google App Engine
This is Rietveld 408576698