You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some situations we require a pointer to be 'dereferenceable'. This is a property that requires a size (how many bytes of memory are dereferenceable), so what should that size be? In general this can only be a lower bound of the actual size due to extern types with a completely unknown size. However, for slices and dyn traits we could take into account the metadata when computing this size. In the future we also might have to consider user-defined DST and whether to take into account that size information.
The text was updated successfully, but these errors were encountered:
I am fairly sure that we do not want to take into account user-defined DST; that would require running arbitrary user-defined code as part of retagging (which is where the 'dereferenceable' comes from) which sounds terrible.
For slices and trait objects, I am inclined to avoid the complication of coupling the aliasing model to the "dynamic size" model -- it seems exceedingly hard for compilers to actually make use of such information, so the model complexity does not seem worth the effort. But this is not a terribly stronf opinion.
So, xlang's dereferenceable currently does not support non-constant expressions, but I'd certainly like for it to eventually support dynamically provided sizes. For starters, the dynamic value could be constant folded into the attribute after inlining (this would be the simplest thing to make use of). Also, by the same regard as what I mentioned in #93, I believe I can make use of "partial load" intrinsics and instructions, knowing that some pointer is dereferenceable for a dynamically known size.
This may be useful, for example, in optimizing a naive impl of a hash function that operates on specifically sized chunks (such as SipHash), by collecting into a bunch of reads of the chunk size, then a partial load of the tail.
RalfJung
changed the title
Should 'derefernceable' take into account the dynamic size information where possible?
Should 'dereferenceable' take into account the dynamic size information where possible?
Jun 14, 2023
In some situations we require a pointer to be 'dereferenceable'. This is a property that requires a size (how many bytes of memory are dereferenceable), so what should that size be? In general this can only be a lower bound of the actual size due to extern types with a completely unknown size. However, for slices and dyn traits we could take into account the metadata when computing this size. In the future we also might have to consider user-defined DST and whether to take into account that size information.
The text was updated successfully, but these errors were encountered: