Changes in / [86fc350:d30804a]
- Files:
-
- 10 deleted
- 29 edited
-
doc/theses/andrew_beach_MMath/code/.gitignore (deleted)
-
doc/theses/andrew_beach_MMath/code/cond-catch.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/cond-catch.cpp (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/cond-fixup.cfa (modified) (3 diffs)
-
doc/theses/andrew_beach_MMath/code/cond_catch.py (deleted)
-
doc/theses/andrew_beach_MMath/code/cross-catch.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/cross-catch.cpp (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/cross-finally.cfa (modified) (1 diff)
-
doc/theses/andrew_beach_MMath/code/cross-resume.cfa (modified) (1 diff)
-
doc/theses/andrew_beach_MMath/code/cross_catch.py (deleted)
-
doc/theses/andrew_beach_MMath/code/cross_finally.py (deleted)
-
doc/theses/andrew_beach_MMath/code/resume-detor.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/resume-empty.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/resume-finally.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/resume-other.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/test.sh (modified) (11 diffs)
-
doc/theses/andrew_beach_MMath/code/throw-detor.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/throw-detor.cpp (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/throw-empty.cfa (modified) (1 diff)
-
doc/theses/andrew_beach_MMath/code/throw-empty.cpp (modified) (1 diff)
-
doc/theses/andrew_beach_MMath/code/throw-finally.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/throw-other.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/throw-other.cpp (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/throw_empty.py (deleted)
-
doc/theses/andrew_beach_MMath/code/throw_finally.py (deleted)
-
doc/theses/andrew_beach_MMath/code/throw_other.py (deleted)
-
doc/theses/andrew_beach_MMath/code/throw_with.py (deleted)
-
doc/theses/andrew_beach_MMath/intro.tex (modified) (2 diffs)
-
doc/theses/mubeen_zulfiqar_MMath/allocator.tex (modified) (1 diff)
-
libcfa/src/concurrency/locks.cfa (modified) (1 diff)
-
src/CompilationState.cc (modified) (2 diffs)
-
src/CompilationState.h (modified) (2 diffs)
-
src/ControlStruct/ExceptDecl.cc (deleted)
-
src/ControlStruct/ExceptDecl.h (deleted)
-
src/ControlStruct/module.mk (modified) (1 diff)
-
src/Parser/TypeData.cc (modified) (2 diffs)
-
src/SynTree/Declaration.h (modified) (2 diffs)
-
src/main.cc (modified) (4 diffs)
-
tests/polymorphism.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/cond-catch.cfa
r86fc350 rd30804a 19 19 throw_exception(); 20 20 } catch (empty_exception * exc ; should_catch) { 21 asm volatile ("# catch block (conditional)");21 // ... 22 22 } 23 23 } … … 37 37 cond_catch(); 38 38 } catch (empty_exception * exc) { 39 asm volatile ("# catch block (unconditional)");39 // ... 40 40 } 41 41 } -
doc/theses/andrew_beach_MMath/code/cond-catch.cpp
r86fc350 rd30804a 19 19 throw_exception(); 20 20 } catch (EmptyException & exc) { 21 if ( !should_catch) {21 if (should_catch) { 22 22 throw; 23 23 } 24 asm volatile ("# catch block (conditional)");25 24 } 26 25 } … … 40 39 cond_catch(); 41 40 } catch (EmptyException &) { 42 asm volatile ("# catch block (unconditional)");41 // ... 43 42 } 44 43 } -
doc/theses/andrew_beach_MMath/code/cond-fixup.cfa
r86fc350 rd30804a 12 12 13 13 void throw_exception() { 14 throw Resume(empty_exception){&empty_vt};14 throw (empty_exception){&empty_vt}; 15 15 } 16 16 … … 18 18 try { 19 19 throw_exception(); 20 } catch Resume(empty_exception * exc ; should_catch) {21 asm volatile ("# fixup block (conditional)");20 } catch (empty_exception * exc ; should_catch) { 21 // ... 22 22 } 23 23 } … … 36 36 try { 37 37 cond_catch(); 38 } catch Resume(empty_exception * exc) {39 asm volatile ("# fixup block (unconditional)");38 } catch (empty_exception * exc) { 39 // ... 40 40 } 41 41 } -
doc/theses/andrew_beach_MMath/code/cross-catch.cfa
r86fc350 rd30804a 7 7 EHM_EXCEPTION(not_raised_exception)(); 8 8 9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt);10 11 9 int main(int argc, char * argv[]) { 12 10 unsigned int times = 1; 13 bool should_throw = false;11 unsigned int total_frames = 1; 14 12 if (1 < argc) { 15 13 times = strtol(argv[1], 0p, 10); 14 } 15 if (2 < argc) { 16 total_frames = strtol(argv[2], 0p, 10); 16 17 } 17 18 … … 19 20 for (unsigned int count = 0 ; count < times ; ++count) { 20 21 try { 21 asm volatile ("# try block" : "=rm" (should_throw)); 22 if (should_throw) { 23 throw (not_raised_exception){¬_vt}; 24 } 22 // ... 25 23 } catch (not_raised_exception *) { 26 asm volatile ("# catch block");24 // ... 27 25 } 28 26 } -
doc/theses/andrew_beach_MMath/code/cross-catch.cpp
r86fc350 rd30804a 11 11 int main(int argc, char * argv[]) { 12 12 unsigned int times = 1; 13 bool should_throw = false;14 13 if (1 < argc) { 15 14 times = strtol(argv[1], nullptr, 10); … … 19 18 for (unsigned int count = 0 ; count < times ; ++count) { 20 19 try { 21 asm volatile ("# try block" : "=rm" (should_throw)); 22 if (should_throw) { 23 throw NotRaisedException(); 24 } 20 // ... 25 21 } catch (NotRaisedException &) { 26 asm volatile ("# catch block");22 // ... 27 23 } 28 24 } -
doc/theses/andrew_beach_MMath/code/cross-finally.cfa
r86fc350 rd30804a 5 5 #include <stdlib.hfa> 6 6 7 EHM_EXCEPTION(not_raised_exception)();8 9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt);10 11 7 int main(int argc, char * argv[]) { 12 8 unsigned int times = 1; 13 bool should_throw = false;9 unsigned int total_frames = 1; 14 10 if (1 < argc) { 15 11 times = strtol(argv[1], 0p, 10); 12 } 13 if (2 < argc) { 14 total_frames = strtol(argv[2], 0p, 10); 16 15 } 17 16 18 17 Time start_time = timeHiRes(); 19 18 for (unsigned int count = 0 ; count < times ; ++count) { 20 try { 21 asm volatile ("# try block" : "=rm" (should_throw)); 22 if (should_throw) { 23 throw (not_raised_exception){¬_vt}; 24 } 19 try { 20 // ... 25 21 } finally { 26 asm volatile ("# finally block");22 // ... 27 23 } 28 24 } -
doc/theses/andrew_beach_MMath/code/cross-resume.cfa
r86fc350 rd30804a 20 20 for (unsigned int count = 0 ; count < times ; ++count) { 21 21 try { 22 asm volatile ("");22 // ... 23 23 } catchResume (not_raised_exception *) { 24 asm volatile ("");24 // ... 25 25 } 26 26 } -
doc/theses/andrew_beach_MMath/code/resume-detor.cfa
r86fc350 rd30804a 12 12 13 13 void ^?{}(WithDestructor & this) { 14 asm volatile ("# destructor body"); 14 // ... 15 15 } 16 16 17 17 void unwind_destructor(unsigned int frames) { 18 if (frames) {18 if (frames) { 19 19 20 WithDestructor object;21 unwind_destructor(frames - 1);22 } else {23 throwResume (empty_exception){&empty_vt};24 }20 WithDestructor object; 21 unwind_destructor(frames - 1); 22 } else { 23 throwResume (empty_exception){&empty_vt}; 24 } 25 25 } 26 26 … … 36 36 37 37 Time start_time = timeHiRes(); 38 for (int count = 0 ; count < times ; ++count) {39 try {40 unwind_destructor(total_frames);41 } catchResume (empty_exception *) {42 asm volatile ("# fixup block"); 43 }44 }38 for (int count = 0 ; count < times ; ++count) { 39 try { 40 unwind_destructor(total_frames); 41 } catchResume (empty_exception *) { 42 // ... 43 } 44 } 45 45 Time end_time = timeHiRes(); 46 46 sout | "Run-Time (ns): " | (end_time - start_time)`ns; -
doc/theses/andrew_beach_MMath/code/resume-empty.cfa
r86fc350 rd30804a 13 13 unwind_empty(frames - 1); 14 14 } else { 15 throw Resume(empty_exception){&empty_vt};15 throw (empty_exception){&empty_vt}; 16 16 } 17 17 } … … 31 31 try { 32 32 unwind_empty(total_frames); 33 } catch Resume(empty_exception *) {34 asm volatile ("# fixup block");33 } catch (empty_exception *) { 34 // ... 35 35 } 36 36 } -
doc/theses/andrew_beach_MMath/code/resume-finally.cfa
r86fc350 rd30804a 14 14 unwind_finally(frames - 1); 15 15 } finally { 16 asm volatile ("# finally block");16 // ... 17 17 } 18 18 } else { … … 36 36 unwind_finally(total_frames); 37 37 } catchResume (empty_exception *) { 38 asm volatile ("# fixup block");38 // ... 39 39 } 40 40 } -
doc/theses/andrew_beach_MMath/code/resume-other.cfa
r86fc350 rd30804a 16 16 unwind_other(frames - 1); 17 17 } catchResume (not_raised_exception *) { 18 asm volatile ("# fixup block (stack)");18 // ... 19 19 } 20 20 } else { … … 38 38 unwind_other(total_frames); 39 39 } catchResume (empty_exception *) { 40 asm volatile ("# fixup block (base)");40 // ... 41 41 } 42 42 } -
doc/theses/andrew_beach_MMath/code/test.sh
r86fc350 rd30804a 18 18 *.cfa) 19 19 # Requires a symbolic link. 20 mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3"$1" -o "${1%.cfa}"20 mmake "${1%.cfa}" "$1" ./cfa "$1" -o "${1%.cfa}" 21 21 ;; 22 22 *.cpp) 23 mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3"$1" -o "${1%.cpp}-cpp"23 mmake "${1%.cpp}-cpp" "$1" g++ "$1" -o "${1%.cpp}-cpp" 24 24 ;; 25 25 *.java) … … 39 39 exit 0 40 40 elif [ 2 -eq "$#" ]; then 41 TEST_LANG="$1"42 TEST_CASE="$2"41 TEST_LANG="$1" 42 TEST_CASE="$2" 43 43 else 44 echo "Unknown call pattern." >&245 exit 244 echo "Unknown call pattern." >&2 45 exit 2 46 46 fi 47 47 … … 58 58 CPP="./cond-catch-cpp $ITERATIONS 1" 59 59 JAVA="java CondCatch $ITERATIONS 1" 60 PYTHON="./cond_catch.py $ITERATIONS 1"61 60 ;; 62 61 cond-match-none) … … 65 64 CPP="./cond-catch-cpp $ITERATIONS 0" 66 65 JAVA="java CondCatch $ITERATIONS 0" 67 PYTHON="./cond_catch.py $ITERATIONS 0"68 66 ;; 69 67 cross-catch) … … 72 70 CPP="./cross-catch-cpp $ITERATIONS" 73 71 JAVA="java CrossCatch $ITERATIONS" 74 PYTHON="./cross_catch.py $ITERATIONS"75 72 ;; 76 73 cross-finally) … … 79 76 CPP=unsupported 80 77 JAVA="java CrossFinally $ITERATIONS" 81 PYTHON="./cross_finally.py $ITERATIONS"82 78 ;; 83 79 raise-detor) … … 86 82 CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT" 87 83 JAVA=unsupported 88 PYTHON=unsupported89 84 ;; 90 85 raise-empty) … … 93 88 CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT" 94 89 JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT" 95 PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"96 90 ;; 97 91 raise-finally) … … 100 94 CPP=unsupported 101 95 JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT" 102 PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT"103 96 ;; 104 97 raise-other) … … 107 100 CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT" 108 101 JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT" 109 PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT"110 102 ;; 111 103 *) … … 120 112 cpp) echo $CPP; $CPP;; 121 113 java) echo $JAVA; $JAVA;; 122 python) echo $PYTHON; $PYTHON;;123 114 *) 124 115 echo "No such language: $TEST_LANG" >&2 125 116 exit 2 126 ;;127 117 esac -
doc/theses/andrew_beach_MMath/code/throw-detor.cfa
r86fc350 rd30804a 12 12 13 13 void ^?{}(WithDestructor & this) { 14 asm volatile ("# destructor body");14 // ... 15 15 } 16 16 … … 39 39 unwind_destructor(total_frames); 40 40 } catch (empty_exception *) { 41 asm volatile ("# catch block");41 // ... 42 42 } 43 43 } -
doc/theses/andrew_beach_MMath/code/throw-detor.cpp
r86fc350 rd30804a 10 10 11 11 struct WithDestructor { 12 ~WithDestructor() { 13 asm volatile ("# destructor body"); 14 } 12 ~WithDestructor() {} 15 13 }; 16 14 … … 39 37 unwind_destructor(total_frames); 40 38 } catch (EmptyException &) { 41 asm volatile ("# catch block");39 // ... 42 40 } 43 41 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cfa
r86fc350 rd30804a 32 32 unwind_empty(total_frames); 33 33 } catch (empty_exception *) { 34 asm volatile ("# catch block");34 // ... 35 35 } 36 36 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cpp
r86fc350 rd30804a 32 32 unwind_empty(total_frames); 33 33 } catch (EmptyException &) { 34 asm volatile ("# catch block");34 // ... 35 35 } 36 36 } -
doc/theses/andrew_beach_MMath/code/throw-finally.cfa
r86fc350 rd30804a 14 14 unwind_finally(frames - 1); 15 15 } finally { 16 asm volatile ("# finally block");16 // ... 17 17 } 18 18 } else { … … 36 36 unwind_finally(total_frames); 37 37 } catch (empty_exception *) { 38 asm volatile ("# catch block");38 // ... 39 39 } 40 40 } -
doc/theses/andrew_beach_MMath/code/throw-other.cfa
r86fc350 rd30804a 16 16 unwind_other(frames - 1); 17 17 } catch (not_raised_exception *) { 18 asm volatile ("# catch block (stack)");18 // ... 19 19 } 20 20 } else { … … 38 38 unwind_other(total_frames); 39 39 } catch (empty_exception *) { 40 asm volatile ("# catch block (base)");40 // ... 41 41 } 42 42 } -
doc/theses/andrew_beach_MMath/code/throw-other.cpp
r86fc350 rd30804a 16 16 unwind_other(frames - 1); 17 17 } catch (NotRaisedException &) { 18 asm volatile ("# catch block (stack)");18 // ... 19 19 } 20 20 } else { … … 38 38 unwind_other(total_frames); 39 39 } catch (EmptyException &) { 40 asm volatile ("# catch block (base)");40 // ... 41 41 } 42 42 } -
doc/theses/andrew_beach_MMath/intro.tex
r86fc350 rd30804a 107 107 108 108 Exception handling is not a new concept, 109 with papers on the subject dating back 70s.\cite{Goodenough} 110 111 Early exceptions were often treated as signals. They carried no information 112 except their identity. Ada still uses this system. 113 114 The modern flag-ship for termination exceptions is \Cpp, 109 with papers on the subject dating back 70s. 110 111 Their were popularised by \Cpp, 115 112 which added them in its first major wave of non-object-orientated features 116 113 in 1990. 117 114 % https://en.cppreference.com/w/cpp/language/history 118 \Cpp has the ability to use any value of any type as an exception. 119 However that seems to immediately pushed aside for classes inherited from 120 \code{C++}{std::exception}. 121 Although there is a special catch-all syntax it does not allow anything to 122 be done with the caught value becuase nothing is known about it. 123 So instead a base type is defined with some common functionality (such as 124 the ability to describe the reason the exception was raised) and all 125 exceptions have that functionality. 126 This seems to be the standard now, as the garentied functionality is worth 127 any lost flexibility from limiting it to a single type. 128 129 Java was the next popular language to use exceptions. 130 Its exception system largely reflects that of \Cpp, except that requires 131 you throw a child type of \code{Java}{java.lang.Throwable} 132 and it uses checked exceptions. 115 116 Java was the next popular language to use exceptions. It is also the most 117 popular language with checked exceptions. 133 118 Checked exceptions are part of the function interface they are raised from. 134 119 This includes functions they propogate through, until a handler for that … … 146 131 Resumption exceptions have been much less popular. 147 132 Although resumption has a history as old as termination's, very few 148 programming languages have implement edthem.133 programming languages have implement them. 149 134 % http://bitsavers.informatik.uni-stuttgart.de/pdf/xerox/parc/techReports/ 150 135 % CSL-79-3_Mesa_Language_Manual_Version_5.0.pdf 151 Mesa is one programming languages that did . Experiance with Mesa152 is quoted as being one of the reasons resumptions were not136 Mesa is one programming languages that did and experiance with that 137 languages is quoted as being one of the reasons resumptions were not 153 138 included in the \Cpp standard. 154 139 % https://en.wikipedia.org/wiki/Exception_handling 155 Since then resumptions have been ignored in the main-stream. 156 157 All of this does call into question the use of resumptions, is 158 something largely rejected decades ago worth revisiting now? 159 Yes, even if it was the right call at the time there have been decades 160 of other developments in computer science that have changed the situation 161 since then. 162 Some of these developments, such as in functional programming's resumption 163 equivalent: algebraic effects\cite{Zhang19}, are directly related to 164 resumptions as well. 165 A complete rexamination of resumptions is beyond a single paper, but it is 166 enough to try them again in \CFA. 167 % Especially considering how much easier they are to implement than 168 % termination exceptions. 169 170 %\subsection 171 Functional languages tend to use other solutions for their primary error 172 handling mechanism, exception-like constructs still appear. 173 Termination appears in error construct, which marks the result of an 174 expression as an error, the result of any expression that tries to use it as 175 an error, and so on until an approprate handler is reached. 176 Resumption appears in algebric effects, where a function dispatches its 177 side-effects to its caller for handling. 140 \todo{A comment about why we did include them when they are so unpopular 141 might be approprate.} 142 143 %\subsection 144 Functional languages, tend to use solutions like the return union, but some 145 exception-like constructs still appear. 146 147 For instance Haskell's built in error mechanism can make the result of any 148 expression, including function calls. Any expression that examines an 149 error value will in-turn produce an error. This continues until the main 150 function produces an error or until it is handled by one of the catch 151 functions. 178 152 179 153 %\subsection 180 154 More recently exceptions seem to be vanishing from newer programming 181 languages, replaced by ``panic". 182 In Rust a panic is just a program level abort that may be implemented by 183 unwinding the stack like in termination exception handling. 155 languages. 156 Rust and Go reduce this feature to panics. 157 Panicing is somewhere between a termination exception and a program abort. 158 Notably in Rust a panic can trigger either, a panic may unwind the stack or 159 simply kill the process. 184 160 % https://doc.rust-lang.org/std/panic/fn.catch_unwind.html 185 Go's panic through is very similar to a termination except it only supports186 a catch-all by calling \code{Go}{recover()}, simplifying the interface at 187 the cost of flexability.161 Go's panic is much more similar to a termination exception but there is 162 only a catch-all function with \code{Go}{recover()}. 163 So exceptions still are appearing, just in reduced forms. 188 164 189 165 %\subsection -
doc/theses/mubeen_zulfiqar_MMath/allocator.tex
r86fc350 rd30804a 111 111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 112 112 113 \section{Added Features and Methods} 114 To improve the UHeapLmmm allocator (FIX ME: cite uHeapLmmm) interface and make it more user friendly, we added a few more routines to the C allocator. Also, we built a CFA (FIX ME: cite cforall) interface on top of C interface to increase the usability of the allocator. 113 \section{Added Features} 115 114 116 \subsection{C Interface}117 We added a few more features and routines to the allocator's C interface that can make the allocator more usable to the programmers. THese features will programmer more control on the dynamic memory allocation.118 115 119 \subsubsection void * aalloc( size_t dim, size_t elemSize ) 120 aalloc is an extension of malloc. It allows programmer to allocate a dynamic array of objects without calculating the total size of array explicitly. The only alternate of this routine in the other allocators is calloc but calloc also fills the dynamic memory with 0 which makes it slower for a programmer who only wants to dynamically allocate an array of objects without filling it with 0. 121 \paragraph{Usage} 122 aalloc takes two parameters. 123 \begin{itemize} 124 \item 125 dim: number of objects in the array 126 \item 127 elemSize: size of the object in the array. 128 \end{itemize} 129 It returns address of dynamic object allocatoed on heap that can contain dim number of objects of the size elemSize. On failure, it returns NULL pointer. 116 \subsection{Methods} 117 Why did we need it? 118 The added benefits. 130 119 131 \subsubsection void * resize( void * oaddr, size_t size )132 resize is an extension of relloc. It allows programmer to reuse a cuurently allocated dynamic object with a new size requirement. Its alternate in the other allocators is realloc but relloc also copy the data in old object to the new object which makes it slower for the programmer who only wants to reuse an old dynamic object for a new size requirement but does not want to preserve the data in the old object to the new object.133 \paragraph{Usage}134 resize takes two parameters.135 \begin{itemize}136 \item137 oaddr: the address of the old object that needs to be resized.138 \item139 size: the new size requirement of the to which the old object needs to be resized.140 \end{itemize}141 It returns an object that is of the size given but it does not preserve the data in the old object. On failure, it returns NULL pointer.142 143 \subsubsection void * resize( void * oaddr, size_t nalign, size_t size )144 This resize is an extension of the above resize (FIX ME: cite above resize). In addition to resizing the size of of an old object, it can also realign the old object to a new alignment requirement.145 \paragraph{Usage}146 This resize takes three parameters. It takes an additional parameter of nalign as compared to the above resize (FIX ME: cite above resize).147 \begin{itemize}148 \item149 oaddr: the address of the old object that needs to be resized.150 \item151 nalign: the new alignment to which the old object needs to be realigned.152 \item153 size: the new size requirement of the to which the old object needs to be resized.154 \end{itemize}155 It returns an object with the size and alignment given in the parameters. On failure, it returns a NULL pointer.156 157 \subsubsection void * amemalign( size_t alignment, size_t dim, size_t elemSize )158 amemalign is a hybrid of memalign and aalloc. It allows programmer to allocate an aligned dynamic array of objects without calculating the total size of the array explicitly. It frees the programmer from calculating the total size of the array.159 \paragraph{Usage}160 amemalign takes three parameters.161 \begin{itemize}162 \item163 alignment: the alignment to which the dynamic array needs to be aligned.164 \item165 dim: number of objects in the array166 \item167 elemSize: size of the object in the array.168 \end{itemize}169 It returns a dynamic array of objects that has the capacity to contain dim number of objects of the size of elemSize. The returned dynamic array is aligned to the given alignment. On failure, it returns NULL pointer.170 171 \subsubsection void * cmemalign( size_t alignment, size_t dim, size_t elemSize )172 cmemalign is a hybrid of amemalign and calloc. It allows programmer to allocate an aligned dynamic array of objects that is 0 filled. The current way to do this in other allocators is to allocate an aligned object with memalign and then fill it with 0 explicitly. This routine provides both features of aligning and 0 filling, implicitly.173 \paragraph{Usage}174 cmemalign takes three parameters.175 \begin{itemize}176 \item177 alignment: the alignment to which the dynamic array needs to be aligned.178 \item179 dim: number of objects in the array180 \item181 elemSize: size of the object in the array.182 \end{itemize}183 It returns a dynamic array of objects that has the capacity to contain dim number of objects of the size of elemSize. The returned dynamic array is aligned to the given alignment and is 0 filled. On failure, it returns NULL pointer.184 185 \subsubsection size_t malloc_alignment( void * addr )186 malloc_alignment returns the alignment of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required alignment.187 \paragraph{Usage}188 malloc_alignment takes one parameters.189 \begin{itemize}190 \item191 addr: the address of the currently allocated dynamic object.192 \end{itemize}193 malloc_alignment returns the alignment of the given dynamic object. On failure, it return the value of default alignment of the uHeapLmmm allocator.194 195 \subsubsection bool malloc_zero_fill( void * addr )196 malloc_zero_fill returns whether a currently allocated dynamic object was initially zero filled at the time of allocation. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verifying the zero filled property of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was zero filled at the time of allocation.197 \paragraph{Usage}198 malloc_zero_fill takes one parameters.199 \begin{itemize}200 \item201 addr: the address of the currently allocated dynamic object.202 \end{itemize}203 malloc_zero_fill returns true if the dynamic object was initially zero filled and return false otherwise. On failure, it returns false.204 205 \subsubsection size_t malloc_size( void * addr )206 malloc_size returns the allocation size of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required size. Its current alternate in the other allocators is malloc_usable_size. But, malloc_size is different from malloc_usable_size as malloc_usabe_size returns the total data capacity of dynamic object including the extra space at the end of the dynamic object. On the other hand, malloc_size returns the size that was given to the allocator at the allocation of the dynamic object. This size is updated when an object is realloced, resized, or passed through a similar allocator routine.207 \paragraph{Usage}208 malloc_size takes one parameters.209 \begin{itemize}210 \item211 addr: the address of the currently allocated dynamic object.212 \end{itemize}213 malloc_size returns the allocation size of the given dynamic object. On failure, it return zero.214 215 \subsubsection void * realloc( void * oaddr, size_t nalign, size_t size )216 This realloc is an extension of the default realloc (FIX ME: cite default realloc). In addition to reallocating an old object and preserving the data in old object, it can also realign the old object to a new alignment requirement.217 \paragraph{Usage}218 This realloc takes three parameters. It takes an additional parameter of nalign as compared to the default realloc.219 \begin{itemize}220 \item221 oaddr: the address of the old object that needs to be reallocated.222 \item223 nalign: the new alignment to which the old object needs to be realigned.224 \item225 size: the new size requirement of the to which the old object needs to be resized.226 \end{itemize}227 It returns an object with the size and alignment given in the parameters that preserves the data in the old object. On failure, it returns a NULL pointer.228 229 \subsection{CFA Malloc Interface}230 We added some routines to the malloc interface of CFA. These routines can only be used in CFA and not in our standalone uHeapLmmm allocator as these routines use some features that are only provided by CFA and not by C. It makes the allocator even more usable to the programmers.231 CFA provides the liberty to know the returned type of a call to the allocator. So, mainly in these added routines, we removed the object size parameter from the routine as allocator can calculate the size of the object from the returned type.232 233 \subsubsection T * malloc( void )234 This malloc is a simplified polymorphic form of defualt malloc (FIX ME: cite malloc). It does not take any parameter as compared to default malloc that takes one parameter.235 \paragraph{Usage}236 This malloc takes no parameters.237 It returns a dynamic object of the size of type T. On failure, it return NULL pointer.238 239 \subsubsection T * aalloc( size_t dim )240 This aalloc is a simplified polymorphic form of above aalloc (FIX ME: cite aalloc). It takes one parameter as compared to the above aalloc that takes two parameters.241 \paragraph{Usage}242 aalloc takes one parameters.243 \begin{itemize}244 \item245 dim: required number of objects in the array.246 \end{itemize}247 It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. On failure, it return NULL pointer.248 249 \subsubsection T * calloc( size_t dim )250 This calloc is a simplified polymorphic form of defualt calloc (FIX ME: cite calloc). It takes one parameter as compared to the default calloc that takes two parameters.251 \paragraph{Usage}252 This calloc takes one parameter.253 \begin{itemize}254 \item255 dim: required number of objects in the array.256 \end{itemize}257 It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. On failure, it return NULL pointer.258 259 \subsubsection T * resize( T * ptr, size_t size )260 This resize is a simplified polymorphic form of above resize (FIX ME: cite resize with alignment). It takes two parameters as compared to the above resize that takes three parameters. It frees the programmer from explicitly mentioning the alignment of the allocation as CFA provides gives allocator the liberty to get the alignment of the returned type.261 \paragraph{Usage}262 This resize takes two parameters.263 \begin{itemize}264 \item265 ptr: address of the old object.266 \item267 size: the required size of the new object.268 \end{itemize}269 It returns a dynamic object of the size given in paramters. The returned object is aligned to the alignemtn of type T. On failure, it return NULL pointer.270 271 \subsubsection T * realloc( T * ptr, size_t size )272 This realloc is a simplified polymorphic form of defualt realloc (FIX ME: cite realloc with align). It takes two parameters as compared to the above realloc that takes three parameters. It frees the programmer from explicitly mentioning the alignment of the allocation as CFA provides gives allocator the liberty to get the alignment of the returned type.273 \paragraph{Usage}274 This realloc takes two parameters.275 \begin{itemize}276 \item277 ptr: address of the old object.278 \item279 size: the required size of the new object.280 \end{itemize}281 It returns a dynamic object of the size given in paramters that preserves the data in the given object. The returned object is aligned to the alignemtn of type T. On failure, it return NULL pointer.282 283 \subsubsection T * memalign( size_t align )284 This memalign is a simplified polymorphic form of defualt memalign (FIX ME: cite memalign). It takes one parameters as compared to the default memalign that takes two parameters.285 \paragraph{Usage}286 memalign takes one parameters.287 \begin{itemize}288 \item289 align: the required alignment of the dynamic object.290 \end{itemize}291 It returns a dynamic object of the size of type T that is aligned to given parameter align. On failure, it return NULL pointer.292 293 \subsubsection T * amemalign( size_t align, size_t dim )294 This amemalign is a simplified polymorphic form of above amemalign (FIX ME: cite amemalign). It takes two parameter as compared to the above amemalign that takes three parameters.295 \paragraph{Usage}296 amemalign takes two parameters.297 \begin{itemize}298 \item299 align: required alignment of the dynamic array.300 \item301 dim: required number of objects in the array.302 \end{itemize}303 It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. The returned object is aligned to the given parameter align. On failure, it return NULL pointer.304 305 \subsubsection T * cmemalign( size_t align, size_t dim )306 This cmemalign is a simplified polymorphic form of above cmemalign (FIX ME: cite cmemalign). It takes two parameter as compared to the above cmemalign that takes three parameters.307 \paragraph{Usage}308 cmemalign takes two parameters.309 \begin{itemize}310 \item311 align: required alignment of the dynamic array.312 \item313 dim: required number of objects in the array.314 \end{itemize}315 It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. The returned object is aligned to the given parameter align and is zero filled. On failure, it return NULL pointer.316 317 \subsubsection T * aligned_alloc( size_t align )318 This aligned_alloc is a simplified polymorphic form of defualt aligned_alloc (FIX ME: cite aligned_alloc). It takes one parameter as compared to the default aligned_alloc that takes two parameters.319 \paragraph{Usage}320 This aligned_alloc takes one parameter.321 \begin{itemize}322 \item323 align: required alignment of the dynamic object.324 \end{itemize}325 It returns a dynamic object of the size of type T that is aligned to the given parameter. On failure, it return NULL pointer.326 327 \subsubsection int posix_memalign( T ** ptr, size_t align )328 This posix_memalign is a simplified polymorphic form of defualt posix_memalign (FIX ME: cite posix_memalign). It takes two parameters as compared to the default posix_memalign that takes three parameters.329 \paragraph{Usage}330 This posix_memalign takes two parameter.331 \begin{itemize}332 \item333 ptr: variable address to store the address of the allocated object.334 \item335 align: required alignment of the dynamic object.336 \end{itemize}337 It stores address of the dynamic object of the size of type T in given parameter ptr. This object is aligned to the given parameter. On failure, it return NULL pointer.338 339 \subsubsection T * valloc( void )340 This valloc is a simplified polymorphic form of defualt valloc (FIX ME: cite valloc). It takes no parameters as compared to the default valloc that takes one parameter.341 \paragraph{Usage}342 valloc takes no parameters.343 It returns a dynamic object of the size of type T that is aligned to the page size. On failure, it return NULL pointer.344 345 \subsubsection T * pvalloc( void )346 This pcvalloc is a simplified polymorphic form of defualt pcvalloc (FIX ME: cite pcvalloc). It takes no parameters as compared to the default pcvalloc that takes one parameter.347 \paragraph{Usage}348 pvalloc takes no parameters.349 It returns a dynamic object of the size that is calcutaed by rouding the size of type T. The returned object is also aligned to the page size. On failure, it return NULL pointer.350 120 351 121 \subsection{Alloc Interface} -
libcfa/src/concurrency/locks.cfa
r86fc350 rd30804a 120 120 owner = t; 121 121 recursion_count = ( t ? 1 : 0 ); 122 if ( t )wait_count--;122 wait_count--; 123 123 unpark( t ); 124 124 } -
src/CompilationState.cc
r86fc350 rd30804a 9 9 // Author : Rob Schluntz 10 10 // Created On : Mon Ju1 30 10:47:01 2018 11 // Last Modified By : Henry Xue12 // Last Modified On : Tue Jul 20 04:27:35 202113 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri May 3 13:45:23 2019 13 // Update Count : 4 14 14 // 15 15 … … 23 23 ctorinitp = false, 24 24 declstatsp = false, 25 exdeclp = false,26 25 exprp = false, 27 26 expraltp = false, -
src/CompilationState.h
r86fc350 rd30804a 9 9 // Author : Rob Schluntz 10 10 // Created On : Mon Ju1 30 10:47:01 2018 11 // Last Modified By : Henry Xue12 // Last Modified On : Tue Jul 20 04:27:35 202113 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri May 3 13:43:21 2019 13 // Update Count : 4 14 14 // 15 15 … … 22 22 ctorinitp, 23 23 declstatsp, 24 exdeclp,25 24 exprp, 26 25 expraltp, -
src/ControlStruct/module.mk
r86fc350 rd30804a 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Henry Xue13 ## Last Modified On : Tue Jul 20 04:10:50 202114 ## Update Count : 512 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Wed Jun 28 16:15:00 2017 14 ## Update Count : 4 15 15 ############################################################################### 16 16 17 17 SRC_CONTROLSTRUCT = \ 18 ControlStruct/ExceptDecl.cc \19 ControlStruct/ExceptDecl.h \20 18 ControlStruct/ForExprMutator.cc \ 21 19 ControlStruct/ForExprMutator.h \ -
src/Parser/TypeData.cc
r86fc350 rd30804a 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:12:51 2015 11 // Last Modified By : Henry Xue12 // Last Modified On : Tue Jul 20 04:10:50202113 // Update Count : 67 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 18:57:31 2021 13 // Update Count : 672 14 14 // 15 15 … … 778 778 case AggregateDecl::Struct: 779 779 case AggregateDecl::Coroutine: 780 case AggregateDecl::Exception:781 780 case AggregateDecl::Generator: 782 781 case AggregateDecl::Monitor: -
src/SynTree/Declaration.h
r86fc350 rd30804a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Henry Xue12 // Last Modified On : Tue Jul 20 04:10:50202113 // Update Count : 1 6011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:35:36 2021 13 // Update Count : 159 14 14 // 15 15 … … 300 300 301 301 bool is_coroutine() { return kind == Coroutine; } 302 bool is_exception() { return kind == Exception; }303 302 bool is_generator() { return kind == Generator; } 304 303 bool is_monitor () { return kind == Monitor ; } -
src/main.cc
r86fc350 rd30804a 9 9 // Author : Peter Buhr and Rob Schluntz 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Henry Xue12 // Last Modified On : Tue Jul 20 04:27:35202113 // Update Count : 65 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 6 15:49:00 2021 13 // Update Count : 656 14 14 // 15 15 … … 49 49 #include "Common/utility.h" // for deleteAll, filter, printAll 50 50 #include "Concurrency/Waitfor.h" // for generateWaitfor 51 #include "ControlStruct/ExceptDecl.h" // for translateExcept52 51 #include "ControlStruct/ExceptTranslate.h" // for translateEHM 53 52 #include "ControlStruct/Mutate.h" // for mutate … … 306 305 CodeTools::fillLocations( translationUnit ); 307 306 Stats::Time::StopBlock(); 308 309 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( translationUnit ) );310 if ( exdeclp ) {311 dump( translationUnit );312 return EXIT_SUCCESS;313 } // if314 307 315 308 // add the assignment statement after the initialization of a type parameter … … 556 549 // code dumps 557 550 { "ast", astp, true, "print AST after parsing" }, 558 { "exdecl", exdeclp, true, "print AST after translating exception decls" },559 551 { "symevt", symtabp, true, "print AST after symbol table events" }, 560 552 { "altexpr", expraltp, true, "print alternatives for expressions" }, -
tests/polymorphism.cfa
r86fc350 rd30804a 71 71 printf(" offset of inner float: %ld\n", ((char *) & x_inner_float ) - ((char *) & x) ); 72 72 73 void showStatic( thing( long longint) & x ) {73 void showStatic( thing(int) & x ) { 74 74 printf("static:\n"); 75 75 SHOW_OFFSETS … … 85 85 86 86 printf("=== checkPlan9offsets\n"); 87 thing( long longint) x;87 thing(int) x; 88 88 showStatic(x); 89 89 showDynamic(x);
Note:
See TracChangeset
for help on using the changeset viewer.