WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
221319
Avoid a virtual function call in HTMLFormControlElement::isDisabledOrReadOnly()
https://bugs.webkit.org/show_bug.cgi?id=221319
Summary
Avoid a virtual function call in HTMLFormControlElement::isDisabledOrReadOnly()
Simon Fraser (smfr)
Reported
2021-02-02 21:51:31 PST
Avoid a virtual function call in HTMLFormControlElement::isDisabledOrReadOnly()
Attachments
Patch
(1.72 KB, patch)
2021-02-02 21:53 PST
,
Simon Fraser (smfr)
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Simon Fraser (smfr)
Comment 1
2021-02-02 21:53:39 PST
Created
attachment 419105
[details]
Patch
Ryosuke Niwa
Comment 2
2021-02-02 22:06:34 PST
Comment on
attachment 419105
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=419105&action=review
> Source/WebCore/ChangeLog:9 > + Avoid calling isDisabledFormControl() which is a virtual function on Element. > + HTMLFormControlElement is the only class in its hierarchy that implements this,
I don't think this is right. HTMLOptGroupElement, HTMLOptionElement, and SliderThumbElement overrides this.
Ryosuke Niwa
Comment 3
2021-02-02 22:09:43 PST
Comment on
attachment 419105
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=419105&action=review
>> Source/WebCore/ChangeLog:9 >> + HTMLFormControlElement is the only class in its hierarchy that implements this, > > I don't think this is right. HTMLOptGroupElement, HTMLOptionElement, and SliderThumbElement overrides this.
Nvm.
EWS
Comment 4
2021-02-02 23:14:30 PST
Committed
r272299
: <
https://trac.webkit.org/changeset/272299
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 419105
[details]
.
Radar WebKit Bug Importer
Comment 5
2021-02-02 23:15:19 PST
<
rdar://problem/73917813
>
Darin Adler
Comment 6
2021-02-03 18:16:53 PST
Comment on
attachment 419105
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=419105&action=review
> Source/WebCore/html/HTMLFormControlElement.h:116 > + bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; }
Can this optimization be done by adding final somewhere instead?
Darin Adler
Comment 7
2021-02-03 18:19:38 PST
Comment on
attachment 419105
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=419105&action=review
>> Source/WebCore/html/HTMLFormControlElement.h:116 >> + bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; } > > Can this optimization be done by adding final somewhere instead?
I don’t get it — given that classes override isDisabledFormControl, is this change correct?
Simon Fraser (smfr)
Comment 8
2021-02-03 19:21:16 PST
(In reply to Darin Adler from
comment #7
)
> Comment on
attachment 419105
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=419105&action=review
> > >> Source/WebCore/html/HTMLFormControlElement.h:116 > >> + bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; } > > > > Can this optimization be done by adding final somewhere instead? > > I don’t get it — given that classes override isDisabledFormControl, is this > change correct?
None of the classes that override isDisabledFormControl() are HTMLFormControlElement subclasses. Would marking HTMLFormControlElement::isDisabledFormControl() final be equivalent? I'm not sure what compiler optimizations are enabled by 'final'.
Ryosuke Niwa
Comment 9
2021-02-03 21:37:07 PST
(In reply to Simon Fraser (smfr) from
comment #8
)
> (In reply to Darin Adler from
comment #7
) > > Comment on
attachment 419105
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=419105&action=review
> > > > >> Source/WebCore/html/HTMLFormControlElement.h:116 > > >> + bool isDisabledOrReadOnly() const { return m_disabled || m_disabledByAncestorFieldset || m_isReadOnly; } > > > > > > Can this optimization be done by adding final somewhere instead? > > > > I don’t get it — given that classes override isDisabledFormControl, is this > > change correct? > > None of the classes that override isDisabledFormControl() are > HTMLFormControlElement subclasses. > > Would marking HTMLFormControlElement::isDisabledFormControl() final be > equivalent? I'm not sure what compiler optimizations are enabled by 'final'.
It'd avoid stable pointer lookup!
Darin Adler
Comment 10
2021-02-04 10:03:58 PST
(In reply to Simon Fraser (smfr) from
comment #8
)
> Would marking HTMLFormControlElement::isDisabledFormControl() final be > equivalent? I'm not sure what compiler optimizations are enabled by 'final'.
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.
Darin Adler
Comment 11
2021-02-04 10:05:13 PST
(In reply to Ryosuke Niwa from
comment #9
)
> It'd avoid stable pointer lookup!
Ryosuke means "vtable pointer lookup". 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.
Ryosuke Niwa
Comment 12
2021-03-05 00:44:18 PST
(In reply to Darin Adler from
comment #11
)
> (In reply to Ryosuke Niwa from
comment #9
) > > It'd avoid stable pointer lookup! > > Ryosuke means "vtable pointer lookup". 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.
Addressing this in
https://bugs.webkit.org/show_bug.cgi?id=222783
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug