Commit 2d11c160 authored by oliver@apple.com's avatar oliver@apple.com

Add Map Iterators

https://bugs.webkit.org/show_bug.cgi?id=124109

Reviewed by Andreas Kling.

Source/JavaScriptCore:

Added new Map iterator implementation.  This is a mostly boilerplate patch
however there's a a little bit of additional logic added to the MapData iterator
to deal with the possibility of map mutation between creation of the iterator
and use of it.  We'll be able to improve the performance of this substantially
by using intrinsics, however I'm pondering coming up with a better way to define
these thunks without requiring so much duplicated logic.

* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSMapIterator.cpp: Added.
(JSC::JSMapIterator::finishCreation):
(JSC::JSMapIterator::visitChildren):
(JSC::JSMapIterator::createPair):
* runtime/JSMapIterator.h: Added.
(JSC::JSMapIterator::createStructure):
(JSC::JSMapIterator::create):
(JSC::JSMapIterator::next):
(JSC::JSMapIterator::JSMapIterator):
* runtime/MapData.h:
(JSC::MapData::const_iterator::ensureSlot):
* runtime/MapIteratorConstructor.cpp: Added.
(JSC::MapIteratorConstructor::finishCreation):
* runtime/MapIteratorConstructor.h: Added.
(JSC::MapIteratorConstructor::create):
(JSC::MapIteratorConstructor::createStructure):
(JSC::MapIteratorConstructor::MapIteratorConstructor):
* runtime/MapIteratorPrototype.cpp: Added.
(JSC::MapIteratorPrototype::finishCreation):
(JSC::MapIteratorPrototypeFuncIterator):
(JSC::MapIteratorPrototypeFuncNext):
* runtime/MapIteratorPrototype.h: Added.
(JSC::MapIteratorPrototype::create):
(JSC::MapIteratorPrototype::createStructure):
(JSC::MapIteratorPrototype::MapIteratorPrototype):
* runtime/MapPrototype.cpp:
(JSC::MapPrototype::finishCreation):
(JSC::mapProtoFuncValues):
(JSC::mapProtoFuncEntries):
(JSC::mapProtoFuncKeys):

LayoutTests:

Moved map tests to a more sensible location, and added new iteration tests.

* js/basic-map-expected.txt: Renamed from LayoutTests/js/dom/basic-map-expected.txt.
* js/basic-map.html: Renamed from LayoutTests/js/dom/basic-map.html.
* js/script-tests/basic-map.js: Renamed from LayoutTests/js/dom/script-tests/basic-map.js.
(set shouldBe):
(set var):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bae0c50b
2013-11-09 Oliver Hunt <oliver@apple.com>
Add Map Iterators
https://bugs.webkit.org/show_bug.cgi?id=124109
Reviewed by Andreas Kling.
Moved map tests to a more sensible location, and added new iteration tests.
* js/basic-map-expected.txt: Renamed from LayoutTests/js/dom/basic-map-expected.txt.
* js/basic-map.html: Renamed from LayoutTests/js/dom/basic-map.html.
* js/script-tests/basic-map.js: Renamed from LayoutTests/js/dom/script-tests/basic-map.js.
(set shouldBe):
(set var):
2013-11-09 Martin Robinson <mrobinson@igalia.com>
[MathML] Poor spacing around delimiters in MathML Torture Test 14
......
......@@ -121,6 +121,100 @@ PASS map.get("5") is 11
PASS map.get(6) is 12
PASS map.get("6") is 13
PASS map.get(4) is 11
map.@@iterator()
PASS key is 0
PASS value is 0
PASS key is '0'
PASS value is 1
PASS key is 1
PASS value is 2
PASS key is '1'
PASS value is 3
PASS key is 2
PASS value is 4
PASS key is '2'
PASS value is 5
PASS key is 3
PASS value is 6
PASS key is '3'
PASS value is 7
PASS key is 4
PASS value is 8
PASS key is '4'
PASS value is 9
map.entries()
PASS i is 10
PASS key is 0
PASS value is 0
PASS key is '0'
PASS value is 1
PASS key is 1
PASS value is 2
PASS key is '1'
PASS value is 3
PASS key is 2
PASS value is 4
PASS key is '2'
PASS value is 5
PASS key is 3
PASS value is 6
PASS key is '3'
PASS value is 7
PASS key is 4
PASS value is 8
PASS key is '4'
PASS value is 9
PASS i is 10
map.keys()
PASS key is 0
PASS key is '0'
PASS key is 1
PASS key is '1'
PASS key is 2
PASS key is '2'
PASS key is 3
PASS key is '3'
PASS key is 4
PASS key is '4'
PASS i is 10
map.values()
PASS value is 0
PASS value is 1
PASS value is 2
PASS value is 3
PASS value is 4
PASS value is 5
PASS value is 6
PASS value is 7
PASS value is 8
PASS value is 9
PASS i is 10
Map mutation with live iterator and GC
PASS key is 1
PASS value is 2
PASS key is 3
PASS value is 6
PASS key is 4
PASS value is 8
PASS key is 5
PASS value is 10
PASS key is 7
PASS value is 14
PASS i is 5
PASS map.size is 4
test forEach
PASS key is 1
PASS value is 2
PASS key is 3
PASS value is 6
PASS key is 4
PASS value is 8
PASS key is 5
PASS value is 10
PASS key is 7
PASS value is 14
PASS i is 5
PASS map.size is 4
PASS successfullyParsed is true
TEST COMPLETE
......
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script src="script-tests/basic-map.js"></script>
<script src="../../resources/js-test-post.js"></script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
......@@ -121,3 +121,119 @@ for (var i = 0; i < keys.length; i++) {
var expectedValue = keys[i][1]
shouldBe("map.get("+JSON.stringify(expectedKey)+")", JSON.stringify(expectedValue));
}
map = new Map;
var count = 5;
var keys = [];
var values = [];
for (var i = 0; i < count; i++) {
map.set(i, i * 2)
map.set("" + i , i * 2 + 1)
keys.push("" + i)
keys.push("'" + i + "'")
values.push(i * 2)
values.push(i * 2 + 1)
}
var i = 0;
debug("map.@@iterator()")
for (var [key, value] of map) {
shouldBe("key", "" + keys[i])
shouldBe("value", "" + values[i])
i++;
}
debug("map.entries()")
shouldBe("i", "" + count * 2)
var i = 0;
for (var [key, value] of map.entries()) {
shouldBe("key", "" + keys[i])
shouldBe("value", "" + values[i])
i++;
}
shouldBe("i", "" + count * 2)
debug("map.keys()")
var i = 0;
for (var key of map.keys()) {
shouldBe("key", "" + keys[i])
i++;
}
shouldBe("i", "" + count * 2)
var i = 0;
debug("map.values()")
for (var value of map.values()) {
shouldBe("value", "" + values[i])
i++;
}
shouldBe("i", "" + count * 2)
debug("Map mutation with live iterator and GC")
map = new Map;
map.set(0, 0)
map.set(1, 2)
map.set(2, 4)
map.set(3, 6)
map.set(4, 8)
map.set(5, 10)
map.set(6, 12)
map.set(7, 14)
map.set(9, 14)
map.set(14, "should be deleted")
var keys = [1,3,4,5,7]
var values = [2,6,8,10,14]
var entries = map.entries();
gc();
map.delete(0)
gc()
var i = 0;
for (var [key, value] of entries) {
shouldBe("key", "" + keys[i])
shouldBe("value", "" + values[i])
if (key == 7)
map.delete(9)
map.delete(1)
map.delete(key * 2)
gc()
i++
}
shouldBe("i", "5")
shouldBe("map.size", "4");
debug("test forEach")
map = new Map;
map.set(0, 0)
map.set(1, 2)
map.set(2, 4)
map.set(3, 6)
map.set(4, 8)
map.set(5, 10)
map.set(6, 12)
map.set(7, 14)
map.set(9, 14)
map.set(14, "should be deleted")
var keys = [1,3,4,5,7]
var values = [2,6,8,10,14]
map.delete(0)
var i = 0;
map.forEach(function (v, k) {
key = k;
value = v;
shouldBe("key", "" + keys[i])
shouldBe("value", "" + values[i])
if (key == 7)
map.delete(9)
map.delete(1)
map.delete(key * 2)
gc()
i++
});
shouldBe("i", "5")
shouldBe("map.size", "4");
......@@ -337,6 +337,7 @@ set(JavaScriptCore_SOURCES
runtime/JSGlobalObjectFunctions.cpp
runtime/JSLock.cpp
runtime/JSMap.cpp
runtime/JSMapIterator.cpp
runtime/JSNameScope.cpp
runtime/JSNotAnObject.cpp
runtime/JSONObject.cpp
......@@ -368,6 +369,8 @@ set(JavaScriptCore_SOURCES
runtime/Lookup.cpp
runtime/MapConstructor.cpp
runtime/MapData.cpp
runtime/MapIteratorConstructor.cpp
runtime/MapIteratorPrototype.cpp
runtime/MapPrototype.cpp
runtime/MathObject.cpp
runtime/MemoryStatistics.cpp
......
2013-11-09 Oliver Hunt <oliver@apple.com>
Add Map Iterators
https://bugs.webkit.org/show_bug.cgi?id=124109
Reviewed by Andreas Kling.
Added new Map iterator implementation. This is a mostly boilerplate patch
however there's a a little bit of additional logic added to the MapData iterator
to deal with the possibility of map mutation between creation of the iterator
and use of it. We'll be able to improve the performance of this substantially
by using intrinsics, however I'm pondering coming up with a better way to define
these thunks without requiring so much duplicated logic.
* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSMapIterator.cpp: Added.
(JSC::JSMapIterator::finishCreation):
(JSC::JSMapIterator::visitChildren):
(JSC::JSMapIterator::createPair):
* runtime/JSMapIterator.h: Added.
(JSC::JSMapIterator::createStructure):
(JSC::JSMapIterator::create):
(JSC::JSMapIterator::next):
(JSC::JSMapIterator::JSMapIterator):
* runtime/MapData.h:
(JSC::MapData::const_iterator::ensureSlot):
* runtime/MapIteratorConstructor.cpp: Added.
(JSC::MapIteratorConstructor::finishCreation):
* runtime/MapIteratorConstructor.h: Added.
(JSC::MapIteratorConstructor::create):
(JSC::MapIteratorConstructor::createStructure):
(JSC::MapIteratorConstructor::MapIteratorConstructor):
* runtime/MapIteratorPrototype.cpp: Added.
(JSC::MapIteratorPrototype::finishCreation):
(JSC::MapIteratorPrototypeFuncIterator):
(JSC::MapIteratorPrototypeFuncNext):
* runtime/MapIteratorPrototype.h: Added.
(JSC::MapIteratorPrototype::create):
(JSC::MapIteratorPrototype::createStructure):
(JSC::MapIteratorPrototype::MapIteratorPrototype):
* runtime/MapPrototype.cpp:
(JSC::MapPrototype::finishCreation):
(JSC::mapProtoFuncValues):
(JSC::mapProtoFuncEntries):
(JSC::mapProtoFuncKeys):
2013-11-08 Zan Dobersek <zdobersek@igalia.com>
Unreviewed GTK build fix.
......
......@@ -926,6 +926,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/JSLock.h \
Source/JavaScriptCore/runtime/JSMap.cpp \
Source/JavaScriptCore/runtime/JSMap.h \
Source/JavaScriptCore/runtime/JSMapIterator.cpp \
Source/JavaScriptCore/runtime/JSMapIterator.h \
Source/JavaScriptCore/runtime/JSNotAnObject.cpp \
Source/JavaScriptCore/runtime/JSNotAnObject.h \
Source/JavaScriptCore/runtime/JSObject.cpp \
......@@ -994,6 +996,10 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/MapConstructor.h\
Source/JavaScriptCore/runtime/MapData.cpp \
Source/JavaScriptCore/runtime/MapData.h \
Source/JavaScriptCore/runtime/MapIteratorConstructor.cpp \
Source/JavaScriptCore/runtime/MapIteratorConstructor.h \
Source/JavaScriptCore/runtime/MapIteratorPrototype.cpp \
Source/JavaScriptCore/runtime/MapIteratorPrototype.h \
Source/JavaScriptCore/runtime/MapPrototype.cpp \
Source/JavaScriptCore/runtime/MapPrototype.h \
Source/JavaScriptCore/runtime/MatchResult.h \
......
......@@ -575,6 +575,7 @@
<ClCompile Include="..\runtime\JSGlobalObjectFunctions.cpp" />
<ClCompile Include="..\runtime\JSLock.cpp" />
<ClCompile Include="..\runtime\JSMap.cpp" />
<ClCompile Include="..\runtime\JSMapIterator.cpp" />
<ClCompile Include="..\runtime\JSNameScope.cpp" />
<ClCompile Include="..\runtime\JSNotAnObject.cpp" />
<ClCompile Include="..\runtime\JSONObject.cpp" />
......@@ -605,6 +606,8 @@
<ClCompile Include="..\runtime\Lookup.cpp" />
<ClCompile Include="..\runtime\MapConstructor.cpp" />
<ClCompile Include="..\runtime\MapData.cpp" />
<ClCompile Include="..\runtime\MapIteratorConstructor.cpp" />
<ClCompile Include="..\runtime\MapIteratorPrototype.cpp" />
<ClCompile Include="..\runtime\MapPrototype.cpp" />
<ClCompile Include="..\runtime\MathObject.cpp" />
<ClCompile Include="..\runtime\NameConstructor.cpp" />
......@@ -1158,6 +1161,7 @@
<ClInclude Include="..\runtime\JSInt8Array.h" />
<ClInclude Include="..\runtime\JSLock.h" />
<ClInclude Include="..\runtime\JSMap.h" />
<ClInclude Include="..\runtime\JSMapIterator.h" />
<ClInclude Include="..\runtime\JSNameScope.h" />
<ClInclude Include="..\runtime\JSNotAnObject.h" />
<ClInclude Include="..\runtime\JSONObject.h" />
......@@ -1195,6 +1199,8 @@
<ClInclude Include="..\runtime\Lookup.h" />
<ClInclude Include="..\runtime\MapConstructor.h" />
<ClInclude Include="..\runtime\MapData.h" />
<ClInclude Include="..\runtime\MapIteratorConstructor.h" />
<ClInclude Include="..\runtime\MapIteratorPrototype.h" />
<ClInclude Include="..\runtime\MapPrototype.h" />
<ClInclude Include="..\runtime\MatchResult.h" />
<ClInclude Include="..\runtime\MathObject.h" />
......
......@@ -1179,6 +1179,12 @@
<ClCompile Include="..\runtime\ArgumentsIteratorPrototype.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\MapIteratorConstructor.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\MapIteratorPrototype.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\jit\AssemblyHelpers.cpp">
<Filter>jit</Filter>
</ClCompile>
......@@ -1188,6 +1194,9 @@
<ClCompile Include="..\runtime\JSArgumentsIterator.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\JSMapIterator.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\jit\Repatch.cpp">
<Filter>jit</Filter>
</ClCompile>
......@@ -2997,6 +3006,12 @@
<ClInclude Include="..\runtime\ArgumentsIteratorConstructor.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\MapIteratorPrototype.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\MapIteratorConstructor.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\jit\AssemblyHelpers.h">
<Filter>jit</Filter>
</ClInclude>
......@@ -3021,6 +3036,9 @@
<ClInclude Include="..\runtime\JSArgumentsIterator.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\JSMapIterator.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\jit\Repatch.h">
<Filter>jit</Filter>
</ClInclude>
......
......@@ -930,6 +930,12 @@
A7482B9411671147003B0712 /* JSWeakObjectMapRefPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7482B7A1166CDEA003B0712 /* JSWeakObjectMapRefPrivate.cpp */; };
A7482E93116A7CAD003B0712 /* JSWeakObjectMapRefInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A7482E37116A697B003B0712 /* JSWeakObjectMapRefInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
A74DE1D0120B875600D40D5B /* ARMv7Assembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74DE1CB120B86D600D40D5B /* ARMv7Assembler.cpp */; };
A74DEF91182D991400522C22 /* MapIteratorConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74DEF8B182D991400522C22 /* MapIteratorConstructor.cpp */; };
A74DEF92182D991400522C22 /* MapIteratorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = A74DEF8C182D991400522C22 /* MapIteratorConstructor.h */; };
A74DEF93182D991400522C22 /* MapIteratorPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74DEF8D182D991400522C22 /* MapIteratorPrototype.cpp */; };
A74DEF94182D991400522C22 /* MapIteratorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A74DEF8E182D991400522C22 /* MapIteratorPrototype.h */; };
A74DEF95182D991400522C22 /* JSMapIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74DEF8F182D991400522C22 /* JSMapIterator.cpp */; };
A74DEF96182D991400522C22 /* JSMapIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = A74DEF90182D991400522C22 /* JSMapIterator.h */; };
A75706DE118A2BCF0057F88F /* JITArithmetic32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */; };
A76140CD182982CB00750624 /* ArgumentsIteratorConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A76140C7182982CB00750624 /* ArgumentsIteratorConstructor.cpp */; };
A76140CE182982CB00750624 /* ArgumentsIteratorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = A76140C8182982CB00750624 /* ArgumentsIteratorConstructor.h */; };
......@@ -2218,6 +2224,12 @@
A7482B7A1166CDEA003B0712 /* JSWeakObjectMapRefPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWeakObjectMapRefPrivate.cpp; sourceTree = "<group>"; };
A7482E37116A697B003B0712 /* JSWeakObjectMapRefInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWeakObjectMapRefInternal.h; sourceTree = "<group>"; };
A74DE1CB120B86D600D40D5B /* ARMv7Assembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ARMv7Assembler.cpp; sourceTree = "<group>"; };
A74DEF8B182D991400522C22 /* MapIteratorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MapIteratorConstructor.cpp; sourceTree = "<group>"; };
A74DEF8C182D991400522C22 /* MapIteratorConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapIteratorConstructor.h; sourceTree = "<group>"; };
A74DEF8D182D991400522C22 /* MapIteratorPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MapIteratorPrototype.cpp; sourceTree = "<group>"; };
A74DEF8E182D991400522C22 /* MapIteratorPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapIteratorPrototype.h; sourceTree = "<group>"; };
A74DEF8F182D991400522C22 /* JSMapIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMapIterator.cpp; sourceTree = "<group>"; };
A74DEF90182D991400522C22 /* JSMapIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMapIterator.h; sourceTree = "<group>"; };
A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITArithmetic32_64.cpp; sourceTree = "<group>"; };
A76140C7182982CB00750624 /* ArgumentsIteratorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArgumentsIteratorConstructor.cpp; sourceTree = "<group>"; };
A76140C8182982CB00750624 /* ArgumentsIteratorConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgumentsIteratorConstructor.h; sourceTree = "<group>"; };
......@@ -3638,6 +3650,12 @@
A7CA3AE017DA41AE006538AF /* WeakMapPrototype.h */,
1420BE7A10AA6DDB00F455D2 /* WeakRandom.h */,
A7DCB77912E3D90500911940 /* WriteBarrier.h */,
A74DEF8B182D991400522C22 /* MapIteratorConstructor.cpp */,
A74DEF8C182D991400522C22 /* MapIteratorConstructor.h */,
A74DEF8D182D991400522C22 /* MapIteratorPrototype.cpp */,
A74DEF8E182D991400522C22 /* MapIteratorPrototype.h */,
A74DEF8F182D991400522C22 /* JSMapIterator.cpp */,
A74DEF90182D991400522C22 /* JSMapIterator.h */,
);
path = runtime;
sourceTree = "<group>";
......@@ -4513,6 +4531,7 @@
7C184E2317BEE240007CB63A /* JSPromiseConstructor.h in Headers */,
7C184E1F17BEE22E007CB63A /* JSPromisePrototype.h in Headers */,
7C3BA29517C039560072DDC9 /* JSPromiseResolver.h in Headers */,
A74DEF96182D991400522C22 /* JSMapIterator.h in Headers */,
7C3BA29717C039560072DDC9 /* JSPromiseResolverConstructor.h in Headers */,
7C3BA29917C039560072DDC9 /* JSPromiseResolverPrototype.h in Headers */,
862553D216136E1A009F17D0 /* JSProxy.h in Headers */,
......@@ -4552,6 +4571,7 @@
86E3C619167BABEE006D760A /* JSWrapperMap.h in Headers */,
BC18C42E0E16F5CD00B34460 /* JSWrapperObject.h in Headers */,
BCFD8C930EEB2EE700283848 /* JumpTable.h in Headers */,
A74DEF94182D991400522C22 /* MapIteratorPrototype.h in Headers */,
A72FFD64139985A800E5365A /* KeywordLookup.h in Headers */,
969A072A0ED1CE6900F1F681 /* Label.h in Headers */,
960097A60EBABB58007A7297 /* LabelScope.h in Headers */,
......@@ -4775,6 +4795,7 @@
14E84FA114EE1ACC00D6D5D4 /* WeakSet.h in Headers */,
14150133154BB13F005D8C98 /* WeakSetInlines.h in Headers */,
BC18C47A0E16F5CD00B34460 /* WebKitAvailability.h in Headers */,
A74DEF92182D991400522C22 /* MapIteratorConstructor.h in Headers */,
A7DCB97312E5193F00911940 /* WriteBarrier.h in Headers */,
0FC8150A14043BF500CFA603 /* WriteBarrierSupport.h in Headers */,
9688CB160ED12B4E001D649F /* X86Assembler.h in Headers */,
......@@ -5283,6 +5304,7 @@
0FD81AD2154FB4EE00983E72 /* DFGDominators.cpp in Sources */,
0FD3C82614115D4000FD81CB /* DFGDriver.cpp in Sources */,
0FF0F19E16B72A0B005DF95B /* DFGEdge.cpp in Sources */,
A74DEF93182D991400522C22 /* MapIteratorPrototype.cpp in Sources */,
0FBC0AE71496C7C400D4FBDD /* DFGExitProfile.cpp in Sources */,
A78A9774179738B8009DF744 /* DFGFailedFinalizer.cpp in Sources */,
A78A9776179738B8009DF744 /* DFGFinalizer.cpp in Sources */,
......@@ -5370,6 +5392,7 @@
0FEA0A0D170513DB00BB722C /* FTLJITCode.cpp in Sources */,
A78A9780179738D5009DF744 /* FTLJITFinalizer.cpp in Sources */,
0F8F2B95172E04A0007DBDA5 /* FTLLink.cpp in Sources */,
A74DEF95182D991400522C22 /* JSMapIterator.cpp in Sources */,
0FCEFADF180738C000472CE4 /* FTLLocation.cpp in Sources */,
0FEA0A0F170513DB00BB722C /* FTLLowerDFGToLLVM.cpp in Sources */,
0FD8A31B17D51F2200CA2C40 /* FTLOSREntry.cpp in Sources */,
......@@ -5604,6 +5627,7 @@
C2F0F2D116BAEEE900187C19 /* StructureRareData.cpp in Sources */,
0F766D3815AE4A1C008F363E /* StructureStubClearingWatchpoint.cpp in Sources */,
BCCF0D0C0EF0B8A500413C8F /* StructureStubInfo.cpp in Sources */,
A74DEF91182D991400522C22 /* MapIteratorConstructor.cpp in Sources */,
C2DF442F1707AC0100A5CA96 /* SuperRegion.cpp in Sources */,
0F919D2815856773004A4E7D /* SymbolTable.cpp in Sources */,
0FC314131814559100033232 /* TempRegisterSet.cpp in Sources */,
......
......@@ -40,6 +40,7 @@
macro(Infinity) \
macro(JSON) \
macro(Map)\
macro(MapIterator)\
macro(Math) \
macro(NaN) \
macro(Number) \
......@@ -88,6 +89,7 @@
macro(displayName) \
macro(document) \
macro(done) \
macro(entries) \
macro(enumerable) \
macro(eval) \
macro(exec) \
......@@ -111,6 +113,7 @@
macro(isPrototypeOf) \
macro(isWatchpoint) \
macro(join) \
macro(keys) \
macro(lastIndex) \
macro(length) \
macro(message) \
......@@ -147,6 +150,7 @@
macro(toPrecision) \
macro(toString) \
macro(value) \
macro(values) \
macro(valueOf) \
macro(window) \
macro(writable)
......
......@@ -72,6 +72,7 @@
#include "JSGlobalObjectFunctions.h"
#include "JSLock.h"
#include "JSMap.h"
#include "JSMapIterator.h"
#include "JSNameScope.h"
#include "JSONObject.h"
#include "JSSet.h"
......@@ -83,6 +84,8 @@
#include "LegacyProfiler.h"
#include "Lookup.h"
#include "MapConstructor.h"
#include "MapIteratorConstructor.h"
#include "MapIteratorPrototype.h"
#include "MapPrototype.h"
#include "MathObject.h"
#include "NameConstructor.h"
......
......@@ -71,6 +71,8 @@ class SourceCode;
struct ActivationStackNode;
struct HashTable;
#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName)
#define FOR_EACH_SIMPLE_BUILTIN_TYPE(macro) \
macro(Set, set, set, JSSet, Set) \
macro(Map, map, map, JSMap, Map) \
......@@ -80,9 +82,11 @@ struct HashTable;
macro(Number, number, numberObject, NumberObject, Number) \
macro(Error, error, error, ErrorInstance, Error) \
macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer) \
macro(WeakMap, weakMap, weakMap, JSWeakMap, WeakMap) \
macro(ArrayIterator, arrayIterator, arrayIterator, JSArrayIterator, ArrayIterator) \
macro(ArgumentsIterator, argumentsIterator, argumentsIterator, JSArgumentsIterator, ArgumentsIterator) \
DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \
DEFINE_STANDARD_BUILTIN(macro, ArrayIterator, arrayIterator) \
DEFINE_STANDARD_BUILTIN(macro, ArgumentsIterator, argumentsIterator) \
DEFINE_STANDARD_BUILTIN(macro, MapIterator, mapIterator) \
#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
class JS ## capitalName; \
......
/*
* Copyright (C) 2013 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "JSMapIterator.h"
#include "JSCJSValueInlines.h"
#include "JSCellInlines.h"
#include "JSMap.h"
#include "SlotVisitorInlines.h"
namespace JSC {
const ClassInfo JSMapIterator::s_info = { "Map Iterator", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSMapIterator) };
void JSMapIterator::finishCreation(VM& vm, JSMap* iteratedObject)
{
Base::finishCreation(vm);
m_iteratedObjectData.set(vm, this, iteratedObject->mapData());
}
void JSMapIterator::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSMapIterator* thisObject = jsCast<JSMapIterator*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_iteratedObjectData);
}
JSValue JSMapIterator::createPair(CallFrame* callFrame, JSValue key, JSValue value)
{
MarkedArgumentBuffer args;
args.append(key);
args.append(value);
JSGlobalObject* globalObject = callFrame->callee()->globalObject();
return constructArray(callFrame, 0, globalObject, args);
}
}
/*
* Copyright (C) 2013 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef JSMapIterator_h
#define JSMapIterator_h
#include "JSDestructibleObject.h"
#include "JSMap.h"
#include "MapData.h"
namespace JSC {
enum MapIterationKind : uint32_t {
MapIterateKey,
MapIterateValue,
MapIterateKeyValue,
};
class JSMapIterator : public JSDestructibleObject {