View previous topic :: View next topic |
Author |
Message |
Hxal
Joined: 26 Nov 2007 Posts: 2
|
Posted: Mon Nov 26, 2007 3:57 am Post subject: Question about coroutines, JIT |
|
|
I noticed that you use Tango.Fiber to yield out of D functions, but not out of the interpreter with D functions on the call stack. Wouldn't it be possible to use Tango.Fiber in the yield instruction if (and possibly only if) a D function was on the call stack - and therefore lift the restriction on coroutines?
On a side note, have you considered adding a JIT, possibly modelled after LuaJIT? There's a C library (libjit) from the dotGNU project that perfroms JIT code generation for x86 - that could provide some start. |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon Nov 26, 2007 8:10 am Post subject: |
|
|
Quote: | Wouldn't it be possible to use Tango.Fiber in the yield instruction if (and possibly only if) a D function was on the call stack - and therefore lift the restriction on coroutines? |
You don't know how much I'd love to lift that restriction but unfortunately since the interpreter can't predict when a native function or metamethod is going to be called, in order for this to work, it'd have to put every MDState in its own Fiber, greatly increasing the cost of creating and using coroutines.
Quote: | On a side note, have you considered adding a JIT, possibly modelled after LuaJIT? There's a C library (libjit) from the dotGNU project that perfroms JIT code generation for x86 - that could provide some start. |
I've considered it. I wonder how much speed could be gained by doing something as simple as converting all the MiniD opcodes into their native API equivalents and compiling that code. Probably not all that much, since that'd basically be skipping the IF/ID stages and not much else. LuaJIT is amazingly advanced and probably way out of my league right now, but I'd definitely like to take a look at what it does and how it does it.
But mostly what I'm concerned with now is getting a relatively reliable and fast interpreter going |
|
Back to top |
|
|
Hxal
Joined: 26 Nov 2007 Posts: 2
|
Posted: Tue Nov 27, 2007 8:33 am Post subject: |
|
|
JarrettBillingsley wrote: | it'd have to put every MDState in its own Fiber, greatly increasing the cost of creating and using coroutines. |
How about a subclass of MDState or simply an option for an MDState to allocate and switch to a Fiber. Op.Yield could then check if the MDState is running in a Fiber and make use of the fact.
PS. I timed Fiber switch times and they seem to be quite acceptably fast. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|