On Tue, May 3, 2011 at 3:41 PM, Charles Lowell <[email protected]>wrote:

> into Ruby like Context and FunctionTemplate. That said, being able to
> get a stable, unique object id for all values would be killer. You
> mentioned that it would be relatively straightforward to roll your
> own? Any chance you could elaborate?
>

For OBJECTS you can presumably use the identity hash, but for non-Objects v8
does not publish a _stable_ unique ID. You can get a (void *) to the
underlying data (Value::Data(), IIRC), which could then be used as a key,
but that address is not guaranteed to be stable - v8 may relocate it as a
side-effect of allocation/gc.

When i first started porting my SpiderMonkey JS/C++ type conversions
framework to v8. that lack of a stable ID was my first big hurdle, and
eventually gave up on the idea that one can tie a (T*) to a JS integer in
v8.

For builtin Object types (Date, Regex, etc) you can't stuff your own
mappings into them because the number of internal fields is defined by the
Template and not on a per-instance basis. e.g. the Regex authors didn't set
aside an internal field for our use then we cannot stuff an internal field
in those instances.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

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

Reply via email to