<?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>253634</bug_id>
          
          <creation_ts>2023-03-09 00:19:31 -0800</creation_ts>
          <short_desc>[JSC] Bound function optimization is observable with instanceof</short_desc>
          <delta_ts>2023-03-13 10:22:09 -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>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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="Jan de Mooij">jdemooij</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</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>1939995</commentid>
    <comment_count>0</comment_count>
      <attachid>465371</attachid>
    <who name="Jan de Mooij">jdemooij</who>
    <bug_when>2023-03-09 00:19:31 -0800</bug_when>
    <thetext>Created attachment 465371
Test

When binding an already-bound function, JSC tries to flatten this chain. This optimization is observable with `instanceof` because it gets the bound function&apos;s immediate target and does a `Symbol.hasInstance` lookup on it.

See the attached testcase. It should alert 10000 but I get 0 with Safari Technology Preview 165.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1940047</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-03-09 06:37:30 -0800</bug_when>
    <thetext>&lt;rdar://problem/106498460&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1940522</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2023-03-10 14:57:22 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/11385</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1940940</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2023-03-13 10:22:09 -0700</bug_when>
    <thetext>https://github.com/WebKit/WebKit/commit/d1911bf073cc55fc8ca76bcee8b4783539e43c2e</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>465371</attachid>
            <date>2023-03-09 00:19:31 -0800</date>
            <delta_ts>2023-03-09 00:19:31 -0800</delta_ts>
            <desc>Test</desc>
            <filename>test.htm</filename>
            <type>text/html</type>
            <size>339</size>
            <attacher name="Jan de Mooij">jdemooij</attacher>
            
              <data encoding="base64">PHNjcmlwdD4KZnVuY3Rpb24gZihhLCBiKSB7IHJldHVybiBhICsgYjsgfTsKbGV0IGNvdW50ID0g
MDsKb25sb2FkID0gZnVuY3Rpb24oKSB7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IDEwXzAwMDsg
aSsrKSB7CiAgICAgICAgdmFyIGcgPSBmLmJpbmQobnVsbCk7CiAgICAgICAgdmFyIGggPSBnLmJp
bmQobnVsbCk7CiAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGcsIFN5bWJvbC5oYXNJbnN0
YW5jZSwge2dldDogZnVuY3Rpb24oKSB7IGNvdW50Kys7IH19KTsKICAgICAgICB2YXIgcmVzID0g
e30gaW5zdGFuY2VvZiBoOwogICAgfQogICAgYWxlcnQoY291bnQpOwp9Owo8L3NjcmlwdD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>