Message from discussion
Associating metadata with non-objects
Received: by 10.68.19.200 with SMTP id h8mr30824pbe.56.1304449720923;
Tue, 03 May 2011 12:08:40 -0700 (PDT)
X-BeenThere: v8-users@googlegroups.com
Received: by 10.68.39.41 with SMTP id m9ls1126059pbk.2.gmail; Tue, 03 May 2011
12:08:39 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.68.7.227 with SMTP id m3mr30901pba.40.1304449719245; Tue, 03
May 2011 12:08:39 -0700 (PDT)
Received: by 35g2000prp.googlegroups.com with HTTP; Tue, 3 May 2011 12:08:39
-0700 (PDT)
Date: Tue, 3 May 2011 12:08:39 -0700 (PDT)
In-Reply-To: <BANLkTimdcH1e41WEMTGBa_vcE0ttrNkV4A@mail.gmail.com>
X-IP: 75.92.8.51
References: <e2ebd362-6081-41a1-854e-f216fcb0097e@hg8g2000vbb.googlegroups.com>
<BANLkTik_vkX1nr1Vjzmay+q0BPuVB4dj4g@mail.gmail.com> <BANLkTimbrJ8rYkUW+wRq5035BKhV+JyK8w@mail.gmail.com>
<BANLkTi=ncT66siZEipTGcgmgnJt=LHZjdA@mail.gmail.com> <BANLkTinj_Ea2XvcP4qYD-rCVPs2QZaR3QQ@mail.gmail.com>
<BANLkTinBUx6f_=j_BWO6JTNCchRNnf2cDw@mail.gmail.com> <3047ddb1-10a2-4246-938b-9e154d32d9ee@d28g2000yqf.googlegroups.com>
<BANLkTimdcH1e41WEMTGBa_vcE0ttrNkV4A@mail.gmail.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7)
AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24,gzip(gfe)
Message-ID: <e2b17c9b-4ed9-48ab-b7ee-63a736daa552@35g2000prp.googlegroups.com>
Subject: Re: Associating metadata with non-objects
From: Charles Lowell <cowb...@thefrontside.net>
To: v8-users <v8-users@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On May 3, 11:35=A0am, Stephan Beal <sgb...@googlemail.com> wrote:
> On Tue, May 3, 2011 at 3:41 PM, Charles Lowell <cowb...@thefrontside.net>=
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 th=
e
> Template and not on a per-instance basis. e.g. the Regex authors didn't s=
et
> aside an internal field for our use then we cannot stuff an internal fiel=
d
> in those instances.
>
Indeed, but Mads mentioned at the very end of his response that there
was a way to roll your own for values, and I'm curious to hear what he
had in mind.
cheers,
Charles
> --