[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Conversion of pointers to integers and vice versa; pointer tagging
- To: jit@gcc.gnu.org
- Subject: Conversion of pointers to integers and vice versa; pointer tagging
- From: Marc Nieper-Wißkirchen <marc.nieper+gnu@gmail.com>
- Date: Tue, 1 Jan 2019 12:00:58 +0100
- Authentication-results: sourceware.org; auth=none
- Delivered-to: listarch-jit@gcc.gnu.org
- Delivered-to: mailing list jit@gcc.gnu.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=wrkyLkKEwf3MQ1O52tmBuwe8hujPdM/0D+OQe2xcGzY=; b=Sb72U5IhPPd6POez0RXxwINHh4/0ztmPml0zlaizoAVNvcHWQMRZfN3hbp5kPcYl5d r2uyShiDclDumMRpn4wAKh3m98A72TE/5xlGOP5fug+iZ/tH/qmhPi05JUnhKkQbZpPM o2dmR6JbizuHFVRqyuHJ8qU7+Hqi/tMGD9Wx3iJM2s8uIUFZwdGkNIC8ZZHV++1lasIe wUJ2kVVEvBRRRnVK/rdCZgUlqcYyHPjb3SnmscgiVVZBVoY4ceq3gBFvomZ9kidT9ClE NqK/stAAY3gNZbqqxyEhNXHQfmtgZ9JXvpjJ8XEFTO6qg5WuHuTwbRY/ejanEaVDG0Qd rIYg==
- List-help: <mailto:jit-help@gcc.gnu.org>
- List-post: <mailto:jit@gcc.gnu.org>
- List-subscribe: <mailto:jit-subscribe@gcc.gnu.org>
- Mailing-list: contact jit-help@gcc.gnu.org; run by ezmlm
- Sender: jit-owner@gcc.gnu.org
Implementations of languages with garbage collection and dynamic
typing often employ the concept of tagged pointers. Unused bits of a
pointer representation are used to distinguish between pointers to
different types or between pointers and immediate values.
Implementing such a language with libgccjit raises a couple of questions:
1) libgccjit has currently only a limited set of type-casting
expressions. In particular, there is no type-casting expression
between an integer type (e.g. uintptr_t) and a pointer type defined.
Are there technical reasons for that or is that just an area where
libgccjit still has to be complemented?
I guess, a workaround could be to use union types à la
union {
uintptr_t i;
void *p;
}
everywhere.
2) For pointer tagging, one needs to know which bits in the integer
representation of a pointer are unused. Does GCC make the guarantee
that on all supported platforms a pointer aligned on a 2^d-byte
boundary has its lower d bits zeroed? Is pointer arithmetic compatible
with the arithmetic on the underlying integer type? (I know that ISO C
does not make these guarantees, but we are talking about a particular
implementation here.)
3) One may want to use bit fields when implementing tags. The
documentation for libgccjit seems to be silent on bit fields in
structures. Is this feature on the TODO list?
Thanks!
-- Marc
P.S.: A Happy New Year to everyone!