WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
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
Details
Formatted Diff
Diff
Patch
(51.21 KB, patch)
2013-09-09 15:41 PDT
,
Oliver Hunt
no flags
Details
Formatted Diff
Diff
Patch
(51.24 KB, patch)
2013-09-09 16:16 PDT
,
Oliver Hunt
no flags
Details
Formatted Diff
Diff
Patch
(58.42 KB, patch)
2013-09-10 13:40 PDT
,
Oliver Hunt
ggaren
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Oliver Hunt
Comment 1
2013-09-06 17:02:35 PDT
Created
attachment 210818
[details]
Patch
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
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass qt-ews (qt): Output:
http://webkit-queues.appspot.com/results/1718207
Early Warning System Bot
Comment 4
2013-09-06 17:11:37 PDT
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass qt-wk2-ews (qt-wk2): Output:
http://webkit-queues.appspot.com/results/1705578
Build Bot
Comment 5
2013-09-06 18:37:15 PDT
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/1704539
Build Bot
Comment 6
2013-09-06 19:17:44 PDT
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/1708553
Build Bot
Comment 7
2013-09-06 19:38:49 PDT
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass win-ews (win): Output:
http://webkit-queues.appspot.com/results/1707594
EFL EWS Bot
Comment 8
2013-09-06 19:41:41 PDT
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass efl-wk2-ews (efl-wk2): Output:
http://webkit-queues.appspot.com/results/1709541
EFL EWS Bot
Comment 9
2013-09-06 19:50:42 PDT
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass efl-ews (efl): Output:
http://webkit-queues.appspot.com/results/1718242
kov's GTK+ EWS bot
Comment 10
2013-09-06 20:20:28 PDT
Comment on
attachment 210818
[details]
Patch
Attachment 210818
[details]
did not pass gtk-ews (gtk): Output:
http://webkit-queues.appspot.com/results/1704565
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
Created
attachment 211107
[details]
Patch
Build Bot
Comment 14
2013-09-09 15:59:34 PDT
Comment on
attachment 211107
[details]
Patch
Attachment 211107
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/1736433
Early Warning System Bot
Comment 15
2013-09-09 16:02:06 PDT
Comment on
attachment 211107
[details]
Patch
Attachment 211107
[details]
did not pass qt-ews (qt): Output:
http://webkit-queues.appspot.com/results/1726714
Early Warning System Bot
Comment 16
2013-09-09 16:08:46 PDT
Comment on
attachment 211107
[details]
Patch
Attachment 211107
[details]
did not pass qt-wk2-ews (qt-wk2): Output:
http://webkit-queues.appspot.com/results/1734446
Oliver Hunt
Comment 17
2013-09-09 16:16:46 PDT
Created
attachment 211112
[details]
Patch
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
Created
attachment 211234
[details]
Patch
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
Committed
r155473
: <
http://trac.webkit.org/changeset/155473
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug