[webkit-dev] JavascriptCore and Multiple Threads

Martijn Scheffer martijn.s at gmail.com
Wed May 18 13:29:02 PDT 2011


I hope i'm sending this mail to the right address, forgive me if i'm wrong..

i selected JavascriptCore over the competition because i read that
it's thread safe.

but, i can't get it to work from within threads with crashing.

the first version of my test was using one context, created with
JSGlobalContextCreateInGroup , and two threads calling
JSEvaluateScript

the first thread was evaluating this->

for(a = 0; a< 10000; a++) {
 print(a)
}

print is simply a function that calls printf.

the second thread was evaluating

for(b = 0; b< 10000; b++) {
 print(b)
}

i'm not even accessing the same variable, but it still crashes.

the second version of my test was using one context per thread, part
of the same group, and i got the same result, some ASSERT function
creating a BAD_ACCESS error.

i was really hoping that i could actually have multiple concurrent
scripts accessing the same objects, at the same time (you can never
predict what the developer of the scripts wants to do)

i tried both versions of my tests with boost threads, and with the
threading library built in JavascriptCore <wtf/Threading.h>

so i can say i'm a bit disappointed !, what am i doing wrong ? or is
this just impossible ?
in that case, what's all that threading/ locking/ mutex etc code for ?

Martin


More information about the webkit-dev mailing list