<?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>246275</bug_id>
          
          <creation_ts>2022-10-10 05:01:32 -0700</creation_ts>
          <short_desc>Array.prototype.indexOf constant-folding should account for non-numeric index</short_desc>
          <delta_ts>2022-11-11 15:14:39 -0800</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>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="EntryHi">entryhii</reporter>
          <assigned_to name="Alexey Shvayka">ashvayka</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1904465</commentid>
    <comment_count>0</comment_count>
    <who name="EntryHi">entryhii</who>
    <bug_when>2022-10-10 05:01:32 -0700</bug_when>
    <thetext>function func(a,c) {
  a[0] = 1.2;
  return a.indexOf(&apos;test&apos;, c) 
}
noInline(func);
var a = [1.1, 2.2];
for (var i = 0; i &lt; 20; i++) {
  func(a, i);
}
func(a,  {
    valueOf: () =&gt; {
    a[0] = {}; 
    return 0;
  }
});
print(a[0])

With the above script as input to JSC, run JSC with the following parameters:
./jsc test.js --useConcurrentJIT=0 --jitPolicyScale=0.1

The above js scripts should print [Object], but jsc wrongly prints 1.2.
In DFGBytecodeParser, indexOf is inlined into ArrayIndexOf node instead of Call. In Fixup, ArrayIndexOf is converted to JSConstant node.
So valueOf is no longer invoked. Thus, a[0]={} is not executed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906089</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-10-17 05:02:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/101242631&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1910734</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2022-11-07 03:48:19 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/6203</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1911910</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-11-11 15:14:36 -0800</bug_when>
    <thetext>Committed 256590@main (77b468c0b1d1): &lt;https://commits.webkit.org/256590@main&gt;

Reviewed commits have been landed. Closing PR #6203 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>