[m-dev.] foreign types and tag bits
Ian MacLarty
maclarty at cs.mu.OZ.AU
Fri Feb 17 06:07:16 AEDT 2006
Hello,
Suppose I have a type like the following:
:- type t
---> f1(foreign_t)
; f2(foreign_t).
where foreign_t is a foreign type.
Suppose also that foreign_t is a word aligned C pointer.
Will the compiler be able to use the tag bits of the C pointer to
implement the type t, or will the foreign type argument end up getting
boxed.
I think they will have to be boxed, since the two current assertions on
foreign_type declarations (can_pass_as_mercury_type and stable) don't
give enough information to know whether the tag bits can be used.
I think there should be another assertion `is_aligned_pointer' which
will allow the tag bits to be used.
Does anyone see any problems with this? Would it be hard to implement?
The reason I'm asking is I've having a look at making version_array's
faster and it occured to me that I could use the tag bits to decide if
the version array is the latest version or not, which would mean
version_array lookups would be as efficient as array looks (for the
latest version), since you'd only need to dereference one pointer.
Currently you must first dereference the foreign_type pointer to find
out if the va is the latest version, and then you must dereference the
array pointer.
Ian.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list