RESOLVED FIXED Bug 120912
Support WeakMap
https://bugs.webkit.org/show_bug.cgi?id=120912
Summary Support WeakMap
Oliver Hunt
Reported 2013-09-06 17:02:22 PDT
Support WeakMap
Attachments
Patch (76.90 KB, patch)
2013-09-06 17:02 PDT, Oliver Hunt
no flags
Patch (51.21 KB, patch)
2013-09-09 15:41 PDT, Oliver Hunt
no flags
Patch (51.24 KB, patch)
2013-09-09 16:16 PDT, Oliver Hunt
no flags
Patch (58.42 KB, patch)
2013-09-10 13:40 PDT, Oliver Hunt
ggaren: review+
Oliver Hunt
Comment 1 2013-09-06 17:02:35 PDT
WebKit Commit Bot
Comment 2 2013-09-06 17:05:20 PDT
Attachment 210818 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj', u'Source/JavaScriptCore/heap/WeakImpl.h', u'Source/JavaScriptCore/heap/WeakInlines.h', u'Source/JavaScriptCore/runtime/CommonIdentifiers.h', u'Source/JavaScriptCore/runtime/JSGlobalObject.cpp', u'Source/JavaScriptCore/runtime/JSGlobalObject.h', u'Source/JavaScriptCore/runtime/JSWeakMap.cpp', u'Source/JavaScriptCore/runtime/JSWeakMap.h', u'Source/JavaScriptCore/runtime/WeakMapConstructor.cpp', u'Source/JavaScriptCore/runtime/WeakMapConstructor.h', u'Source/JavaScriptCore/runtime/WeakMapData.cpp', u'Source/JavaScriptCore/runtime/WeakMapData.h', u'Source/JavaScriptCore/runtime/WeakMapPrototype.cpp', u'Source/JavaScriptCore/runtime/WeakMapPrototype.h', u'Source/JavaScriptCore/tests/mozilla/actual.html']" exit_code: 1 Source/JavaScriptCore/runtime/WeakMapData.cpp:57: Code inside a namespace should not be indented. [whitespace/indent] [4] Source/JavaScriptCore/runtime/WeakMapData.cpp:59: Missing spaces around >> [whitespace/operators] [3] Source/JavaScriptCore/runtime/WeakMapData.cpp:69: Missing spaces around >> [whitespace/operators] [3] Source/JavaScriptCore/runtime/WeakMapData.cpp:77: Missing spaces around >> [whitespace/operators] [3] Source/JavaScriptCore/runtime/WeakMapData.cpp:87: Missing spaces around >> [whitespace/operators] [3] Source/JavaScriptCore/runtime/WeakMapData.cpp:96: Could not find a newline character at the end of the file. [whitespace/ending_newline] [5] Source/JavaScriptCore/runtime/WeakMapConstructor.cpp:64: Could not find a newline character at the end of the file. [whitespace/ending_newline] [5] Total errors found: 7 in 16 files If any of these errors are false positives, please file a bug against check-webkit-style.
Early Warning System Bot
Comment 3 2013-09-06 17:09:50 PDT
Early Warning System Bot
Comment 4 2013-09-06 17:11:37 PDT
Build Bot
Comment 5 2013-09-06 18:37:15 PDT
Build Bot
Comment 6 2013-09-06 19:17:44 PDT
Build Bot
Comment 7 2013-09-06 19:38:49 PDT
EFL EWS Bot
Comment 8 2013-09-06 19:41:41 PDT
EFL EWS Bot
Comment 9 2013-09-06 19:50:42 PDT
kov's GTK+ EWS bot
Comment 10 2013-09-06 20:20:28 PDT
Sam Weinig
Comment 11 2013-09-07 08:38:44 PDT
Comment on attachment 210818 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=210818&action=review > Source/JavaScriptCore/runtime/JSGlobalObject.h:204 > WriteBarrier<Structure> m_mapDataStructure; > + WriteBarrier<Structure> m_weakMapDataStructure; Does the WeakMapData object's structure need to be per-global object if it is not expose (e.g. can it be per-vm)? Same question for MapData's structure?
Oliver Hunt
Comment 12 2013-09-07 12:08:55 PDT
(In reply to comment #11) > (From update of attachment 210818 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=210818&action=review > > > Source/JavaScriptCore/runtime/JSGlobalObject.h:204 > > WriteBarrier<Structure> m_mapDataStructure; > > + WriteBarrier<Structure> m_weakMapDataStructure; > > Does the WeakMapData object's structure need to be per-global object if it is not expose (e.g. can it be per-vm)? Same question for MapData's structure? Not strictly but the destructible object is an Object and thus requires a global object :-/ I'm still working on WeakMap so was using this to move the patch around -- it's currently hideously ugly, leaks like a sieve, etc, etc :-/
Oliver Hunt
Comment 13 2013-09-09 15:41:17 PDT
Build Bot
Comment 14 2013-09-09 15:59:34 PDT
Early Warning System Bot
Comment 15 2013-09-09 16:02:06 PDT
Early Warning System Bot
Comment 16 2013-09-09 16:08:46 PDT
Oliver Hunt
Comment 17 2013-09-09 16:16:46 PDT
Sam Weinig
Comment 18 2013-09-10 03:30:46 PDT
Comment on attachment 211112 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=211112&action=review > Source/JavaScriptCore/runtime/JSWeakMap.h:35 > +class JSWeakMap : public JSObject { Most of these instance classes are derived from JSNonFinalObjects.
Oliver Hunt
Comment 19 2013-09-10 13:40:14 PDT
Geoffrey Garen
Comment 20 2013-09-10 13:58:08 PDT
Comment on attachment 211234 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=211234&action=review r=me > Source/JavaScriptCore/ChangeLog:25 > + (JSC::JSGlobalObject::reset): > + (JSC::JSGlobalObject::visitChildren): I don't like empty function lists like this :(. > Source/JavaScriptCore/runtime/WeakMapConstructor.cpp:46 > +static EncodedJSValue JSC_HOST_CALL constructWeakMapConstructor(ExecState* exec) Let's call this "constructWeakMap". > Source/JavaScriptCore/runtime/WeakMapData.cpp:44 > + , m_gcCleaner(this) Let's call this "m_deadKeyCleaner". > Source/JavaScriptCore/runtime/WeakMapData.cpp:66 > + // This sin't exact, but it is close enough, and proportional to the actual Should be "isn't". > Source/JavaScriptCore/runtime/WeakMapData.cpp:79 > + auto iter = m_map.find(key); > + if (iter != m_map.end()) { > + iter->value.set(callFrame->vm(), this, value); > + return; > + } > + // Here we force the write barrier on the key. > + m_map.add(WriteBarrier<JSObject>(callFrame->vm(), this, key).get(), WriteBarrier<Unknown>(callFrame->vm(), this, value)); I think it would be better to use the "add 0" idiom here: auto result = m_map.add(WriteBarrier<JSObject>(callFrame->vm(), this, key).get(), WriteBarrier<Unknown>(callFrame->vm(), this, value)); if (!result.isNewEntry) result.iterator->value = value; This avoids a second hash table lookup in the case where we add a new entry to the table. > Source/JavaScriptCore/runtime/WeakMapData.cpp:113 > + for (auto ptr = m_target->m_map.begin(), end = m_target->m_map.end(); ptr != end; ++ptr) { I think we usually use "it" for iterators. > Source/JavaScriptCore/runtime/WeakMapData.cpp:131 > + for (auto ptr = m_target->m_map.begin(), end = m_target->m_map.end(); ptr != end; ++ptr) { Ditto. > Source/JavaScriptCore/runtime/WeakMapData.cpp:140 > + for (auto ptr = m_target->m_map.begin(), end = m_target->m_map.end(); ptr != end; ++ptr) { Ditto.
Geoffrey Garen
Comment 21 2013-09-10 14:00:10 PDT
> I think it would be better to use the "add 0" idiom here: > > auto result = m_map.add(WriteBarrier<JSObject>(callFrame->vm(), this, key).get(), WriteBarrier<Unknown>(callFrame->vm(), this, value)); > if (!result.isNewEntry) > result.iterator->value = value; I meant: auto result = m_map.add(WriteBarrier<JSObject>(callFrame->vm(), this, key).get(), WriteBarrier<Unknown>());
Oliver Hunt
Comment 22 2013-09-10 14:15:47 PDT
Note You need to log in before you can comment on or make changes to this bug.