Title: [221359] releases/WebKitGTK/webkit-2.18/Source/_javascript_Core
Revision
221359
Author
carlo...@webkit.org
Date
2017-08-30 03:07:57 -0700 (Wed, 30 Aug 2017)

Log Message

Merge r221223 - Merge WeakMapData into JSWeakMap and JSWeakSet
https://bugs.webkit.org/show_bug.cgi?id=143919

Reviewed by Darin Adler.

This patch changes WeakMapData from JSCell to JSDestructibleObject,
renaming it to WeakMapBase, and JSWeakMap and JSWeakSet simply inherit
it instead of separately allocating WeakMapData. This reduces memory
consumption and allocation times.

Also this patch a bit optimizes sizeof(DeadKeyCleaner) by dropping m_target
field. Since this class is always embedded in WeakMapBase, we can calculate
WeakMapBase address from the address of DeadKeyCleaner.

This patch does not include the optimization changing WeakMapData to Set
for JSWeakSet.

* CMakeLists.txt:
* _javascript_Core.xcodeproj/project.pbxproj:
* inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::weakMapSize):
(Inspector::JSInjectedScriptHost::weakMapEntries):
(Inspector::JSInjectedScriptHost::weakSetSize):
(Inspector::JSInjectedScriptHost::weakSetEntries):
* runtime/JSWeakMap.cpp:
(JSC::JSWeakMap::finishCreation): Deleted.
(JSC::JSWeakMap::visitChildren): Deleted.
* runtime/JSWeakMap.h:
(JSC::JSWeakMap::createStructure): Deleted.
(JSC::JSWeakMap::create): Deleted.
(JSC::JSWeakMap::weakMapData): Deleted.
(JSC::JSWeakMap::JSWeakMap): Deleted.
* runtime/JSWeakSet.cpp:
(JSC::JSWeakSet::finishCreation): Deleted.
(JSC::JSWeakSet::visitChildren): Deleted.
* runtime/JSWeakSet.h:
(JSC::JSWeakSet::createStructure): Deleted.
(JSC::JSWeakSet::create): Deleted.
(JSC::JSWeakSet::weakMapData): Deleted.
(JSC::JSWeakSet::JSWeakSet): Deleted.
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:
* runtime/WeakMapBase.cpp: Renamed from Source/_javascript_Core/runtime/WeakMapData.cpp.
(JSC::WeakMapBase::WeakMapBase):
(JSC::WeakMapBase::destroy):
(JSC::WeakMapBase::estimatedSize):
(JSC::WeakMapBase::visitChildren):
(JSC::WeakMapBase::set):
(JSC::WeakMapBase::get):
(JSC::WeakMapBase::remove):
(JSC::WeakMapBase::contains):
(JSC::WeakMapBase::clear):
(JSC::WeakMapBase::DeadKeyCleaner::target):
(JSC::WeakMapBase::DeadKeyCleaner::visitWeakReferences):
(JSC::WeakMapBase::DeadKeyCleaner::finalizeUnconditionally):
* runtime/WeakMapBase.h: Renamed from Source/_javascript_Core/runtime/WeakMapData.h.
(JSC::WeakMapBase::size const):
* runtime/WeakMapPrototype.cpp:
(JSC::getWeakMap):
(JSC::protoFuncWeakMapDelete):
(JSC::protoFuncWeakMapGet):
(JSC::protoFuncWeakMapHas):
(JSC::protoFuncWeakMapSet):
(JSC::getWeakMapData): Deleted.
* runtime/WeakSetPrototype.cpp:
(JSC::getWeakSet):
(JSC::protoFuncWeakSetDelete):
(JSC::protoFuncWeakSetHas):
(JSC::protoFuncWeakSetAdd):
(JSC::getWeakMapData): Deleted.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/CMakeLists.txt (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/CMakeLists.txt	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/CMakeLists.txt	2017-08-30 10:07:57 UTC (rev 221359)
@@ -927,8 +927,8 @@
     runtime/VMTraps.cpp
     runtime/VarOffset.cpp
     runtime/Watchdog.cpp
+    runtime/WeakMapBase.cpp
     runtime/WeakMapConstructor.cpp
-    runtime/WeakMapData.cpp
     runtime/WeakMapPrototype.cpp
     runtime/WeakSetConstructor.cpp
     runtime/WeakSetPrototype.cpp

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/ChangeLog (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/ChangeLog	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/ChangeLog	2017-08-30 10:07:57 UTC (rev 221359)
@@ -1,3 +1,77 @@
+2017-08-26  Yusuke Suzuki  <utatane....@gmail.com>
+
+        Merge WeakMapData into JSWeakMap and JSWeakSet
+        https://bugs.webkit.org/show_bug.cgi?id=143919
+
+        Reviewed by Darin Adler.
+
+        This patch changes WeakMapData from JSCell to JSDestructibleObject,
+        renaming it to WeakMapBase, and JSWeakMap and JSWeakSet simply inherit
+        it instead of separately allocating WeakMapData. This reduces memory
+        consumption and allocation times.
+
+        Also this patch a bit optimizes sizeof(DeadKeyCleaner) by dropping m_target
+        field. Since this class is always embedded in WeakMapBase, we can calculate
+        WeakMapBase address from the address of DeadKeyCleaner.
+
+        This patch does not include the optimization changing WeakMapData to Set
+        for JSWeakSet.
+
+        * CMakeLists.txt:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * inspector/JSInjectedScriptHost.cpp:
+        (Inspector::JSInjectedScriptHost::weakMapSize):
+        (Inspector::JSInjectedScriptHost::weakMapEntries):
+        (Inspector::JSInjectedScriptHost::weakSetSize):
+        (Inspector::JSInjectedScriptHost::weakSetEntries):
+        * runtime/JSWeakMap.cpp:
+        (JSC::JSWeakMap::finishCreation): Deleted.
+        (JSC::JSWeakMap::visitChildren): Deleted.
+        * runtime/JSWeakMap.h:
+        (JSC::JSWeakMap::createStructure): Deleted.
+        (JSC::JSWeakMap::create): Deleted.
+        (JSC::JSWeakMap::weakMapData): Deleted.
+        (JSC::JSWeakMap::JSWeakMap): Deleted.
+        * runtime/JSWeakSet.cpp:
+        (JSC::JSWeakSet::finishCreation): Deleted.
+        (JSC::JSWeakSet::visitChildren): Deleted.
+        * runtime/JSWeakSet.h:
+        (JSC::JSWeakSet::createStructure): Deleted.
+        (JSC::JSWeakSet::create): Deleted.
+        (JSC::JSWeakSet::weakMapData): Deleted.
+        (JSC::JSWeakSet::JSWeakSet): Deleted.
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        * runtime/VM.h:
+        * runtime/WeakMapBase.cpp: Renamed from Source/_javascript_Core/runtime/WeakMapData.cpp.
+        (JSC::WeakMapBase::WeakMapBase):
+        (JSC::WeakMapBase::destroy):
+        (JSC::WeakMapBase::estimatedSize):
+        (JSC::WeakMapBase::visitChildren):
+        (JSC::WeakMapBase::set):
+        (JSC::WeakMapBase::get):
+        (JSC::WeakMapBase::remove):
+        (JSC::WeakMapBase::contains):
+        (JSC::WeakMapBase::clear):
+        (JSC::WeakMapBase::DeadKeyCleaner::target):
+        (JSC::WeakMapBase::DeadKeyCleaner::visitWeakReferences):
+        (JSC::WeakMapBase::DeadKeyCleaner::finalizeUnconditionally):
+        * runtime/WeakMapBase.h: Renamed from Source/_javascript_Core/runtime/WeakMapData.h.
+        (JSC::WeakMapBase::size const):
+        * runtime/WeakMapPrototype.cpp:
+        (JSC::getWeakMap):
+        (JSC::protoFuncWeakMapDelete):
+        (JSC::protoFuncWeakMapGet):
+        (JSC::protoFuncWeakMapHas):
+        (JSC::protoFuncWeakMapSet):
+        (JSC::getWeakMapData): Deleted.
+        * runtime/WeakSetPrototype.cpp:
+        (JSC::getWeakSet):
+        (JSC::protoFuncWeakSetDelete):
+        (JSC::protoFuncWeakSetHas):
+        (JSC::protoFuncWeakSetAdd):
+        (JSC::getWeakMapData): Deleted.
+
 2017-08-22  Saam Barati  <sbar...@apple.com>
 
         We are using valueProfileForBytecodeOffset when there may not be a value profile

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-08-30 10:07:57 UTC (rev 221359)
@@ -2045,8 +2045,8 @@
 		A7CA3AE617DA41AE006538AF /* WeakMapPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CA3AE017DA41AE006538AF /* WeakMapPrototype.h */; };
 		A7CA3AE717DA41AE006538AF /* JSWeakMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7CA3AE117DA41AE006538AF /* JSWeakMap.cpp */; };
 		A7CA3AE817DA41AE006538AF /* JSWeakMap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CA3AE217DA41AE006538AF /* JSWeakMap.h */; };
-		A7CA3AEB17DA5168006538AF /* WeakMapData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7CA3AE917DA5168006538AF /* WeakMapData.cpp */; };
-		A7CA3AEC17DA5168006538AF /* WeakMapData.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CA3AEA17DA5168006538AF /* WeakMapData.h */; };
+		A7CA3AEB17DA5168006538AF /* WeakMapBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7CA3AE917DA5168006538AF /* WeakMapBase.cpp */; };
+		A7CA3AEC17DA5168006538AF /* WeakMapBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CA3AEA17DA5168006538AF /* WeakMapBase.h */; };
 		A7D801A41880D66E0026C39B /* BuiltinExecutables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D801A11880D66E0026C39B /* BuiltinExecutables.cpp */; };
 		A7D801A51880D66E0026C39B /* BuiltinExecutables.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D801A21880D66E0026C39B /* BuiltinExecutables.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A7D801A81880D6A80026C39B /* JSCBuiltins.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D801A61880D6A80026C39B /* JSCBuiltins.cpp */; };
@@ -4687,8 +4687,8 @@
 		A7CA3AE017DA41AE006538AF /* WeakMapPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakMapPrototype.h; sourceTree = "<group>"; };
 		A7CA3AE117DA41AE006538AF /* JSWeakMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWeakMap.cpp; sourceTree = "<group>"; };
 		A7CA3AE217DA41AE006538AF /* JSWeakMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWeakMap.h; sourceTree = "<group>"; };
-		A7CA3AE917DA5168006538AF /* WeakMapData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakMapData.cpp; sourceTree = "<group>"; };
-		A7CA3AEA17DA5168006538AF /* WeakMapData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakMapData.h; sourceTree = "<group>"; };
+		A7CA3AE917DA5168006538AF /* WeakMapBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakMapBase.cpp; sourceTree = "<group>"; };
+		A7CA3AEA17DA5168006538AF /* WeakMapBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakMapBase.h; sourceTree = "<group>"; };
 		A7D801A01880D66E0026C39B /* ArrayPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = ArrayPrototype.js; sourceTree = "<group>"; };
 		A7D801A11880D66E0026C39B /* BuiltinExecutables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BuiltinExecutables.cpp; sourceTree = "<group>"; };
 		A7D801A21880D66E0026C39B /* BuiltinExecutables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BuiltinExecutables.h; sourceTree = "<group>"; };
@@ -7189,10 +7189,10 @@
 				FED94F2C171E3E2300BE77A4 /* Watchdog.h */,
 				14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */,
 				AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */,
+				A7CA3AE917DA5168006538AF /* WeakMapBase.cpp */,
+				A7CA3AEA17DA5168006538AF /* WeakMapBase.h */,
 				A7CA3ADD17DA41AE006538AF /* WeakMapConstructor.cpp */,
 				A7CA3ADE17DA41AE006538AF /* WeakMapConstructor.h */,
-				A7CA3AE917DA5168006538AF /* WeakMapData.cpp */,
-				A7CA3AEA17DA5168006538AF /* WeakMapData.h */,
 				A7CA3ADF17DA41AE006538AF /* WeakMapPrototype.cpp */,
 				A7CA3AE017DA41AE006538AF /* WeakMapPrototype.h */,
 				709FB8631AE335C60039D069 /* WeakSetConstructor.cpp */,
@@ -9600,8 +9600,8 @@
 				14F7256614EE265E00B1652B /* WeakHandleOwner.h in Headers */,
 				14E84FA214EE1ACC00D6D5D4 /* WeakImpl.h in Headers */,
 				14BE7D3317135CF400D1807A /* WeakInlines.h in Headers */,
+				A7CA3AEC17DA5168006538AF /* WeakMapBase.h in Headers */,
 				A7CA3AE417DA41AE006538AF /* WeakMapConstructor.h in Headers */,
-				A7CA3AEC17DA5168006538AF /* WeakMapData.h in Headers */,
 				A7CA3AE617DA41AE006538AF /* WeakMapPrototype.h in Headers */,
 				0F242DA713F3B1E8007ADD4C /* WeakReferenceHarvester.h in Headers */,
 				14E84FA114EE1ACC00D6D5D4 /* WeakSet.h in Headers */,
@@ -11083,8 +11083,8 @@
 				1ACF7377171CA6FB00C9BB1E /* Weak.cpp in Sources */,
 				14E84F9E14EE1ACC00D6D5D4 /* WeakBlock.cpp in Sources */,
 				14F7256514EE265E00B1652B /* WeakHandleOwner.cpp in Sources */,
+				A7CA3AEB17DA5168006538AF /* WeakMapBase.cpp in Sources */,
 				A7CA3AE317DA41AE006538AF /* WeakMapConstructor.cpp in Sources */,
-				A7CA3AEB17DA5168006538AF /* WeakMapData.cpp in Sources */,
 				A7CA3AE517DA41AE006538AF /* WeakMapPrototype.cpp in Sources */,
 				14E84FA014EE1ACC00D6D5D4 /* WeakSet.cpp in Sources */,
 				709FB8691AE335C60039D069 /* WeakSetConstructor.cpp in Sources */,

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -57,7 +57,7 @@
 #include "ScopedArguments.h"
 #include "SourceCode.h"
 #include "TypedArrayInlines.h"
-#include "WeakMapData.h"
+#include "WeakMapBase.h"
 
 using namespace JSC;
 
@@ -424,7 +424,7 @@
     if (!weakMap)
         return jsUndefined();
 
-    return jsNumber(weakMap->weakMapData()->size());
+    return jsNumber(weakMap->size());
 }
 
 JSValue JSInjectedScriptHost::weakMapEntries(ExecState* exec)
@@ -449,7 +449,7 @@
 
     JSArray* array = constructEmptyArray(exec, nullptr);
     RETURN_IF_EXCEPTION(scope, JSValue());
-    for (auto it = weakMap->weakMapData()->begin(); it != weakMap->weakMapData()->end(); ++it) {
+    for (auto it = weakMap->begin(); it != weakMap->end(); ++it) {
         JSObject* entry = constructEmptyObject(exec);
         entry->putDirect(exec->vm(), Identifier::fromString(exec, "key"), it->key);
         entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), it->value.get());
@@ -473,7 +473,7 @@
     if (!weakSet)
         return jsUndefined();
 
-    return jsNumber(weakSet->weakMapData()->size());
+    return jsNumber(weakSet->size());
 }
 
 JSValue JSInjectedScriptHost::weakSetEntries(ExecState* exec)
@@ -498,7 +498,7 @@
 
     JSArray* array = constructEmptyArray(exec, nullptr);
     RETURN_IF_EXCEPTION(scope, JSValue());
-    for (auto it = weakSet->weakMapData()->begin(); it != weakSet->weakMapData()->end(); ++it) {
+    for (auto it = weakSet->begin(); it != weakSet->end(); ++it) {
         JSObject* entry = constructEmptyObject(exec);
         entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), it->key);
         array->putDirectIndex(exec, fetched++, entry);

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakMap.cpp (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakMap.cpp	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakMap.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -27,25 +27,12 @@
 #include "JSWeakMap.h"
 
 #include "JSCInlines.h"
-#include "WeakMapData.h"
+#include "WeakMapBase.h"
 
 namespace JSC {
 
 const ClassInfo JSWeakMap::s_info = { "WeakMap", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWeakMap) };
 
-void JSWeakMap::finishCreation(VM& vm)
-{
-    Base::finishCreation(vm);
-    m_weakMapData.set(vm, this, WeakMapData::create(vm));
-}
-
-void JSWeakMap::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    Base::visitChildren(cell, visitor);
-    JSWeakMap* thisObj = jsCast<JSWeakMap*>(cell);
-    visitor.append(thisObj->m_weakMapData);
-}
-
 String JSWeakMap::toStringName(const JSObject*, ExecState*)
 {
     return ASCIILiteral("Object");

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakMap.h (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakMap.h	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakMap.h	2017-08-30 10:07:57 UTC (rev 221359)
@@ -26,14 +26,13 @@
 #pragma once
 
 #include "JSObject.h"
+#include "WeakMapBase.h"
 
 namespace JSC {
 
-class WeakMapData;
-
-class JSWeakMap : public JSNonFinalObject {
+class JSWeakMap final : public WeakMapBase {
 public:
-    typedef JSNonFinalObject Base;
+    using Base = WeakMapBase;
 
     DECLARE_EXPORT_INFO;
 
@@ -54,15 +53,6 @@
         return create(exec->vm(), structure);
     }
 
-    WeakMapData* weakMapData() { return m_weakMapData.get(); }
-
-    JSValue get(CallFrame*, JSObject*);
-    bool has(CallFrame*, JSObject*);
-    bool remove(CallFrame*, JSObject*);
-
-    void set(CallFrame*, JSObject*, JSValue);
-    void clear(CallFrame*);
-
 private:
     JSWeakMap(VM& vm, Structure* structure)
         : Base(vm, structure)
@@ -69,11 +59,7 @@
     {
     }
 
-    void finishCreation(VM&);
-    static void visitChildren(JSCell*, SlotVisitor&);
     static String toStringName(const JSObject*, ExecState*);
-
-    WriteBarrier<WeakMapData> m_weakMapData;
 };
 
 } // namespace JSC

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakSet.cpp (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakSet.cpp	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakSet.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -27,25 +27,12 @@
 #include "JSWeakSet.h"
 
 #include "JSCInlines.h"
-#include "WeakMapData.h"
+#include "WeakMapBase.h"
 
 namespace JSC {
 
 const ClassInfo JSWeakSet::s_info = { "WeakSet", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWeakSet) };
 
-void JSWeakSet::finishCreation(VM& vm)
-{
-    Base::finishCreation(vm);
-    m_weakMapData.set(vm, this, WeakMapData::create(vm));
-}
-
-void JSWeakSet::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    Base::visitChildren(cell, visitor);
-    JSWeakSet* thisObj = jsCast<JSWeakSet*>(cell);
-    visitor.append(thisObj->m_weakMapData);
-}
-
 String JSWeakSet::toStringName(const JSC::JSObject*, ExecState*)
 {
     return ASCIILiteral("Object");

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakSet.h (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakSet.h	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/JSWeakSet.h	2017-08-30 10:07:57 UTC (rev 221359)
@@ -26,14 +26,13 @@
 #pragma once
 
 #include "JSObject.h"
+#include "WeakMapBase.h"
 
 namespace JSC {
 
-class WeakMapData;
-
-class JSWeakSet : public JSNonFinalObject {
+class JSWeakSet final : public WeakMapBase {
 public:
-    typedef JSNonFinalObject Base;
+    using Base = WeakMapBase;
 
     DECLARE_EXPORT_INFO;
 
@@ -54,15 +53,6 @@
         return create(exec->vm(), structure);
     }
 
-    WeakMapData* weakMapData() { return m_weakMapData.get(); }
-
-    JSValue get(CallFrame*, JSObject*);
-    bool has(CallFrame*, JSObject*);
-    bool remove(CallFrame*, JSObject*);
-
-    void set(CallFrame*, JSObject*, JSValue);
-    void clear(CallFrame*);
-
 private:
     JSWeakSet(VM& vm, Structure* structure)
         : Base(vm, structure)
@@ -69,11 +59,7 @@
     {
     }
 
-    void finishCreation(VM&);
-    static void visitChildren(JSCell*, SlotVisitor&);
     static String toStringName(const JSObject*, ExecState*);
-
-    WriteBarrier<WeakMapData> m_weakMapData;
 };
 
 } // namespace JSC

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/VM.cpp (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/VM.cpp	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/VM.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -111,7 +111,6 @@
 #include "WasmWorklist.h"
 #include "Watchdog.h"
 #include "WeakGCMapInlines.h"
-#include "WeakMapData.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/ProcessID.h>
 #include <wtf/ReadWriteLock.h>
@@ -260,7 +259,6 @@
     unlinkedFunctionCodeBlockStructure.set(*this, UnlinkedFunctionCodeBlock::createStructure(*this, 0, jsNull()));
     unlinkedModuleProgramCodeBlockStructure.set(*this, UnlinkedModuleProgramCodeBlock::createStructure(*this, 0, jsNull()));
     propertyTableStructure.set(*this, PropertyTable::createStructure(*this, 0, jsNull()));
-    weakMapDataStructure.set(*this, WeakMapData::createStructure(*this, 0, jsNull()));
     inferredValueStructure.set(*this, InferredValue::createStructure(*this, 0, jsNull()));
     inferredTypeStructure.set(*this, InferredType::createStructure(*this, 0, jsNull()));
     inferredTypeTableStructure.set(*this, InferredTypeTable::createStructure(*this, 0, jsNull()));

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/VM.h (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/VM.h	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/VM.h	2017-08-30 10:07:57 UTC (rev 221359)
@@ -368,7 +368,6 @@
     Strong<Structure> unlinkedFunctionCodeBlockStructure;
     Strong<Structure> unlinkedModuleProgramCodeBlockStructure;
     Strong<Structure> propertyTableStructure;
-    Strong<Structure> weakMapDataStructure;
     Strong<Structure> inferredValueStructure;
     Strong<Structure> inferredTypeStructure;
     Strong<Structure> inferredTypeTableStructure;

Copied: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapBase.cpp (from rev 221357, releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.cpp) (0 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapBase.cpp	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapBase.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2013, 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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 "WeakMapBase.h"
+
+#include "ExceptionHelpers.h"
+#include "JSCInlines.h"
+
+#include <wtf/MathExtras.h>
+
+namespace JSC {
+
+const ClassInfo WeakMapBase::s_info = { "WeakMapBase", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(WeakMapBase) };
+
+WeakMapBase::WeakMapBase(VM& vm, Structure* structure)
+    : Base(vm, structure)
+{
+    ASSERT(m_deadKeyCleaner.target() == this);
+}
+
+void WeakMapBase::destroy(JSCell* cell)
+{
+    static_cast<WeakMapBase*>(cell)->~WeakMapBase();
+}
+
+size_t WeakMapBase::estimatedSize(JSCell* cell)
+{
+    auto* thisObj = jsCast<WeakMapBase*>(cell);
+    return Base::estimatedSize(cell) + (thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>)));
+}
+
+void WeakMapBase::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+    Base::visitChildren(cell, visitor);
+    auto* thisObj = jsCast<WeakMapBase*>(cell);
+    visitor.addUnconditionalFinalizer(&thisObj->m_deadKeyCleaner);
+    visitor.addWeakReferenceHarvester(&thisObj->m_deadKeyCleaner);
+
+    // Rough approximation of the external storage needed for the hashtable.
+    // This isn't exact, but it is close enough, and proportional to the actual
+    // external memory usage.
+    visitor.reportExtraMemoryVisited(thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>)));
+}
+
+void WeakMapBase::set(VM& vm, JSObject* key, JSValue value)
+{
+    // Here we force the write barrier on the key.
+    auto result = m_map.add(WriteBarrier<JSObject>(vm, this, key).get(), WriteBarrier<Unknown>());
+    result.iterator->value.set(vm, this, value);
+}
+
+JSValue WeakMapBase::get(JSObject* key)
+{
+    auto iter = m_map.find(key);
+    if (iter == m_map.end())
+        return jsUndefined();
+    return iter->value.get();
+}
+
+bool WeakMapBase::remove(JSObject* key)
+{
+    return m_map.remove(key);
+}
+
+bool WeakMapBase::contains(JSObject* key)
+{
+    return m_map.contains(key);
+}
+
+void WeakMapBase::clear()
+{
+    m_map.clear();
+}
+
+inline WeakMapBase* WeakMapBase::DeadKeyCleaner::target()
+{
+    return bitwise_cast<WeakMapBase*>(bitwise_cast<char*>(this) - OBJECT_OFFSETOF(WeakMapBase, m_deadKeyCleaner));
+}
+
+void WeakMapBase::DeadKeyCleaner::visitWeakReferences(SlotVisitor& visitor)
+{
+    WeakMapBase* map = target();
+    m_liveKeyCount = 0;
+    for (auto& pair : map->m_map) {
+        if (!Heap::isMarked(pair.key))
+            continue;
+        m_liveKeyCount++;
+        visitor.append(pair.value);
+    }
+    ASSERT(m_liveKeyCount <= map->m_map.size());
+}
+
+void WeakMapBase::DeadKeyCleaner::finalizeUnconditionally()
+{
+    WeakMapBase* map = target();
+    if (m_liveKeyCount > map->m_map.size() / 2) {
+        RELEASE_ASSERT(m_liveKeyCount <= map->m_map.size());
+        int deadCount = map->m_map.size() - m_liveKeyCount;
+        if (!deadCount)
+            return;
+        Vector<JSObject*> deadEntries;
+        deadEntries.reserveCapacity(deadCount);
+        for (auto& pair : map->m_map) {
+            if (Heap::isMarked(pair.key))
+                continue;
+            deadEntries.uncheckedAppend(pair.key);
+        }
+        for (auto& deadEntry : deadEntries)
+            map->m_map.remove(deadEntry);
+    } else {
+        MapType newMap;
+        for (auto& pair : map->m_map) {
+            if (!Heap::isMarked(pair.key))
+                continue;
+            newMap.add(pair.key, pair.value);
+        }
+        map->m_map.swap(newMap);
+    }
+}
+
+}

Copied: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapBase.h (from rev 221357, releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.h) (0 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapBase.h	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapBase.h	2017-08-30 10:07:57 UTC (rev 221359)
@@ -0,0 +1,73 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#pragma once
+
+#include "JSDestructibleObject.h"
+#include "Structure.h"
+#include <wtf/HashMap.h>
+#include <wtf/MathExtras.h>
+
+namespace JSC {
+
+class WeakMapBase : public JSDestructibleObject {
+public:
+    using Base = JSDestructibleObject;
+
+    void set(VM&, JSObject*, JSValue);
+    JSValue get(JSObject*);
+    bool remove(JSObject*);
+    bool contains(JSObject*);
+    void clear();
+
+    DECLARE_INFO;
+
+    using MapType = HashMap<JSObject*, WriteBarrier<Unknown>>;
+    MapType::const_iterator begin() const { return m_map.begin(); }
+    MapType::const_iterator end() const { return m_map.end(); }
+
+    unsigned size() const { return m_map.size(); }
+
+    static size_t estimatedSize(JSCell*);
+    static void visitChildren(JSCell*, SlotVisitor&);
+
+protected:
+    WeakMapBase(VM&, Structure*);
+    static void destroy(JSCell*);
+
+    class DeadKeyCleaner : public UnconditionalFinalizer, public WeakReferenceHarvester {
+    public:
+        WeakMapBase* target();
+
+    private:
+        void visitWeakReferences(SlotVisitor&) override;
+        void finalizeUnconditionally() override;
+        unsigned m_liveKeyCount;
+    };
+    DeadKeyCleaner m_deadKeyCleaner;
+    MapType m_map;
+};
+
+} // namespace JSC

Deleted: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.cpp (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.cpp	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2013, 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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 "WeakMapData.h"
-
-#include "ExceptionHelpers.h"
-#include "JSCInlines.h"
-
-#include <wtf/MathExtras.h>
-
-namespace JSC {
-
-const ClassInfo WeakMapData::s_info = { "WeakMapData", nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(WeakMapData) };
-
-WeakMapData::WeakMapData(VM& vm)
-    : Base(vm, vm.weakMapDataStructure.get())
-    , m_deadKeyCleaner(this)
-{
-}
-
-void WeakMapData::finishCreation(VM& vm)
-{
-    Base::finishCreation(vm);
-}
-
-void WeakMapData::destroy(JSCell* cell)
-{
-    static_cast<WeakMapData*>(cell)->~WeakMapData();
-}
-
-size_t WeakMapData::estimatedSize(JSCell* cell)
-{
-    WeakMapData* thisObj = jsCast<WeakMapData*>(cell);
-    return Base::estimatedSize(cell) + (thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>)));
-}
-
-void WeakMapData::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    Base::visitChildren(cell, visitor);
-    WeakMapData* thisObj = jsCast<WeakMapData*>(cell);
-    visitor.addUnconditionalFinalizer(&thisObj->m_deadKeyCleaner);
-    visitor.addWeakReferenceHarvester(&thisObj->m_deadKeyCleaner);
-
-    // Rough approximation of the external storage needed for the hashtable.
-    // This isn't exact, but it is close enough, and proportional to the actual
-    // external memory usage.
-    visitor.reportExtraMemoryVisited(thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>)));
-}
-
-void WeakMapData::set(VM& vm, JSObject* key, JSValue value)
-{
-    // Here we force the write barrier on the key.
-    auto result = m_map.add(WriteBarrier<JSObject>(vm, this, key).get(), WriteBarrier<Unknown>());
-    result.iterator->value.set(vm, this, value);
-}
-
-JSValue WeakMapData::get(JSObject* key)
-{
-    auto iter = m_map.find(key);
-    if (iter == m_map.end())
-        return jsUndefined();
-    return iter->value.get();
-}
-
-bool WeakMapData::remove(JSObject* key)
-{
-    auto iter = m_map.find(key);
-    if (iter == m_map.end())
-        return false;
-
-    m_map.remove(iter);
-    return true;
-}
-
-bool WeakMapData::contains(JSObject* key)
-{
-    return m_map.contains(key);
-}
-
-void WeakMapData::clear()
-{
-    m_map.clear();
-}
-
-void WeakMapData::DeadKeyCleaner::visitWeakReferences(SlotVisitor& visitor)
-{
-    m_liveKeyCount = 0;
-    for (auto& pair : m_target->m_map) {
-        if (!Heap::isMarked(pair.key))
-            continue;
-        m_liveKeyCount++;
-        visitor.append(pair.value);
-    }
-    RELEASE_ASSERT(m_liveKeyCount <= m_target->m_map.size());
-}
-
-void WeakMapData::DeadKeyCleaner::finalizeUnconditionally()
-{
-    if (m_liveKeyCount > m_target->m_map.size() / 2) {
-        RELEASE_ASSERT(m_liveKeyCount <= m_target->m_map.size());
-        int deadCount = m_target->m_map.size() - m_liveKeyCount;
-        if (!deadCount)
-            return;
-        Vector<JSObject*> deadEntries;
-        deadEntries.reserveCapacity(deadCount);
-        for (auto& pair : m_target->m_map) {
-            if (Heap::isMarked(pair.key))
-                continue;
-            deadEntries.uncheckedAppend(pair.key);
-        }
-        for (auto& deadEntry : deadEntries)
-            m_target->m_map.remove(deadEntry);
-    } else {
-        MapType newMap;
-        for (auto& pair : m_target->m_map) {
-            if (!Heap::isMarked(pair.key))
-                continue;
-            newMap.add(pair.key, pair.value);
-        }
-        m_target->m_map.swap(newMap);
-    }
-}
-
-}

Deleted: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.h (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.h	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapData.h	2017-08-30 10:07:57 UTC (rev 221359)
@@ -1,91 +0,0 @@
-/*
- * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
- */
-
-#pragma once
-
-#include "JSCell.h"
-#include "Structure.h"
-#include <wtf/HashMap.h>
-#include <wtf/MathExtras.h>
-
-namespace JSC {
-
-class WeakMapData final : public JSCell {
-public:
-    typedef JSCell Base;
-    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
-
-    static WeakMapData* create(VM& vm)
-    {
-        WeakMapData* weakMapData = new (NotNull, allocateCell<WeakMapData>(vm.heap)) WeakMapData(vm);
-        weakMapData->finishCreation(vm);
-        return weakMapData;
-    }
-
-    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-    {
-        return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info());
-    }
-
-    static const bool needsDestruction = true;
-
-    void set(VM&, JSObject*, JSValue);
-    JSValue get(JSObject*);
-    bool remove(JSObject*);
-    bool contains(JSObject*);
-    void clear();
-
-    DECLARE_INFO;
-
-    typedef HashMap<JSObject*, WriteBarrier<Unknown>> MapType;
-    MapType::const_iterator begin() const { return m_map.begin(); }
-    MapType::const_iterator end() const { return m_map.end(); }
-
-    int size() const { return m_map.size(); }
-
-private:
-    WeakMapData(VM&);
-    static void destroy(JSCell*);
-    static size_t estimatedSize(JSCell*);
-    static void visitChildren(JSCell*, SlotVisitor&);
-    void finishCreation(VM&);
-
-    class DeadKeyCleaner : public UnconditionalFinalizer, public WeakReferenceHarvester {
-    public:
-        DeadKeyCleaner(WeakMapData* target)
-            : m_target(target)
-        {
-        }
-    private:
-        void visitWeakReferences(SlotVisitor&) override;
-        void finalizeUnconditionally() override;
-        unsigned m_liveKeyCount;
-        WeakMapData* m_target;
-    };
-    DeadKeyCleaner m_deadKeyCleaner;
-    MapType m_map;
-};
-
-} // namespace JSC

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapPrototype.cpp (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapPrototype.cpp	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakMapPrototype.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -28,7 +28,7 @@
 
 #include "JSCInlines.h"
 #include "JSWeakMap.h"
-#include "WeakMapData.h"
+#include "WeakMapBase.h"
 
 namespace JSC {
 
@@ -53,7 +53,7 @@
     putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "WeakMap"), DontEnum | ReadOnly);
 }
 
-static WeakMapData* getWeakMapData(CallFrame* callFrame, JSValue value)
+static JSWeakMap* getWeakMap(CallFrame* callFrame, JSValue value)
 {
     VM& vm = callFrame->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
@@ -64,7 +64,7 @@
     }
 
     if (JSWeakMap* weakMap = jsDynamicCast<JSWeakMap*>(vm, value))
-        return weakMap->weakMapData();
+        return weakMap;
 
     throwTypeError(callFrame, scope, WTF::ASCIILiteral("Called WeakMap function on a non-WeakMap object"));
     return nullptr;
@@ -72,7 +72,7 @@
 
 EncodedJSValue JSC_HOST_CALL protoFuncWeakMapDelete(CallFrame* callFrame)
 {
-    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
+    auto* map = getWeakMap(callFrame, callFrame->thisValue());
     if (!map)
         return JSValue::encode(jsUndefined());
     JSValue key = callFrame->argument(0);
@@ -81,7 +81,7 @@
 
 EncodedJSValue JSC_HOST_CALL protoFuncWeakMapGet(CallFrame* callFrame)
 {
-    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
+    auto* map = getWeakMap(callFrame, callFrame->thisValue());
     if (!map)
         return JSValue::encode(jsUndefined());
     JSValue key = callFrame->argument(0);
@@ -92,7 +92,7 @@
 
 EncodedJSValue JSC_HOST_CALL protoFuncWeakMapHas(CallFrame* callFrame)
 {
-    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
+    auto* map = getWeakMap(callFrame, callFrame->thisValue());
     if (!map)
         return JSValue::encode(jsUndefined());
     JSValue key = callFrame->argument(0);
@@ -104,7 +104,7 @@
     VM& vm = callFrame->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
+    auto* map = getWeakMap(callFrame, callFrame->thisValue());
     ASSERT(!!scope.exception() == !map);
     if (!map)
         return JSValue::encode(jsUndefined());

Modified: releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakSetPrototype.cpp (221358 => 221359)


--- releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakSetPrototype.cpp	2017-08-30 09:51:45 UTC (rev 221358)
+++ releases/WebKitGTK/webkit-2.18/Source/_javascript_Core/runtime/WeakSetPrototype.cpp	2017-08-30 10:07:57 UTC (rev 221359)
@@ -28,7 +28,7 @@
 
 #include "JSCInlines.h"
 #include "JSWeakSet.h"
-#include "WeakMapData.h"
+#include "WeakMapBase.h"
 
 namespace JSC {
 
@@ -51,7 +51,7 @@
     putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "WeakSet"), DontEnum | ReadOnly);
 }
 
-static WeakMapData* getWeakMapData(CallFrame* callFrame, JSValue value)
+static JSWeakSet* getWeakSet(CallFrame* callFrame, JSValue value)
 {
     VM& vm = callFrame->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
@@ -62,7 +62,7 @@
     }
 
     if (JSWeakSet* weakSet = jsDynamicCast<JSWeakSet*>(vm, value))
-        return weakSet->weakMapData();
+        return weakSet;
 
     throwTypeError(callFrame, scope, WTF::ASCIILiteral("Called WeakSet function on a non-WeakSet object"));
     return nullptr;
@@ -70,20 +70,20 @@
 
 EncodedJSValue JSC_HOST_CALL protoFuncWeakSetDelete(CallFrame* callFrame)
 {
-    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
-    if (!map)
+    auto* set = getWeakSet(callFrame, callFrame->thisValue());
+    if (!set)
         return JSValue::encode(jsUndefined());
     JSValue key = callFrame->argument(0);
-    return JSValue::encode(jsBoolean(key.isObject() && map->remove(asObject(key))));
+    return JSValue::encode(jsBoolean(key.isObject() && set->remove(asObject(key))));
 }
 
 EncodedJSValue JSC_HOST_CALL protoFuncWeakSetHas(CallFrame* callFrame)
 {
-    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
-    if (!map)
+    auto* set = getWeakSet(callFrame, callFrame->thisValue());
+    if (!set)
         return JSValue::encode(jsUndefined());
     JSValue key = callFrame->argument(0);
-    return JSValue::encode(jsBoolean(key.isObject() && map->contains(asObject(key))));
+    return JSValue::encode(jsBoolean(key.isObject() && set->contains(asObject(key))));
 }
 
 EncodedJSValue JSC_HOST_CALL protoFuncWeakSetAdd(CallFrame* callFrame)
@@ -91,14 +91,14 @@
     VM& vm = callFrame->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    WeakMapData* map = getWeakMapData(callFrame, callFrame->thisValue());
-    ASSERT(!!scope.exception() == !map);
-    if (!map)
+    auto* set = getWeakSet(callFrame, callFrame->thisValue());
+    ASSERT(!!scope.exception() == !set);
+    if (!set)
         return JSValue::encode(jsUndefined());
     JSValue key = callFrame->argument(0);
     if (!key.isObject())
         return JSValue::encode(throwTypeError(callFrame, scope, WTF::ASCIILiteral("Attempted to add a non-object key to a WeakSet")));
-    map->set(vm, asObject(key), jsUndefined());
+    set->set(vm, asObject(key), jsUndefined());
     return JSValue::encode(callFrame->thisValue());
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to