Changeset 183128 in webkit


Ignore:
Timestamp:
Apr 22, 2015 1:44:32 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

SparseArrayEntry's write barrier owner should be the SparseArrayValueMap.
https://bugs.webkit.org/show_bug.cgi?id=144067

Reviewed by Michael Saboff.

Currently, there are a few places where the JSObject that owns the
SparseArrayValueMap is designated as the owner of the SparseArrayEntry
write barrier. This is a bug and can result in the GC collecting the
SparseArrayEntry even though it is being referenced by the
SparseArrayValueMap. This patch fixes the bug.

  • runtime/JSObject.cpp:

(JSC::JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists):
(JSC::JSObject::putIndexedDescriptor):

  • tests/stress/sparse-array-entry-update-144067.js: Added.

(useMemoryToTriggerGCs):
(foo):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r183124 r183128  
     12015-04-22  Mark Lam  <mark.lam@apple.com>
     2
     3        SparseArrayEntry's write barrier owner should be the SparseArrayValueMap.
     4        https://bugs.webkit.org/show_bug.cgi?id=144067
     5
     6        Reviewed by Michael Saboff.
     7
     8        Currently, there are a few places where the JSObject that owns the
     9        SparseArrayValueMap is designated as the owner of the SparseArrayEntry
     10        write barrier.  This is a bug and can result in the GC collecting the
     11        SparseArrayEntry even though it is being referenced by the
     12        SparseArrayValueMap.  This patch fixes the bug.
     13
     14        * runtime/JSObject.cpp:
     15        (JSC::JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists):
     16        (JSC::JSObject::putIndexedDescriptor):
     17        * tests/stress/sparse-array-entry-update-144067.js: Added.
     18        (useMemoryToTriggerGCs):
     19        (foo):
     20
    1212015-04-22  Mark Lam  <mark.lam@apple.com>
    222
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r182406 r183128  
    585585        // and attributes are default so no need to set them.
    586586        if (value)
    587             map->add(this, i).iterator->value.set(vm, this, value);
     587            map->add(this, i).iterator->value.set(vm, map, value);
    588588    }
    589589
     
    17181718{
    17191719    VM& vm = exec->vm();
     1720    auto map = m_butterfly->arrayStorage()->m_sparseMap.get();
    17201721
    17211722    if (descriptor.isDataDescriptor()) {
    17221723        if (descriptor.value())
    1723             entryInMap->set(vm, this, descriptor.value());
     1724            entryInMap->set(vm, map, descriptor.value());
    17241725        else if (oldDescriptor.isAccessorDescriptor())
    1725             entryInMap->set(vm, this, jsUndefined());
     1726            entryInMap->set(vm, map, jsUndefined());
    17261727        entryInMap->attributes = descriptor.attributesOverridingCurrent(oldDescriptor) & ~Accessor;
    17271728        return;
     
    17461747            accessor->setSetter(vm, exec->lexicalGlobalObject(), setter);
    17471748
    1748         entryInMap->set(vm, this, accessor);
     1749        entryInMap->set(vm, map, accessor);
    17491750        entryInMap->attributes = descriptor.attributesOverridingCurrent(oldDescriptor) & ~ReadOnly;
    17501751        return;
Note: See TracChangeset for help on using the changeset viewer.