[q-lang-users] q in Q
Brought to you by:
agraef
From: John C. <co...@cc...> - 2006-06-16 13:50:28
|
Albert Graef scripsit: > Yes, that should be possible, but I'm probably not the one who is going > to do it. ;-) I'd rather like to bootstrap Q in Q once we have native > compilation. Well, there's a few approaches to that. I presume a classical compiler to assembly language chain is out. Then there's compilation to C, or compilation to something else (Chicken, e.g.) that compiles to C. Then there is compilation to some standard byte code set with JIT compilation in place, like the JVM or the CLR. Any or all of these would probably make q-in-Q feasible. > I'm not sure about that. At least it would still need to do reference > counting, since I want objects encapsulating state to be cleaned up > (closing files, etc.) as soon as possible. This makes handling temporary > stateful objects much more convenient. Reference counting has its own costs, though, specifically the cost of recursive freeing, which is unpredictable in scope. Chicken has two garbage collectors, both stop-and-copy. The first one is intertwined with how Chicken uses the stack. All Scheme objects are initially allocated on the C stack, and each Scheme procedure is compiled into a C procedure which explicitly calls its continuation. However, the continuation never returns. Instead, when the stack gets full, all live Scheme objects are copied to the heap and a longjmp() is done to reset the stack. A regular Baker two-space collector is periodically run on the two halves of the heap. Any object can have a finalizer, which is run when the object becomes garbage. > > Chicken doesn't do native threads, though, only call/cc based ones. > > I guess that this would be a showstopper for me, with all the realtime > multimedia applications I'm doing. Q has a global interpreter lock, right? So all threads except one have to be running C code, but which one it is can change. I'm not sure whether Chicken can safely spawn OS threads, but if so, they can't be running Chicken code, at least not easily, given the mechanism explained above. The whole idea probably isn't practical. -- John Cowan <co...@cc...> Yakka foob mog. Grug pubbawup zink wattoom gazork. Chumble spuzz. -- Calvin, giving Newton's First Law "in his own words" |