digitalmars.D - Dynamic Class Loading Idea
- Craig Black (20/20) Nov 02 2007 Dynamic class loading has the requirement that the class library can be
- Vladimir Panteleev (5/24) Nov 03 2007 I like DDL's approach, in which it acts as a run-time linker. It uses re...
- Craig Black (1/4) Nov 03 2007 Does this relocation use function pointers?
- Vladimir Panteleev (7/11) Nov 03 2007 "Relocation data" is just a list of addresses which have pointers. I did...
- Craig Black (4/29) Nov 03 2007 Thanks for the explanation. So then modules can be loaded at run time, ...
- Vladimir Panteleev (5/39) Nov 03 2007 Yes, that's the goal and purpose of DDL.
- Daniel Keep (6/12) Nov 03 2007 Here's how I understand it. DDL is a linker. The only difference
- Craig Black (6/18) Nov 03 2007 That's pretty cool then. Since we have DDL, can we effectively say that...
- Vladimir Panteleev (5/27) Nov 03 2007 DDL is, at the moment, defunct when it comes to compatibility with newer...
- TomD (7/13) Nov 04 2007 Any chance to get this compatible to Phobos? As far as I could see,
- Bruce Adams (2/19) Nov 03 2007 Its also what an operating does to load dynamic link libraries or shared...
- Craig Black (4/24) Nov 03 2007 Right, but the operating system does not do this when loading dll's or s...
- Bruce Adams (3/33) Nov 04 2007 It depends on the operating system but generally yes it does. On some sy...
- Craig Black (6/50) Nov 05 2007 I think you are talking about delay loaded libraries. I'm talking about...
Dynamic class loading has the requirement that the class library can be loaded at run time. Traditionally, this means that all functions had to be bound via function pointers or virtual functions. This would mean that all the local functions would have to be virtual, and static/global functions would need to be bound via function pointers somehow. This is obviously a performance issue. However, self modifying code could be employed to load a class at run time without using function pointers and virtual functions. For each function in a dynamically loadable class, we could have an array of pointers that would point to the addresses in code where that function is called (call sites). Before the class library is loaded, these call sites would simply throw exceptions. When the class is loaded, the code at the call site to throw the exception could be overwritten to call the appropriate function. This would eliminate the requirement to use function pointers/virtual functions and allow us to do high-performance dynamic class loading. I don't know if it is possible to modify functions that reside in the code segment. Does the operating system allow this? If not, we could place functions with these dynamic call sites on the heap. Thoughts? -Craig
Nov 02 2007
On Sat, 03 Nov 2007 08:26:42 +0200, Craig Black <craigblack2 cox.net> wrote:Dynamic class loading has the requirement that the class library can be loaded at run time. Traditionally, this means that all functions had to be bound via function pointers or virtual functions. This would mean that all the local functions would have to be virtual, and static/global functions would need to be bound via function pointers somehow. This is obviously a performance issue. However, self modifying code could be employed to load a class at run time without using function pointers and virtual functions. For each function in a dynamically loadable class, we could have an array of pointers that would point to the addresses in code where that function is called (call sites). Before the class library is loaded, these call sites would simply throw exceptions. When the class is loaded, the code at the call site to throw the exception could be overwritten to call the appropriate function. This would eliminate the requirement to use function pointers/virtual functions and allow us to do high-performance dynamic class loading. I don't know if it is possible to modify functions that reside in the code segment. Does the operating system allow this? If not, we could place functions with these dynamic call sites on the heap. Thoughts?I like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries. -- Best regards, Vladimir mailto:thecybershadow gmail.com
Nov 03 2007
I like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
On Sat, 03 Nov 2007 15:40:34 +0200, Craig Black <craigblack2 cox.net> wrote:"Relocation data" is just a list of addresses which have pointers. I didn't express myself correctly, relocation data isn't used to resolve cross-module references. It is only used to "move" that code at a random address. To do that, the linker/loader adds the address to which the code is relocated to each DWORD the address of which is specified in the relocation list. References are resolved by having a list of symbols, and each symbol having an address of where in this module it's referenced. The linker/loader then simply places the address of each symbol into the referenced locations. Since this is done before any code in the module is executed, it should be possible to implement on all platforms (except platforms where code and data is strictly separated). -- Best regards, Vladimir mailto:thecybershadow gmail.comI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
"Vladimir Panteleev" <thecybershadow gmail.com> wrote in message news:op.t0741htdm02fvl cybershadow...On Sat, 03 Nov 2007 15:40:34 +0200, Craig Black <craigblack2 cox.net> wrote:Thanks for the explanation. So then modules can be loaded at run time, and this system effectively eliminates function pointers?"Relocation data" is just a list of addresses which have pointers. I didn't express myself correctly, relocation data isn't used to resolve cross-module references. It is only used to "move" that code at a random address. To do that, the linker/loader adds the address to which the code is relocated to each DWORD the address of which is specified in the relocation list. References are resolved by having a list of symbols, and each symbol having an address of where in this module it's referenced. The linker/loader then simply places the address of each symbol into the referenced locations. Since this is done before any code in the module is executed, it should be possible to implement on all platforms (except platforms where code and data is strictly separated). -- Best regards, Vladimir mailto:thecybershadow gmail.comI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
On Sat, 03 Nov 2007 18:28:13 +0200, Craig Black <craigblack2 cox.net> wrote:"Vladimir Panteleev" <thecybershadow gmail.com> wrote in message news:op.t0741htdm02fvl cybershadow...Yes, that's the goal and purpose of DDL. -- Best regards, Vladimir mailto:thecybershadow gmail.comOn Sat, 03 Nov 2007 15:40:34 +0200, Craig Black <craigblack2 cox.net> wrote:Thanks for the explanation. So then modules can be loaded at run time, and this system effectively eliminates function pointers?"Relocation data" is just a list of addresses which have pointers. I didn't express myself correctly, relocation data isn't used to resolve cross-module references. It is only used to "move" that code at a random address. To do that, the linker/loader adds the address to which the code is relocated to each DWORD the address of which is specified in the relocation list. References are resolved by having a list of symbols, and each symbol having an address of where in this module it's referenced. The linker/loader then simply places the address of each symbol into the referenced locations. Since this is done before any code in the module is executed, it should be possible to implement on all platforms (except platforms where code and data is strictly separated). -- Best regards, Vladimir mailto:thecybershadow gmail.comI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
Craig Black wrote:Here's how I understand it. DDL is a linker. The only difference between DDL and dmd/gcc is that it works at run time instead of compile time. What you described is basically what a linker does, hence what DDL does. -- DanielI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
"Daniel Keep" <daniel.keep.lists gmail.com> wrote in message news:fgi777$na4$2 digitalmars.com...Craig Black wrote:That's pretty cool then. Since we have DDL, can we effectively say that we have dynamic class loading? Or are features missing from DDL that make it not a full dynamic class loader? -CraigHere's how I understand it. DDL is a linker. The only difference between DDL and dmd/gcc is that it works at run time instead of compile time. What you described is basically what a linker does, hence what DDL does. -- DanielI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
On Sat, 03 Nov 2007 20:47:58 +0200, Craig Black <craigblack2 cox.net> wrote:"Daniel Keep" <daniel.keep.lists gmail.com> wrote in message news:fgi777$na4$2 digitalmars.com...DDL is, at the moment, defunct when it comes to compatibility with newer versions of the compiler - and it has been so for a while now. There have been recent talks of someone getting their hands dirty and bringing it up-to-date. -- Best regards, Vladimir mailto:thecybershadow gmail.comCraig Black wrote:That's pretty cool then. Since we have DDL, can we effectively say that we have dynamic class loading? Or are features missing from DDL that make it not a full dynamic class loader?Here's how I understand it. DDL is a linker. The only difference between DDL and dmd/gcc is that it works at run time instead of compile time. What you described is basically what a linker does, hence what DDL does. -- DanielI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
Vladimir Panteleev Wrote: [...]DDL is, at the moment, defunct when it comes to compatibility with newer versions of the compiler - and it has been so for a while now. There have been recent talks of someone getting their hands dirty and bringing it up-to-date. -- Best regards, Vladimir mailto:thecybershadow gmail.comAny chance to get this compatible to Phobos? As far as I could see, the thing relies on (M/T)ango, at least for I/O (which should be quite easily adjustable). Are there further complications involved? Ciao Tom
Nov 04 2007
Daniel Keep Wrote:Craig Black wrote:Its also what an operating does to load dynamic link libraries or shared objects.Here's how I understand it. DDL is a linker. The only difference between DDL and dmd/gcc is that it works at run time instead of compile time. What you described is basically what a linker does, hence what DDL does. -- DanielI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
"Bruce Adams" <tortoise_74 yeah.who.co.uk> wrote in message news:fgicuv$11j1$1 digitalmars.com...Daniel Keep Wrote:Right, but the operating system does not do this when loading dll's or so's at run-time.Craig Black wrote:Its also what an operating does to load dynamic link libraries or shared objects.Here's how I understand it. DDL is a linker. The only difference between DDL and dmd/gcc is that it works at run time instead of compile time. What you described is basically what a linker does, hence what DDL does. -- DanielI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 03 2007
Craig Black Wrote:"Bruce Adams" <tortoise_74 yeah.who.co.uk> wrote in message news:fgicuv$11j1$1 digitalmars.com...It depends on the operating system but generally yes it does. On some systems libraries are only loaded when they are first needed. On others they are loaded whent the program starts. And then there's usually a runtime API of some sort. LoadLibrary and GetProcAddress on windows. Those only half count because their too low level. I don't know much about DDL is it OS specific or portable?Daniel Keep Wrote:Right, but the operating system does not do this when loading dll's or so's at run-time.Craig Black wrote:Its also what an operating does to load dynamic link libraries or shared objects.Here's how I understand it. DDL is a linker. The only difference between DDL and dmd/gcc is that it works at run time instead of compile time. What you described is basically what a linker does, hence what DDL does. -- DanielI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 04 2007
"Bruce Adams" <tortoise_74 yeah.who.co.uk> wrote in message news:fgk1n1$et3$1 digitalmars.com...Craig Black Wrote:I think you are talking about delay loaded libraries. I'm talking about libraries that are loaded as plug-ins via LoadLibrary. In this case linking is done with something like GetProcAddress which provides a function pointer."Bruce Adams" <tortoise_74 yeah.who.co.uk> wrote in message news:fgicuv$11j1$1 digitalmars.com...It depends on the operating system but generally yes it does. On some systems libraries are only loaded when they are first needed. On others they are loaded whent the program starts. And then there's usually a runtime API of some sort. LoadLibrary and GetProcAddress on windows. Those only half count because their too low level. I don't know much about DDL is it OS specific or portable?Daniel Keep Wrote:Right, but the operating system does not do this when loading dll's or so's at run-time.Craig Black wrote:Its also what an operating does to load dynamic link libraries or shared objects.Here's how I understand it. DDL is a linker. The only difference between DDL and dmd/gcc is that it works at run time instead of compile time. What you described is basically what a linker does, hence what DDL does. -- DanielI like DDL's approach, in which it acts as a run-time linker. It uses relocation data in OBJ files to find address references and fix them (thus "relocating" the code for any memory address) when loading the libraries.Does this relocation use function pointers?
Nov 05 2007