View previous topic :: View next topic |
Author |
Message |
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Sat May 26, 2007 8:30 pm Post subject: Status of dynamic library loading -- and ... tango |
|
|
Okay, so I've been trying to get dynamic module loading working, so you'd be able to do something like:
Code: |
module test;
import mylib;
mylib.someFunc(5);
|
in MiniD, and it would look for mylib.dll, load it, load the symbols out of it, and then you'd be able to access all the stuff that mylib exposes.
The problem with this is that DLLs in D are terrible. The biggest problem is that typeinfo is duplicated, so for example the MDString in the host is not the same as the MDString in the DLL, and this messes up all kinds of stuff. Another issue is the size -- every DLL ends up having the entire MiniD library embedded in it, meaning that it's going to be at least ~500KB. This one I'm not so sure whether it's a problem or just something I'm doing wrong. Another issue is the GC -- even though the DLL sets its GC handle to the host application's handle, there still seem to be issues when the DLL is unloaded. You'll notice that the DLL example on the D spec cleverly avoids having any memory allocated in the DLL when it's unloaded, and doesn't mention what happens otherwise.
Given all these issues, and given that I don't even know where to start with SOs or what their abilities/problems are, I'm thinking I'll wait for DDL to get updated and use that instead. It'll be cross-platform, it'll solve the typeinfo issue, it'll solve the size issue, and it'll solve the GC issue.
[edit]DDL, being based on Tango (or at least in the near future it will be), necessitated MiniD's switch to Tango. The conversion is now complete; all that remains for dynamic libraries now is for DDL to be completed.[/edit]
Last edited by JarrettBillingsley on Mon Aug 13, 2007 8:27 am; edited 4 times in total |
|
Back to top |
|
|
csauls
Joined: 27 Mar 2004 Posts: 278
|
Posted: Mon May 28, 2007 10:05 am Post subject: |
|
|
<snob>Do not cough at me, sir.</snob>
I've been working on some other things the last week or so, so I admit I haven't looked at the MiniD/Tango conversions lately. BUT, I shall. Tangobos is improving at bounds as well, so its becoming more and more likely to make a reasonable bridge.
That said: I also think DDL might be the best (or at least easiest) way to do what you want. _________________ Chris Nicholson-Sauls |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon May 28, 2007 11:20 am Post subject: |
|
|
MiniD compiles splendidly under tangobos, you'll be pleased to hear. It just requires a few comments in the tangobos headers to resolve some linking issues, but now Gregor knows about this, so..
Unfortunately I've been messing with Tango proper for the last day or so and I'm really not pleased with it at all. Its formatting, text handling, IO, and general design philosophy don't really match up at all with how MiniD and my code are designed, nor with how my brain works.
I'll give it some more time, but I'm starting to seriously wonder if this is such a good idea. |
|
Back to top |
|
|
qbert
Joined: 30 Mar 2004 Posts: 209 Location: Dallas, Texas
|
Posted: Mon May 28, 2007 6:04 pm Post subject: |
|
|
It takes some time to get used to Tango , but after the initial steep curve it pays off by being much more flexible ( and fast!).
But I think DDL uses only phobos ? |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon May 28, 2007 6:15 pm Post subject: |
|
|
As of now, perhaps, but have a look at the DDL repo -- recently there have been some commits, and all the newly-updated files use Tango, so there's probably a switch underway. |
|
Back to top |
|
|
qbert
Joined: 30 Mar 2004 Posts: 209 Location: Dallas, Texas
|
Posted: Mon May 28, 2007 6:38 pm Post subject: |
|
|
Ahh I see, I know Deadlock uses the phobos version of DDL , so you might hit them up for their version, just a thought .
Charlie |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon May 28, 2007 7:40 pm Post subject: |
|
|
An all-phobos version? Or does it still depend on the old (pre-Tango) mango, as DDL does now? |
|
Back to top |
|
|
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Tue May 29, 2007 8:54 am Post subject: |
|
|
Wow, now this is interesting news. I've been following MiniD for a while now, and I honestly thought you were going to (eventually) create your own module format that is more closely tied to your VM?
DDL is indeed going the Tango route, and I am in the process of porting things over. So far, things are kind of a mess, but the results are encouraging. _________________ -- !Eric.t.Anderton at gmail |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Tue May 29, 2007 3:02 pm Post subject: |
|
|
Ahh, there are already MiniD code modules -- it's basically the bytecode serialized out to a file. Where DDL comes in is writing native D modules that expose a MiniD interface. Think pygame |
|
Back to top |
|
|
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Tue May 29, 2007 3:39 pm Post subject: |
|
|
JarrettBillingsley wrote: | Ahh, there are already MiniD code modules -- it's basically the bytecode serialized out to a file. Where DDL comes in is writing native D modules that expose a MiniD interface. Think pygame |
Ahh... that makes sense. Thanks for clearing that up. _________________ -- !Eric.t.Anderton at gmail |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Sun Jun 03, 2007 8:25 pm Post subject: |
|
|
OK, so MiniD is virtually converted over to Tango. I was able to remove tangobos from the include paths today There are, however, a few issues.
- There is a linking issue with tango.text.Regex. Sean doesn't have any problems with it though, so either something's weird on his end or something's weird on my end, but he's looking into it regardless. In the meantime, it can be made to work by commenting out one line in tango.text.Regex -- though I'd hardly call that a solution.
- Formatting has changed. Output formatting is a mix between Tango and Phobos formatting -- it uses the {} style of formatting specifiers, but you can output things without a format string, and any parameter can be a format string like in Phobos. The problem is input formatting: there is none. Tango doesn't provide any kind of readf mechanism, so it'll either have to be implemented manually, or it'll have to wait until such a time that Tango acquires it.
- All the free-standing functions in the IO stdlib were (mostly) easy to port. The problem is the Stream class, and by proxy the File function and stdin/out/err variables. Phobos' streams don't really have any kind of 1:1 mapping to Tango's IO constructs. Tango's IO API is certainly more powerful and flexible than Phobos', but MiniD doesn't need quite as much abstraction and flexibility as Tango provides. This may be ameliorated in the near future with the introduction of the Input/OutputStream classes in Tango, which may make it possible to have maybe two or three classes in the MiniD IO library, rather than the several which would be necessary now.
In the meantime, I probably won't upload anything until at least the Regex linking issue is resolved. It probably won't have any file or input support, but at least there's still write[f][ln]. |
|
Back to top |
|
|
qbert
Joined: 30 Mar 2004 Posts: 209 Location: Dallas, Texas
|
Posted: Mon Jun 04, 2007 6:56 pm Post subject: |
|
|
Good to hear , this will make MiniD much more accesible for me and other Tango users . Also good to hear Tango is going with an alternative, simpler Input/Output class!
Charlie |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Mon Jun 04, 2007 9:03 pm Post subject: |
|
|
qbert wrote: | ... good to hear Tango is going with an alternative, simpler Input/Output class!
Charlie |
Not quite accurate, Charles ... the changes do not imply a secondary means of handling IO. Instead, tango.io allows some entities to masquerade as streams instead. For example, Conduit is actually a host for two streams -- InputStream & OutputStream -- so it can be applied in that manner if you prefer. Under the covers it's the same, and you still open files, sockets and so on in the same way. In short, it's backward compatible
Last edited by kris on Mon Jun 04, 2007 9:39 pm; edited 2 times in total |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon Jun 04, 2007 9:04 pm Post subject: |
|
|
Quote: | Also good to hear Tango is going with an alternative, simpler Input/Output class! |
So am I. That buffers, filters, and conduits will basically be entirely interchangeable makes a lot more sense to me than how it was before. |
|
Back to top |
|
|
|