Changeset 149834 in webkit


Ignore:
Timestamp:
May 9, 2013, 12:38:23 PM (12 years ago)
Author:
[email protected]
Message:

DFGArrayMode::fromObserved is too liberal when it sees different Array and NonArray shapes
https://bugs.webkit.org/show_bug.cgi?id=115805

Source/JavaScriptCore:

Reviewed by Geoffrey Garen.

It checks the observed ArrayModes to see if we have seen any ArrayWith* first. If so, it assumes it's
an Array::Array, even if we've also observed any NonArrayWith* in the ArrayProfile. This leads to the
code generated by jumpSlowForUnwantedArrayMode to check the indexing type against (shape | IsArray)
instead of just shape, which can cause us to exit a lot in the case that we saw a NonArray.

To fix this we need to add a case that checks for both ArrayWith* and NonArrayWith* cases first, which
should then use Array::PossiblyArray, then do the checks we were already doing.

  • bytecode/ArrayProfile.h:

(JSC::hasSeenArray):
(JSC::hasSeenNonArray):

  • dfg/DFGArrayMode.cpp:

(JSC::DFG::ArrayMode::fromObserved):

LayoutTests:

Added regression test for array access over polymorphic array vs. non-array indexing types.
With the fix, we get 3.666x faster on this microbenchmark.

Reviewed by Geoffrey Garen.

  • fast/js/regress/array-nonarray-polymorphic-access-expected.txt: Added.
  • fast/js/regress/array-nonarray-polymorphic-access.html: Added.
  • fast/js/regress/script-tests/array-nonarray-polymorphic-access.js: Added.

(f):
(run):

Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r149803 r149834  
     12013-05-08  Mark Hahnenberg  <[email protected]>
     2
     3        DFGArrayMode::fromObserved is too liberal when it sees different Array and NonArray shapes
     4        https://bugs.webkit.org/show_bug.cgi?id=115805
     5
     6        Added regression test for array access over polymorphic array vs. non-array indexing types.
     7        With the fix, we get 3.666x faster on this microbenchmark.
     8
     9        Reviewed by Geoffrey Garen.
     10
     11        * fast/js/regress/array-nonarray-polymorphic-access-expected.txt: Added.
     12        * fast/js/regress/array-nonarray-polymorphic-access.html: Added.
     13        * fast/js/regress/script-tests/array-nonarray-polymorphic-access.js: Added.
     14        (f):
     15        (run):
     16
     17<<<<<<< .mine
     182013-05-08  Mark Hahnenberg  <[email protected]>
     19
     20        DFGArrayMode::fromObserved is too liberal when it sees different Array and NonArray shapes
     21        https://bugs.webkit.org/show_bug.cgi?id=115805
     22
     23        Reviewed by Geoffrey Garen.
     24
     25        Added regression test for array access over polymorphic array vs. non-array indexing types.
     26        With the fix, we get 3.666x faster on this microbenchmark.
     27
     28        * fast/js/regress/array-nonarray-polymorphic-access-expected.txt: Added.
     29        * fast/js/regress/array-nonarray-polymorphic-access.html: Added.
     30        * fast/js/regress/script-tests/array-nonarray-polymorhpic-access.js: Added.
     31        (f):
     32        (run):
     33
     34=======
    1352013-05-09  Radu Stavila  <[email protected]>
    236
     
    97131        * platform/qt/fast/js/global-constructors-attributes-expected.txt: Added after r149758.
    98132
     133>>>>>>> .r149833
    991342013-05-08  Seokju Kwon  <[email protected]>
    100135
  • trunk/Source/JavaScriptCore/ChangeLog

    r149825 r149834  
     12013-05-08  Mark Hahnenberg  <[email protected]>
     2
     3        DFGArrayMode::fromObserved is too liberal when it sees different Array and NonArray shapes
     4        https://bugs.webkit.org/show_bug.cgi?id=115805
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        It checks the observed ArrayModes to see if we have seen any ArrayWith* first. If so, it assumes it's
     9        an Array::Array, even if we've also observed any NonArrayWith* in the ArrayProfile. This leads to the
     10        code generated by jumpSlowForUnwantedArrayMode to check the indexing type against (shape | IsArray)
     11        instead of just shape, which can cause us to exit a lot in the case that we saw a NonArray.
     12
     13        To fix this we need to add a case that checks for both ArrayWith* and NonArrayWith* cases first, which
     14        should then use Array::PossiblyArray, then do the checks we were already doing.
     15
     16        * bytecode/ArrayProfile.h:
     17        (JSC::hasSeenArray):
     18        (JSC::hasSeenNonArray):
     19        * dfg/DFGArrayMode.cpp:
     20        (JSC::DFG::ArrayMode::fromObserved):
     21
    1222013-05-09  Joe Mason  <[email protected]>
    223
  • trunk/Source/JavaScriptCore/bytecode/ArrayProfile.h

    r137937 r149834  
    116116}
    117117
     118inline bool hasSeenArray(ArrayModes arrayModes)
     119{
     120    return arrayModes & ALL_ARRAY_ARRAY_MODES;
     121}
     122
     123inline bool hasSeenNonArray(ArrayModes arrayModes)
     124{
     125    return arrayModes & ALL_NON_ARRAY_ARRAY_MODES;
     126}
     127
    118128class ArrayProfile {
    119129public:
  • trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp

    r146887 r149834  
    113113            type = Array::Undecided;
    114114       
    115         if (observed & (asArrayModes(ArrayWithUndecided) | asArrayModes(ArrayWithInt32) | asArrayModes(ArrayWithDouble) | asArrayModes(ArrayWithContiguous) | asArrayModes(ArrayWithArrayStorage) | asArrayModes(ArrayWithSlowPutArrayStorage)))
     115        if (hasSeenArray(observed) && hasSeenNonArray(observed))
     116            arrayClass = Array::PossiblyArray;
     117        else if (hasSeenArray(observed))
    116118            arrayClass = Array::Array;
    117         else if (observed & (asArrayModes(NonArray) | asArrayModes(NonArrayWithInt32) | asArrayModes(NonArrayWithDouble) | asArrayModes(NonArrayWithContiguous) | asArrayModes(NonArrayWithArrayStorage) | asArrayModes(NonArrayWithSlowPutArrayStorage)))
     119        else if (hasSeenNonArray(observed))
    118120            arrayClass = Array::NonArray;
    119121        else
Note: See TracChangeset for help on using the changeset viewer.