Changeset dc80280


Ignore:
Timestamp:
Dec 13, 2023, 6:27:31 PM (7 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
0fa0201d
Parents:
21ce2c7
Message:

Started the storage section (inling and weak reference)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/proposals/enum.tex

    r21ce2c7 rdc80280  
    205205\end{lstlisting}
    206206
    207 \section{Enumeration Characteristic}
    208 
    209 \subsection{Enumerator Storage}
     207\section{Enumeration Storage}
     208
     209\subsection{Enumeration Variable}
    210210
    211211Although \CFA enumeration captures three different attributes, an enumeration instance does not store all this information.
     
    231231These generated functions are $Companion Functions$, they take an $companion$ object and the position as parameters.
    232232
     233\subsection{Enumeration Data}
     234It is a work in progress, outlined the idea but will update with more information later...
     235A \CFA enumeration is backed by data structures to store necessary data. Specifically, an enumeration has arrays to store its labels and values.
     236\begin{lstlisting}[label=lst:enumeration_back_data]
     237enum(T) E;
     238// backing data
     239T* E_values;
     240char** E_labels;
     241\end{lstlisting}
     242Depending on the use cases, the value and label array might not be necessary to the program.
     243
     244\subsection{Weak Reference}
     245If the value and label need to be determined at the runtime, the data arrays are necessary. However, allocating the attribute arrays in every compilation unit can take up a lot of memory and it is not ideal. \CFA Optimized it by using GCC weak reference ( @__attribute(weak)__@ ).
     246
     247\subsection{Aggressive Inline}
     248If the label and value can be determined during the compilation, \CFA can inline the attributes and no allocation is needed.
     249
    233250\section{Unification}
    234251
Note: See TracChangeset for help on using the changeset viewer.