Bug 186724 - [DFG] DFG fixup checkArray typically considers only one Structure
Summary: [DFG] DFG fixup checkArray typically considers only one Structure
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on: 186193
  Show dependency treegraph
Reported: 2018-06-16 11:26 PDT by Yusuke Suzuki
Modified: 2018-06-19 08:27 PDT (History)
5 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2018-06-16 11:26:34 PDT
The simple example is below.

function test()
    var array = [0, 1, 2, 3];
    for (var i = 0; i < 4; ++i) {
        array[0] = array[0] + 1;
    return array;

for (var i = 0; i < 1e6; ++i)

Our ArrayProfile takes only one array. So typically, `array[0]` op_put_by_val says "Yeah, the array seems ArrayWithInt32".
But actually, this should see both `CopyOnWriteArrayWithInt32` and `ArrayWithInt32`.
The above example first emit CheckStructure for ArrayWithInt32. Then it fails repeatedly, and the op_put_by_val emits

PutByVal(Check:Untyped:@26, Check:Untyped:@29, Check:Untyped:Kill:@47, MustGen|VarArgs, Generic+OriginalNonArray+OutOfBounds+AsIs+Write, R:World, W:Heap, Exits, ClobbersExit, bc#37, ExitValid)

It is bad. Ideally, we should emit ArrayifyToStructure for ArrayWithInt32 first.
Comment 1 Yusuke Suzuki 2018-06-16 11:27:22 PDT
I think this is the reason why Kraken crypto-aes and crypto-ccm cause regression right now.
Comment 2 Yusuke Suzuki 2018-06-16 11:37:57 PDT
Keith, Saam do you have any idea to fix this?
One way fixing this is https://bugs.webkit.org/show_bug.cgi?id=186193.
Comment 3 Keith Miller 2018-06-19 08:27:36 PDT
I think the simplest solution to this have ArrayProfile track if it has seen a CoW array. Then, if fixup sees original and maybe copy on write can can do an arrayify to structure. Thoughts?