Commit 005f9e8f authored by oliver@apple.com's avatar oliver@apple.com

Implement ES6 Map object

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

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Implement support for the ES6 Map type and related classes.

* JavaScriptCore.xcodeproj/project.pbxproj:
* heap/CopyToken.h: Add a new token to track copying the backing store
* runtime/CommonIdentifiers.h: Add new identifiers
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
    Add new structures and prototypes

* runtime/JSMap.cpp: Added.
* runtime/JSMap.h: Added.
    New JSMap class to represent a Map instance

* runtime/MapConstructor.cpp: Added.
* runtime/MapConstructor.h: Added.
    The Map constructor

* runtime/MapData.cpp: Added.
* runtime/MapData.h: Added.
    The most interesting data structure.  The roughly corresponds
    to the ES6 notion of MapData.  It provides the core JSValue->JSValue
    map implementation.  We implement it using 2 hashtables and a flat
    table.  Due to the different semantics of string comparisons vs.
    all others we need have one map keyed by String and the other by
    generic JSValue.  The actual table is represented more or less
    exactly as described in the ES6 draft - a single contiguous list of
    key/value pairs.  The entire map could be achieved with just this
    table, however we need the HashMaps in order to maintain O(1) lookup.

    Deleted values are simply cleared as the draft says, however the
    implementation compacts the storage on copy as long as the are no
    active iterators.

* runtime/MapPrototype.cpp: Added.
* runtime/MapPrototype.h: Added.
    Implement Map prototype functions

* runtime/VM.cpp:
    Add new structures.

LayoutTests:

Tests

* fast/js/basic-map-expected.txt: Added.
* fast/js/basic-map.html: Added.
* fast/js/script-tests/basic-map.js: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7fc419f3
2013-08-29 Oliver Hunt <oliver@apple.com>
Implement ES6 Map object
https://bugs.webkit.org/show_bug.cgi?id=120333
Reviewed by Geoffrey Garen.
Tests
* fast/js/basic-map-expected.txt: Added.
* fast/js/basic-map.html: Added.
* fast/js/script-tests/basic-map.js: Added.
2013-08-29 Joseph Pecoraro <pecoraro@apple.com>
[Mac] Web Inspector: inspector/storage-panel-dom-storage-update.html fails
Tests basic correctness of ES Map object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Map instanceof Map is false
PASS Map.prototype instanceof Map is false
PASS new Map() instanceof Map is true
PASS new Map(null) instanceof Map is true
PASS new Map(undefined) instanceof Map is true
PASS new Map(undefined, undefined) instanceof Map is true
PASS new Map(null, undefined) instanceof Map is true
PASS new Map(1) threw exception TypeError: Map constructor does not accept arguments.
PASS new Map(true) threw exception TypeError: Map constructor does not accept arguments.
PASS new Map([]) threw exception TypeError: Map constructor does not accept arguments.
PASS new Map({}) threw exception TypeError: Map constructor does not accept arguments.
PASS new Map(undefined, null) threw exception RangeError: Invalid comparator function.
PASS new Map(undefined, {}) threw exception RangeError: Invalid comparator function.
PASS Object.hasOwnProperty(map, 'size') is false
PASS Map.prototype.hasOwnProperty('size') is true
PASS Map.prototype.size threw exception TypeError: Map operation called on non-Map object.
PASS map.size is 0
PASS map.set(-0, 1) is map
PASS map.set(0, 2) is map
PASS map.set(Infinity, 3) is map
PASS map.set(-Infinity, 4) is map
PASS map.set(NaN, 5) is map
PASS map.set('0', 6) is map
PASS map.set(0.1, 7) is map
PASS map.size is 7
PASS map.get(-0) is 1
PASS map.get(0) is 2
PASS map.get(Infinity) is 3
PASS map.get(-Infinity) is 4
PASS map.get(NaN) is 5
PASS map.get('0') is 6
PASS map.get(0.1) is 7
PASS map.has(-0) is true
PASS map.has(0) is true
PASS map.has(Infinity) is true
PASS map.has(-Infinity) is true
PASS map.has(NaN) is true
PASS map.has('0') is true
PASS map.has(0.1) is true
PASS map.delete(-0) is true
PASS map.delete(0) is true
PASS map.delete(Infinity) is true
PASS map.delete(-Infinity) is true
PASS map.delete(NaN) is true
PASS map.delete('0') is true
PASS map.delete(0.1) is true
PASS map.delete(-0) is false
PASS map.delete(0) is false
PASS map.delete(Infinity) is false
PASS map.delete(-Infinity) is false
PASS map.delete(NaN) is false
PASS map.delete('0') is false
PASS map.delete(0.1) is false
PASS map.get(simpleString) is map.get(otherString)
PASS map.clear() is undefined.
PASS map.size is 0
PASS map.set(0, 0) is map
PASS map.set('0', 1) is map
PASS map.set(1, 2) is map
PASS map.set('1', 3) is map
PASS map.set(2, 4) is map
PASS map.set('2', 5) is map
PASS map.set(3, 6) is map
PASS map.set('3', 7) is map
PASS map.set(4, 8) is map
PASS map.set('4', 9) is map
PASS map.set(5, 10) is map
PASS map.set('5', 11) is map
PASS map.set(6, 12) is map
PASS map.set('6', 13) is map
PASS map.size is 14
forEach #0
PASS testThis is undefined.
0
forEach #1
PASS testThis is thisValue
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
PASS map.forEach(debug) is undefined.
0 : number => 0
0 : string => 1
1 : number => 2
1 : string => 3
2 : number => 4
2 : string => 5
3 : string => 7
4 : string => 9
5 : number => 10
5 : string => 11
6 : number => 12
6 : string => 13
4 : number => 11
PASS map.get(0) is 0
PASS map.get("0") is 1
PASS map.get(1) is 2
PASS map.get("1") is 3
PASS map.get(2) is 4
PASS map.get("2") is 5
PASS map.get("3") is "replaced"
PASS map.get("4") is 9
PASS map.get(5) is 10
PASS map.get("5") is 11
PASS map.get(6) is 12
PASS map.get("6") is 13
PASS map.get(4) is 11
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<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>
</body>
</html>
description("Tests basic correctness of ES Map object");
// Currently we don't support iterators, so we throw
// on any non-throwing parameters
shouldBeFalse("Map instanceof Map");
shouldBeFalse("Map.prototype instanceof Map");
shouldBeTrue("new Map() instanceof Map");
shouldBeTrue("new Map(null) instanceof Map");
shouldBeTrue("new Map(undefined) instanceof Map");
shouldBeTrue("new Map(undefined, undefined) instanceof Map");
shouldBeTrue("new Map(null, undefined) instanceof Map");
shouldThrow("new Map(1)");
shouldThrow("new Map(true)");
shouldThrow("new Map([])");
shouldThrow("new Map({})");
shouldThrow("new Map(undefined, null)");
shouldThrow("new Map(undefined, {})");
var map = new Map;
shouldBeFalse("Object.hasOwnProperty(map, 'size')")
shouldBeTrue("Map.prototype.hasOwnProperty('size')")
shouldThrow("Map.prototype.size")
shouldBe("map.size", "0")
shouldBe("map.set(-0, 1)", "map")
shouldBe("map.set(0, 2)", "map")
shouldBe("map.set(Infinity, 3)", "map")
shouldBe("map.set(-Infinity, 4)", "map")
shouldBe("map.set(NaN, 5)", "map")
shouldBe("map.set('0', 6)", "map")
shouldBe("map.set(0.1, 7)", "map")
shouldBe("map.size", "7")
shouldBe("map.get(-0)", "1")
shouldBe("map.get(0)", "2")
shouldBe("map.get(Infinity)", "3")
shouldBe("map.get(-Infinity)", "4")
shouldBe("map.get(NaN)", "5")
shouldBe("map.get('0')", "6")
shouldBe("map.get(0.1)", "7")
shouldBeTrue("map.has(-0)")
shouldBeTrue("map.has(0)")
shouldBeTrue("map.has(Infinity)")
shouldBeTrue("map.has(-Infinity)")
shouldBeTrue("map.has(NaN)")
shouldBeTrue("map.has('0')")
shouldBeTrue("map.has(0.1)")
shouldBeTrue("map.delete(-0)")
shouldBeTrue("map.delete(0)")
shouldBeTrue("map.delete(Infinity)")
shouldBeTrue("map.delete(-Infinity)")
shouldBeTrue("map.delete(NaN)")
shouldBeTrue("map.delete('0')")
shouldBeTrue("map.delete(0.1)")
shouldBeFalse("map.delete(-0)")
shouldBeFalse("map.delete(0)")
shouldBeFalse("map.delete(Infinity)")
shouldBeFalse("map.delete(-Infinity)")
shouldBeFalse("map.delete(NaN)")
shouldBeFalse("map.delete('0')")
shouldBeFalse("map.delete(0.1)")
var simpleString = "aaaaa";
var otherString = "";
for (var i = 0; i < 5; i++)
otherString += "a"
map.set(simpleString, {});
shouldBe("map.get(simpleString)", "map.get(otherString)");
shouldBeUndefined("map.clear()");
shouldBe("map.size", "0")
var count = 7;
for (var i = 0; i < count; i++) {
shouldBe("map.set(" + i + ", " + (i * 2) + ")", "map")
shouldBe("map.set('" + i + "', " + (i * 2 + 1) + ")", "map")
}
shouldBe("map.size", "14")
var thisValue = 0xf00
var testThis;
var count = 0;
try {
map.forEach(function() { "use strict"; debug("forEach #0"); testThis = this; shouldBeUndefined("testThis"); throw count++; })
} catch(e) {
debug(e)
}
try {
map.forEach(function() { "use strict"; debug("forEach #1"); testThis = this; shouldBe("testThis", "thisValue"); throw count++; }, thisValue)
} catch(e) {
debug(e)
}
shouldBeUndefined('map.forEach(debug)')
map.forEach(function (v,k) {
debug(k + " : " + typeof (k) + " => " + v)
if (k == 2)
map.delete(3)
if (k == "3") {
map.set("3", "replaced");
map.delete(4)
map.set(4, 11)
}
})
var keys;
map.forEach(function (v,k) {
keys = keys || [];
keys.push([k,v]);
})
gc();
for (var i = 0; i < keys.length; i++) {
var expectedKey = keys[i][0]
var expectedValue = keys[i][1]
shouldBe("map.get("+JSON.stringify(expectedKey)+")", JSON.stringify(expectedValue));
}
......@@ -334,6 +334,9 @@ set(JavaScriptCore_SOURCES
runtime/JSGlobalObject.cpp
runtime/JSGlobalObjectFunctions.cpp
runtime/JSLock.cpp
runtime/JSMap.cpp
runtime/JSMapConstructor.cpp
runtime/JSMapPrototype.cpp
runtime/JSNameScope.cpp
runtime/JSNotAnObject.cpp
runtime/JSONObject.cpp
......@@ -361,6 +364,7 @@ set(JavaScriptCore_SOURCES
runtime/JSWrapperObject.cpp
runtime/LiteralParser.cpp
runtime/Lookup.cpp
runtime/MapData.cpp
runtime/MathObject.cpp
runtime/MemoryStatistics.cpp
runtime/NameConstructor.cpp
......
2013-08-29 Oliver Hunt <oliver@apple.com>
Implement ES6 Map object
https://bugs.webkit.org/show_bug.cgi?id=120333
Reviewed by Geoffrey Garen.
Implement support for the ES6 Map type and related classes.
* JavaScriptCore.xcodeproj/project.pbxproj:
* heap/CopyToken.h: Add a new token to track copying the backing store
* runtime/CommonIdentifiers.h: Add new identifiers
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
Add new structures and prototypes
* runtime/JSMap.cpp: Added.
* runtime/JSMap.h: Added.
New JSMap class to represent a Map instance
* runtime/MapConstructor.cpp: Added.
* runtime/MapConstructor.h: Added.
The Map constructor
* runtime/MapData.cpp: Added.
* runtime/MapData.h: Added.
The most interesting data structure. The roughly corresponds
to the ES6 notion of MapData. It provides the core JSValue->JSValue
map implementation. We implement it using 2 hashtables and a flat
table. Due to the different semantics of string comparisons vs.
all others we need have one map keyed by String and the other by
generic JSValue. The actual table is represented more or less
exactly as described in the ES6 draft - a single contiguous list of
key/value pairs. The entire map could be achieved with just this
table, however we need the HashMaps in order to maintain O(1) lookup.
Deleted values are simply cleared as the draft says, however the
implementation compacts the storage on copy as long as the are no
active iterators.
* runtime/MapPrototype.cpp: Added.
* runtime/MapPrototype.h: Added.
Implement Map prototype functions
* runtime/VM.cpp:
Add new structures.
2013-08-29 Filip Pizlo <fpizlo@apple.com>
Teach DFG::Worklist and its clients that it may be reused for different kinds of compilations
......
......@@ -872,6 +872,9 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/JSInt8Array.h \
Source/JavaScriptCore/runtime/JSLock.cpp \
Source/JavaScriptCore/runtime/JSLock.h \
Source/JavaScriptCore/runtime/JSMap.cpp \
Source/JavaScriptCore/runtime/JSMapConstructor.cpp \
Source/JavaScriptCore/runtime/JSMapPrototype.cpp \
Source/JavaScriptCore/runtime/JSNotAnObject.cpp \
Source/JavaScriptCore/runtime/JSNotAnObject.h \
Source/JavaScriptCore/runtime/JSObject.cpp \
......
......@@ -469,6 +469,9 @@
<ClCompile Include="..\runtime\JSGlobalObject.cpp" />
<ClCompile Include="..\runtime\JSGlobalObjectFunctions.cpp" />
<ClCompile Include="..\runtime\JSLock.cpp" />
<ClCompile Include="..\runtime\JSMap.cpp" />
<ClCompile Include="..\runtime\JSMapConstructor.cpp" />
<ClCompile Include="..\runtime\JSMapPrototype.cpp" />
<ClCompile Include="..\runtime\JSNameScope.cpp" />
<ClCompile Include="..\runtime\JSNotAnObject.cpp" />
<ClCompile Include="..\runtime\JSONObject.cpp" />
......@@ -495,6 +498,7 @@
<ClCompile Include="..\runtime\JSWrapperObject.cpp" />
<ClCompile Include="..\runtime\LiteralParser.cpp" />
<ClCompile Include="..\runtime\Lookup.cpp" />
<ClCompile Include="..\runtime\MapData.cpp" />
<ClCompile Include="..\runtime\MathObject.cpp" />
<ClCompile Include="..\runtime\NameConstructor.cpp" />
<ClCompile Include="..\runtime\NameInstance.cpp" />
......@@ -895,6 +899,9 @@
<ClInclude Include="..\runtime\JSInt32Array.h" />
<ClInclude Include="..\runtime\JSInt8Array.h" />
<ClInclude Include="..\runtime\JSLock.h" />
<ClInclude Include="..\runtime\JSMap.h" />
<ClInclude Include="..\runtime\JSMapConstructor.h" />
<ClInclude Include="..\runtime\JSMapPrototype.h" />
<ClInclude Include="..\runtime\JSNameScope.h" />
<ClInclude Include="..\runtime\JSNotAnObject.h" />
<ClInclude Include="..\runtime\JSONObject.h" />
......@@ -928,6 +935,7 @@
<ClInclude Include="..\runtime\JSWrapperObject.h" />
<ClInclude Include="..\runtime\LiteralParser.h" />
<ClInclude Include="..\runtime\Lookup.h" />
<ClInclude Include="..\runtime\MapData.h" />
<ClInclude Include="..\runtime\MatchResult.h" />
<ClInclude Include="..\runtime\MathObject.h" />
<ClInclude Include="..\runtime\NameConstructor.h" />
......
......@@ -573,6 +573,15 @@
<ClCompile Include="..\runtime\JSLock.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\JSMap.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\JSMapPrototype.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\JSMapConstructor.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\JSNameScope.cpp">
<Filter>runtime</Filter>
</ClCompile>
......@@ -621,6 +630,9 @@
<ClCompile Include="..\runtime\Lookup.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\MapData.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\MathObject.cpp">
<Filter>runtime</Filter>
</ClCompile>
......
......@@ -323,6 +323,10 @@ SOURCES += \
runtime/JSGlobalObject.cpp \
runtime/JSGlobalObjectFunctions.cpp \
runtime/JSLock.cpp \
runtime/JSMap.cpp \
runtime/JSMapConstructor.cpp \
runtime/JSPrototype.cpp \
runtime/JSNameScope.cpp \
runtime/JSNameScope.cpp \
runtime/JSNotAnObject.cpp \
runtime/JSONObject.cpp \
......@@ -349,6 +353,7 @@ SOURCES += \
runtime/JSWrapperObject.cpp \
runtime/LiteralParser.cpp \
runtime/Lookup.cpp \
runtime/MapData.cpp \
runtime/MathObject.cpp \
runtime/MemoryStatistics.cpp \
runtime/NameConstructor.cpp \
......
......@@ -30,7 +30,8 @@ namespace JSC {
enum CopyToken {
ButterflyCopyToken,
TypedArrayVectorCopyToken
TypedArrayVectorCopyToken,
MapBackingStoreCopyToken
};
} // namespace JSC
......
......@@ -136,7 +136,12 @@
macro(value) \
macro(valueOf) \
macro(window) \
macro(writable)
macro(writable) \
macro(has) \
macro(forEach) \
macro(clear) \
macro(size) \
macro(Map)
#define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \
macro(null) \
......
......@@ -64,6 +64,7 @@
#include "JSGenericTypedArrayViewPrototypeInlines.h"
#include "JSGlobalObjectFunctions.h"
#include "JSLock.h"
#include "JSMap.h"
#include "JSNameScope.h"
#include "JSONObject.h"
#include "JSTypedArrayConstructors.h"
......@@ -72,6 +73,9 @@
#include "JSWithScope.h"
#include "LegacyProfiler.h"
#include "Lookup.h"
#include "MapConstructor.h"
#include "MapData.h"
#include "MapPrototype.h"
#include "MathObject.h"
#include "NameConstructor.h"
#include "NameInstance.h"
......@@ -317,6 +321,11 @@ void JSGlobalObject::reset(JSValue prototype)
m_promiseWrapperCallbackStructure.set(exec->vm(), this, JSPromiseWrapperCallback::createStructure(exec->vm(), this, m_functionPrototype.get()));
#endif // ENABLE(PROMISES)
m_mapDataStructure.set(exec->vm(), this, MapData::createStructure(exec->vm(), this, jsNull()));
m_mapPrototype.set(exec->vm(), this, MapPrototype::create(exec, this, MapPrototype::createStructure(exec->vm(), this, m_objectPrototype.get())));
m_mapStructure.set(exec->vm(), this, JSMap::createStructure(exec->vm(), this, m_mapPrototype.get()));
// Constructors
JSCell* objectConstructor = ObjectConstructor::create(exec, this, ObjectConstructor::createStructure(exec->vm(), this, m_functionPrototype.get()), m_objectPrototype.get());
......@@ -331,6 +340,7 @@ void JSGlobalObject::reset(JSValue prototype)
JSCell* promiseConstructor = JSPromiseConstructor::create(exec, this, JSPromiseConstructor::createStructure(exec->vm(), this, m_functionPrototype.get()), m_promisePrototype.get());
JSCell* promiseResolverConstructor = JSPromiseResolverConstructor::create(exec, this, JSPromiseResolverConstructor::createStructure(exec->vm(), this, m_functionPrototype.get()), m_promiseResolverPrototype.get());
#endif // ENABLE(PROMISES)
JSCell* mapConstructor = MapConstructor::create(exec, this, MapConstructor::createStructure(exec->vm(), this, m_functionPrototype.get()), m_mapPrototype.get());
m_regExpConstructor.set(exec->vm(), this, RegExpConstructor::create(exec, this, RegExpConstructor::createStructure(exec->vm(), this, m_functionPrototype.get()), m_regExpPrototype.get()));
......@@ -358,6 +368,7 @@ void JSGlobalObject::reset(JSValue prototype)
m_promisePrototype->putDirectWithoutTransition(exec->vm(), exec->propertyNames().constructor, promiseConstructor, DontEnum);
m_promiseResolverPrototype->putDirectWithoutTransition(exec->vm(), exec->propertyNames().constructor, promiseResolverConstructor, DontEnum);
#endif
m_mapPrototype->putDirectWithoutTransition(exec->vm(), exec->propertyNames().constructor, mapConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Object, objectConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Function, functionConstructor, DontEnum);
......@@ -378,6 +389,7 @@ void JSGlobalObject::reset(JSValue prototype)
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Promise, promiseConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().PromiseResolver, promiseResolverConstructor, DontEnum);
#endif
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Map, mapConstructor, DontEnum);
m_evalFunction.set(exec->vm(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval.string(), globalFuncEval));
putDirectWithoutTransition(exec->vm(), exec->propertyNames().eval, m_evalFunction.get(), DontEnum);
......@@ -638,6 +650,9 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
visitor.append(&thisObject->m_promiseCallbackStructure);
visitor.append(&thisObject->m_promiseWrapperCallbackStructure);
#endif // ENABLE(PROMISES)
visitor.append(&thisObject->m_mapPrototype);
visitor.append(&thisObject->m_mapDataStructure);
visitor.append(&thisObject->m_mapStructure);
visitor.append(&thisObject->m_arrayBufferPrototype);
visitor.append(&thisObject->m_arrayBufferStructure);
......
......@@ -63,6 +63,7 @@ class JSPromisePrototype;
class JSPromiseResolverPrototype;
class JSStack;
class LLIntOffsetsExtractor;
class MapPrototype;
class NativeErrorConstructor;
class ProgramCodeBlock;
class ProgramExecutable;
......@@ -150,6 +151,7 @@ protected:
WriteBarrier<ErrorPrototype> m_errorPrototype;
WriteBarrier<JSPromisePrototype> m_promisePrototype;
WriteBarrier<JSPromiseResolverPrototype> m_promiseResolverPrototype;
WriteBarrier<MapPrototype> m_mapPrototype;
WriteBarrier<Structure> m_withScopeStructure;
WriteBarrier<Structure> m_strictEvalActivationStructure;
......@@ -191,6 +193,9 @@ protected:
WriteBarrier<Structure> m_promiseWrapperCallbackStructure;
#endif // ENABLE(PROMISES)
WriteBarrier<Structure> m_mapDataStructure;
WriteBarrier<Structure> m_mapStructure;
WriteBarrier<JSArrayBufferPrototype> m_arrayBufferPrototype;
WriteBarrier<Structure> m_arrayBufferStructure;
......@@ -381,6 +386,8 @@ public:
Structure* numberObjectStructure() const { return m_numberObjectStructure.get(); }
Structure* privateNameStructure() const { return m_privateNameStructure.get(); }
Structure* internalFunctionStructure() const { return m_internalFunctionStructure.get(); }
Structure* mapStructure() const { return m_mapStructure.get(); }
Structure* mapDataStructure() const { return m_mapDataStructure.get(); }
Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); }
Structure* regExpStructure() const { return m_regExpStructure.get(); }
Structure* stringObjectStructure() const { return m_stringObjectStructure.get(); }
......
/*
* 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 "JSMap.h"
#include "JSCJSValueInlines.h"
#include "MapData.h"
#include "SlotVisitorInlines.h"
namespace JSC {
const ClassInfo JSMap::s_info = { "Map", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSMap) };
void JSMap::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
Base::visitChildren(cell, visitor);
JSMap* thisObject = jsCast<JSMap*>(cell);
visitor.append(&thisObject->m_mapData);
}
void JSMap::finishCreation(VM& vm, JSGlobalObject* globalObject)
{
Base::finishCreation(vm);
m_mapData.set(vm, this, MapData::create(vm, globalObject));
}
}
/*
* 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