<?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>221319</bug_id>
          
          <creation_ts>2021-02-02 21:51:31 -0800</creation_ts>
          <short_desc>Avoid a virtual function call in HTMLFormControlElement::isDisabledOrReadOnly()</short_desc>
          <delta_ts>2021-03-05 00:44:18 -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>Forms</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=222783</see_also>
          <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="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Simon Fraser (smfr)">simon.fraser</assigned_to>
          <cc>cdumez</cc>
    
    <cc>changseok</cc>
    
    <cc>darin</cc>
    
    <cc>esprehn+autocc</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>mifenton</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1725017</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-02-02 21:51:31 -0800</bug_when>
    <thetext>Avoid a virtual function call in HTMLFormControlElement::isDisabledOrReadOnly()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725019</commentid>
    <comment_count>1</comment_count>
      <attachid>419105</attachid>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-02-02 21:53:39 -0800</bug_when>
    <thetext>Created attachment 419105
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725022</commentid>
    <comment_count>2</comment_count>
      <attachid>419105</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-02-02 22:06:34 -0800</bug_when>
    <thetext>Comment on attachment 419105
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=419105&amp;action=review

&gt; Source/WebCore/ChangeLog:9
&gt; +        Avoid calling isDisabledFormControl() which is a virtual function on Element.
&gt; +        HTMLFormControlElement is the only class in its hierarchy that implements this,

I don&apos;t think this is right. HTMLOptGroupElement, HTMLOptionElement, and SliderThumbElement overrides this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725025</commentid>
    <comment_count>3</comment_count>
      <attachid>419105</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-02-02 22:09:43 -0800</bug_when>
    <thetext>Comment on attachment 419105
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=419105&amp;action=review

&gt;&gt; Source/WebCore/ChangeLog:9
&gt;&gt; +        HTMLFormControlElement is the only class in its hierarchy that implements this,
&gt; 
&gt; I don&apos;t think this is right. HTMLOptGroupElement, HTMLOptionElement, and SliderThumbElement overrides this.

Nvm.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725045</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2021-02-02 23:14:30 -0800</bug_when>
    <thetext>Committed r272299: &lt;https://trac.webkit.org/changeset/272299&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 419105.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725046</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-02-02 23:15:19 -0800</bug_when>
    <thetext>&lt;rdar://problem/73917813&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725427</commentid>
    <comment_count>6</comment_count>
      <attachid>419105</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2021-02-03 18:16:53 -0800</bug_when>
    <thetext>Comment on attachment 419105
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=419105&amp;action=review

&gt; Source/WebCore/html/HTMLFormControlElement.h:116
&gt; +    bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; }

Can this optimization be done by adding final somewhere instead?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725429</commentid>
    <comment_count>7</comment_count>
      <attachid>419105</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2021-02-03 18:19:38 -0800</bug_when>
    <thetext>Comment on attachment 419105
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=419105&amp;action=review

&gt;&gt; Source/WebCore/html/HTMLFormControlElement.h:116
&gt;&gt; +    bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; }
&gt; 
&gt; Can this optimization be done by adding final somewhere instead?

I don’t get it — given that classes override isDisabledFormControl, is this change correct?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725447</commentid>
    <comment_count>8</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-02-03 19:21:16 -0800</bug_when>
    <thetext>(In reply to Darin Adler from comment #7)
&gt; Comment on attachment 419105 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=419105&amp;action=review
&gt; 
&gt; &gt;&gt; Source/WebCore/html/HTMLFormControlElement.h:116
&gt; &gt;&gt; +    bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; }
&gt; &gt; 
&gt; &gt; Can this optimization be done by adding final somewhere instead?
&gt; 
&gt; I don’t get it — given that classes override isDisabledFormControl, is this
&gt; change correct?

None of the classes that override isDisabledFormControl() are HTMLFormControlElement subclasses.

Would marking HTMLFormControlElement::isDisabledFormControl() final be equivalent? I&apos;m not sure what compiler optimizations are enabled by &apos;final&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725488</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-02-03 21:37:07 -0800</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #8)
&gt; (In reply to Darin Adler from comment #7)
&gt; &gt; Comment on attachment 419105 [details]
&gt; &gt; Patch
&gt; &gt; 
&gt; &gt; View in context:
&gt; &gt; https://bugs.webkit.org/attachment.cgi?id=419105&amp;action=review
&gt; &gt; 
&gt; &gt; &gt;&gt; Source/WebCore/html/HTMLFormControlElement.h:116
&gt; &gt; &gt;&gt; +    bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; }
&gt; &gt; &gt; 
&gt; &gt; &gt; Can this optimization be done by adding final somewhere instead?
&gt; &gt; 
&gt; &gt; I don’t get it — given that classes override isDisabledFormControl, is this
&gt; &gt; change correct?
&gt; 
&gt; None of the classes that override isDisabledFormControl() are
&gt; HTMLFormControlElement subclasses.
&gt; 
&gt; Would marking HTMLFormControlElement::isDisabledFormControl() final be
&gt; equivalent? I&apos;m not sure what compiler optimizations are enabled by &apos;final&apos;.

It&apos;d avoid stable pointer lookup!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725679</commentid>
    <comment_count>10</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2021-02-04 10:03:58 -0800</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #8)
&gt; Would marking HTMLFormControlElement::isDisabledFormControl() final be
&gt; equivalent? I&apos;m not sure what compiler optimizations are enabled by &apos;final&apos;.

Yes, I think it would be equivalent, as long as the implementation of isDisabledFormControl was in the header. The combination of final and inlining should do exactly the same as this change. And the bonus is that it would optimize any other similar call sites in the same way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1725680</commentid>
    <comment_count>11</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2021-02-04 10:05:13 -0800</bug_when>
    <thetext>(In reply to Ryosuke Niwa from comment #9)
&gt; It&apos;d avoid stable pointer lookup!

Ryosuke means &quot;vtable pointer lookup&quot;. Basically, if we didn’t inline, then the function would be faster, and who knows how good the link time optimization is at giving the same benefits as inlining. But, as I said, with inlining it should literally be the same.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1736208</commentid>
    <comment_count>12</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-03-05 00:44:18 -0800</bug_when>
    <thetext>(In reply to Darin Adler from comment #11)
&gt; (In reply to Ryosuke Niwa from comment #9)
&gt; &gt; It&apos;d avoid stable pointer lookup!
&gt; 
&gt; Ryosuke means &quot;vtable pointer lookup&quot;. Basically, if we didn’t inline, then
&gt; the function would be faster, and who knows how good the link time
&gt; optimization is at giving the same benefits as inlining. But, as I said,
&gt; with inlining it should literally be the same.

Addressing this in https://bugs.webkit.org/show_bug.cgi?id=222783</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>419105</attachid>
            <date>2021-02-02 21:53:39 -0800</date>
            <delta_ts>2021-02-02 23:14:32 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-221319-20210202215339.patch</filename>
            <type>text/plain</type>
            <size>1763</size>
            <attacher name="Simon Fraser (smfr)">simon.fraser</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjcyMjE4CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZ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