Talk:Tagged pointer

Use in ObjC
The references to iOS 7 and iPhone 5s feel dated, unless (and highly improbably) for some reason tagger pointers were only used in that specific combination of O/S and device. --  Raybellis (talk) 09:45, 18 September 2018 (UTC)


 * That's the first release of iOS/iPhone which used tagged pointers (and quite possibly the first smartphone OS to do so), but they were also used on iOS 7.1, iOS 8, iPhone 6, and so on. The address sizes and alignment may have changed in future versions, which is probably why those specific versions were mentioned.  Could it be worded more clearly to indicate that all future iOS (and contemporary macOS) releases still use tagged pointers?  — Preceding unsigned comment added by 73.109.4.101 (talk) 21:48, 6 September 2020 (UTC)


 * I think recent versions of ARM added more hardware support for tagged pointers. That could also be included. Operator-zeta (talk) 16:14, 5 January 2022 (UTC)

Tagged pointers in OCaml
This article is rather C-specific. It doesn't cover how tags are used in functional languages at all. In Lisp, tags are pretty fundamental, so much so that often special hardware is used (eg. Lisp machines, SPARC). OCaml uses the least significant bit to tag the difference between pointers and integers. See here for an analysis of the (surprisingly minimal) performance impact: http://caml.inria.fr/pub/ml-archives/caml-list/2004/07/e86a25aa6c6a6a7d08dd7eb50cfd5d52.en.html Richard W.M. Jones 13:29, 3 December 2006 (UTC)

I agree. I was expecting to see the years of history on this subject. As you mention LISP started it. The first time I saw it, it was in Smalltalk. I think it would be good to cover the history and current practices used today. For example, today they use the IEEE-754 NaN space to store information about the 'tag' which is fairly clever. That way Doubles don't lose any precision. The link to tagged architectures in hardware is also pretty weak. I will spend some time on this to provide information here soon. — Preceding unsigned comment added by Drudru (talk • contribs) 20:08, 13 November 2012 (UTC)

Literal 0 vs. all-bits-zero
The C example mentions "0", but that doesn't mean that a C null pointer looks the same as a pointer to memory location 0.

The C language only guarantees that if the integer 0 is converted to a pointer, the resulting pointer will be the (a?) system-specific null pointer. This *may* be a pointer to address 0 (i.e. a pointer word with all-bits-zero) but this is not guaranteed; the contents of the pointer memory cell might as well be, say, 0xDEADBEEF, as long as the system guarantees that such a pointer will, when converted to an integer, give 0 as the answer. -- pne (talk) 10:44, 13 May 2009 (UTC)

Use of the high bits
With current early-generation 64-bit machines like AMD64, high address bits are dropped. An interesting scheme is used to prevent pointers with these bits set from being loaded into the wrong registers or dereferenced. Of course any system that tries to use those bits for tagging will be obselete at the point when the full virtual address space begins to be utilized.

But where do we draw the semantic line between tagged pointers using the high bits and the various segment/area/aperture based tricks that have been used for ages on various architectures, and VM arenas? —Preceding unsigned comment added by 71.192.212.78 (talk) 02:01, 29 June 2009 (UTC)

Meaningless (almost) examples
The examples, as they are written now, are meaningless. It's not me that is stupid – instead the author of them thought out some smart things in a sequence and forgot to mention 50% of them, such as in the example 1 we are using a pointer to an integer (usually a case where a C programmer is not providing a heap object!), where immediatelly before the integer value a tag is stored to mark that this thingie is not a pointer. The code and example 1 text provides no info that correlates specifically to tagged pointers.

The example 2 weirdly enough presents no code, except an execution structure inside a code. It is just a skeleton saying nothing, except that null pointers and sentinels shall be treated differently from pointers, which was already said in the intro. It provides nothing new, and can instead be replaced by simple text.

Example 3 has some merit, but might profit from a figure where the tag bit is pointed out by an arrow. It should instead be example 1. Current example 1 (--&gt; 2) can describe how the tag bit is removed for operations on the data, current example 2 (--&gt; 3) can more elaborately describe how the tag bit is extracted and how f.ex. garbage collector code is acting on it, expanding the code comments in the current if/if else/else-structure.

// comments are not valid C (except in C99 and further on). ... said: Rursus ( m bork³ ) 19:29, 29 September 2009 (UTC)

Arm 8.5 hardware support
It looks like Arm just added hardware support for memory tagging. https://community.arm.com/processors/b/blog/posts/arm-a-profile-architecture-2018-developments-armv85a Chris Dolan (talk) 14:11, 19 September 2018 (UTC)

"Null versus aligned pointer" section
I've read the "Null versus aligned pointer" section a couple times. I'm having trouble understanding how it's related to tagged pointers at all. Even the title is confusing: tagged pointer architectures obviously still have null pointers.

Furthermore, the entire section has no external references, except to parts of the GNU and Linux manuals related to pointer alignment in general. It's full of weasel words and phrases like "It is generally accepted practice in software design" and "these uses appear to be rare".

Can anyone make out what it's trying to say, and how it's related to tagged pointers? The only thing I can guess is that it's referring to application programmers tagging the NULL pointer, only, in order to create a global set of sentinel values for use in pointer variables. But in 4 paragraphs, it never actually says that outright, so I'm not sure if that's what it means or not. I've never heard of any system doing that.

I'm leaning towards just deleting this section. There's a lot of useful information that can be said about tagged pointers (Mike Ash's blog has some good articles), and I don't see how this section contributes at all. — Preceding unsigned comment added by 73.109.4.101 (talk) 22:03, 6 September 2020 (UTC)