FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question about coroutines, JIT

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
Hxal



Joined: 26 Nov 2007
Posts: 2

PostPosted: Mon Nov 26, 2007 3:57 am    Post subject: Question about coroutines, JIT Reply with quote

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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Mon Nov 26, 2007 8:10 am    Post subject: Reply with quote

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 Smile 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 Smile
Back to top
View user's profile Send private message
Hxal



Joined: 26 Nov 2007
Posts: 2

PostPosted: Tue Nov 27, 2007 8:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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