Hey Michael, I'm also interested in co-routines for V8 and was running into a very similar problem this weekend. I think the problem is that setjmp(2)/ longjmp(2) does not properly integrate with V8's notion of what threads are. In fact, I've produced a small-ish test-case for this behavior http://gist.github.com/577360.
Running this results in the following output starting v8 in callback ... foo! # # Fatal error in src/api.h, line 384 # CHECK(blocks_.length() == 0) failed # Abort trap >From what I can tell, the problem is that the V8 runtime needs to be able to rely on implementations of v8::internal::Thread and v8::internal::ThreadHandle to provide correct thread local storage semantics. The test case that I posted above runs into assertion failures because the V8 execution on the alternate stack is still referencing the thread-local state from the first stack. Can someone from the V8 team weigh in on this? If one wishes to use setjmp(2) (and friends) or setcontext(2) (and friends), what needs to be done to coerce V8 into playing nicely with these foreign control flow semantics? It seems that alternate implementations of some combination of Thread and ThreadHandle (and others?) are needed. Thanks, Peter On Sun, Sep 12, 2010 at 1:02 AM, Michael Carter <[email protected]>wrote: > > > On Sat, Sep 11, 2010 at 10:21 PM, malcolm handley < > [email protected]> wrote: > >> Are you determined to do this with a single thread? I had good results >> implementing a fiber API in with v8 where I used a separate pthread for each >> fiber. I assume that you could support continuations that way too. >> >> > Yes, I am determined to do this with a single thread; in fact, the main > purpose of this exercise is to avoid the overhead of threads. Regardless, I > appreciate the response. > > Thanks, > > Michael Carter > > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- @pgriess <http://twitter.com/pgriess> / http://blog.std.in -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
