Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

inconsistency in Get/set private data

4 views
Skip to first unread message

rethish

unread,
Sep 25, 2006, 11:42:04 AM9/25/06
to dev-tech-...@lists.mozilla.org
Hi;

If I do the following operation

a = PRIVATE_TO_JSVAL(7);

b = JSVAL_TO_PRIVATE(a);

I get b's value as '6'. !

Can't I set anyt integar value to private?

Can this operation be done only on pointers?

Thanks & regards

Rethish

This e-mail and attachments contain confidential information from HUAWEI,
which is intended only for the person or entity whose address is listed
above. Any use of the information contained herein in any way (including,
but not limited to, total or partial disclosure, reproduction, or
dissemination) by persons other than the intended recipient's) is
prohibited. If you receive this e-mail in error, please notify the sender by
phone or email immediately and delete it

John Bandhauer

unread,
Sep 25, 2006, 12:56:30 PM9/25/06
to
You (and everyone else who uses JSAPI) would be wise to read and
understand the JSVAL macros at the top of jsapi.h.

John.

Boris Zbarsky

unread,
Sep 25, 2006, 6:29:27 PM9/25/06
to
rethish wrote:
> Can't I set anyt integar value to private?
>
> Can this operation be done only on pointers?

Yes. In fact, the private pointer needs to be 8-byte aligned.

-Boris

John Bandhauer

unread,
Sep 25, 2006, 9:59:52 PM9/25/06
to

Hey Boris,

I'm curious why you added the comment about 8-byte alignment. The
PRIVATE macros just tag and untag the 0th bit. From the engine's
perspective, this makes a private jsval indistinguishable from any
other int jsval. That bit is all it takes for the engine to know this
is not a gcthing. Why would the 'full' 31 bits not be available to the
api user? I can't think of any way that the engine would care about
the state of the other 2 low bits. Am I missing something?

John.

>
> -Boris

Boris Zbarsky

unread,
Sep 25, 2006, 10:06:54 PM9/25/06
to
John Bandhauer wrote:
> I'm curious why you added the comment about 8-byte alignment. The
> PRIVATE macros just tag and untag the 0th bit.

Ah, right. We're talking about private pointers, not gcthing pointers being
stored in a jsval. The latter need to be 8-byte aligned. The private pointers
just need to be 2-byte aligned...

-Boris

0 new messages