Yes, this is a well-known technique: have a pointer to memory where a
real pointer to object resides.

I think everyone who wants to use the V8 engine will start studying
v8.h because it defines an external interface to the V8 engine.
Studying Handle<T> he or she will find that a handle contains a
pointer to the object. The code of the operator '==' shows internal
meaning of the pointer. It looks like a glass floor in a car when you
can see how "interface parts" of the car you use are connected to the
car engine and etc. :)
The best way is to have defiinition of the operator '==' in .cc file,
but this affects performance.

However I got valuable information.

On Apr 1, 5:54 pm, Anton Muhin <[email protected]> wrote:
> It's not about tight coupling, but about level of indirecton.  v8 uses
> several moving gc algorithms.  for example, sailfish (js engine in
> Safari, e.g.) doesn't use moving algorithms and thus doesn't need
> handles at all.
>
> yours,
> anton.
>
>
>
> On Thu, Apr 1, 2010 at 5:31 PM, Evgeny Astigeevich <[email protected]> wrote:
> > Thanks a lot.
> > This explains the code completely.
> > For me it's strange to have an abstraction of handle with tight
> > coupling to the internal implementation of handles. Guess this is done
> > due to perfomance reasons.
>
> > On Apr 1, 5:07 pm, Anton Muhin <[email protected]> wrote:
> >> Sorry about assert, it's in internal handles (v8::internal::Handle).
>
> >> Despite it's name val_ in v8::Handle is actually
> >> v8::internal::Object** ---it's a location where a pointer to actual v8
> >> object is stored.  v8's garbage collector is aware of all such handles
> >> and would update v8::internal::Object* pointers when object is moved.
>
> >> To see the problem you need the code like that (sorry, is not tested).
>
> >> Local handleA(some object);
> >> Local handleB(*handleA);
>
> >> with your change handleA != handleB (as they use different locations
> >> to store pointers---their val_ should be different).  W/o handleA ==
> >> handleB as both point to the same object.
>
> >> yours,
> >> anton.
>
> > --
> > v8-dev mailing list
> > [email protected]
> >http://groups.google.com/group/v8-dev
>
> > To unsubscribe, reply using "remove me" as the subject.

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to