Skip to content

Commit a0b575e

Browse files
committed
Elaborating on compiler optimizations and full-access objects
1 parent a2544e0 commit a0b575e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

content/courses/advanced-ada/parts/data_types/shared_variable_control.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,14 @@ a test application:
662662
The example contains assignments such as :ada:`WR.Horizontal_Cnt := 800` and
663663
:ada:`WR.Vertical_Cnt:= 600`. Because :ada:`Window_Register` is a full-access
664664
type, these assignments are performed for the complete 32-bit register, even
665-
though we're updating just a single component of the record object. (Note that
666-
if :ada:`Window_Register` wasn't a *full-access* object, an assignment such as
667-
:ada:`WR.Horizontal_Cnt := 800` could be performed with a 16-bit operation.)
665+
though we're updating just a single component of the record object.
666+
667+
Note that if :ada:`Window_Register` wasn't a *full-access* object, an
668+
assignment such as :ada:`WR.Horizontal_Cnt := 800` could be performed with a
669+
16-bit operation. In fact, this is what a compiler would most probably select
670+
for this assignment, because that is more efficient than manipulating the
671+
entire object. Therefore, using a *full-access* object prevents the compiler
672+
from generating operations that could lead to unexpected results.
668673

669674
Whenever possible, this *full-access* assignment is performed in a single
670675
machine operation. However, if it's not possible to generate a single machine

0 commit comments

Comments
 (0)