March 06, 2013 [Issue 9655] New: Two functions with identical implementations are allowed to have the same address | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9655 Summary: Two functions with identical implementations are allowed to have the same address Product: D Version: D2 Platform: All URL: http://www.informit.com/guides/content.aspx?g=cplusplu s&seqNum=561 OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: websites AssignedTo: nobody@puremagic.com ReportedBy: bugzilla@digitalmars.com --- Comment #0 from Walter Bright <bugzilla@digitalmars.com> 2013-03-05 21:54:35 PST --- In regards to: http://d.puremagic.com/issues/show_bug.cgi?id=9623 Related C++ article "Can Two Functions Have the Same Address?" http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=561 This quote pretty much sells me: -- Additionally, Google's compiler team have experimented with Identical Code Folding (ICF) and reported that "[d]etailed experiments on the x86 platform show that ICF can reduce the text size [the program section in which functions' code is stored, DK] of some Google binaries, whose average text size is 50 MB, by up to 7%." -- We should settle the issue by updating the D spec to explicitly allow functions to have the same address. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 06, 2013 [Issue 9655] Two functions with identical implementations are allowed to have the same address | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | http://d.puremagic.com/issues/show_bug.cgi?id=9655 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2013-03-06 02:05:52 PST --- (In reply to comment #0) > In regards to: > > http://d.puremagic.com/issues/show_bug.cgi?id=9623 > > Related C++ article "Can Two Functions Have the Same Address?" http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=561 > > This quote pretty much sells me: > > -- > Additionally, Google's compiler team have experimented with Identical Code Folding (ICF) and reported that "[d]etailed experiments on the x86 platform show that ICF can reduce the text size [the program section in which functions' code is stored, DK] of some Google binaries, whose average text size is 50 MB, by up to 7%." > -- > > We should settle the issue by updating the D spec to explicitly allow functions to have the same address. 1) What are the downsides of such folding in D? 2) Since recently, LLVM (used by LDC) folds identical functions if you use a compiler switch. IF you use such switch, where the compiler sees two identical functions, replaces one of them with just a jump to the other. So their address is distinct, but the amount of wasted space in the binary is minimal. 3) Often templates generate not just identical functions, but functions that differ only in a small part, for only few asm instructions. So a good D compiler could try to split those functions in virtual chunks (maybe if the parts are not inside a loop), keep only one copy of the shared part. I presume this is not easy to do in general. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation