[ 
https://issues.apache.org/jira/browse/LUCY-234?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marvin Humphrey updated LUCY-234:
---------------------------------

    Attachment: member_offset_variable.c
                member_offset_constant.c

The files member_offset_constant.c and member_offset_variable.c illustrate one
approach: accessing member vars via variable offsets at runtime.

When those files are compiled to assembler with optimization enabled
({{cc -Wall -Wextra -c -S -O2}}), here are the only differences:

{noformat}
$ diff -u member_offset_constant.s member_offset_variable.s
--- member_offset_constant.s    2012-09-07 11:16:10.000000000 -0700
+++ member_offset_variable.s    2012-09-07 11:16:05.000000000 -0700
@@ -12,7 +12,8 @@
        movq    %rsp, %rbp
 Ltmp4:
        .cfi_def_cfa_register %rbp
-       movl    %esi, 8(%rdi)
+       movq    _Foo_num_OFFSET(%rip), %rax
+       movl    %esi, (%rdi,%rax)
        popq    %rbp
        ret
        .cfi_endproc
@@ -30,7 +31,8 @@
        movq    %rsp, %rbp
 Ltmp9:
        .cfi_def_cfa_register %rbp
-       movl    8(%rdi), %eax
+       movq    _Foo_num_OFFSET(%rip), %rax
+       movl    (%rdi,%rax), %eax
        popq    %rbp
        ret
        .cfi_endproc
$
{noformat}
                
> Brittle object struct ABI
> -------------------------
>
>                 Key: LUCY-234
>                 URL: https://issues.apache.org/jira/browse/LUCY-234
>             Project: Lucy
>          Issue Type: Bug
>          Components: Clownfish
>            Reporter: Marvin Humphrey
>         Attachments: member_offset_constant.c, member_offset_variable.c
>
>
> If an upstream parcel adds, removes or rearranges member variables,
> downstream extensions that build on the affected classes will break.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to