<?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>311452</bug_id>
          
          <creation_ts>2026-04-03 17:07:20 -0700</creation_ts>
          <short_desc>Build Time Improvement: Move variant-heavy inline functions from CalcTree headers to .cpp files</short_desc>
          <delta_ts>2026-04-07 11:12:50 -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>New Bugs</component>
          <version>WebKit Nightly Build</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="Brent Fulgham">bfulgham</reporter>
          <assigned_to name="Brent Fulgham">bfulgham</assigned_to>
          <cc>sam</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2196737</commentid>
    <comment_count>0</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2026-04-03 17:07:20 -0700</bug_when>
    <thetext>The CSSCalc::Node (38-type variant) and Style::Calculation::Node (33-type variant) trigger expensive mpark::variant template instantiations (constructor, destructor, move_constructor, switchOn dispatch) in every translation unit that includes their headers.

This patch moves convenience functions that create, move, or switchOn these variant types from inline definitions in headers to their corresponding .cpp files. This avoids unnecessary variant template instantiation in files that include the headers but don&apos;t call these functions.

(1) CSSCalcTree.h =&gt; CSSCalcTree.cpp:
* isNumeric() (switchOn over 38-type variant)add(), multiply(), subtract()
* makeChildWithValueBasedOn() (4 overloads)

(2) StyleCalculationTree.h =&gt; StyleCalculationTree.cpp:
* number(), percentage(), dimension()
* add(), multiply(), subtract(), blend()

Note: Trivial move constructors/operators (Children, ChildOrNone) were left inline to avoid runtime overhead on hot paths.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196742</commentid>
    <comment_count>1</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2026-04-03 17:35:41 -0700</bug_when>
    <thetext>Build data from -ftrace-time comparing builds:

   1.   -21.13s  (21.26s -&gt; 0.12s, -99.4%)  [221 -&gt; 1 TUs] WebCore::CSSCalc::Child::switchOn&lt;(lambda ...
   2.   -21.01s  (21.13s -&gt; 0.12s, -99.4%)  [221 -&gt; 1 TUs] WTF::visitOneVariant&lt;0UL, WTF::Visitor&lt;(lambda ...
   3.    -4.60s  (4.64s -&gt; 0.03s, -99.3%)  [221 -&gt; 1 TUs] WTF::visitOneVariant&lt;32UL, WTF::Visitor&lt;(lambda ...
   4.    -2.90s  (2.90s -&gt; 0.00s, -100.0%)  [200 -&gt; 0 TUs] WebCore::CSSCalc::Child::switchOn&lt;(lambda ...
   5.    -2.84s  (2.84s -&gt; 0.00s, -100.0%)  [200 -&gt; 0 TUs] WTF::visitOneVariant&lt;0UL, WTF::Visitor&lt;(lambda ...
   6.    -1.46s  (1.46s -&gt; 0.00s, -99.7%)  [229 -&gt; 1 TUs] WebCore::Style::Calculation::makeChild&lt;WebCore::Style::Calculation::Blend&gt;
   7.    -1.41s  (1.42s -&gt; 0.00s, -99.7%)  [229 -&gt; 1 TUs] WebCore::Style::Calculation::ChildConstruction&lt;WebCore::Style::Calculation::Blend&gt;::make
   8.    -1.15s  (1.15s -&gt; 0.00s, -99.6%)  [221 -&gt; 1 TUs] WebCore::CSSCalc::makeChild&lt;WebCore::CSSCalc::Negate&gt;
   9.    -1.11s  (1.11s -&gt; 0.00s, -99.6%)  [221 -&gt; 1 TUs] WebCore::CSSCalc::ChildConstruction&lt;WebCore::CSSCalc::Negate&gt;::make
  10.    -0.99s  (0.99s -&gt; 0.00s, -99.6%)  [229 -&gt; 1 TUs] WebCore::Style::Calculation::makeChild&lt;WebCore::Style::Calculation::Negate&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196743</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-04-03 17:35:57 -0700</bug_when>
    <thetext>&lt;rdar://problem/174049948&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196745</commentid>
    <comment_count>3</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2026-04-03 17:38:39 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/62009</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2197701</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-07 11:12:47 -0700</bug_when>
    <thetext>Committed 310727@main (0bd48dfc0abc): &lt;https://commits.webkit.org/310727@main&gt;

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

    </bug>

</bugzilla>