www.digitalmars.com         C & C++   DMDScript  

D - Inlining between modules

reply Simon Hobbs <Simon_member pathlink.com> writes:
Is the compiler able to perform inlining between modules? I.e. if I have a
module containing a vector class, are the functions able to be inlined when I
use this class in a separate module.

The reason I ask is that inlining would usually be performed on some
intermediate format for the code rather than on the final binary I believe, but
?obviously? no such representation is available to the D import mechanism.

To perform inlining on the machine code makes the inlining machine dependant.

Or am I missing something here?

I'd try this out myself but I don't seem to get any symbol information out of
the compiler. WinDbg wants a .pdb file but no such file is emitted. Help with
this would also be much appreciated. How are other people debugging D? Again,
sorry if I'm being thick, but I'm an IDE boy so I haven't come up against these
issues before.

Thanks in advance.

Si
Apr 16 2004
next sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
Simon Hobbs wrote:

 Is the compiler able to perform inlining between modules? I.e. if I 
 have a
 module containing a vector class, are the functions able to be inlined 
 when I
 use this class in a separate module.

 The reason I ask is that inlining would usually be performed on some
 intermediate format for the code rather than on the final binary I 
 believe, but
 ?obviously? no such representation is available to the D import 
 mechanism.

 To perform inlining on the machine code makes the inlining machine 
 dependant.

 Or am I missing something here?

 I'd try this out myself but I don't seem to get any symbol information 
 out of
 the compiler. WinDbg wants a .pdb file but no such file is emitted. 
 Help with
 this would also be much appreciated. How are other people debugging D? 
 Again,
 sorry if I'm being thick, but I'm an IDE boy so I haven't come up 
 against these
 issues before.

 Thanks in advance.

 Si


  

Charles and I, just released today Dig-Dug 0.0.1, a debugger for D written in D. You may find it useful in it's present state for your particular problem, u may not. You can get it from: Location: http://svn.dsource.org/svn/projects/digdug/ Main file: http://svn.dsource.org/svn/projects/digdug/setup.exe -- -- -Anderson: http://badmama.com.au/~anderson/
Apr 16 2004
prev sibling parent Ilya Minkov <minkov cs.tum.edu> writes:
Simon Hobbs schrieb:
 Is the compiler able to perform inlining between modules? I.e. if I have a
 module containing a vector class, are the functions able to be inlined when I
 use this class in a separate module.

In principle, they should be inlined in release mode. There is an inlinability meter, which decides whether or not to make the function inlinable - and unless it is very short and simple it shouldn't.
 The reason I ask is that inlining would usually be performed on some
 intermediate format for the code rather than on the final binary I believe, but
 ?obviously? no such representation is available to the D import mechanism.

Source is parsed into memory structures - all files which are requiered (either contain interface or are candidates for inlining). Someday it may be optimized into serializing this intermediate representation to disk, but considering that parser is extremely fast, Walter does not see much sense. Besides, if you compile multiple files to object files in one command, the other source files need to be only parsed once - count a couple of seconds for that - while with C++ you'd be reparsing (roughly same order of magnitude) many megabytes headers for each source file, which is not requiered with D. So, inlining is done in the front-end, which also reduces D (high-level) to low-level though rather machine independant constructs. The low level soup is passed to a back-end, which generates machine code. There were at least 4 back ends in the history of D, namely DigitalMars (x86, closed source), Burton Radon's DLI (non-optimizing), and 2 GCC based of different quality.
 To perform inlining on the machine code makes the inlining machine dependant.

It wouldn't really work too reliably either.
 Or am I missing something here?
 
 I'd try this out myself but I don't seem to get any symbol information out of
 the compiler. WinDbg wants a .pdb file but no such file is emitted. Help with
 this would also be much appreciated. How are other people debugging D? Again,
 sorry if I'm being thick, but I'm an IDE boy so I haven't come up against these
 issues before.

I heard people say that WinDbg works somewhat. Didn't come to try it myself though. -eye
Apr 16 2004