Changeset bbdb0c6
- Timestamp:
- Mar 18, 2020, 3:41:01 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 778452d, d658183
- Parents:
- c4fd4ef (diff), 45f4147 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 20 added
- 54 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Jenkinsfile
rc4fd4ef rbbdb0c6 126 126 } 127 127 128 sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} ${targets} --quiet"128 sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} AR=gcc-ar RANLIB=gcc-ranlib ${targets} --quiet --prefix=${BuildDir}" 129 129 130 130 // Configure libcfa … … 155 155 dir (BuildDir) { 156 156 sh "make -j 8 --no-print-directory -C libcfa/${Settings.Architecture.name}-nodebug" 157 } 158 } 159 160 build_stage('Build : install', true) { 161 // Build outside of the src tree to ease cleaning 162 dir (BuildDir) { 163 sh "make -j 8 --no-print-directory install" 157 164 } 158 165 } … … 179 186 echo "Archiving core dumps" 180 187 dir (BuildDir) { 181 archiveArtifacts artifacts: "tests/crashes/**/* ", fingerprint: true188 archiveArtifacts artifacts: "tests/crashes/**/*,lib/**/lib*.so*", fingerprint: true 182 189 } 183 190 throw err … … 325 332 public String CXX 326 333 public String CC 327 328 CC_Desc(String name, String CXX, String CC) { 334 public String lto 335 336 CC_Desc(String name, String CXX, String CC, String lto) { 329 337 this.name = name 330 338 this.CXX = CXX 331 this.CC = CC 339 this.CC = CC 340 this.lto = lto 332 341 } 333 342 } … … 364 373 switch( param.Compiler ) { 365 374 case 'gcc-9': 366 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9' )375 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9', '-flto=auto') 367 376 break 368 377 case 'gcc-8': 369 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8' )378 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8', '-flto=auto') 370 379 break 371 380 case 'gcc-7': 372 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7' )381 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7', '-flto=auto') 373 382 break 374 383 case 'gcc-6': 375 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6' )384 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6', '-flto=auto') 376 385 break 377 386 case 'gcc-5': 378 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5' )387 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5', '-flto=auto') 379 388 break 380 389 case 'gcc-4.9': 381 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9' )390 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9', '-flto=auto') 382 391 break 383 392 case 'clang': 384 this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6' )393 this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6', '-flto=thin -flto-jobs=0') 385 394 break 386 395 default : … … 439 448 // prepare the properties 440 449 properties ([ \ 450 buildDiscarder(logRotator( \ 451 artifactDaysToKeepStr: '', \ 452 artifactNumToKeepStr: '', \ 453 daysToKeepStr: '730', \ 454 numToKeepStr: '1000' \ 455 )), \ 441 456 [$class: 'ParametersDefinitionProperty', \ 442 457 parameterDefinitions: [ \ -
benchmark/Makefile.am
rc4fd4ef rbbdb0c6 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sat Jan 25 09:20:44202014 ## Update Count : 25 513 ## Last Modified On : Tue Mar 10 11:41:18 2020 14 ## Update Count : 258 15 15 ############################################################################### 16 16 … … 108 108 creation_cfa_coroutine_DURATION = 100000000 109 109 creation_cfa_coroutine_eager_DURATION = 10000000 110 creation_cfa_generator_DURATION = 1000000000 110 111 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION} 111 112 creation_cfa_thread_DURATION = 10000000 -
benchmark/Makefile.in
rc4fd4ef rbbdb0c6 447 447 creation_cfa_coroutine_DURATION = 100000000 448 448 creation_cfa_coroutine_eager_DURATION = 10000000 449 creation_cfa_generator_DURATION = 1000000000 449 450 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION} 450 451 creation_cfa_thread_DURATION = 10000000 -
benchmark/creation/cfa_gen.cfa
rc4fd4ef rbbdb0c6 1 #include " bench.h"1 #include "../bench.h" 2 2 3 struct C{3 generator G { 4 4 volatile int restart; // ensure compiler does not optimize away all the code 5 5 }; 6 void ?{}( C & c ) { c.restart = 0; }7 void main( C& ) {}6 void ?{}( G & g ) { g.restart = 0; } 7 void main( G & ) {} 8 8 9 9 int main( int argc, char * argv[] ) { … … 11 11 BENCH( 12 12 for ( times ) { 13 C c;13 G g; 14 14 }, 15 15 result -
benchmark/ctxswitch/cfa_cor.cfa
rc4fd4ef rbbdb0c6 2 2 #include <thread.hfa> 3 3 4 #include " bench.h"4 #include "../bench.h" 5 5 6 coroutine C {} c;6 coroutine C {}; 7 7 void main( __attribute__((unused)) C & ) { 8 while() {9 suspend ();8 for () { 9 suspend; 10 10 } 11 11 } 12 12 int main( int argc, char * argv[] ) { 13 C c; 13 14 BENCH_START() 14 15 BENCH( -
benchmark/ctxswitch/cfa_gen.cfa
rc4fd4ef rbbdb0c6 1 1 #include "../bench.h" 2 2 3 typedef struct { 4 void * next; 5 } C; 6 7 void comain( C * c ) { 8 if ( __builtin_expect(c->next != 0, 1) ) goto *(c->next); 9 c->next = &&s1; 3 generator G {}; 4 void main( G & ) { 10 5 for () { 11 return; 12 s1: ; 6 suspend; 13 7 } 14 8 } 15 9 16 10 int main( int argc, char * argv[] ) { 11 G g; 17 12 BENCH_START() 18 C c = { 0 };19 13 BENCH( 20 14 for ( times ) { 21 comain( &c);15 resume( g ); 22 16 }, 23 17 result -
configure
rc4fd4ef rbbdb0c6 2557 2557 # don't use the default CFLAGS as they unconditonnaly add -O2 2558 2558 : ${CFLAGS=""} 2559 : ${CXXFLAGS=""} 2559 2560 2560 2561 am__api_version='1.15' -
configure.ac
rc4fd4ef rbbdb0c6 14 14 # don't use the default CFLAGS as they unconditonnaly add -O2 15 15 : ${CFLAGS=""} 16 : ${CXXFLAGS=""} 16 17 17 18 AM_INIT_AUTOMAKE([subdir-objects]) -
doc/papers/concurrency/Paper.tex
rc4fd4ef rbbdb0c6 248 248 } 249 249 250 \new box\myboxA251 \new box\myboxB252 \new box\myboxC253 \new box\myboxD250 \newsavebox{\myboxA} 251 \newsavebox{\myboxB} 252 \newsavebox{\myboxC} 253 \newsavebox{\myboxD} 254 254 255 255 \title{\texorpdfstring{Advanced Control-flow and Concurrency in \protect\CFA}{Advanced Control-flow in Cforall}} … … 2967 2967 \lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}} 2968 2968 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 2969 @coroutine@ C {} c;2970 void main( C & ) { while() { @suspend;@ } }2969 @coroutine@ C {}; 2970 void main( C & ) { for () { @suspend;@ } } 2971 2971 int main() { // coroutine test 2972 C c; 2972 2973 BENCH( for ( N ) { @resume( c );@ } ) 2973 2974 sout | result; … … 2989 2990 \multicolumn{1}{@{}c}{} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 2990 2991 C function & 1.8 & 1.8 & 0.0 \\ 2991 \CFA generator & 1.8 & 1.8 & 0.1\\2992 \CFA generator & 1.8 & 2.0 & 0.3 \\ 2992 2993 \CFA coroutine & 32.5 & 32.9 & 0.8 \\ 2993 2994 \CFA thread & 93.8 & 93.6 & 2.2 \\ -
doc/theses/andrew_beach_MMath/Makefile
rc4fd4ef rbbdb0c6 5 5 TEXSRC=$(wildcard *.tex) 6 6 BIBSRC=$(wildcard *.bib) 7 STYSRC=$(wildcard *.sty) 8 CLSSRC=$(wildcard *.cls) 7 9 TEXLIB= .:${BUILD}: 8 10 BIBLIB= .:../../bibliography … … 24 26 all: ${DOC} 25 27 26 ${BUILD}/${DOC}: ${TEXSRC} ${BIBSRC} Makefile | ${BUILD}28 ${BUILD}/${DOC}: ${TEXSRC} ${BIBSRC} ${STYSRC} ${CLSSRC} Makefile | ${BUILD} 27 29 ${LATEX} ${BASE} 28 30 ${BIBTEX} ${BUILD}/${BASE} -
doc/theses/andrew_beach_MMath/thesis.tex
rc4fd4ef rbbdb0c6 1 % uWaterloo Thesis Template for LaTeX 2 % Last Updated June 14, 2017 by Stephen Carr, IST Client Services 3 % FOR ASSISTANCE, please send mail to rt-IST-CSmathsci@ist.uwaterloo.ca 4 5 % Effective October 2006, the University of Waterloo 6 % requires electronic thesis submission. See the uWaterloo thesis regulations at 7 % https://uwaterloo.ca/graduate-studies/thesis. 8 9 % DON'T FORGET TO ADD YOUR OWN NAME AND TITLE in the "hyperref" package 10 % configuration. THIS INFORMATION GETS EMBEDDED IN THE FINAL PDF DOCUMENT. 11 % You can view the information if you view Properties of the PDF document. 12 13 % Many faculties/departments also require one or more printed 14 % copies. This template attempts to satisfy both types of output. 15 % It is based on the standard "book" document class which provides all 16 % necessary sectioning structures and allows multi-part theses. 17 18 % DISCLAIMER 19 % To the best of our knowledge, this template satisfies the current uWaterloo 20 % requirements. However, it is your responsibility to assure that you have met 21 % all requirements of the University and your particular department. 22 % Many thanks for the feedback from many graduates that assisted the 23 % development of this template. 24 25 % ----------------------------------------------------------------------- 26 27 % By default, output is produced that is geared toward generating a PDF 28 % version optimized for viewing on an electronic display, including 29 % hyperlinks within the PDF. 30 31 % E.g. to process a thesis called "mythesis.tex" based on this template, run: 32 33 % pdflatex mythesis -- first pass of the pdflatex processor 34 % bibtex mythesis -- generates bibliography from .bib data file(s) 35 % makeindex -- should be run only if an index is used 36 % pdflatex mythesis -- fixes numbering in cross-references, 37 % pdflatex mythesis -- bibliographic references, glossaries, index, etc. 38 39 % N.B. The "pdftex" program allows graphics in the following formats to be 40 % included with the "\includegraphics" command: PNG, PDF, JPEG, TIFF 41 % Tip 1: Generate your figures and photos in the size you want them to appear 42 % in your thesis, rather than scaling them with \includegraphics options. 43 % Tip 2: Any drawings you do should be in scalable vector graphic formats: 44 % SVG, PNG, WMF, EPS and then converted to PNG or PDF, so they are scalable in 45 % the final PDF as well. 46 % Tip 3: Photographs should be cropped and compressed so as not to be too large. 47 48 % To create a PDF output that is optimized for double-sided printing: 49 % 50 % 1) comment-out the \documentclass statement in the preamble below, and 51 % un-comment the second \documentclass line. 52 % 53 % 2) change the value assigned below to the boolean variable 54 % "PrintVersion" from "false" to "true". 55 56 % --------------------- Start of Document Preamble ----------------------- 57 58 % Specify the document class, default style attributes, and page dimensions 59 % For hyperlinked PDF, suitable for viewing on a computer, use this: 60 \documentclass[letterpaper,12pt,titlepage,oneside,final]{book} 61 62 % For PDF, suitable for double-sided printing, change the PrintVersion 63 % variable below to "true" and use this \documentclass line instead of the one 64 % above: 65 %\documentclass[letterpaper,12pt,titlepage,openright,twoside,final]{book} 66 67 % Some LaTeX commands I define for my own nomenclature. 68 % If you have to, it's better to change nomenclature once here than in a 69 % million places throughout your thesis! 70 \newcommand{\package}[1]{\textbf{#1}} % package names in bold text 71 \newcommand{\cmmd}[1]{\textbackslash\texttt{#1}} % command name in tt font 72 \newcommand{\href}[1]{#1} % does nothing, but defines the command so the 73 % print-optimized version will ignore \href tags (redefined by hyperref pkg). 74 %\newcommand{\texorpdfstring}[2]{#1} % does nothing, but defines the command 75 % Anything defined here may be redefined by packages added below... 76 77 % This package allows if-then-else control structures. 78 \usepackage{ifthen} 79 \newboolean{PrintVersion} 80 \setboolean{PrintVersion}{false} 81 % CHANGE THIS VALUE TO "true" as necessary, to improve printed results for 82 % hard copies by overriding some options of the hyperref package below. 1 % Main tex file for thesis document. 2 \documentclass[digital]{uw-ethesis} 3 \usepackage{comment} 4 \usepackage{fullpage} 5 \setlength{\textheight}{8.75in} 6 \renewcommand\labelitemi{\footnotesize$\bullet$} % shrink bullet for level 1 itemize 7 \usepackage{lmodern} % bold typewriter font 8 9 \usepackage{listings} % format program code 10 % Default underscore is too low and wide. Cannot use lstlisting "literate" as replacing underscore 11 % removes it as a variable-name character so keywords in variables are highlighted. MUST APPEAR 12 % AFTER HYPERREF. 13 %\DeclareTextCommandDefault{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}} 14 \renewcommand{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}} 15 % parindent is relative, i.e., toggled on/off in environments like itemize, so store the value for 16 % use rather than use \parident directly. 17 \newlength{\parindentlnth} 18 \setlength{\parindentlnth}{\parindent} 19 20 % CFA programming language, based on ANSI C (with some gcc additions) 21 \lstdefinelanguage{CFA}[ANSI]{C}{ 22 morekeywords={ 23 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, __attribute, __attribute__, 24 auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, __const, __const__, 25 coroutine, disable, dtype, enable, exception, __extension__, fallthrough, fallthru, finally, 26 __float80, float80, __float128, float128, forall, ftype, generator, _Generic, _Imaginary, __imag, __imag__, 27 inline, __inline, __inline__, __int128, int128, __label__, monitor, mutex, _Noreturn, one_t, or, 28 otype, restrict, resume, __restrict, __restrict__, __signed, __signed__, _Static_assert, suspend, thread, 29 _Thread_local, throw, throwResume, timeout, trait, try, ttype, typeof, __typeof, __typeof__, 30 virtual, __volatile, __volatile__, waitfor, when, with, zero_t}, 31 moredirectives={defined,include_next}, 32 % replace/adjust listing characters that look bad in sanserif 33 literate={-}{\makebox[1ex][c]{\raisebox{0.5ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1 34 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 % {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1 35 {<}{\textrm{\textless}}1 {>}{\textrm{\textgreater}}1 36 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.5ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textrm{\textgreater}}}2, 37 } 38 39 \lstset{ 40 language=CFA, 41 columns=fullflexible, 42 basicstyle=\linespread{0.9}\tt, % reduce line spacing and use sanserif font 43 stringstyle=\tt, % use typewriter font 44 tabsize=5, % N space tabbing 45 xleftmargin=\parindentlnth, % indent code to paragraph indentation 46 %mathescape=true, % LaTeX math escape in CFA code $...$ 47 escapechar=\$, % LaTeX escape in CFA code 48 keepspaces=true, 49 showstringspaces=false, % do not show spaces with cup 50 showlines=true, % show blank lines at end of code 51 aboveskip=4pt, % spacing above/below code block 52 belowskip=3pt, 53 moredelim=**[is][\color{red}]{`}{`}, 54 }% lstset 55 56 \lstnewenvironment{cfa}[1][] 57 {\lstset{#1}} 58 {} 59 % inline code @...@ 60 61 % Commands used in documenting how to use the template. To remove. 62 \newcommand{\package}[1]{\textbf{#1}} 63 \newcommand{\cmmd}[1]{\textbackslash\texttt{#1}} 64 \newcommand{\href}[1]{#1} 83 65 84 66 % For a nomenclature (optional; available from ctan.org) … … 86 68 % Lots of math symbols and environments 87 69 \usepackage{amsmath,amssymb,amstext} 88 % For including graphics N.B. pdftex graphics driver70 % For including graphics, sets the pdftex graphics driver. 89 71 \usepackage[pdftex]{graphicx} 90 72 91 % I believe the general index function is covered by the glossaries. 92 % \usepackage{makeidx} 93 % \makeindex 94 95 % Hyperlinks make it very easy to navigate an electronic document. 96 % In addition, this is where you should specify the thesis title 97 % and author as they appear in the properties of the PDF document. 98 % Use the "hyperref" package 99 % N.B. HYPERREF MUST BE THE LAST PACKAGE LOADED; ADD ADDITIONAL PKGS ABOVE 100 % N.B. pagebackref=true provides links back from the References to the body 101 % text. This can cause trouble for printing. 102 \usepackage[pdftex,pagebackref=false]{hyperref} % with basic options 103 \hypersetup{ 104 plainpages=false, % needed if Roman numbers in frontpages 105 unicode=false, % non-Latin characters in Acrobat’s bookmarks 106 pdftoolbar=true, % show Acrobat’s toolbar? 107 pdfmenubar=true, % show Acrobat’s menu? 108 pdffitwindow=false, % window fit to page when opened 109 pdfstartview={FitH}, % fits the width of the page to the window 110 pdftitle={uWaterloo\ LaTeX\ Thesis\ Template}, % title: CHANGE THIS TEXT! 111 % pdfauthor={Author}, % author: CHANGE THIS TEXT! and uncomment this line 112 % pdfsubject={Subject}, % subject: CHANGE THIS TEXT! and uncomment this line 113 % pdfkeywords={keyword1} {key2} {key3}, % list of keywords, and uncomment this line if desired 114 pdfnewwindow=true, % links in new window 115 colorlinks=true, % false: boxed links; true: colored links 116 linkcolor=blue, % color of internal links 117 citecolor=green, % color of links to bibliography 118 filecolor=magenta, % color of file links 119 urlcolor=cyan % color of external links 120 } 121 \ifthenelse{\boolean{PrintVersion}}{ 122 % for improved print quality, override some hyperref options 123 \hypersetup{ 124 % colorlinks,% 125 citecolor=black,% 126 filecolor=black,% 127 linkcolor=black,% 128 urlcolor=black} 129 }{} % end of ifthenelse (no else) 130 131 \usepackage[toc,abbreviations]{glossaries-extra} % Exception to the 132 % rule of hyperref being the last add-on package. If glossaries-extra is not 133 % in your LaTeX distribution, get it from CTAN 134 % (http://ctan.org/pkg/glossaries-extra). 135 136 % Setting up the page margins... 137 % uWaterloo thesis requirements specify a minimum of 1 inch (72pt) margin at 138 % the top, bottom, and outside page edges and a 1.125 in. (81pt) gutter 139 % margin (on binding side). While this is not an issue for electronic 140 % viewing, a PDF may be printed, and so we have the same page layout for 141 % both printed and electronic versions, we leave the gutter margin in. 142 % Set margins to minimum permitted by uWaterloo thesis regulations: 143 \setlength{\marginparwidth}{0pt} % width of margin notes 144 % N.B. If margin notes are used, you must adjust \textwidth, \marginparwidth 145 % and \marginparsep so that the space left between the margin notes and page 146 % edge is less than 15 mm (0.6 in.) 147 % Width of space between body text and margin notes. 148 \setlength{\marginparsep}{0pt} 149 \setlength{\evensidemargin}{0.125in} % Adds 1/8 in. to binding side of all 150 % even-numbered pages when the "twoside" printing option is selected 151 \setlength{\oddsidemargin}{0.125in} % Adds 1/8 in. to the left of all pages 152 % when "oneside" printing is selected, and to the left of all odd-numbered 153 % pages when "twoside" printing is selected 154 % Assuming US letter paper (8.5 in. x 11 in.) and side margins as above. 155 \setlength{\textwidth}{6.375in} 156 \raggedbottom 157 158 % The following statement specifies the amount of space between paragraphs. 159 % Other reasonable specifications are \bigskipamount and \smallskipamount. 160 \setlength{\parskip}{\medskipamount} 161 162 % The following statement controls the line spacing. The default 163 % spacing corresponds to good typographic conventions and only slight 164 % changes (e.g., perhaps "1.2"), if any, should be made. 165 \renewcommand{\baselinestretch}{1} % this is the default line space setting 166 167 % By default, each chapter will start on a recto (right-hand side) 168 % page. We also force each section of the front pages to start on 169 % a recto page by inserting \cleardoublepage commands. 170 % In many cases, this will require that the verso page be 171 % blank and, while it should be counted, a page number should not be 172 % printed. The following statements ensure a page number is not 173 % printed on an otherwise blank verso page. 174 \let\origdoublepage\cleardoublepage 175 \newcommand{\clearemptydoublepage}{% 176 \clearpage{\pagestyle{empty}\origdoublepage}} 177 \let\cleardoublepage\clearemptydoublepage 178 179 % Define Glossary terms (This is properly done here, in the preamble. 180 % Could be \input{} from a file...) 73 \usepackage{cfalab} 74 75 \usehyperrefpackage[pdftex,pagebackref=false]{ 76 pdftitle={Exception Handling in CFA}, 77 pdfauthor={Andrew James Beach}, 78 pdfsubject={Programming Languages}, 79 pdfkeywords={exceptions,implementation}, 80 } 81 82 % The \phantomsection is used to help the hyperref package create links. 83 84 % Maybe only package that should be loaded after the hyperref package. 85 % From http://ctan.org/pkg/glossaries-extra, extends glossaries which replaces 86 % glossary and builds off of the makeindex system. 87 \usepackage[toc,abbreviations]{glossaries-extra} 88 181 89 % Main glossary entries -- definitions of relevant terminology 182 90 \newglossaryentry{computer} … … 194 102 type=nomenclature, 195 103 name=dingledorf, 196 description={A person of supposed average intelligence who makes incredibly brainless misjudgments} 104 description={A person of supposed average intelligence who makes incredibly 105 brainless misjudgments} 197 106 } 198 107 199 108 % List of Abbreviations (abbreviations are from the glossaries-extra package) 200 \newabbreviation{aaaaz}{AAAAZ}{American Association of Amature Astronomers and Zoologists} 109 \newabbreviation{aaaaz}{AAAAZ}{American Association of Amature Astronomers 110 and Zoologists} 201 111 202 112 % List of Symbols … … 207 117 sort={label}, 208 118 type=symbols, 209 description={Random vector: a location in n-dimensional Cartesian space, where each dimensional component is determined by a random process} 210 } 211 119 description={Random vector: a location in n-dimensional Cartesian space, where 120 each dimensional component is determined by a random process} 121 } 122 123 % Must be here of cause problems with glossaries-extra. 124 \lstMakeShortInline$% 125 126 % Generate the glossaries defined above. 212 127 \makeglossaries 213 128 214 %======================================================================215 % L O G I C A L D O C U M E N T -- the content of your thesis216 %======================================================================217 129 \begin{document} 218 130 219 % For a large document, it is a good idea to divide your thesis220 % into several files, each one containing one chapter.221 % To illustrate this idea, the "front pages" (i.e., title page,222 % declaration, borrowers' page, abstract, acknowledgements,223 % dedication, table of contents, list of tables, list of figures,224 % nomenclature) are contained within the file "uw-ethesis-frontpgs.tex" which225 % is included into the document by the following statement.226 131 %---------------------------------------------------------------------- 227 132 % FRONT MATERIAL … … 232 137 % MAIN BODY 233 138 %---------------------------------------------------------------------- 234 % Because this is a short document, and to reduce the number of files 235 % needed for this template, the chapters are not separate 236 % documents as suggested above, but you get the idea. If they were 237 % separate documents, they would each start with the \chapter command, i.e, do 238 % not contain \documentclass or \begin{document} and \end{document} commands. 139 \input{unwinding} 140 239 141 %====================================================================== 240 142 \chapter{Introduction} … … 327 229 %---------------------------------------------------------------------- 328 230 329 % B I B L I O G R A P H Y 330 % ----------------------- 331 332 % The following statement selects the style to use for references. It controls 333 % the sort order of the entries in the bibliography and also the formatting 334 % for the in-text labels. 335 \bibliographystyle{plain} 336 % This specifies the location of the file containing the bibliographic 337 % information. It assumes you're using BibTeX (if not, why not?). 338 339 % This is needed if the book class is used, to place the anchor in the correct 340 % page, because the bibliography will start on its own page. 231 %---------------------------------------------------------------------- 232 % BIBLIOGRAPHY 233 %---------------------------------------------------------------------- 234 341 235 % Use \clearpage instead if the document class uses the "oneside" argument. 342 236 \cleardoublepage 343 % With hyperref package, enables hyperlinking from the table of contents to344 % bibliography345 237 \phantomsection 346 238 347 % The following statement causes the title "References" to be used for the 348 % bibliography section: 349 \renewcommand*{\bibname}{References} 350 351 % Add the References to the Table of Contents 352 \addcontentsline{toc}{chapter}{\textbf{References}} 353 354 % Tip 5: You can create multiple .bib files to organize your references. Just 355 % list them all in the \bibliogaphy command, separated by commas (no spaces). 239 % Bibliography setup and creation, renamed to References. 240 \addcontentsline{toc}{chapter}{\textbf{\bibname}} 241 \bibliographystyle{plain} 356 242 \bibliography{thesis} 357 243 358 % The following statement causes the specified references to be added to the 359 % bibliography even if they were not cited in the text. The asterisk is a 360 % wildcard that causes all entries in the bibliographic database to be 361 % included (optional). 244 % Include all uncited entries in the bibliography. 362 245 \nocite{*} 363 246 364 % The \appendix statement indicates the beginning of the appendices.247 % Begin the appendix, add a title and table of contents entry. 365 248 \appendix 366 % Add a title page before the appendices and a line in the Table of Contents367 249 \chapter*{APPENDICES} 368 250 \addcontentsline{toc}{chapter}{APPENDICES} -
doc/theses/thierry_delisle_PhD/comp_II/comp_II.tex
rc4fd4ef rbbdb0c6 8 8 \usepackage{graphicx} 9 9 \usepackage{epic,eepic} 10 \usepackage[hidelinks]{hyperref}11 10 \usepackage{glossaries} 12 11 \usepackage{textcomp} 12 \usepackage[hidelinks]{hyperref} 13 13 %\usepackage[margin=1in]{geometry} 14 14 %\usepackage{float} … … 151 151 \begin{table} 152 152 \begin{center} 153 \begin{tabular}{| c|c|c|}154 \ hline155 & Many Processors & Few Processors\\153 \begin{tabular}{|r|l|l|} 154 \cline{2-3} 155 \multicolumn{1}{r|}{} & \multicolumn{1}{c|}{Many Processors} & \multicolumn{1}{c|}{Few Processors} \\ 156 156 \hline 157 157 Many Threads & A: good performance & B: good performance \\ … … 260 260 261 261 262 \cleardoublepage263 264 262 % B I B L I O G R A P H Y 265 263 % ----------------------------- 266 \addcontentsline{toc}{chapter}{Bibliography} 264 \cleardoublepage 265 \phantomsection % allows hyperref to link to the correct page 266 \addcontentsline{toc}{section}{\refname} 267 267 \bibliographystyle{plain} 268 268 \bibliography{pl,local} 269 270 % G L O S S A R Y 271 % ----------------------------- 269 272 \cleardoublepage 270 273 \phantomsection % allows hyperref to link to the correct page 271 272 % G L O S S A R Y 273 % ----------------------------- 274 \addcontentsline{toc}{chapter}{Glossary} 274 \addcontentsline{toc}{section}{Glossary} 275 275 \printglossary 276 \cleardoublepage277 \phantomsection % allows hyperref to link to the correct page278 276 279 277 \end{document} -
libcfa/prelude/builtins.c
rc4fd4ef rbbdb0c6 48 48 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 49 49 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 50 51 forall(dtype T) 52 static inline T & identity(T & i) { 53 return i; 54 } 55 56 // generator support 57 struct $generator { 58 inline int; 59 }; 60 61 static inline void ?{}($generator & this) { ((int&)this) = 0; } 62 static inline void ^?{}($generator &) {} 63 64 trait is_generator(dtype T) { 65 void main(T & this); 66 $generator * get_generator(T & this); 67 }; 68 69 forall(dtype T | is_generator(T)) 70 static inline T & resume(T & gen) { 71 main(gen); 72 return gen; 73 } 50 74 51 75 // implicit increment, decrement if += defined, and implicit not if != defined -
libcfa/src/Makefile.am
rc4fd4ef rbbdb0c6 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Mon Jul 15 22:43:27 201914 ## Update Count : 24 113 ## Last Modified On : Mon Mar 16 18:07:59 2020 14 ## Update Count : 242 15 15 ############################################################################### 16 16 … … 39 39 #---------------------------------------------------------------------------------------------------------------- 40 40 if BUILDLIB 41 headers_nosrc = math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa41 headers_nosrc = bitmanip.hfa math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa 42 42 headers = fstream.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \ 43 43 containers/maybe.hfa containers/pair.hfa containers/result.hfa containers/vector.hfa -
libcfa/src/Makefile.in
rc4fd4ef rbbdb0c6 237 237 limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \ 238 238 containers/maybe.hfa containers/pair.hfa containers/result.hfa \ 239 containers/vector.hfa math.hfa gmp.hfa time_t.hfa \239 containers/vector.hfa bitmanip.hfa math.hfa gmp.hfa time_t.hfa \ 240 240 bits/align.hfa bits/containers.hfa bits/defs.hfa \ 241 241 bits/debug.hfa bits/locks.hfa concurrency/coroutine.hfa \ … … 432 432 am__v_GOC_0 = @echo " GOC " $@; 433 433 am__v_GOC_1 = 434 AM_V_PY = $(am__v_PY_@AM_V@) 435 am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@) 436 am__v_PY_0 = @echo " PYTHON " $@; 437 am__v_PY_1 = 434 438 AM_V_RUST = $(am__v_RUST_@AM_V@) 435 439 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@) 436 am__v_RUST_0 = @echo " RUST 440 am__v_RUST_0 = @echo " RUST " $@; 437 441 am__v_RUST_1 = 438 442 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@) 439 443 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@) 440 am__v_NODEJS_0 = @echo " NODEJS 444 am__v_NODEJS_0 = @echo " NODEJS " $@; 441 445 am__v_NODEJS_1 = 442 446 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) … … 457 461 458 462 #---------------------------------------------------------------------------------------------------------------- 459 @BUILDLIB_TRUE@headers_nosrc = math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa463 @BUILDLIB_TRUE@headers_nosrc = bitmanip.hfa math.hfa gmp.hfa time_t.hfa bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa 460 464 @BUILDLIB_FALSE@headers = 461 465 @BUILDLIB_TRUE@headers = fstream.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa time.hfa stdlib.hfa common.hfa \ -
libcfa/src/concurrency/coroutine.cfa
rc4fd4ef rbbdb0c6 208 208 209 209 if(cor->state == Primed) { 210 suspend();210 __cfactx_suspend(); 211 211 } 212 212 -
libcfa/src/concurrency/coroutine.hfa
rc4fd4ef rbbdb0c6 46 46 //----------------------------------------------------------------------------- 47 47 // Public coroutine API 48 static inline void suspend(void);49 50 forall(dtype T | is_coroutine(T))51 static inline T & resume(T & cor);52 53 48 forall(dtype T | is_coroutine(T)) 54 49 void prime(T & cor); … … 96 91 97 92 // Suspend implementation inlined for performance 98 static inline void suspend(void) { 99 // optimization : read TLS once and reuse it 100 // Safety note: this is preemption safe since if 101 // preemption occurs after this line, the pointer 102 // will also migrate which means this value will 103 // stay in syn with the TLS 104 $coroutine * src = TL_GET( this_thread )->curr_cor; 93 extern "C" { 94 static inline void __cfactx_suspend(void) { 95 // optimization : read TLS once and reuse it 96 // Safety note: this is preemption safe since if 97 // preemption occurs after this line, the pointer 98 // will also migrate which means this value will 99 // stay in syn with the TLS 100 $coroutine * src = TL_GET( this_thread )->curr_cor; 105 101 106 assertf( src->last != 0,107 "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n"108 "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",109 src->name, src );110 assertf( src->last->state != Halted,111 "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n"112 "Possible cause is terminated coroutine's main routine has already returned.",113 src->name, src, src->last->name, src->last );102 assertf( src->last != 0, 103 "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n" 104 "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.", 105 src->name, src ); 106 assertf( src->last->state != Halted, 107 "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n" 108 "Possible cause is terminated coroutine's main routine has already returned.", 109 src->name, src, src->last->name, src->last ); 114 110 115 $ctx_switch( src, src->last ); 111 $ctx_switch( src, src->last ); 112 } 116 113 } 117 114 -
libcfa/src/exception.c
rc4fd4ef rbbdb0c6 252 252 } 253 253 254 #pragma GCC push_options255 #pragma GCC optimize("O0")256 257 254 // This is our personality routine. For every stack frame annotated with 258 255 // ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding. … … 413 410 return _URC_CONTINUE_UNWIND; 414 411 } 412 413 #pragma GCC push_options 414 #pragma GCC optimize("O0") 415 415 416 416 // Try statements are hoisted out see comments for details. While this could probably be unique -
libcfa/src/interpose.cfa
rc4fd4ef rbbdb0c6 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 2 17:37:00202013 // Update Count : 17 612 // Last Modified On : Fri Mar 13 17:35:37 2020 13 // Update Count : 178 14 14 // 15 15 … … 234 234 235 235 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 236 __cfaabi_ dbg_write("\n", 1 );236 __cfaabi_bits_write( STDERR_FILENO, "\n", 1 ); 237 237 } // if 238 238 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); -
libcfa/src/iostream.cfa
rc4fd4ef rbbdb0c6 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 5 15:56:16202013 // Update Count : 8 3412 // Last Modified On : Wed Mar 11 14:35:35 2020 13 // Update Count : 860 14 14 // 15 15 … … 534 534 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \ 535 535 forall( dtype ostype | ostream( ostype ) ) \ 536 static void base10_128( ostype & os, _Ostream_Manip(T) fmt ) { \ 537 if ( fmt.val > UINT64_MAX ) { \ 538 base10_128( os, fmt.val / P10_UINT64 ); /* recursive */ \ 539 _Ostream_Manip(unsigned long long int) fmt2 @= { (uint64_t)(fmt.val % P10_UINT64), 0, 19, 'u', { .all : 0 } }; \ 540 fmt2.flags.nobsdp = true; \ 541 printf( "fmt2 %c %lld %d\n", fmt2.base, fmt2.val, fmt2.all ); \ 536 static void base10_128( ostype & os, _Ostream_Manip(T) f ) { \ 537 if ( f.val > UINT64_MAX ) { \ 538 unsigned long long int lsig = f.val % P10_UINT64; \ 539 f.val /= P10_UINT64; /* msig */ \ 540 base10_128( os, f ); /* recursion */ \ 541 _Ostream_Manip(unsigned long long int) fmt @= { lsig, 0, 19, 'u', { .all : 0 } }; \ 542 fmt.flags.nobsdp = true; \ 543 /* printf( "fmt1 %c %lld %d\n", fmt.base, fmt.val, fmt.all ); */ \ 542 544 sepOff( os ); \ 543 (ostype &)(os | fmt 2); \545 (ostype &)(os | fmt); \ 544 546 } else { \ 545 printf( "fmt %c %lld %d\n", fmt.base, (unsigned long long int)fmt.val, fmt.all );\546 _Ostream_Manip(SIGNED long long int) x @= { (unsigned long long int)fmt.val, fmt.wd, fmt.pc, fmt.base, { .all : fmt.all } }; \547 (ostype &)(os | x); \547 /* printf( "fmt2 %c %lld %d\n", f.base, (unsigned long long int)f.val, f.all ); */ \ 548 _Ostream_Manip(SIGNED long long int) fmt @= { (SIGNED long long int)f.val, f.wd, f.pc, f.base, { .all : f.all } }; \ 549 (ostype &)(os | fmt); \ 548 550 } /* if */ \ 549 } /* base10_128 */ 551 } /* base10_128 */ \ 550 552 forall( dtype ostype | ostream( ostype ) ) { \ 551 553 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ … … 564 566 if ( f.base == 'b' | f.base == 'B' ) { \ 565 567 if ( f.wd > 64 ) fmt.wd = f.wd - 64; \ 568 if ( f.flags.pc && f.pc > 64 ) fmt.pc = f.pc - 64; \ 566 569 fmt2.wd = 64; \ 567 570 (ostype &)(os | fmt | "" | fmt2); \ … … 569 572 fmt.val = (unsigned long long int)fmt.val >> 2; \ 570 573 if ( f.wd > 21 ) fmt.wd = f.wd - 21; \ 574 if ( f.flags.pc && f.pc > 21 ) fmt.pc = f.pc - 21; \ 571 575 fmt2.wd = 1; \ 572 576 fmt2.val = ((msig & 0x3) << 1) + 1; \ … … 578 582 } else { \ 579 583 if ( f.flags.left ) { \ 580 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; 581 fmt.wd = 16; 584 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \ 585 fmt.wd = 16; \ 582 586 } else { \ 583 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \ 584 fmt2.wd = 16; \ 587 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \ 588 if ( f.flags.pc && f.pc > 16 ) fmt.pc = f.pc - 16; \ 589 fmt2.wd = 16; \ 585 590 } /* if */ \ 586 591 (ostype &)(os | fmt | "" | fmt2); \ … … 588 593 } /* if */ \ 589 594 } else { \ 595 if ( CODE == 'd' ) { \ 596 if ( f.val < 0 ) { fmt( os, "-" ); sepOff( os ); f.val = -f.val; f.flags.sign = false; } \ 597 } /* if */ \ 590 598 base10_128( os, f ); \ 591 599 } /* if */ \ -
src/AST/Convert.cpp
rc4fd4ef rbbdb0c6 493 493 } 494 494 495 const ast::Stmt * visit(const ast::SuspendStmt * node ) override final { 496 if ( inCache( node ) ) return nullptr; 497 auto stmt = new SuspendStmt(); 498 stmt->then = get<CompoundStmt>().accept1( node->then ); 499 switch(node->type) { 500 case ast::SuspendStmt::None : stmt->type = SuspendStmt::None ; break; 501 case ast::SuspendStmt::Coroutine: stmt->type = SuspendStmt::Coroutine; break; 502 case ast::SuspendStmt::Generator: stmt->type = SuspendStmt::Generator; break; 503 } 504 return stmtPostamble( stmt, node ); 505 } 506 495 507 const ast::Stmt * visit( const ast::WaitForStmt * node ) override final { 496 508 if ( inCache( node ) ) return nullptr; … … 1859 1871 } 1860 1872 1873 virtual void visit( const SuspendStmt * old ) override final { 1874 if ( inCache( old ) ) return; 1875 ast::SuspendStmt::Type type; 1876 switch (old->type) { 1877 case SuspendStmt::Coroutine: type = ast::SuspendStmt::Coroutine; break; 1878 case SuspendStmt::Generator: type = ast::SuspendStmt::Generator; break; 1879 case SuspendStmt::None : type = ast::SuspendStmt::None ; break; 1880 default: abort(); 1881 } 1882 this->node = new ast::SuspendStmt( 1883 old->location, 1884 GET_ACCEPT_1(then , CompoundStmt), 1885 type, 1886 GET_LABELS_V(old->labels) 1887 ); 1888 cache.emplace( old, this->node ); 1889 } 1890 1861 1891 virtual void visit( const WaitForStmt * old ) override final { 1862 1892 if ( inCache( old ) ) return; -
src/AST/Decl.hpp
rc4fd4ef rbbdb0c6 259 259 260 260 bool is_coroutine() { return kind == Coroutine; } 261 bool is_monitor() { return kind == Monitor; } 262 bool is_thread() { return kind == Thread; } 261 bool is_generator() { return kind == Generator; } 262 bool is_monitor () { return kind == Monitor ; } 263 bool is_thread () { return kind == Thread ; } 263 264 264 265 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/Fwd.hpp
rc4fd4ef rbbdb0c6 53 53 class CatchStmt; 54 54 class FinallyStmt; 55 class SuspendStmt; 55 56 class WaitForStmt; 56 57 class WithStmt; -
src/AST/Pass.hpp
rc4fd4ef rbbdb0c6 111 111 const ast::Stmt * visit( const ast::CatchStmt * ) override final; 112 112 const ast::Stmt * visit( const ast::FinallyStmt * ) override final; 113 const ast::Stmt * visit( const ast::SuspendStmt * ) override final; 113 114 const ast::Stmt * visit( const ast::WaitForStmt * ) override final; 114 115 const ast::Decl * visit( const ast::WithStmt * ) override final; -
src/AST/Pass.impl.hpp
rc4fd4ef rbbdb0c6 823 823 824 824 //-------------------------------------------------------------------------- 825 // FinallyStmt 826 template< typename pass_t > 827 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::SuspendStmt * node ) { 828 VISIT_START( node ); 829 830 VISIT( 831 maybe_accept( node, &SuspendStmt::then ); 832 ) 833 834 VISIT_END( Stmt, node ); 835 } 836 837 //-------------------------------------------------------------------------- 825 838 // WaitForStmt 826 839 template< typename pass_t > -
src/AST/Print.cpp
rc4fd4ef rbbdb0c6 674 674 safe_print( node->body ); 675 675 --indent; 676 677 return node; 678 } 679 680 virtual const ast::Stmt * visit( const ast::SuspendStmt * node ) override final { 681 os << "Suspend Statement"; 682 switch (node->type) { 683 case ast::SuspendStmt::None : os << " with implicit target"; break; 684 case ast::SuspendStmt::Generator: os << " for generator"; break; 685 case ast::SuspendStmt::Coroutine: os << " for coroutine"; break; 686 } 687 os << endl; 688 689 ++indent; 690 if(node->then) { 691 os << indent << " with post statement :" << endl; 692 safe_print( node->then ); 693 } 694 ++indent; 676 695 677 696 return node; -
src/AST/Stmt.hpp
rc4fd4ef rbbdb0c6 342 342 }; 343 343 344 /// Suspend statement 345 class SuspendStmt final : public Stmt { 346 public: 347 ptr<CompoundStmt> then; 348 enum Type { None, Coroutine, Generator } type = None; 349 350 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} ) 351 : Stmt(loc, std::move(labels)), then(then), type(type) {} 352 353 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 354 private: 355 SuspendStmt * clone() const override { return new SuspendStmt{ *this }; } 356 MUTATE_FRIEND 357 }; 358 344 359 /// Wait for concurrency statement `when (...) waitfor (... , ...) ... timeout(...) ... else ...` 345 360 class WaitForStmt final : public Stmt { -
src/AST/Visitor.hpp
rc4fd4ef rbbdb0c6 47 47 virtual const ast::Stmt * visit( const ast::CatchStmt * ) = 0; 48 48 virtual const ast::Stmt * visit( const ast::FinallyStmt * ) = 0; 49 virtual const ast::Stmt * visit( const ast::SuspendStmt * ) = 0; 49 50 virtual const ast::Stmt * visit( const ast::WaitForStmt * ) = 0; 50 51 virtual const ast::Decl * visit( const ast::WithStmt * ) = 0; -
src/Common/PassVisitor.h
rc4fd4ef rbbdb0c6 110 110 virtual void visit( FinallyStmt * finallyStmt ) override final; 111 111 virtual void visit( const FinallyStmt * finallyStmt ) override final; 112 virtual void visit( SuspendStmt * suspendStmt ) override final; 113 virtual void visit( const SuspendStmt * suspendStmt ) override final; 112 114 virtual void visit( WaitForStmt * waitforStmt ) override final; 113 115 virtual void visit( const WaitForStmt * waitforStmt ) override final; … … 276 278 virtual Statement * mutate( CatchStmt * catchStmt ) override final; 277 279 virtual Statement * mutate( FinallyStmt * finallyStmt ) override final; 280 virtual Statement * mutate( SuspendStmt * suspendStmt ) override final; 278 281 virtual Statement * mutate( WaitForStmt * waitforStmt ) override final; 279 282 virtual Declaration * mutate( WithStmt * withStmt ) override final; -
src/Common/PassVisitor.impl.h
rc4fd4ef rbbdb0c6 1522 1522 1523 1523 //-------------------------------------------------------------------------- 1524 // SuspendStmt 1525 template< typename pass_type > 1526 void PassVisitor< pass_type >::visit( SuspendStmt * node ) { 1527 VISIT_START( node ); 1528 1529 maybeAccept_impl( node->then , *this ); 1530 1531 VISIT_END( node ); 1532 } 1533 1534 template< typename pass_type > 1535 void PassVisitor< pass_type >::visit( const SuspendStmt * node ) { 1536 VISIT_START( node ); 1537 1538 maybeAccept_impl( node->then , *this ); 1539 1540 VISIT_END( node ); 1541 } 1542 1543 template< typename pass_type > 1544 Statement * PassVisitor< pass_type >::mutate( SuspendStmt * node ) { 1545 MUTATE_START( node ); 1546 1547 maybeMutate_impl( node->then , *this ); 1548 1549 MUTATE_END( Statement, node ); 1550 } 1551 1552 //-------------------------------------------------------------------------- 1524 1553 // WaitForStmt 1525 1554 template< typename pass_type > -
src/Concurrency/Keywords.cc
rc4fd4ef rbbdb0c6 16 16 #include "Concurrency/Keywords.h" 17 17 18 #include <cassert> // for assert 19 #include <string> // for string, operator== 20 21 #include "Common/PassVisitor.h" // for PassVisitor 22 #include "Common/SemanticError.h" // for SemanticError 23 #include "Common/utility.h" // for deleteAll, map_range 24 #include "CodeGen/OperatorTable.h" // for isConstructor 25 #include "InitTweak/InitTweak.h" // for getPointerBase 26 #include "SynTree/LinkageSpec.h" // for Cforall 27 #include "SynTree/Constant.h" // for Constant 28 #include "SynTree/Declaration.h" // for StructDecl, FunctionDecl, ObjectDecl 29 #include "SynTree/Expression.h" // for VariableExpr, ConstantExpr, Untype... 30 #include "SynTree/Initializer.h" // for SingleInit, ListInit, Initializer ... 31 #include "SynTree/Label.h" // for Label 32 #include "SynTree/Statement.h" // for CompoundStmt, DeclStmt, ExprStmt 33 #include "SynTree/Type.h" // for StructInstType, Type, PointerType 34 #include "SynTree/Visitor.h" // for Visitor, acceptAll 18 #include <cassert> // for assert 19 #include <string> // for string, operator== 20 21 #include "Common/PassVisitor.h" // for PassVisitor 22 #include "Common/SemanticError.h" // for SemanticError 23 #include "Common/utility.h" // for deleteAll, map_range 24 #include "CodeGen/OperatorTable.h" // for isConstructor 25 #include "ControlStruct/LabelGenerator.h" // for LebelGenerator 26 #include "InitTweak/InitTweak.h" // for getPointerBase 27 #include "SynTree/LinkageSpec.h" // for Cforall 28 #include "SynTree/Constant.h" // for Constant 29 #include "SynTree/Declaration.h" // for StructDecl, FunctionDecl, ObjectDecl 30 #include "SynTree/Expression.h" // for VariableExpr, ConstantExpr, Untype... 31 #include "SynTree/Initializer.h" // for SingleInit, ListInit, Initializer ... 32 #include "SynTree/Label.h" // for Label 33 #include "SynTree/Statement.h" // for CompoundStmt, DeclStmt, ExprStmt 34 #include "SynTree/Type.h" // for StructInstType, Type, PointerType 35 #include "SynTree/Visitor.h" // for Visitor, acceptAll 35 36 36 37 class Attribute; … … 147 148 }; 148 149 150 151 149 152 //----------------------------------------------------------------------------- 150 153 //Handles monitor type declarations : … … 180 183 181 184 //----------------------------------------------------------------------------- 185 //Handles generator type declarations : 186 // generator MyGenerator { struct MyGenerator { 187 // int data; int data; 188 // a_struct_t more_data; a_struct_t more_data; 189 // => int __gen_next; 190 // }; }; 191 // 192 class GeneratorKeyword final : public ConcurrentSueKeyword { 193 public: 194 195 GeneratorKeyword() : ConcurrentSueKeyword( 196 "$generator", 197 "__generator_state", 198 "get_generator", 199 "Unable to find builtin type $generator\n", 200 true, 201 AggregateDecl::Generator 202 ) 203 {} 204 205 virtual ~GeneratorKeyword() {} 206 207 virtual bool is_target( StructDecl * decl ) override final { return decl->is_generator(); } 208 209 static void implement( std::list< Declaration * > & translationUnit ) { 210 PassVisitor< GeneratorKeyword > impl; 211 mutateAll( translationUnit, impl ); 212 } 213 }; 214 215 216 //----------------------------------------------------------------------------- 217 class SuspendKeyword final : public WithStmtsToAdd, public WithGuards { 218 public: 219 SuspendKeyword() = default; 220 virtual ~SuspendKeyword() = default; 221 222 void premutate( FunctionDecl * ); 223 DeclarationWithType * postmutate( FunctionDecl * ); 224 225 Statement * postmutate( SuspendStmt * ); 226 227 static void implement( std::list< Declaration * > & translationUnit ) { 228 PassVisitor< SuspendKeyword > impl; 229 mutateAll( translationUnit, impl ); 230 } 231 232 private: 233 DeclarationWithType * is_main( FunctionDecl * ); 234 bool is_real_suspend( FunctionDecl * ); 235 236 Statement * make_generator_suspend( SuspendStmt * ); 237 Statement * make_coroutine_suspend( SuspendStmt * ); 238 239 struct LabelPair { 240 Label obj; 241 int idx; 242 }; 243 244 LabelPair make_label() { 245 labels.push_back( gen.newLabel("generator") ); 246 return { labels.back(), int(labels.size()) }; 247 } 248 249 DeclarationWithType * in_generator = nullptr; 250 FunctionDecl * decl_suspend = nullptr; 251 std::vector<Label> labels; 252 ControlStruct::LabelGenerator & gen = *ControlStruct::LabelGenerator::getGenerator(); 253 }; 254 255 //----------------------------------------------------------------------------- 182 256 //Handles mutex routines definitions : 183 257 // void foo( A * mutex a, B * mutex b, int i ) { void foo( A * a, B * b, int i ) { … … 251 325 CoroutineKeyword ::implement( translationUnit ); 252 326 MonitorKeyword ::implement( translationUnit ); 327 GeneratorKeyword ::implement( translationUnit ); 328 SuspendKeyword ::implement( translationUnit ); 253 329 } 254 330 … … 446 522 447 523 declsToAddAfter.push_back( get_decl ); 448 449 // get_decl->fixUniqueId(); 450 } 524 } 525 526 //============================================================================================= 527 // Suspend keyword implementation 528 //============================================================================================= 529 DeclarationWithType * SuspendKeyword::is_main( FunctionDecl * func) { 530 if(func->name != "main") return nullptr; 531 if(func->type->parameters.size() != 1) return nullptr; 532 533 auto param = func->type->parameters.front(); 534 535 auto type = dynamic_cast<ReferenceType * >(param->get_type()); 536 if(!type) return nullptr; 537 538 auto obj = dynamic_cast<StructInstType *>(type->base); 539 if(!obj) return nullptr; 540 541 if(!obj->baseStruct->is_generator()) return nullptr; 542 543 return param; 544 } 545 546 bool SuspendKeyword::is_real_suspend( FunctionDecl * func ) { 547 if(isMangled(func->linkage)) return false; // the real suspend isn't mangled 548 if(func->name != "__cfactx_suspend") return false; // the real suspend has a specific name 549 if(func->type->parameters.size() != 0) return false; // Too many parameters 550 if(func->type->returnVals.size() != 0) return false; // Too many return values 551 552 return true; 553 } 554 555 void SuspendKeyword::premutate( FunctionDecl * func ) { 556 GuardValue(in_generator); 557 in_generator = nullptr; 558 559 // Is this the real suspend? 560 if(is_real_suspend(func)) { 561 decl_suspend = decl_suspend ? decl_suspend : func; 562 return; 563 } 564 565 // Is this the main of a generator? 566 auto param = is_main( func ); 567 if(!param) return; 568 569 if(func->type->returnVals.size() != 0) SemanticError(func->location, "Generator main must return void"); 570 571 in_generator = param; 572 GuardValue(labels); 573 labels.clear(); 574 } 575 576 DeclarationWithType * SuspendKeyword::postmutate( FunctionDecl * func ) { 577 if( !func->statements ) return func; // Not the actual definition, don't do anything 578 if( !in_generator ) return func; // Not in a generator, don't do anything 579 if( labels.empty() ) return func; // Generator has no states, nothing to do, could throw a warning 580 581 // This is a generator main, we need to add the following code to the top 582 // static void * __generator_labels[] = {&&s0, &&s1, ...}; 583 // goto * __generator_labels[gen.__generator_state]; 584 const auto & loc = func->location; 585 586 const auto first_label = gen.newLabel("generator"); 587 588 // for each label add to declaration 589 std::list<Initializer*> inits = { new SingleInit( new LabelAddressExpr( first_label ) ) }; 590 for(const auto & label : labels) { 591 inits.push_back( 592 new SingleInit( 593 new LabelAddressExpr( label ) 594 ) 595 ); 596 } 597 auto init = new ListInit(std::move(inits), noDesignators, true); 598 labels.clear(); 599 600 // create decl 601 auto decl = new ObjectDecl( 602 "__generator_labels", 603 Type::StorageClasses( Type::Static ), 604 LinkageSpec::AutoGen, 605 nullptr, 606 new ArrayType( 607 Type::Qualifiers(), 608 new PointerType( 609 Type::Qualifiers(), 610 new VoidType( Type::Qualifiers() ) 611 ), 612 nullptr, 613 false, false 614 ), 615 init 616 ); 617 618 // create the goto 619 assert(in_generator); 620 621 auto go_decl = new ObjectDecl( 622 "__generator_label", 623 noStorageClasses, 624 LinkageSpec::AutoGen, 625 nullptr, 626 new PointerType( 627 Type::Qualifiers(), 628 new VoidType( Type::Qualifiers() ) 629 ), 630 new SingleInit( 631 new UntypedExpr( 632 new NameExpr("?[?]"), 633 { 634 new NameExpr("__generator_labels"), 635 new UntypedMemberExpr( 636 new NameExpr("__generator_state"), 637 new VariableExpr( in_generator ) 638 ) 639 } 640 ) 641 ) 642 ); 643 go_decl->location = loc; 644 645 auto go = new BranchStmt( 646 new VariableExpr( go_decl ), 647 BranchStmt::Goto 648 ); 649 go->location = loc; 650 go->computedTarget->location = loc; 651 652 auto noop = new NullStmt({ first_label }); 653 noop->location = loc; 654 655 // wrap everything in a nice compound 656 auto body = new CompoundStmt({ 657 new DeclStmt( decl ), 658 new DeclStmt( go_decl ), 659 go, 660 noop, 661 func->statements 662 }); 663 body->location = loc; 664 func->statements = body; 665 666 return func; 667 } 668 669 Statement * SuspendKeyword::postmutate( SuspendStmt * stmt ) { 670 SuspendStmt::Type type = stmt->type; 671 if(type == SuspendStmt::None) { 672 // This suspend has a implicit target, find it 673 type = in_generator ? SuspendStmt::Generator : SuspendStmt::Coroutine; 674 } 675 676 // Check that the target makes sense 677 if(!in_generator && type == SuspendStmt::Generator) SemanticError( stmt->location, "'suspend generator' must be used inside main of generator type."); 678 679 // Act appropriately 680 switch(type) { 681 case SuspendStmt::Generator: return make_generator_suspend(stmt); 682 case SuspendStmt::Coroutine: return make_coroutine_suspend(stmt); 683 default: abort(); 684 } 685 } 686 687 Statement * SuspendKeyword::make_generator_suspend( SuspendStmt * stmt ) { 688 assert(in_generator); 689 // Target code is : 690 // gen.__generator_state = X; 691 // { THEN } 692 // return; 693 // __gen_X:; 694 695 // Save the location and delete the old statement, we only need the location from this point on 696 auto loc = stmt->location; 697 698 // Build the label and get its index 699 auto label = make_label(); 700 701 // Create the context saving statement 702 auto save = new ExprStmt( new UntypedExpr( 703 new NameExpr( "?=?" ), 704 { 705 new UntypedMemberExpr( 706 new NameExpr("__generator_state"), 707 new VariableExpr( in_generator ) 708 ), 709 new ConstantExpr( 710 Constant::from_int( label.idx ) 711 ) 712 } 713 )); 714 assert(save->expr); 715 save->location = loc; 716 stmtsToAddBefore.push_back( save ); 717 718 // if we have a then add it here 719 auto then = stmt->then; 720 stmt->then = nullptr; 721 delete stmt; 722 if(then) stmtsToAddBefore.push_back( then ); 723 724 // Create the return statement 725 auto ret = new ReturnStmt( nullptr ); 726 ret->location = loc; 727 stmtsToAddBefore.push_back( ret ); 728 729 // Create the null statement with the created label 730 auto noop = new NullStmt({ label.obj }); 731 noop->location = loc; 732 733 // Return the null statement to take the place of the previous statement 734 return noop; 735 } 736 737 Statement * SuspendKeyword::make_coroutine_suspend( SuspendStmt * stmt ) { 738 if(stmt->then) SemanticError( stmt->location, "Compound statement following coroutines is not implemented."); 739 740 // Save the location and delete the old statement, we only need the location from this point on 741 auto loc = stmt->location; 742 delete stmt; 743 744 // Create the call expression 745 if(!decl_suspend) SemanticError( loc, "suspend keyword applied to coroutines requires coroutines to be in scope, add #include <coroutine.hfa>\n"); 746 auto expr = new UntypedExpr( VariableExpr::functionPointer( decl_suspend ) ); 747 expr->location = loc; 748 749 // Change this statement into a regular expr 750 assert(expr); 751 auto nstmt = new ExprStmt( expr ); 752 nstmt->location = loc; 753 return nstmt; 754 } 755 451 756 452 757 //============================================================================================= -
src/Parser/ParseNode.h
rc4fd4ef rbbdb0c6 428 428 Statement * build_asm( bool voltile, Expression * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr ); 429 429 Statement * build_directive( std::string * directive ); 430 SuspendStmt * build_suspend( StatementNode *, SuspendStmt::Type = SuspendStmt::None); 430 431 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when ); 431 432 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing ); -
src/Parser/StatementNode.cc
rc4fd4ef rbbdb0c6 249 249 } // build_finally 250 250 251 SuspendStmt * build_suspend( StatementNode * then, SuspendStmt::Type type ) { 252 auto node = new SuspendStmt(); 253 254 node->type = type; 255 256 std::list< Statement * > stmts; 257 buildMoveList< Statement, StatementNode >( then, stmts ); 258 if(!stmts.empty()) { 259 assert( stmts.size() == 1 ); 260 node->then = dynamic_cast< CompoundStmt * >( stmts.front() ); 261 } 262 263 return node; 264 } 265 251 266 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when ) { 252 267 auto node = new WaitForStmt(); -
src/Parser/TypeData.cc
rc4fd4ef rbbdb0c6 769 769 case AggregateDecl::Struct: 770 770 case AggregateDecl::Coroutine: 771 case AggregateDecl::Generator: 771 772 case AggregateDecl::Monitor: 772 773 case AggregateDecl::Thread: -
src/Parser/lex.ll
rc4fd4ef rbbdb0c6 65 65 #define FLOATXX(v) KEYWORD_RETURN(v); 66 66 #else 67 #define FLOATXX(v) IDENTIFIER_RETURN(); 67 #define FLOATXX(v) IDENTIFIER_RETURN(); 68 68 #endif // HAVE_KEYWORDS_FLOATXX 69 69 … … 301 301 _Static_assert { KEYWORD_RETURN(STATICASSERT); } // C11 302 302 struct { KEYWORD_RETURN(STRUCT); } 303 /* suspend { KEYWORD_RETURN(SUSPEND); } // CFA */ 303 suspend { KEYWORD_RETURN(SUSPEND); } // CFA 304 304 switch { KEYWORD_RETURN(SWITCH); } 305 305 thread { KEYWORD_RETURN(THREAD); } // C11 -
src/Parser/parser.yy
rc4fd4ef rbbdb0c6 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 26 14:27:39202013 // Update Count : 447 212 // Last Modified On : Fri Mar 6 17:26:45 2020 13 // Update Count : 4474 14 14 // 15 15 … … 278 278 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA 279 279 %token SIZEOF OFFSETOF 280 // %token SUSPEND RESUME // CFA 280 // %token RESUME // CFA 281 %token SUSPEND // CFA 281 282 %token ATTRIBUTE EXTENSION // GCC 282 283 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN … … 918 919 conditional_expression 919 920 | unary_expression assignment_operator assignment_expression 920 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 921 { 922 if ( $2 == OperKinds::AtAssn ) { 923 SemanticError( yylloc, "C @= assignment is currently unimplemented." ); $$ = nullptr; 924 } else { 925 $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); 926 } // if 927 } 921 928 | unary_expression '=' '{' initializer_list_opt comma_opt '}' 922 929 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } … … 1259 1266 | RETURN '{' initializer_list_opt comma_opt '}' ';' 1260 1267 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } 1261 // | SUSPEND ';' 1262 // { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; } 1263 // | SUSPEND compound_statement ';' 1264 // { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; } 1268 | SUSPEND ';' 1269 { $$ = new StatementNode( build_suspend( nullptr ) ); } 1270 | SUSPEND compound_statement 1271 { $$ = new StatementNode( build_suspend( $2 ) ); } 1272 | SUSPEND COROUTINE ';' 1273 { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Coroutine ) ); } 1274 | SUSPEND COROUTINE compound_statement 1275 { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Coroutine ) ); } 1276 | SUSPEND GENERATOR ';' 1277 { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Generator ) ); } 1278 | SUSPEND GENERATOR compound_statement 1279 { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Generator ) ); } 1265 1280 | THROW assignment_expression_opt ';' // handles rethrow 1266 1281 { $$ = new StatementNode( build_throw( $2 ) ); } … … 2077 2092 aggregate_control: // CFA 2078 2093 GENERATOR 2079 { SemanticError( yylloc, "generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }2094 { yyy = true; $$ = AggregateDecl::Generator; } 2080 2095 | MONITOR GENERATOR 2081 2096 { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } -
src/SynTree/Declaration.h
rc4fd4ef rbbdb0c6 302 302 303 303 bool is_coroutine() { return kind == Coroutine; } 304 bool is_monitor() { return kind == Monitor; } 305 bool is_thread() { return kind == Thread; } 304 bool is_generator() { return kind == Generator; } 305 bool is_monitor () { return kind == Monitor ; } 306 bool is_thread () { return kind == Thread ; } 306 307 307 308 virtual StructDecl * clone() const override { return new StructDecl( *this ); } -
src/SynTree/Mutator.h
rc4fd4ef rbbdb0c6 51 51 virtual Statement * mutate( CatchStmt * catchStmt ) = 0; 52 52 virtual Statement * mutate( FinallyStmt * catchStmt ) = 0; 53 virtual Statement * mutate( SuspendStmt * suspendStmt ) = 0; 53 54 virtual Statement * mutate( WaitForStmt * waitforStmt ) = 0; 54 55 virtual Declaration * mutate( WithStmt * withStmt ) = 0; -
src/SynTree/Statement.cc
rc4fd4ef rbbdb0c6 420 420 } 421 421 422 SuspendStmt::SuspendStmt( const SuspendStmt & other ) 423 : Statement( other ) 424 , then( maybeClone(other.then) ) 425 {} 426 427 SuspendStmt::~SuspendStmt() { 428 delete then; 429 } 430 431 void SuspendStmt::print( std::ostream & os, Indenter indent ) const { 432 os << "Suspend Statement"; 433 switch (type) { 434 case None : os << " with implicit target"; break; 435 case Generator: os << " for generator" ; break; 436 case Coroutine: os << " for coroutine" ; break; 437 } 438 os << endl; 439 indent += 1; 440 441 if(then) { 442 os << indent << " with post statement :" << endl; 443 then->print( os, indent + 1); 444 } 445 } 446 422 447 WaitForStmt::WaitForStmt() : Statement() { 423 448 timeout.time = nullptr; -
src/SynTree/Statement.h
rc4fd4ef rbbdb0c6 422 422 }; 423 423 424 class SuspendStmt : public Statement { 425 public: 426 CompoundStmt * then = nullptr; 427 enum Type { None, Coroutine, Generator } type = None; 428 429 SuspendStmt() = default; 430 SuspendStmt( const SuspendStmt & ); 431 virtual ~SuspendStmt(); 432 433 virtual SuspendStmt * clone() const override { return new SuspendStmt( *this ); } 434 virtual void accept( Visitor & v ) override { v.visit( this ); } 435 virtual void accept( Visitor & v ) const override { v.visit( this ); } 436 virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 437 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 438 }; 439 424 440 class WaitForStmt : public Statement { 425 441 public: -
src/SynTree/SynTree.h
rc4fd4ef rbbdb0c6 54 54 class CatchStmt; 55 55 class FinallyStmt; 56 class SuspendStmt; 56 57 class WaitForStmt; 57 58 class WithStmt; -
src/SynTree/Visitor.h
rc4fd4ef rbbdb0c6 78 78 virtual void visit( FinallyStmt * node ) { visit( const_cast<const FinallyStmt *>(node) ); } 79 79 virtual void visit( const FinallyStmt * finallyStmt ) = 0; 80 virtual void visit( SuspendStmt * node ) { visit( const_cast<const SuspendStmt *>(node) ); } 81 virtual void visit( const SuspendStmt * suspendStmt ) = 0; 80 82 virtual void visit( WaitForStmt * node ) { visit( const_cast<const WaitForStmt *>(node) ); } 81 83 virtual void visit( const WaitForStmt * waitforStmt ) = 0; -
tests/concurrent/coroutineYield.cfa
rc4fd4ef rbbdb0c6 33 33 sout | "Coroutine 2"; 34 34 #endif 35 suspend ();35 suspend; 36 36 } 37 37 } -
tests/concurrent/suspend_then.cfa
rc4fd4ef rbbdb0c6 1 1 #include <fstream.hfa> 2 2 #include <kernel.hfa> 3 #include <monitor.hfa>4 3 #include <thread.hfa> 5 4 #include <time.hfa> … … 10 9 #include "long_tests.hfa" 11 10 12 #ifndef PREEMPTION_RATE13 #define PREEMPTION_RATE 10`ms14 #endif15 16 11 Duration default_preemption() { 17 return PREEMPTION_RATE;12 return 0; 18 13 } 19 14 … … 26 21 #if !defined(TEST_FOREVER) 27 22 static inline void print(const char * const text ) { 28 write( STD ERR_FILENO, text, strlen(text) );23 write( STDOUT_FILENO, text, strlen(text) ); 29 24 } 30 25 #else … … 32 27 #endif 33 28 34 coroutine Coroutine {};29 generator Coroutine { int i; }; 35 30 36 31 volatile bool done = false; … … 49 44 50 45 void main(Coroutine& this) { 51 suspend(); 52 for(int i = 0; TEST(i < N); i++) { 46 this.i = 0; 47 suspend; 48 for(;TEST(this.i < N); this.i++) { 53 49 54 print("C - Suspending ");55 void publish(){56 print("C - Publishing ");50 print("C - Suspending\n"); 51 suspend{ 52 print("C - Publishing\n"); 57 53 assert(!the_cor); 58 54 store( this ); 59 55 } 60 suspend_then(publish);61 56 assert(!the_cor); 62 print("C oroutine 2");57 print("C - Back\n"); 63 58 KICK_WATCHDOG; 64 59 yield(); 65 60 } 66 61 done = true; 67 suspend ();62 suspend; 68 63 } 69 64 … … 77 72 if(!mine) continue; 78 73 79 print("T - took ");74 print("T - took\n"); 80 75 resume(*mine); 81 print("T - back");82 76 } 83 77 } -
tests/coroutine/.expect/fmtLines.txt
rc4fd4ef rbbdb0c6 48 48 { // f or n ewli 49 49 ne c hara cter s su 50 spen d (); if ( fm51 t.ch != '\n' ) b reak52 ; / / ig nore new line53 } // for sout54 | f mt.c h; //55 prin t ch arac ter }56 // f or sou t | " "57 ; // prin t bl58 ock sepa rato r } //59 for sou t | nl;60 // p rint gro up s61 epar ator } / / fo r} /62 / ma invo id p rt( Form63 at & fmt , ch ar c h )64 { fmt .ch = ch ;65 res ume( fmt );} //66 prti nt m ain( ) { Form67 at f mt; char ch; for68 ( ; ; ) { s in | ch;69 // rea d on70 e ch arac ter if ( e71 of( sin ) ) brea k;72 // eof ? p rt(73 fmt, ch ); } // for}74 // main // L ocal Var75 iabl es: //// tab -wid76 th: 4 // // c ompi le-c77 omma nd: "cfa fmt Line78 s.cf a" / /// End: //50 spen d; i f ( fmt. 51 ch ! = '\ n' ) bre ak; 52 // igno re n ewli ne 53 } // f or so ut | 54 fmt .ch; / / pr 55 int char acte r } // 56 for s out | " "; 57 / / pr int bloc 58 k se para tor } / / fo 59 r s out | nl ; 60 // pri nt g roup sep 61 arat or } // for} // 62 main void prt ( Fo rmat 63 & f mt, char ch ) { 64 f mt.c h = ch; r 65 esum e( f mt ) ;} / / pr 66 tint mai n() { Fo rmat 67 fmt ; ch ar c h; f or ( 68 ;; ) { sin | c h; 69 // r ead one 70 char acte r if ( eof 71 ( si n ) ) br eak; 72 / / eo f ? prt ( fm 73 t, c h ); } / / fo r} / 74 / ma in// Loc al V aria 75 bles : // // t ab-w idth 76 : 4 //// com pile -com 77 mand : "c fa f mtLi nes. 78 cfa" /// / En d: / / -
tests/coroutine/.in/fmtLines.txt
rc4fd4ef rbbdb0c6 35 35 for ( fmt.b = 0; fmt.b < 4; fmt.b += 1 ) { // blocks of 4 characters 36 36 for ( ;; ) { // for newline characters 37 suspend ();37 suspend; 38 38 if ( fmt.ch != '\n' ) break; // ignore newline 39 39 } // for -
tests/coroutine/cntparens.cfa
rc4fd4ef rbbdb0c6 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 6 // 7 7 // cntparens.cfa -- match left/right parenthesis 8 // 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Apr 20 11:04:45 2019 … … 12 12 // Last Modified On : Sat Apr 20 11:06:21 2019 13 13 // Update Count : 1 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 26 26 void main( CntParens & cpns ) with( cpns ) { 27 27 for ( ; ch == '('; cnt += 1 ) { // left parenthesis 28 suspend ();28 suspend; 29 29 } 30 30 for ( ; ch == ')' && cnt > 1; cnt -= 1 ) { // right parenthesis 31 suspend ();31 suspend; 32 32 } 33 33 status = ch == ')' ? Match : Error; 34 34 } // main 35 35 36 36 void ?{}( CntParens & cpns ) with( cpns ) { status = Cont; cnt = 0; } 37 37 -
tests/coroutine/devicedriver.cfa
rc4fd4ef rbbdb0c6 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // devicedriver.cfa -- 8 // 6 // 7 // devicedriver.cfa -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Mar 16 15:30:34 2019 … … 12 12 // Last Modified On : Sat Apr 20 09:07:19 2019 13 13 // Update Count : 90 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 29 29 30 30 void checkCRC( Driver & d, unsigned int sum ) with( d ) { 31 suspend ();31 suspend; 32 32 unsigned short int crc = byte << 8; // sign extension over written 33 suspend ();33 suspend; 34 34 // prevent sign extension for signed char 35 35 status = (crc | (unsigned char)byte) == sum ? MSG : ECRC; … … 41 41 status = CONT; 42 42 unsigned int lnth = 0, sum = 0; 43 while ( byte != STX ) suspend ();43 while ( byte != STX ) suspend; 44 44 emsg: for () { 45 suspend ();45 suspend; 46 46 choose ( byte ) { // process byte 47 47 case STX: 48 status = ESTX; suspend (); continue msg;48 status = ESTX; suspend; continue msg; 49 49 case ETX: 50 50 break emsg; 51 51 case ESC: 52 suspend ();52 suspend; 53 53 } // choose 54 54 if ( lnth >= MaxMsg ) { // buffer full ? 55 status = ELNTH; suspend (); continue msg;55 status = ELNTH; suspend; continue msg; 56 56 } // if 57 57 msg[lnth++] = byte; … … 60 60 msg[lnth] = '\0'; // terminate string 61 61 checkCRC( d, sum ); // refactor CRC check 62 suspend ();62 suspend; 63 63 } // for 64 64 } // main -
tests/coroutine/fibonacci.cfa
rc4fd4ef rbbdb0c6 22 22 int fn1, fn2; // retained between resumes 23 23 fn = 0; fn1 = fn; // 1st case 24 suspend (); // restart last resume24 suspend; // restart last resume 25 25 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 26 suspend (); // restart last resume26 suspend; // restart last resume 27 27 for () { 28 28 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 29 suspend (); // restart last resume29 suspend; // restart last resume 30 30 } // for 31 31 } -
tests/coroutine/fibonacci_1.cfa
rc4fd4ef rbbdb0c6 12 12 // Last Modified On : Thu Mar 21 08:10:45 2019 13 13 // Update Count : 25 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 23 23 [fn1, fn] = [0, 1]; // precompute first two states 24 24 for () { 25 suspend (); // restart last resume25 suspend; // restart last resume 26 26 [fn1, fn] = [fn, fn1 + fn]; // general case 27 27 } // for -
tests/coroutine/fmtLines.cfa
rc4fd4ef rbbdb0c6 27 27 for ( b = 0; b < 4; b += 1 ) { // blocks of 4 characters 28 28 for () { // for newline characters 29 suspend ();29 suspend; 30 30 if ( ch != '\n' ) break; // ignore newline 31 31 } // for -
tests/coroutine/raii.cfa
rc4fd4ef rbbdb0c6 39 39 Raii raii = { "Coroutine" }; 40 40 sout | "Before Suspend"; 41 suspend ();41 suspend; 42 42 sout | "After Suspend"; 43 43 } -
tests/coroutine/runningTotal.cfa
rc4fd4ef rbbdb0c6 25 25 void update( RunTotal & rntl, int input ) with( rntl ) { // helper 26 26 total += input; // remember between activations 27 suspend (); // inactivate on stack27 suspend; // inactivate on stack 28 28 } 29 29 -
tests/coroutine/suspend_then.cfa
rc4fd4ef rbbdb0c6 15 15 16 16 #include <fstream.hfa> 17 #include <coroutine.hfa>18 17 19 void then() { 20 sout | "Then!"; 21 } 22 23 coroutine Fibonacci { int fn; }; // used for communication 18 generator Fibonacci { 19 int fn; // used for communication 20 int fn1, fn2; // retained between resumes 21 }; 24 22 25 23 void main( Fibonacci & fib ) with( fib ) { // called on first resume 26 int fn1, fn2; // retained between resumes27 24 fn = 0; fn1 = fn; // 1st case 28 suspend _then(then);// restart last resume25 suspend { sout | "Then!"; } // restart last resume 29 26 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 30 suspend _then(then);// restart last resume27 suspend { sout | "Then!"; } // restart last resume 31 28 for () { 32 29 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 33 suspend _then(then);// restart last resume30 suspend { sout | "Then!"; } // restart last resume 34 31 } // for 35 32 } -
tests/errors/.expect/completeType.txt
rc4fd4ef rbbdb0c6 27 27 void 28 28 ) 29 Environment:( _8 3_4_DT ) -> instance of struct A with body 0 (no widening)29 Environment:( _85_4_DT ) -> instance of struct A with body 0 (no widening) 30 30 31 31 … … 50 50 void 51 51 ) 52 Environment:( _8 3_4_DT ) -> instance of struct B with body 1 (no widening)52 Environment:( _85_4_DT ) -> instance of struct B with body 1 (no widening) 53 53 54 54 … … 127 127 void 128 128 ) 129 Environment:( _10 2_0_T ) -> instance of type T (not function type) (no widening)129 Environment:( _104_0_T ) -> instance of type T (not function type) (no widening) 130 130 131 131 Could not satisfy assertion: 132 132 ?=?: pointer to function 133 133 ... with parameters 134 reference to instance of type _10 2_0_T (not function type)135 instance of type _10 2_0_T (not function type)134 reference to instance of type _104_0_T (not function type) 135 instance of type _104_0_T (not function type) 136 136 ... returning 137 _retval__operator_assign: instance of type _10 2_0_T (not function type)137 _retval__operator_assign: instance of type _104_0_T (not function type) 138 138 ... with attributes: 139 139 Attribute with name: unused
Note: See TracChangeset
for help on using the changeset viewer.