[M3devel] 64-bit alignment on 32-bit target?
Rodney M. Bates
rodney_bates at lcwb.coop
Sun Jan 28 04:08:12 CET 2018
This would be nice, but thinking about it more, this seems like a huge tar pit.
Aligning *within* a record, array, activation record, heap object, global area, etc. can be
done with existing mechanisms just by setting the alignment for LONGINT. But getting these
entire areas 64-aligned on a 32-bit target is messy.
For example, for stacks, you either have to make every field 64-aligned, so it is always that way
or do runtime alignment, conditional on whether it's already 64-aligned, at call sites, before
pushing any parameters, return address, etc. Neither is nice. And it's difficult to do it
conditionally on whether the to-be-called AR contains 64-aligned fields (usually not) because
you don't necessarily have anything but the signature for the callee when compiling call site code.
All heap objects pretty much have to be 64-aligned. I think mixed alignments of heap objects
has probably been shown to be a real mess, and in the case of opaque types, you may not know
at the NEW site what the needed alignment is anyway.
Also, the linker and loader would have to put sections on 64-bit boundaries as well. Maybe some
do, but we can hardly depend on it universally, and these are tools we don't control.
On 01/26/2018 01:09 PM, Jay K wrote:
> I believe LONGINT should be 64-aligned on 32-bit x86 so for example you can use InterlockedCompareExchange64 on it.
Is it feasible to implement a 64-bit atomic operation on a 32-bit machine anyway, with, often,
32-bit RAM access? That would entail making a pair of accesses to a pair of words all atomic.
And if that could happen, the pair probably wouldn't need to be 64-aligned anyway.
>
> I suggest LONGINT should be 64-aligned so maybe all targets have the same layout, in general.
>
>
> - Jay
>
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *From:* M3devel <m3devel-bounces at elegosoft.com> on behalf of Rodney M. Bates <rodney_bates at lcwb.coop>
> *Sent:* Friday, January 26, 2018 6:35 PM
> *To:* m3devel
> *Subject:* [M3devel] 64-bit alignment on 32-bit target?
>
> Does anybody know:
>
> Do we support, or does there even exist, a target that has 32-bit native words,
> but has some instruction or other reason why some operand would need to be
> 64-bit aligned?
>
> We appear to be 64-bit aligning LONGINT and big enough subranges thereof on
> 32-bit targets, which then needs to propagate through records, arrays, and objects
> that contain them, as well as all heap allocated objects, stack frames, etc.
>
> --
> Rodney Bates
> rodney.m.bates at acm.org
> _______________________________________________
> M3devel mailing list
> M3devel at elegosoft.com
> https://m3lists.elegosoft.com/mailman/listinfo/m3devel
>
>
> _______________________________________________
> M3devel mailing list
> M3devel at elegosoft.com
> https://m3lists.elegosoft.com/mailman/listinfo/m3devel
>
--
Rodney Bates
rodney.m.bates at acm.org
More information about the M3devel
mailing list