pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-33
REFALIGNED(8)
If a structure pointer specifies REFALIGNED(8) or inherits its reference alignment from
a SHARED8 structure, but the base of the structure is not well-aligned, your program
might run significantly slower than you anticipate. You will observe significantly
degraded performance if your REFALIGNED(8) pointer references a structure field that
is not, in fact, well-aligned. Each such reference in your program will cause a trap to
the millicode exception handler, which accesses the field your program is referencing
and then returns to your program. Your program’s behavior is not affected by having to
access the field from the exception handler except that its performance for each such
trap is significantly degraded.
pTAL generates conservative code for references to a pointer that specifies
REFALIGNED(8) if it detects that a trap would occur if it generated optimal code.
For the assignment i32 := p1.i, pTAL generates fast code to access the field
described by t1 because the declaration of pointer p1 specifies REFALIGNED(8). If
the field is not well-aligned, your program will run significantly slower because each
reference to elements of p1 will trap to the millicode exception handler to resolve each
memory access.
For the assignment i32 := p2.i, pTAL generates conservative code to access the
field described by t2 because the field might not be well-aligned. The native compiler
might generate extra instructions to access the field.
Example 11-15. REFALIGNED(8)
STRUCT t1 (*) FIELDALIGN(SHARED2);
BEGIN
INT(32) i;
END;
STRUCT t2 (*) FIELDALIGN(SHARED8);
BEGIN
STRUCT s (t1);
INT(32) i;
END;
INT .EXT p1 (t1) REFALIGNED (8) := extended address;
INT .EXT p2 (t2) REFALIGNED (2) := extended address;
INT .EXT p3 (t2) := extended address;
INT(32) i32;
i32 := p1.i;
i32 := p2.i;
i32 := p3.s.i;