Changes in / [a6af031:727cf70f]
- Files:
-
- 4 edited
-
doc/bibliography/cfa.bib (modified) (1 diff)
-
doc/generic_types/.gitignore (modified) (1 diff)
-
doc/generic_types/generic_types.tex (modified) (7 diffs)
-
src/libcfa/startup.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/bibliography/cfa.bib
ra6af031 r727cf70f 860 860 } 861 861 862 @techreport{C11, 863 type = {International Standard}, 862 @manual{C11, 864 863 keywords = {ISO/IEC C 11}, 865 864 contributer = {pabuhr@plg}, 866 key = { {ISO/IEC} 9889-2011},865 key = {C11}, 867 866 title = {American National Standard Information technology -- Programming Languages -- {C}}, 868 institution = {International Standard Organization}, 867 organization= {International Standard ISO/IEC 9899-2011[2012]}, 868 publisher = {International Standard Organization}, 869 869 address = {http://www.iso.org}, 870 870 year = 2012, 871 871 } 872 872 873 @techreport{C++Concepts, 874 type = {International Standard}, 873 @manual{C++Concepts, 875 874 keywords = {ISO/IEC TS 19217:2015}, 876 875 contributer = {a3moss@uwaterloo.ca}, 877 key = { {ISO/IEC} {TS} 19217},876 key = {C++ Concepts}, 878 877 title = {Information technology -- Programming languages -- {C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Extensions for concepts}, 879 institution = {International Standard Organization}, 878 organization= {International Standard ISO/IEC TS 19217:2015}, 879 publisher = {International Standard Organization}, 880 880 address = {http://www.iso.org}, 881 881 year = 2015 -
doc/generic_types/.gitignore
ra6af031 r727cf70f 16 16 *.lot 17 17 *.synctex.gz 18 comment.cut -
doc/generic_types/generic_types.tex
ra6af031 r727cf70f 29 29 \newcommand{\CCtwenty}{\rm C\kern-.1em\hbox{+\kern-.25em+}20\xspace} % C++20 symbolic name 30 30 31 \newcommand{\TODO}[1]{\textbf{TODO}: #1} % TODO included 32 %\newcommand{\TODO}[1]{} % TODO elided 31 \newcommand{\TODO}{\textbf{TODO}} 33 32 \newcommand{\eg}{\textit{e}.\textit{g}.,\xspace} 34 33 \newcommand{\ie}{\textit{i}.\textit{e}.,\xspace} … … 281 280 }; 282 281 \end{lstlisting} 283 Given the information provided for an @otype@, variables of polymorphic type can be treated as if they were a complete struct type -- they can be stack-allocated using the @alloca@ compiler builtin, default or copy-initialized, assigned, and deleted. As an example, the @sum@ function produces generated code something like the following (simplified for clarity and brevity) \TODO{fix example, maybe elide, it's likely too long with the more complicated function}:282 Given the information provided for an @otype@, variables of polymorphic type can be treated as if they were a complete struct type -- they can be stack-allocated using the @alloca@ compiler builtin, default or copy-initialized, assigned, and deleted. As an example, the @sum@ function produces generated code something like the following (simplified for clarity and brevity) \TODO{} fix example, maybe elide, it's likely too long with the more complicated function: 284 283 \begin{lstlisting} 285 284 void abs( size_t _sizeof_M, size_t _alignof_M, … … 630 629 [int, [int, int], int] g(); 631 630 632 ([int, double])f(); $\C{// (1)}$633 ([int, int, int])g(); $\C{// (2)}$634 ([void, [int, int]])g(); $\C{// (3)}$635 ([int, int, int, int])g(); $\C{// (4)}$636 ([int, [int, int, int]])g(); $\C{// (5)}$631 ([int, double])f(); // (1) 632 ([int, int, int])g(); // (2) 633 ([void, [int, int]])g(); // (3) 634 ([int, int, int, int])g(); // (4) 635 ([int, [int, int, int]])g(); // (5) 637 636 \end{lstlisting} 638 637 … … 767 766 In the call to @new@, @Pair(double, char)@ is selected to match @T@, and @Params@ is expanded to match @[double, char]@. The constructor (1) may be specialized to satisfy the assertion for a constructor with an interface compatible with @void ?{}(Pair(int, char) *, int, char)@. 768 767 769 \TODO{ Check if we actually can use ttype parameters on generic types (if they set the complete flag, it should work, or nearly so).}768 \TODO{} Check if we actually can use ttype parameters on generic types (if they set the complete flag, it should work, or nearly so). 770 769 771 770 \subsection{Implementation} … … 850 849 The various kinds of tuple assignment, constructors, and destructors generate GNU C statement expressions. A variable is generated to store the value produced by a statement expression, since its fields may need to be constructed with a non-trivial constructor and it may need to be referred to multiple time, \eg in a unique expression. The use of statement expressions allows the translator to arbitrarily generate additional temporary variables as needed, but binds the implementation to a non-standard extension of the C language. However, there are other places where the \CFA translator makes use of GNU C extensions, such as its use of nested functions, so this restriction is not new. 851 850 852 \section{Evaluation}853 854 \TODO{Magnus suggests we need some graphs, it's kind of a done thing that the reviewers will be looking for. Also, we've made some unsubstantiated claims about the runtime performance of \CFA, which some micro-benchmarks could help with. I'm thinking a simple stack push and pop, with an idiomatic \lstinline@void*@, \CFA, \CC template and \CC virtual inheritance versions (the void* and virtual inheritance versions likely need to be linked lists, or clumsy in their API -- possibly both versions) to test generics, and variadic print to test tuples. We measure SLOC, runtime performance, executable size (making sure to include benchmarks for multiple types in the executable), and possibly manually count the number of places where the programmer must provide un-type-checked type information. Appendices don't count against our page limit, so we might want to include the source code for the benchmarks (or at least the relevant implementation details) in one.}855 856 851 \section{Related Work} 857 852 … … 860 855 Cyclone also provides capabilities for polymorphic functions and existential types~\citep{Grossman06}, similar in concept to \CFA's @forall@ functions and generic types. Cyclone existential types can include function pointers in a construct similar to a virtual function table, but these pointers must be explicitly initialized at some point in the code, a tedious and potentially error-prone process. Furthermore, Cyclone's polymorphic functions and types are restricted in that they may only abstract over types with the same layout and calling convention as @void*@, in practice only pointer types and @int@ - in \CFA terms, all Cyclone polymorphism must be dtype-static. This design provides the efficiency benefits discussed in Section~\ref{sec:generic-apps} for dtype-static polymorphism, but is more restrictive than \CFA's more general model. 861 856 862 Go \citep{Go} and Rust \citep{Rust}are both modern, compiled languages with abstraction features similar to \CFA traits, \emph{interfaces} in Go and \emph{traits} in Rust. However, both languages represent dramatic departures from C in terms of language model, and neither has the same level of compatibility with C as \CFA. Go is a garbage-collected language, imposing the associated runtime overhead, and complicating foreign-function calls with the necessity of accounting for data transfer between the managed Go runtime and the unmanaged C runtime. Furthermore, while generic types and functions are available in Go, they are limited to a small fixed set provided by the compiler, with no language facility to define more. Rust is not garbage-collected, and thus has a lighter-weight runtime that is more easily interoperable with C. It also possesses much more powerful abstraction capabilities for writing generic code than Go. On the other hand, Rust's borrow-checker, while it does provide strong safety guarantees, is complex and difficult to learn, and imposes a distinctly idiomatic programming style on Rust. \CFA, with its more modest safety features, is significantly easier to port C code to, while maintaining the idiomatic style of the original source.857 Go and Rust are both modern, compiled languages with abstraction features similar to \CFA traits, \emph{interfaces} in Go and \emph{traits} in Rust. However, both languages represent dramatic departures from C in terms of language model, and neither has the same level of compatibility with C as \CFA. Go is a garbage-collected language, imposing the associated runtime overhead, and complicating foreign-function calls with the necessity of accounting for data transfer between the managed Go runtime and the unmanaged C runtime. Furthermore, while generic types and functions are available in Go, they are limited to a small fixed set provided by the compiler, with no language facility to define more. Rust is not garbage-collected, and thus has a lighter-weight runtime that is more easily interoperable with C. It also possesses much more powerful abstraction capabilities for writing generic code than Go. On the other hand, Rust's borrow-checker, while it does provide strong safety guarantees, is complex and difficult to learn, and imposes a distinctly idiomatic programming style on Rust. \CFA, with its more modest safety features, is significantly easier to port C code to, while maintaining the idiomatic style of the original source. 863 858 864 859 \section{Conclusion \& Future Work} … … 867 862 868 863 \begin{acks} 869 The authors would like to thank Magnus Madsen for valuable editorial feedback.870 871 864 This work is supported in part by a corporate partnership with \grantsponsor{Huawei}{Huawei Ltd.}{http://www.huawei.com}\ and the first author's \grantsponsor{NSERC-PGS}{NSERC PGS D}{http://www.nserc-crsng.gc.ca/Students-Etudiants/PG-CS/BellandPostgrad-BelletSuperieures_eng.asp} scholarship. 872 865 \end{acks} -
src/libcfa/startup.h
ra6af031 r727cf70f 18 18 #define STARTUP_H 19 19 20 #if GCC_VERSION > 5000021 20 extern "C" { 22 21 enum { … … 27 26 }; 28 27 } 29 #else30 #define STARTUP_PRIORITY_CORE 10131 #define STARTUP_PRIORITY_KERNEL 10232 #define STARTUP_PRIORITY_MEMORY 10333 #define STARTUP_PRIORITY_IOSTREAM 10434 #endif35 28 36 29 #endif //STARTUP_H
Note:
See TracChangeset
for help on using the changeset viewer.