⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245813 in webkit


Ignore:
Timestamp:
May 28, 2019, 9:03:02 AM (7 years ago)
Author:
Tadeu Zagallo
Message:

JITOperations putByVal should mark negative array indices as out-of-bounds
​https://bugs.webkit.org/show_bug.cgi?id=198271

Reviewed by Saam Barati.

JSTests:

  • microbenchmarks/get-by-val-negative-array-index.js:

(foo):
Update the getByVal microbenchmark added in r245769. This now shows that r245769
is 4.2x faster than the previous commit.

  • microbenchmarks/put-by-val-negative-array-index.js: Added.

(foo):

Source/JavaScriptCore:

Similar to what was done to getByVal in r245769, we should also mark put_by_val as out-of-bounds
when we exit from DFG for putting to a negative index. This avoids the same scenario where we keep
recompiling a CodeBlock with DFG and exiting at the same bytecode.

This is a 3.7x improvement in the microbenchmark being added: put-by-val-negative-array-index.js.

  • jit/JITOperations.cpp:
Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r245769 r245813  
     12019-05-28  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        JITOperations putByVal should mark negative array indices as out-of-bounds
     4        https://bugs.webkit.org/show_bug.cgi?id=198271
     5
     6        Reviewed by Saam Barati.
     7
     8        * microbenchmarks/get-by-val-negative-array-index.js:
     9        (foo):
     10        Update the getByVal microbenchmark added in r245769. This now shows that r245769
     11        is 4.2x faster than the previous commit.
     12
     13        * microbenchmarks/put-by-val-negative-array-index.js: Added.
     14        (foo):
     15
    1162019-05-25  Tadeu Zagallo  <tzagallo@apple.com>
    217
  • trunk/JSTests/microbenchmarks/get-by-val-negative-array-index.js

    r245769 r245813  
    11function foo(arr, index) {
     2    for (let i = 0; i < 1e2; i++) {
     3        let x = {};
     4        x.x = arr;
     5    }
     6
    27    return arr[index];
    38}
    49noInline(foo);
    510
    6 const arr = new Array(1000).fill({});
    7 for (let i = 0; i < 1e7; i++) {
     11const arr = new Array(10).fill({});
     12for (let i = 0; i < 1e6; i++) {
    813    foo(arr, i % arr.length);
    9     if (!(i % 1e3))
     14}
     15for (let i = 0; i < 1e6; i++) {
     16    foo(arr, i % arr.length);
     17    if (!(i % arr.length))
    1018        foo(arr, -1);
    1119}
  • trunk/Source/JavaScriptCore/ChangeLog

    r245808 r245813  
     12019-05-28  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        JITOperations putByVal should mark negative array indices as out-of-bounds
     4        https://bugs.webkit.org/show_bug.cgi?id=198271
     5
     6        Reviewed by Saam Barati.
     7
     8        Similar to what was done to getByVal in r245769, we should also mark put_by_val as out-of-bounds
     9        when we exit from DFG for putting to a negative index. This avoids the same scenario where we keep
     10        recompiling a CodeBlock with DFG and exiting at the same bytecode.
     11
     12        This is a 3.7x improvement in the microbenchmark being added: put-by-val-negative-array-index.js.
     13
     14        * jit/JITOperations.cpp:
     15
    1162019-05-28  Yusuke Suzuki  <ysuzuki@apple.com>
    217
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r245769 r245813  
    654654        baseValue.putByIndex(callFrame, i, value, callFrame->codeBlock()->isStrictMode());
    655655        return;
     656    } else if (subscript.isInt32()) {
     657        byValInfo->tookSlowPath = true;
     658        if (baseValue.isObject())
     659            byValInfo->arrayProfile->setOutOfBounds();
    656660    }
    657661
Note: See TracChangeset for help on using the changeset viewer.