www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - modifying the DMD compiler

reply Moritz <mpipahl gspgmbh.com> writes:
Hello,

Im a student of computer science and at university, we're working on a 
distributed shared memory system, implemented as a C library.

Im also a great fan of D, and so Im asking myself if I could connect D 
to the C library (which is no problem, as far as I know) and then modify 
the memory allocation of the compiler to place objects into the 
distributed memory (I would also need to disable garbage collection, but 
that should be no problem).

Ive already reviewed the sourcecode of the dmd (the parts of it that are 
shipped with the dmd) and found out malloc() is called in Mem.c

So I guess a rather simple way to do what I need would be to overwrite 
the new() operator or to add another operator to allocate distributed 
memory (something like new_shared() maybe).

But there are a lot of questions, which I would like to ask here, before 
I start to code...

1. The most elegant way to modify the compiler would be to create a 
class "sharable" and all objects inheriting from it would be created in 
distributed memory, but I guess this way would be rather complicated, 
wouldnt it?

2. Is a modification like the one with new_shared() or those described 
in 1 possible with the DMD or do I have to modify the GDC?

3. Any hints whatsoever to make my task easier?

Thanks in advance for your help!
Dec 13 2008
next sibling parent reply torhu <no spam.invalid> writes:
On 13.12.2008 17:16, Moritz wrote:
 Hello,

 Im a student of computer science and at university, we're working on a
 distributed shared memory system, implemented as a C library.

 Im also a great fan of D, and so Im asking myself if I could connect D
 to the C library (which is no problem, as far as I know) and then modify
 the memory allocation of the compiler to place objects into the
 distributed memory (I would also need to disable garbage collection, but
 that should be no problem).

 Ive already reviewed the sourcecode of the dmd (the parts of it that are
 shipped with the dmd) and found out malloc() is called in Mem.c

 So I guess a rather simple way to do what I need would be to overwrite
 the new() operator or to add another operator to allocate distributed
 memory (something like new_shared() maybe).
D supports 'placement new' like in C++: http://www.digitalmars.com/d/1.0/class.html#allocators If you're using Tango or dmd 2.x you can also replace the GC with your own version if you need to.
Dec 13 2008
next sibling parent "Jarrett Billingsley" <jarrett.billingsley gmail.com> writes:
On Sat, Dec 13, 2008 at 1:25 PM, torhu <no spam.invalid> wrote:
 On 13.12.2008 17:16, Moritz wrote:
 Hello,

 Im a student of computer science and at university, we're working on a
 distributed shared memory system, implemented as a C library.

 Im also a great fan of D, and so Im asking myself if I could connect D
 to the C library (which is no problem, as far as I know) and then modify
 the memory allocation of the compiler to place objects into the
 distributed memory (I would also need to disable garbage collection, but
 that should be no problem).

 Ive already reviewed the sourcecode of the dmd (the parts of it that are
 shipped with the dmd) and found out malloc() is called in Mem.c

 So I guess a rather simple way to do what I need would be to overwrite
 the new() operator or to add another operator to allocate distributed
 memory (something like new_shared() maybe).
D supports 'placement new' like in C++: http://www.digitalmars.com/d/1.0/class.html#allocators If you're using Tango or dmd 2.x you can also replace the GC with your own version if you need to.
He's... he's modifying the DMD source, which is in C++.
Dec 13 2008
prev sibling parent Brad Roberts <braddr puremagic.com> writes:
Jarrett Billingsley wrote:
 On Sat, Dec 13, 2008 at 1:25 PM, torhu <no spam.invalid> wrote:
 On 13.12.2008 17:16, Moritz wrote:
 Hello,

 Im a student of computer science and at university, we're working on a
 distributed shared memory system, implemented as a C library.

 Im also a great fan of D, and so Im asking myself if I could connect D
 to the C library (which is no problem, as far as I know) and then modify
 the memory allocation of the compiler to place objects into the
 distributed memory (I would also need to disable garbage collection, but
 that should be no problem).

 Ive already reviewed the sourcecode of the dmd (the parts of it that are
 shipped with the dmd) and found out malloc() is called in Mem.c

 So I guess a rather simple way to do what I need would be to overwrite
 the new() operator or to add another operator to allocate distributed
 memory (something like new_shared() maybe).
D supports 'placement new' like in C++: http://www.digitalmars.com/d/1.0/class.html#allocators If you're using Tango or dmd 2.x you can also replace the GC with your own version if you need to.
He's... he's modifying the DMD source, which is in C++.
While he's asked about how to modify the compiler, I suspect what he's really interested is in modifying the runtime so that applications that are written in D can take advantage of what he's doing. Modifying the compiler would be of minimal value. Later, Brad
Dec 13 2008
prev sibling parent Moritz <moritz.pipahl uni-duesseldorf.de> writes:
Brad Roberts Wrote:

 Jarrett Billingsley wrote:
 On Sat, Dec 13, 2008 at 1:25 PM, torhu <no spam.invalid> wrote:
 On 13.12.2008 17:16, Moritz wrote:
 Hello,

 Im a student of computer science and at university, we're working on a
 distributed shared memory system, implemented as a C library.

 Im also a great fan of D, and so Im asking myself if I could connect D
 to the C library (which is no problem, as far as I know) and then modify
 the memory allocation of the compiler to place objects into the
 distributed memory (I would also need to disable garbage collection, but
 that should be no problem).

 Ive already reviewed the sourcecode of the dmd (the parts of it that are
 shipped with the dmd) and found out malloc() is called in Mem.c

 So I guess a rather simple way to do what I need would be to overwrite
 the new() operator or to add another operator to allocate distributed
 memory (something like new_shared() maybe).
D supports 'placement new' like in C++: http://www.digitalmars.com/d/1.0/class.html#allocators If you're using Tango or dmd 2.x you can also replace the GC with your own version if you need to.
He's... he's modifying the DMD source, which is in C++.
While he's asked about how to modify the compiler, I suspect what he's really interested is in modifying the runtime so that applications that are written in D can take advantage of what he's doing. Modifying the compiler would be of minimal value. Later, Brad
First of all, thank you for your answers. Im not really interested in modifying the source, I thought I had no other choice to get objects into our shared memory. But I guess the 'placement new' solution will work perfectly for me, so theres no need to touch the holy DMD :-)
Dec 15 2008