<?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>158438</bug_id>
          
          <creation_ts>2016-06-06 15:31:29 -0700</creation_ts>
          <short_desc>EXITs when using spread operator with mixed type array</short_desc>
          <delta_ts>2016-06-06 15:31:29 -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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>saam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1199733</commentid>
    <comment_count>0</comment_count>
      <attachid>280637</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2016-06-06 15:31:29 -0700</bug_when>
    <thetext>Created attachment 280637
[TEST] Test case

* SUMMARY
EXITs when using spread operator with mixed type array.

* TEST
(function() {
    function myLog() {
        var args = Array.from(arguments);
        print(args.join(&quot; &quot;));
    }
    function myAssert(condition, ...args) {
        &quot;use strict&quot;;
        if (!condition)
            myLog(...args);
    }

    noInline(myLog);
    noInline(myAssert);

    for (var i = 0; i &lt; 1e6; ++i)
        myAssert((i % 1e4), &quot;Expected Failure&quot;, i);
})();

* STEPS TO REPRODUCE
1. jsc test.js -p profile
  =&gt; Profile shows &quot;Bad Type&quot; errors when handling the spread operator

* PROFILE
Lots more Baseline/DFG runs then expected due to exists.
&gt; l myAssert
Compilation myAssert#CCcDJe-1-Baseline:
    Total count: 240941  Max count: 20064
Compilation myAssert#CCcDJe-2-DFG:
    Total count: 701430  Max count: 58445
    EXIT: at bc#190 due to BadType, 5 times
Compilation myAssert#CCcDJe-3-FTL:
    Total count: 11061788  Max count: 921463

Exits are when spreading the array via inlined array iterator code
&gt; b myAssert
...
    [ 169] get_by_id         loc17, loc16, done(@id4)    predicting None
    [ 178] jtrue             loc17, 50(-&gt;228)
    [ 181] get_by_id         loc16, loc16, value(@id5)    predicting None
    [ 190] jmp               -104(-&gt;86)
    !!!!!                    EXIT: in myAssert#CCcDJe-2-DFG due to BadType, 5 times
...

Looks like it was predicting Boolint32, but the spreaded array (the rest param) should always have [String (&quot;Expected Failure&quot;), int32 (i)]. So that prediction seems unexpected.
&gt; d myAssert
...
9/5/184/0                      185:&lt; 3:loc14&gt;	GetByOffset(KnownCell:@182, KnownCell:@182, JS|UseAsOther, Boolint32, id5{value}, 1, inferredType = Top, R:NamedProperties(5), Exits, bc#181)  predicting Boolint32
9/5/184/0                           0x3baa19e02d1a: mov 0x18(%rax), %rsi
9/5/184/0                      186:&lt;!0:-&gt;	MovHint(Untyped:@185, MustGen, loc16, W:SideState, ClobbersExit, bc#181)
9/5/184/0                      187:&lt;!0:-&gt;	Check(Check:Int32:@185, MustGen, Exits, bc#181, exit: bc#190)
9/5/184/0                           0x3baa19e02d1e: cmp %r14, %rsi
9/5/184/0                           0x3baa19e02d21: jb 0x3baa19e0335f
  !!!!!                                           EXIT: due to BadType, 5 times
...</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>280637</attachid>
            <date>2016-06-06 15:31:29 -0700</date>
            <delta_ts>2016-06-06 15:31:29 -0700</delta_ts>
            <desc>[TEST] Test case</desc>
            <filename>spread-bench.js</filename>
            <type>application/x-javascript</type>
            <size>452</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">dmFyIHN0YXJ0ID0gRGF0ZS5ub3coKTsKCihmdW5jdGlvbigpIHsKICAgIGZ1bmN0aW9uIG15TG9n
KCkgewogICAgICAgIHZhciBhcmdzID0gQXJyYXkuZnJvbShhcmd1bWVudHMpOwogICAgICAgIHBy
aW50KGFyZ3Muam9pbigiICIpKTsKICAgIH0KICAgIGZ1bmN0aW9uIG15QXNzZXJ0KGNvbmRpdGlv
biwgLi4uYXJncykgewogICAgICAgICJ1c2Ugc3RyaWN0IjsKICAgICAgICBpZiAoIWNvbmRpdGlv
bikKICAgICAgICAgICAgbXlMb2coLi4uYXJncyk7CiAgICB9CgogICAgbm9JbmxpbmUobXlMb2cp
OwogICAgbm9JbmxpbmUobXlBc3NlcnQpOwoKICAgIGZvciAodmFyIGkgPSAwOyBpIDwgMWU2OyAr
K2kpCiAgICAgICAgbXlBc3NlcnQoKGkgJSAxZTQpLCAiRXhwZWN0ZWQgRmFpbHVyZSIsIGkpOwp9
KSgpOwoKdmFyIGVuZCA9IERhdGUubm93KCk7CnByaW50KChlbmQtc3RhcnQpKyJtcyIpOwo=
</data>

          </attachment>
      

    </bug>

</bugzilla>