Bug 72367 - DFG should distinguish between constants in the constant pool and weak constants added as artifacts of code generation
Summary: DFG should distinguish between constants in the constant pool and weak consta...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 72312
  Show dependency treegraph
 
Reported: 2011-11-15 01:37 PST by Filip Pizlo
Modified: 2011-11-15 13:55 PST (History)
0 users

See Also:


Attachments
the patch (23.93 KB, patch)
2011-11-15 01:44 PST, Filip Pizlo
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2011-11-15 01:37:13 PST
Some constants come from the constant pool, which is derived directly from the source code.  These can be safely pinned by the code block.  Other constants are pure artifacts of code generation, such as structure references for heap access checks, and function constants for linked calls.  This latter set of constants should be referred to in a special way so that the GC knows that they are weak references.  Furthermore, the pseudo-constant support for CheckMethod should be eliminated and replaced with weak constants.
Comment 1 Filip Pizlo 2011-11-15 01:44:56 PST
Created attachment 115124 [details]
the patch

Running on bigmac...
376/376                                                          
Generating benchmark report at TipOfTree_WeakJSConst_SunSpiderV8Kraken_20111115_0124_benchReport.txt

Benchmark report for SunSpider, V8, and Kraken on bigmac.local (MacPro5,1).

VMs tested:
"TipOfTree" at /Volumes/Data/pizlo/quinary/OpenSource/WebKitBuild/Release/jsc (r100248)
"WeakJSConst" at /Volumes/Data/pizlo/OpenSource/WebKitBuild/Release/jsc (r100248)

Collected 12 samples per benchmark/VM, with 4 VM invocations per benchmark. Emitted a call to gc() between sample
measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the jsc-specific preciseTime()
function to get microsecond-level timing. Reporting benchmark execution times with 95% confidence intervals in
milliseconds.

                                            TipOfTree              WeakJSConst                                   
SunSpider:
   3d-cube                                7.4749+-0.0644          7.4299+-0.0192       
   3d-morph                               8.3845+-0.0461    ?     8.3906+-0.0284       ?
   3d-raytrace                            7.7442+-0.0700          7.6742+-0.0584       
   access-binary-trees                    1.6025+-0.0109    ?     1.6034+-0.0091       ?
   access-fannkuch                        7.5388+-0.0119    ?     7.5642+-0.0418       ?
   access-nbody                           4.2395+-0.0128    ^     4.1948+-0.0065       ^ definitely 1.0107x faster
   access-nsieve                          3.1577+-0.0480    ?     3.1684+-0.0500       ?
   bitops-3bit-bits-in-byte               1.2435+-0.0116          1.2418+-0.0119       
   bitops-bits-in-byte                    4.8996+-0.0090    ?     4.9031+-0.0096       ?
   bitops-bitwise-and                     3.2956+-0.0132          3.2876+-0.0039       
   bitops-nsieve-bits                     5.6474+-0.0347    ?     5.6776+-0.0355       ?
   controlflow-recursive                  2.2776+-0.0138    ?     2.2893+-0.0182       ?
   crypto-aes                             7.1383+-0.0307    ?     7.3632+-0.2517       ? might be 1.0315x slower
   crypto-md5                             2.5141+-0.0186    ?     2.5172+-0.0167       ?
   crypto-sha1                            2.2031+-0.0262          2.1913+-0.0143       
   date-format-tofte                     10.6322+-0.0729    ?    10.9712+-0.3371       ? might be 1.0319x slower
   date-format-xparb                     10.1367+-0.2002         10.0286+-0.1488         might be 1.0108x faster
   math-cordic                            7.1391+-0.0312          7.1318+-0.0148       
   math-partial-sums                     10.4731+-0.0346    ?    10.7321+-0.2996       ? might be 1.0247x slower
   math-spectral-norm                     2.6151+-0.0197          2.6026+-0.0024       
   regexp-dna                            13.3218+-0.1639         13.2719+-0.1412       
   string-base64                          4.0115+-0.0681          3.9744+-0.0308       
   string-fasta                           7.0860+-0.0260          7.0744+-0.0186       
   string-tagcloud                       13.2013+-0.0443    ?    13.2020+-0.0594       ?
   string-unpack-code                    22.6294+-0.0993    ?    22.7089+-0.2704       ?
   string-validate-input                  5.7298+-0.0414          5.7200+-0.0230       

   <arithmetic> *                         6.7822+-0.0247    ?     6.8044+-0.0282       ?
   <geometric>                            5.3983+-0.0200    ?     5.4067+-0.0192       ?
   <harmonic>                             4.2055+-0.0179    ?     4.2055+-0.0147       ?

                                            TipOfTree              WeakJSConst                                   
V8:
   crypto                                78.1498+-0.2724    ^    77.3261+-0.1327       ^ definitely 1.0107x faster
   deltablue                            173.6689+-0.8090    ^   168.7560+-0.5806       ^ definitely 1.0291x faster
   earley-boyer                         105.4148+-2.0278        104.7088+-1.1564       
   raytrace                              63.6958+-0.4413         63.3436+-0.4916       
   regexp                               124.1665+-0.3106        124.0606+-0.4326       
   richards                             140.4802+-1.0213    ^   137.4830+-0.6866       ^ definitely 1.0218x faster
   splay                                 90.1787+-0.8668    ?    91.1472+-0.7120       ? might be 1.0107x slower

   <arithmetic>                         110.8221+-0.3299    ^   109.5465+-0.1881       ^ definitely 1.0116x faster
   <geometric> *                        105.2702+-0.3705    ^   104.3266+-0.2047       ^ definitely 1.0090x faster
   <harmonic>                            99.9830+-0.3998    ^    99.2811+-0.2329       ^ definitely 1.0071x faster

                                            TipOfTree              WeakJSConst                                   
Kraken:
   ai-astar                             807.9812+-12.9122   !   827.6739+-0.3705       ! definitely 1.0244x slower
   audio-beat-detection                 206.9572+-0.5520    ^   205.2212+-0.7636       ^ definitely 1.0085x faster
   audio-dft                            262.6355+-2.1494    ?   263.0267+-2.3754       ?
   audio-fft                            134.7678+-0.4457    ^   133.4789+-0.8316       ^ definitely 1.0097x faster
   audio-oscillator                     290.3653+-1.2749    !   293.2817+-0.4361       ! definitely 1.0100x slower
   imaging-darkroom                     333.7685+-4.7964    ?   337.6759+-5.2766       ? might be 1.0117x slower
   imaging-desaturate                   240.9239+-0.1990        240.8862+-0.0772       
   imaging-gaussian-blur                620.7632+-0.1905    ^   620.3618+-0.1823       ^ definitely 1.0006x faster
   json-parse-financial                  73.1431+-0.5153    ^    71.4270+-0.0834       ^ definitely 1.0240x faster
   json-stringify-tinderbox              78.6364+-0.2496         78.4720+-0.1564       
   stanford-crypto-aes                  115.8029+-0.2686    !   119.1632+-1.5551       ! definitely 1.0290x slower
   stanford-crypto-ccm                  114.2002+-0.3795    ?   114.5494+-0.8313       ?
   stanford-crypto-pbkdf2               232.5823+-1.8490        230.6294+-1.1833       
   stanford-crypto-sha256-iterative      97.4059+-0.3245    ?    97.5911+-0.6459       ?

   <arithmetic> *                       257.8524+-1.0178    !   259.5313+-0.4196       ! definitely 1.0065x slower
   <geometric>                          198.5256+-0.3483    ?   198.9190+-0.3913       ?
   <harmonic>                           159.3606+-0.2079        159.1536+-0.3199       

                                            TipOfTree              WeakJSConst                                   
All benchmarks:
   <arithmetic>                          97.0644+-0.3347    ?    97.3868+-0.1179       ?
   <geometric>                           24.5881+-0.0648    ?    24.5908+-0.0486       ?
   <harmonic>                             7.4129+-0.0311          7.4123+-0.0253       

                                            TipOfTree              WeakJSConst                                   
Geomean of preferred means:
   <scaled-result>                       56.8869+-0.1522    ?    56.9013+-0.0887       ?

Sending VM builds to oldmac...
Running on oldmac...
376/376                                                          
Generating benchmark report at TipOfTree_WeakJSConst_SunSpiderV8Kraken_20111115_0127_benchReport.txt

Benchmark report for SunSpider, V8, and Kraken on oldmac.local (MacPro4,1).

VMs tested:
"TipOfTree" at /Volumes/Data/pizlo/quinary/OpenSource/WebKitBuild/Release/jsc (r100248)
"WeakJSConst" at /Volumes/Data/pizlo/OpenSource/WebKitBuild/Release/jsc (r100248)

Collected 12 samples per benchmark/VM, with 4 VM invocations per benchmark. Emitted a call to gc() between sample
measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the jsc-specific preciseTime()
function to get microsecond-level timing. Reporting benchmark execution times with 95% confidence intervals in
milliseconds.

                                            TipOfTree              WeakJSConst                                   
SunSpider:
   3d-cube                                8.9425+-0.0383    ?     8.9616+-0.0345       ?
   3d-morph                              10.2570+-0.1317    ?    10.2937+-0.1880       ?
   3d-raytrace                            9.2555+-0.1080          9.2050+-0.0553       
   access-binary-trees                    1.9135+-0.0095    ?     1.9174+-0.0079       ?
   access-fannkuch                        9.1043+-0.0106    ?     9.1074+-0.0059       ?
   access-nbody                           5.0819+-0.0142          5.0600+-0.0117       
   access-nsieve                          3.7666+-0.0575    ?     3.7699+-0.0527       ?
   bitops-3bit-bits-in-byte               1.4877+-0.0113          1.4803+-0.0027       
   bitops-bits-in-byte                    5.9165+-0.0190    ?     5.9399+-0.0100       ?
   bitops-bitwise-and                     3.9737+-0.0067          3.9719+-0.0046       
   bitops-nsieve-bits                     6.8549+-0.0430    ?     6.8720+-0.1110       ?
   controlflow-recursive                  2.7898+-0.0428          2.7436+-0.0167         might be 1.0168x faster
   crypto-aes                             8.5988+-0.0527    ?     8.6744+-0.0734       ?
   crypto-md5                             3.0130+-0.0175    ?     3.0381+-0.0485       ?
   crypto-sha1                            2.6243+-0.0170          2.6172+-0.0161       
   date-format-tofte                     13.1531+-0.1519         12.9377+-0.1004         might be 1.0166x faster
   date-format-xparb                     12.5332+-0.2095    ^    12.1236+-0.1408       ^ definitely 1.0338x faster
   math-cordic                            8.6686+-0.0594          8.6045+-0.0184       
   math-partial-sums                     12.6790+-0.1089         12.6032+-0.0355       
   math-spectral-norm                     3.1294+-0.0055    ?     3.1669+-0.0427       ? might be 1.0120x slower
   regexp-dna                            16.6257+-0.1365         16.4281+-0.1658         might be 1.0120x faster
   string-base64                          4.8965+-0.1119          4.8018+-0.0518         might be 1.0197x faster
   string-fasta                           8.5147+-0.0180    ?     8.5332+-0.0255       ?
   string-tagcloud                       16.2785+-0.2002         16.1218+-0.0840       
   string-unpack-code                    28.1218+-0.0674         27.9960+-0.0699       
   string-validate-input                  6.8594+-0.0535    ?     6.9221+-0.0654       ?

   <arithmetic> *                         8.2708+-0.0360          8.2266+-0.0344       
   <geometric>                            6.5372+-0.0279          6.5153+-0.0269       
   <harmonic>                             5.0648+-0.0211          5.0543+-0.0191       

                                            TipOfTree              WeakJSConst                                   
V8:
   crypto                                94.9970+-0.5431    ^    93.4692+-0.3338       ^ definitely 1.0163x faster
   deltablue                            211.1545+-1.9324    ^   204.2170+-0.6939       ^ definitely 1.0340x faster
   earley-boyer                         126.3291+-1.4626        126.3195+-1.2244       
   raytrace                              75.6431+-0.4070         75.5980+-0.1789       
   regexp                               148.4928+-0.3598    ?   149.1518+-0.6791       ?
   richards                             170.8354+-1.4016    ^   166.2814+-1.0149       ^ definitely 1.0274x faster
   splay                                108.2884+-2.0837    ?   109.2343+-3.2458       ?

   <arithmetic>                         133.6772+-0.4452    ^   132.0387+-0.4015       ^ definitely 1.0124x faster
   <geometric> *                        126.7711+-0.4663    ^   125.6073+-0.4761       ^ definitely 1.0093x faster
   <harmonic>                           120.2082+-0.4698        119.3899+-0.5073       

                                            TipOfTree              WeakJSConst                                   
Kraken:
   ai-astar                             895.7836+-0.5789    ?   895.9724+-0.3912       ?
   audio-beat-detection                 252.2690+-0.6783    ^   248.8660+-0.4767       ^ definitely 1.0137x faster
   audio-dft                            316.4345+-3.9175        315.3966+-2.9579       
   audio-fft                            164.5795+-0.6091    ^   162.6430+-1.1441       ^ definitely 1.0119x faster
   audio-oscillator                     352.6447+-1.1985        351.2094+-1.3555       
   imaging-darkroom                     407.3634+-9.4839        402.3328+-5.4317         might be 1.0125x faster
   imaging-desaturate                   291.1928+-0.0429    ?   291.3071+-0.2392       ?
   imaging-gaussian-blur                750.8642+-0.2608        750.8458+-0.1683       
   json-parse-financial                  88.7181+-0.8579    ^    87.0559+-0.0599       ^ definitely 1.0191x faster
   json-stringify-tinderbox              95.3538+-0.4301         95.2726+-0.8561       
   stanford-crypto-aes                  141.5629+-1.1342        141.2541+-0.8239       
   stanford-crypto-ccm                  135.5763+-0.4886    !   137.1899+-0.9901       ! definitely 1.0119x slower
   stanford-crypto-pbkdf2               283.6872+-3.0294        278.6610+-2.4037         might be 1.0180x faster
   stanford-crypto-sha256-iterative     117.9124+-0.2105    ?   117.9779+-0.3163       ?

   <arithmetic> *                       306.7102+-0.8325        305.4275+-0.5782       
   <geometric>                          239.1825+-0.6048    ^   237.9623+-0.4812       ^ definitely 1.0051x faster
   <harmonic>                           192.8737+-0.4437    ^   191.8515+-0.3680       ^ definitely 1.0053x faster

                                            TipOfTree              WeakJSConst                                   
All benchmarks:
   <arithmetic>                         115.8452+-0.2534    ^   115.1946+-0.1865       ^ definitely 1.0056x faster
   <geometric>                           29.7055+-0.0825         29.5646+-0.0737       
   <harmonic>                             8.9280+-0.0366          8.9088+-0.0329       

                                            TipOfTree              WeakJSConst                                   
Geomean of preferred means:
   <scaled-result>                       68.5112+-0.1737    ^    68.0838+-0.1387       ^ definitely 1.0063x faster
Comment 2 Filip Pizlo 2011-11-15 02:06:35 PST
Performance from one other machine...



Benchmark report for SunSpider, V8, and Kraken on nitroflex.local (MacBookPro8,2).

VMs tested:
"TipOfTree" at /Volumes/Data/pizlo/quinary/OpenSource/WebKitBuild/Release/jsc (r100248)
"WeakJSConst" at /Volumes/Data/pizlo/OpenSource/WebKitBuild/Release/jsc (r100248)

Collected 12 samples per benchmark/VM, with 4 VM invocations per benchmark. Emitted a call to gc() between sample
measurements. Used 1 benchmark iteration per VM invocation for warm-up. Used the jsc-specific preciseTime()
function to get microsecond-level timing. Reporting benchmark execution times with 95% confidence intervals in
milliseconds.

                                            TipOfTree              WeakJSConst                                   
SunSpider:
   3d-cube                                6.9690+-0.1862          6.8899+-0.1703         might be 1.0115x faster
   3d-morph                               7.5911+-0.1116    ?     8.0039+-0.8044       ? might be 1.0544x slower
   3d-raytrace                            7.2039+-0.1805          7.0971+-0.1649         might be 1.0150x faster
   access-binary-trees                    1.5393+-0.0630          1.5069+-0.0386         might be 1.0216x faster
   access-fannkuch                        6.1566+-0.1158    ?     6.1892+-0.1367       ?
   access-nbody                           3.5211+-0.0853          3.4606+-0.0575         might be 1.0175x faster
   access-nsieve                          2.5639+-0.1050    ?     2.6152+-0.0919       ? might be 1.0200x slower
   bitops-3bit-bits-in-byte               1.2652+-0.0240    ?     1.2688+-0.0262       ?
   bitops-bits-in-byte                    2.3806+-0.0723    ?     2.3888+-0.0622       ?
   bitops-bitwise-and                     3.4731+-0.0593          3.4184+-0.0741         might be 1.0160x faster
   bitops-nsieve-bits                     5.2280+-0.0928    ?     5.3354+-0.0887       ? might be 1.0205x slower
   controlflow-recursive                  2.0994+-0.0654          2.0638+-0.0416         might be 1.0172x faster
   crypto-aes                             6.8391+-0.2195    ?     6.9613+-0.2245       ? might be 1.0179x slower
   crypto-md5                             2.4006+-0.0919          2.3620+-0.0525         might be 1.0163x faster
   crypto-sha1                            2.0546+-0.0506    ?     2.0591+-0.0574       ?
   date-format-tofte                      9.9640+-0.1418          9.9102+-0.1292       
   date-format-xparb                      9.7058+-0.2774          9.3958+-0.2312         might be 1.0330x faster
   math-cordic                            6.2552+-0.0733    ?     6.2652+-0.0978       ?
   math-partial-sums                      7.4376+-0.1587    ?     7.4660+-0.1481       ?
   math-spectral-norm                     2.3454+-0.0588    ?     2.3696+-0.0535       ? might be 1.0103x slower
   regexp-dna                            11.6714+-0.1873         11.4908+-0.2494         might be 1.0157x faster
   string-base64                          3.8272+-0.0690          3.7632+-0.0545         might be 1.0170x faster
   string-fasta                           6.2927+-0.1082          6.2699+-0.0873       
   string-tagcloud                       11.6750+-0.3077         11.5916+-0.2417       
   string-unpack-code                    19.7977+-0.2062    ?    20.0248+-0.2556       ? might be 1.0115x slower
   string-validate-input                  5.1825+-0.0683    !     5.4800+-0.1552       ! definitely 1.0574x slower

   <arithmetic> *                         5.9785+-0.0166    ?     5.9864+-0.0459       ?
   <geometric>                            4.7712+-0.0178    ?     4.7726+-0.0391       ?
   <harmonic>                             3.7762+-0.0325          3.7713+-0.0396       

                                            TipOfTree              WeakJSConst                                   
V8:
   crypto                                70.0168+-0.5636         69.9285+-0.7331       
   deltablue                            154.7862+-0.7264    ^   147.1490+-0.4319       ^ definitely 1.0519x faster
   earley-boyer                          84.8812+-0.8977    ?    85.2087+-0.7574       ?
   raytrace                              56.3155+-0.5422         56.1517+-0.4802       
   regexp                               103.6272+-0.6497    ?   103.6485+-0.5164       ?
   richards                             122.4161+-1.0821    ^   117.1848+-0.9286       ^ definitely 1.0446x faster
   splay                                 70.8845+-0.8013    ?    72.0424+-1.1337       ? might be 1.0163x slower

   <arithmetic>                          94.7039+-0.2980    ^    93.0448+-0.2858       ^ definitely 1.0178x faster
   <geometric> *                         89.6551+-0.3417    ^    88.6580+-0.3171       ^ definitely 1.0112x faster
   <harmonic>                            85.1384+-0.3823         84.6244+-0.3477       

                                            TipOfTree              WeakJSConst                                   
Kraken:
   ai-astar                             488.3918+-4.9309    ?   490.9525+-4.5239       ?
   audio-beat-detection                 185.6475+-0.5684    !   188.4291+-2.0541       ! definitely 1.0150x slower
   audio-dft                            263.5478+-4.2151        263.1814+-5.5742       
   audio-fft                            123.2022+-0.6668    ^   121.9842+-0.5167       ^ definitely 1.0100x faster
   audio-oscillator                     249.5455+-1.0532    ?   250.0184+-2.5857       ?
   imaging-darkroom                     295.9794+-3.5622    ?   297.4527+-4.3890       ?
   imaging-desaturate                   221.5647+-0.4850    ?   222.1165+-0.8970       ?
   imaging-gaussian-blur                547.5262+-2.6360        545.9149+-3.1049       
   json-parse-financial                  56.8624+-0.4049    !    57.6907+-0.3272       ! definitely 1.0146x slower
   json-stringify-tinderbox              66.7937+-0.3418    ?    66.9288+-0.2141       ?
   stanford-crypto-aes                   97.5175+-1.9351    ^    94.2016+-0.6394       ^ definitely 1.0352x faster
   stanford-crypto-ccm                   97.4379+-0.4193    ?    98.2483+-1.1594       ?
   stanford-crypto-pbkdf2               187.9402+-1.2941        186.8538+-1.5546       
   stanford-crypto-sha256-iterative      80.3322+-0.3642    ^    79.5220+-0.3426       ^ definitely 1.0102x faster

   <arithmetic> *                       211.5921+-0.4609    ?   211.6782+-0.4314       ?
   <geometric>                          168.0736+-0.2727        167.9442+-0.3710       
   <harmonic>                           134.7031+-0.3014        134.5551+-0.3801       

                                            TipOfTree              WeakJSConst                                   
All benchmarks:
   <arithmetic>                          80.4395+-0.1392         80.2225+-0.1521       
   <geometric>                           21.3370+-0.0543         21.2998+-0.1130       
   <harmonic>                             6.6465+-0.0559          6.6375+-0.0682       

                                            TipOfTree              WeakJSConst                                   
Geomean of preferred means:
   <scaled-result>                       48.4045+-0.0913         48.2519+-0.1704
Comment 3 Geoffrey Garen 2011-11-15 10:54:54 PST
Comment on attachment 115124 [details]
the patch

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

r=me

> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:540
> +        HashMap<JSCell*, NodeIndex>::iterator iter = m_cellConstantNodes.find(cell);
> +        if (iter != m_cellConstantNodes.end())
> +            return iter->second;
> +        
> +        NodeIndex result = addToGraph(WeakJSConstant, OpInfo(cell));
> +        m_cellConstantNodes.add(cell, result);
> +        return result;

The idiom for "add if not existing" is:

pair<iterator, bool> result = table.add(DummyValue);
if (result.second)
    result.first->second = RealValue;

This saves a redundant hash lookup when first adding something to the table.
Comment 4 Filip Pizlo 2011-11-15 12:38:11 PST
(In reply to comment #3)
> (From update of attachment 115124 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=115124&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:540
> > +        HashMap<JSCell*, NodeIndex>::iterator iter = m_cellConstantNodes.find(cell);
> > +        if (iter != m_cellConstantNodes.end())
> > +            return iter->second;
> > +        
> > +        NodeIndex result = addToGraph(WeakJSConstant, OpInfo(cell));
> > +        m_cellConstantNodes.add(cell, result);
> > +        return result;
> 
> The idiom for "add if not existing" is:
> 
> pair<iterator, bool> result = table.add(DummyValue);
> if (result.second)
>     result.first->second = RealValue;
> 
> This saves a redundant hash lookup when first adding something to the table.

Ah, good point.
Comment 5 Filip Pizlo 2011-11-15 13:55:01 PST
http://trac.webkit.org/changeset/100315