<?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>248023</bug_id>
          
          <creation_ts>2022-11-16 22:52:41 -0800</creation_ts>
          <short_desc>For-of should perform toPrimitive(done) in the interpreter before checking the iteration is done.</short_desc>
          <delta_ts>2022-11-23 22:53:16 -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 Local Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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="Nobody">webkit-unassigned</assigned_to>
          <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>1913096</commentid>
    <comment_count>0</comment_count>
    <who name="EntryHi">entryhii</who>
    <bug_when>2022-11-16 22:52:41 -0800</bug_when>
    <thetext>var it=0
var iterator_fn = new Proxy(function () {
}, {
  apply() {
    print(&apos;2&apos;)
    return it;
  }
});
var obj = new Proxy({}, {
  get: function (target, name) {
    it = obj;
    print(&apos;1&apos;)
    return iterator_fn;
  }
});

for (var v of obj) {
  print(&apos;3&apos;)
}

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

According to ECMA, the correct result should be &apos;12121&apos;, but JSC prints &apos;121211&apos;. I alse test the script in Safari, the result is alse &apos;121211&apos;. However, the result is &apos;12121&apos; in Google. If I set the JITPolicyScale to 0. JSC JIT will print &apos;12121&apos;.

The problem may be in LowLevelInterpreter64.asm. In op_iterator_next, m_done is JSValue from _llint_slow_path_iterator_next_get_done. In the scripts, m_done is a Proxy Object. This value should perform toPrimitive before btqnz, otherwise it will iterate one more time and print &apos;1&apos; wrongly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1914434</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-11-23 22:53:16 -0800</bug_when>
    <thetext>&lt;rdar://problem/102640049&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>