Changeset 175249 in webkit


Ignore:
Timestamp:
Oct 28, 2014 8:29:51 AM (9 years ago)
Author:
mark.lam@apple.com
Message:

Holes are not copied properly when Arrays change shape to ArrayStorage type.
<https://webkit.org/b/138118>

Reviewed by Mark Hahnenberg.

When we convert non-ArrayStorage typed arrays into ArrayStorage typed arrays,
we skipped the holes. As a result, the slots in the ArrayStorage vector that
corresponds to those holes are uninitialize. This is now fixed.

  • runtime/JSObject.cpp:

(JSC::JSObject::convertUndecidedToArrayStorage):
(JSC::JSObject::convertInt32ToArrayStorage):
(JSC::JSObject::convertDoubleToArrayStorage):
(JSC::JSObject::convertContiguousToArrayStorage):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r175243 r175249  
     12014-10-27  Mark Lam  <mark.lam@apple.com>
     2
     3        Holes are not copied properly when Arrays change shape to ArrayStorage type.
     4        <https://webkit.org/b/138118>
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        When we convert non-ArrayStorage typed arrays into ArrayStorage typed arrays,
     9        we skipped the holes.  As a result, the slots in the ArrayStorage vector that
     10        corresponds to those holes are uninitialize.  This is now fixed.
     11
     12        * runtime/JSObject.cpp:
     13        (JSC::JSObject::convertUndecidedToArrayStorage):
     14        (JSC::JSObject::convertInt32ToArrayStorage):
     15        (JSC::JSObject::convertDoubleToArrayStorage):
     16        (JSC::JSObject::convertContiguousToArrayStorage):
     17
    1182014-10-27  Mark Lam  <mark.lam@apple.com>
    219
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r175240 r175249  
    733733    ArrayStorage* storage = constructConvertedArrayStorageWithoutCopyingElements(vm, vectorLength);
    734734    // No need to copy elements.
     735    ASSERT(!m_butterfly->publicLength());
    735736   
    736737    Structure* newStructure = Structure::nonPropertyTransition(vm, structure(vm), transition);
     
    779780    unsigned vectorLength = m_butterfly->vectorLength();
    780781    ArrayStorage* newStorage = constructConvertedArrayStorageWithoutCopyingElements(vm, vectorLength);
    781     for (unsigned i = m_butterfly->publicLength(); i--;) {
     782    for (unsigned i = 0; i < m_butterfly->publicLength(); i++) {
    782783        JSValue v = m_butterfly->contiguous()[i].get();
    783         if (!v)
    784             continue;
    785         newStorage->m_vector[i].setWithoutWriteBarrier(v);
    786         newStorage->m_numValuesInVector++;
     784        if (v) {
     785            newStorage->m_vector[i].setWithoutWriteBarrier(v);
     786            newStorage->m_numValuesInVector++;
     787        } else
     788            newStorage->m_vector[i].clear();
    787789    }
    788790   
     
    848850    unsigned vectorLength = m_butterfly->vectorLength();
    849851    ArrayStorage* newStorage = constructConvertedArrayStorageWithoutCopyingElements(vm, vectorLength);
    850     for (unsigned i = m_butterfly->publicLength(); i--;) {
     852    for (unsigned i = 0; i < m_butterfly->publicLength(); i++) {
    851853        double value = m_butterfly->contiguousDouble()[i];
    852         if (value != value)
    853             continue;
    854         newStorage->m_vector[i].setWithoutWriteBarrier(JSValue(JSValue::EncodeAsDouble, value));
    855         newStorage->m_numValuesInVector++;
     854        if (value == value) {
     855            newStorage->m_vector[i].setWithoutWriteBarrier(JSValue(JSValue::EncodeAsDouble, value));
     856            newStorage->m_numValuesInVector++;
     857        } else
     858            newStorage->m_vector[i].clear();
    856859    }
    857860   
     
    873876    unsigned vectorLength = m_butterfly->vectorLength();
    874877    ArrayStorage* newStorage = constructConvertedArrayStorageWithoutCopyingElements(vm, vectorLength);
    875     for (unsigned i = m_butterfly->publicLength(); i--;) {
     878    for (unsigned i = 0; i < m_butterfly->publicLength(); i++) {
    876879        JSValue v = m_butterfly->contiguous()[i].get();
    877         if (!v)
    878             continue;
    879         newStorage->m_vector[i].setWithoutWriteBarrier(v);
    880         newStorage->m_numValuesInVector++;
     880        if (v) {
     881            newStorage->m_vector[i].setWithoutWriteBarrier(v);
     882            newStorage->m_numValuesInVector++;
     883        } else
     884            newStorage->m_vector[i].clear();
    881885    }
    882886   
Note: See TracChangeset for help on using the changeset viewer.