#364: ptr_alignment 8 not honored, sparc 64bit broken
---------------------+------------------------------------------------------
Reporter: rurban | Owner: rurban
Type: bug | Status: assigned
Priority: blocker | Milestone: 1.0
Component: core | Version: trunk
Severity: release | Keywords:
Lang: | Patch:
Platform: other |
---------------------+------------------------------------------------------
Comment(by doughera):
Replying to [ticket:364 rurban]:
> A strict 64bit cpu with a ptr_alignment=8 will break when reading pbc's
or just frozen pmc's because our alignment when writing our bytecode is
16/ptrsize and not 16.
No. You are mixing up units here. The alignment is supposed to be on a
16-byte boundary. However, the code is supposed to step through the pbc
in steps of size sizeof(opcode_t). Therefore, it is also true that the
alignment is 16/sizeof(opcode_t), when measured in units of
sizeof(opcode_t).
As I have explained before, the ALIGN_16 macro assumes you are stepping
through the bytecode in steps of sizeof(opcode_t). If there are alignment
problems, it seems likely to me that those problems are due to breaking
that assumption earlier. The problem is not the ALIGN_16 macro (though it
could, of course, be replaced by a more defensive, but slower function),
but in the steps preceeding the call to ALIGN_16 which are somehow
violating the assumption that the reader is stepping through the file in
units of sizeof(opcode_t). For this problem here, a backtrace showing
where the stream pointer came from would be helpful.
The decision to step through the file in units of sizeof(opcode_t) was a
deliberate choice for at least two reasons: efficiency, and avoiding
compiler warnings. gcc on SPARC in particular will issue warnings when
casting from (char *) to things like (opcode_t *):
"warning: cast increases required alignment of target type". Please don't
change that.
For reading foreign files with a different sizeof(opcode_t), you are
correct that you will have to step through the file in steps of the
foreign stepsize. But that's not the problem here -- everything is
native.
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/364#comment:5>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets