[squeak-dev] Re: Using V8 for other languages

Igor Stasenko siguctua at gmail.com
Thu Sep 4 17:44:43 UTC 2008


2008/9/3 Eliot Miranda <eliot.miranda at gmail.com>:
>
>
> On Wed, Sep 3, 2008 at 8:05 AM, David Griswold
> <david.griswold.256 at gmail.com> wrote:
>>
>> After sleeping on it, I woke up and realized that V8 is almost certainly
>> not multi-threaded at the client code level (within a single VM instance),
>> since they have that indirection... the indirection sounds more like a
>> traditional object table, like VisualWorks, and I don't see how they could
>> possibly have made something like that multi-threaded since performance
>> would critically depend on caching the body pointer within a method
>> activation.  But they can't do that because another method might be adding
>> or removing properties while the method is running, and that is way too
>> fine-grained to be doing any kind of check.
>
> Look at include/v8.h which explains the concurrency model which sounds very
> similar to Strongtalk:
>  * Multiple threads in V8 are allowed, but only one thread at a time
>  * is allowed to use V8.  The definition of 'using V8' includes
>  * accessing handles or holding onto object pointers obtained from V8
>  * handles.  It is up to the user of V8 to ensure (perhaps with
>  * locking) that this constraint is not violated.
>  *
>  * If you wish to start using V8 in a thread you can do this by constructing
>  * a v8::Locker object.  After the code using V8 has completed for the
>  * current thread you can call the destructor.  This can be combined
>  * with C++ scope-based construction as follows:
>  *
>  * \code
>  * ...
>  * {
>  *   v8::Locker locker;
>  *   ...
>  *   // Code using V8 goes here.
>  *   ...
>  * } // Destructor called here
>  * \endcode
>  *
>  * If you wish to stop using V8 in a thread A you can do this by either
>  * by destroying the v8::Locker object as above or by constructing a
>  * v8::Unlocker object:
>  *

[ snip ]

This indicates that VM is written with no concurrency in mind.
They did a simplest possible thing: use a global lock to enable
calling VM functions from many threads. But only single thread could
use it at some point of time.

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list