<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>186724</bug_id>
          
          <creation_ts>2018-06-16 11:26:34 -0700</creation_ts>
          <short_desc>[DFG] DFG fixup checkArray typically considers only one Structure</short_desc>
          <delta_ts>2018-06-19 08:27:36 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>186193</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yusuke Suzuki">ysuzuki</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>saam</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1433744</commentid>
    <comment_count>0</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-06-16 11:26:34 -0700</bug_when>
    <thetext>The simple example is below.

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

for (var i = 0; i &lt; 1e6; ++i)
    test();


Our ArrayProfile takes only one array. So typically, `array[0]` op_put_by_val says &quot;Yeah, the array seems ArrayWithInt32&quot;.
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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433745</commentid>
    <comment_count>1</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-06-16 11:27:22 -0700</bug_when>
    <thetext>I think this is the reason why Kraken crypto-aes and crypto-ccm cause regression right now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433750</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-06-16 11:37:57 -0700</bug_when>
    <thetext>Keith, Saam do you have any idea to fix this?
One way fixing this is https://bugs.webkit.org/show_bug.cgi?id=186193.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434394</commentid>
    <comment_count>3</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2018-06-19 08:27:36 -0700</bug_when>
    <thetext>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?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>