Changeset 203033 in webkit


Ignore:
Timestamp:
Jul 9, 2016, 1:50:51 PM (9 years ago)
Author:
keith_miller@apple.com
Message:

appendMemcpy might fail in concatAppendOne
https://bugs.webkit.org/show_bug.cgi?id=159601
Source/JavaScriptCore:

<rdar://problem/27211300>

Reviewed by Mark Lam.

There are multiple reasons why we might fail appendMemcpy. One
reason, which I suspect was the source of the crashes, is that one
of the Array prototypes has an indexed property. This patch
consolidates the two old cases by just creating an array then
attempting to memcpy append. If that fails, we fall back to
moveElements.

  • runtime/ArrayPrototype.cpp:

(JSC::concatAppendOne):

  • tests/stress/concat-with-holesMustForwardToPrototype.js: Added.

(arrayEq):

LayoutTests:

Reviewed by Mark Lam.

Add new microbenchmark testing the performance of concat
when appending one new element. This patch appears to be
about a 13% progression on this test.

  • js/regress/concat-append-one-expected.txt: Added.
  • js/regress/concat-append-one.html: Added.
  • js/regress/script-tests/concat-append-one.js: Added.

(test):

Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203029 r203033  
     12016-07-09  Keith Miller  <keith_miller@apple.com>
     2
     3        appendMemcpy might fail in concatAppendOne
     4        https://bugs.webkit.org/show_bug.cgi?id=159601
     5
     6        Reviewed by Mark Lam.
     7
     8        Add new microbenchmark testing the performance of concat
     9        when appending one new element. This patch appears to be
     10        about a 13% progression on this test.
     11
     12        * js/regress/concat-append-one-expected.txt: Added.
     13        * js/regress/concat-append-one.html: Added.
     14        * js/regress/script-tests/concat-append-one.js: Added.
     15        (test):
     16
    1172016-07-09  Youenn Fablet  <youenn@apple.com>
    218
  • trunk/Source/JavaScriptCore/ChangeLog

    r203028 r203033  
     12016-07-09  Keith Miller  <keith_miller@apple.com>
     2
     3        appendMemcpy might fail in concatAppendOne
     4        https://bugs.webkit.org/show_bug.cgi?id=159601
     5        <rdar://problem/27211300>
     6
     7        Reviewed by Mark Lam.
     8
     9        There are multiple reasons why we might fail appendMemcpy. One
     10        reason, which I suspect was the source of the crashes, is that one
     11        of the Array prototypes has an indexed property. This patch
     12        consolidates the two old cases by just creating an array then
     13        attempting to memcpy append. If that fails, we fall back to
     14        moveElements.
     15
     16        * runtime/ArrayPrototype.cpp:
     17        (JSC::concatAppendOne):
     18        * tests/stress/concat-with-holesMustForwardToPrototype.js: Added.
     19        (arrayEq):
     20
    1212016-07-09  Benjamin Poulain  <bpoulain@apple.com>
    222
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r202943 r203033  
    10481048
    10491049    IndexingType type = first->mergeIndexingTypeForCopying(indexingTypeForValue(second) | IsArray);
    1050     JSArray* result;
    1051     if (type == NonArray) {
    1052         result = constructEmptyArray(exec, nullptr, firstArraySize + 1);
    1053         if (vm.exception())
    1054             return JSValue::encode(JSValue());
    1055 
     1050    if (type == NonArray)
     1051        type = ArrayWithUndecided;
     1052
     1053    Structure* resultStructure = exec->lexicalGlobalObject()->arrayStructureForIndexingTypeDuringAllocation(type);
     1054    JSArray* result = JSArray::create(vm, resultStructure, firstArraySize + 1);
     1055    if (!result)
     1056        return JSValue::encode(throwOutOfMemoryError(exec));
     1057
     1058    if (!result->appendMemcpy(exec, vm, 0, first)) {
    10561059        if (!moveElements(exec, vm, result, 0, first, firstArraySize)) {
    10571060            ASSERT(vm.exception());
    10581061            return JSValue::encode(JSValue());
    10591062        }
    1060 
    1061     } else {
    1062         Structure* resultStructure = exec->lexicalGlobalObject()->arrayStructureForIndexingTypeDuringAllocation(type);
    1063         result = JSArray::tryCreateUninitialized(vm, resultStructure, firstArraySize + 1);
    1064         if (!result)
    1065             return JSValue::encode(throwOutOfMemoryError(exec));
    1066 
    1067         bool memcpyResult = result->appendMemcpy(exec, vm, 0, first);
    1068         RELEASE_ASSERT(memcpyResult);
    10691063    }
    10701064
Note: See TracChangeset for help on using the changeset viewer.