[webkit-reviews] review granted: [Bug 120912] Support WeakMap : [Attachment 211234] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Sep 10 13:58:54 PDT 2013


Geoffrey Garen <ggaren at apple.com> has granted Oliver Hunt <oliver at apple.com>'s
request for review:
Bug 120912: Support WeakMap
https://bugs.webkit.org/show_bug.cgi?id=120912

Attachment 211234: Patch
https://bugs.webkit.org/attachment.cgi?id=211234&action=review

------- Additional Comments from Geoffrey Garen <ggaren at apple.com>
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.


More information about the webkit-reviews mailing list