Changeset d83b266 for doc/theses/andrew_beach_MMath/code
- Timestamp:
- Jul 26, 2021, 2:42:34 PM (5 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- 0a061c0
- Parents:
- c86ee4c (diff), 98233b3 (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. - Location:
- doc/theses/andrew_beach_MMath/code
- Files:
-
- 8 added
- 19 edited
-
.gitignore (added)
-
cond-catch.cfa (modified) (2 diffs)
-
cond-catch.cpp (modified) (2 diffs)
-
cond-fixup.cfa (modified) (3 diffs)
-
cond_catch.py (added)
-
cross-catch.cfa (modified) (2 diffs)
-
cross-catch.cpp (modified) (2 diffs)
-
cross-finally.cfa (modified) (1 diff)
-
cross-resume.cfa (modified) (1 diff)
-
cross_catch.py (added)
-
cross_finally.py (added)
-
resume-detor.cfa (modified) (2 diffs)
-
resume-empty.cfa (modified) (2 diffs)
-
resume-finally.cfa (modified) (2 diffs)
-
resume-other.cfa (modified) (2 diffs)
-
test.sh (modified) (12 diffs)
-
throw-detor.cfa (modified) (2 diffs)
-
throw-detor.cpp (modified) (2 diffs)
-
throw-empty.cfa (modified) (1 diff)
-
throw-empty.cpp (modified) (1 diff)
-
throw-finally.cfa (modified) (2 diffs)
-
throw-other.cfa (modified) (2 diffs)
-
throw-other.cpp (modified) (2 diffs)
-
throw_empty.py (added)
-
throw_finally.py (added)
-
throw_other.py (added)
-
throw_with.py (added)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/cond-catch.cfa
rc86ee4c rd83b266 19 19 throw_exception(); 20 20 } catch (empty_exception * exc ; should_catch) { 21 // ...21 asm volatile ("# catch block (conditional)"); 22 22 } 23 23 } … … 37 37 cond_catch(); 38 38 } catch (empty_exception * exc) { 39 // ...39 asm volatile ("# catch block (unconditional)"); 40 40 } 41 41 } -
doc/theses/andrew_beach_MMath/code/cond-catch.cpp
rc86ee4c rd83b266 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)"); 24 25 } 25 26 } … … 39 40 cond_catch(); 40 41 } catch (EmptyException &) { 41 // ...42 asm volatile ("# catch block (unconditional)"); 42 43 } 43 44 } -
doc/theses/andrew_beach_MMath/code/cond-fixup.cfa
rc86ee4c rd83b266 12 12 13 13 void throw_exception() { 14 throw (empty_exception){&empty_vt};14 throwResume (empty_exception){&empty_vt}; 15 15 } 16 16 … … 18 18 try { 19 19 throw_exception(); 20 } catch (empty_exception * exc ; should_catch) {21 // ...20 } catchResume (empty_exception * exc ; should_catch) { 21 asm volatile ("# fixup block (conditional)"); 22 22 } 23 23 } … … 36 36 try { 37 37 cond_catch(); 38 } catch (empty_exception * exc) {39 // ...38 } catchResume (empty_exception * exc) { 39 asm volatile ("# fixup block (unconditional)"); 40 40 } 41 41 } -
doc/theses/andrew_beach_MMath/code/cross-catch.cfa
rc86ee4c rd83b266 7 7 EHM_EXCEPTION(not_raised_exception)(); 8 8 9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt); 10 9 11 int main(int argc, char * argv[]) { 10 12 unsigned int times = 1; 11 unsigned int total_frames = 1;13 volatile bool should_throw = false; 12 14 if (1 < argc) { 13 15 times = strtol(argv[1], 0p, 10); 14 }15 if (2 < argc) {16 total_frames = strtol(argv[2], 0p, 10);17 16 } 18 17 … … 20 19 for (unsigned int count = 0 ; count < times ; ++count) { 21 20 try { 22 // ... 21 asm volatile ("# try block"); 22 if (should_throw) { 23 throw (not_raised_exception){¬_vt}; 24 } 23 25 } catch (not_raised_exception *) { 24 // ...26 asm volatile ("# catch block"); 25 27 } 26 28 } -
doc/theses/andrew_beach_MMath/code/cross-catch.cpp
rc86ee4c rd83b266 11 11 int main(int argc, char * argv[]) { 12 12 unsigned int times = 1; 13 volatile bool should_throw = false; 13 14 if (1 < argc) { 14 15 times = strtol(argv[1], nullptr, 10); … … 18 19 for (unsigned int count = 0 ; count < times ; ++count) { 19 20 try { 20 // ... 21 asm volatile ("# try block"); 22 if (should_throw) { 23 throw NotRaisedException(); 24 } 21 25 } catch (NotRaisedException &) { 22 // ...26 asm volatile ("# catch block"); 23 27 } 24 28 } -
doc/theses/andrew_beach_MMath/code/cross-finally.cfa
rc86ee4c rd83b266 5 5 #include <stdlib.hfa> 6 6 7 EHM_EXCEPTION(not_raised_exception)(); 8 9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt); 10 7 11 int main(int argc, char * argv[]) { 8 12 unsigned int times = 1; 9 unsigned int total_frames = 1;13 volatile bool should_throw = false; 10 14 if (1 < argc) { 11 15 times = strtol(argv[1], 0p, 10); 12 }13 if (2 < argc) {14 total_frames = strtol(argv[2], 0p, 10);15 16 } 16 17 17 18 Time start_time = timeHiRes(); 18 19 for (unsigned int count = 0 ; count < times ; ++count) { 19 try { 20 // ... 20 try { 21 asm volatile ("# try block"); 22 if (should_throw) { 23 throw (not_raised_exception){¬_vt}; 24 } 21 25 } finally { 22 // ...26 asm volatile ("# finally block"); 23 27 } 24 28 } -
doc/theses/andrew_beach_MMath/code/cross-resume.cfa
rc86ee4c rd83b266 20 20 for (unsigned int count = 0 ; count < times ; ++count) { 21 21 try { 22 // ...22 asm volatile (""); 23 23 } catchResume (not_raised_exception *) { 24 // ...24 asm volatile (""); 25 25 } 26 26 } -
doc/theses/andrew_beach_MMath/code/resume-detor.cfa
rc86ee4c rd83b266 12 12 13 13 void ^?{}(WithDestructor & this) { 14 // ... 14 asm volatile ("# destructor body"); 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 // ... 43 }44 }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 } 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
rc86ee4c rd83b266 13 13 unwind_empty(frames - 1); 14 14 } else { 15 throw (empty_exception){&empty_vt};15 throwResume (empty_exception){&empty_vt}; 16 16 } 17 17 } … … 31 31 try { 32 32 unwind_empty(total_frames); 33 } catch (empty_exception *) {34 // ...33 } catchResume (empty_exception *) { 34 asm volatile ("# fixup block"); 35 35 } 36 36 } -
doc/theses/andrew_beach_MMath/code/resume-finally.cfa
rc86ee4c rd83b266 14 14 unwind_finally(frames - 1); 15 15 } finally { 16 // ...16 asm volatile ("# finally block"); 17 17 } 18 18 } else { … … 36 36 unwind_finally(total_frames); 37 37 } catchResume (empty_exception *) { 38 // ...38 asm volatile ("# fixup block"); 39 39 } 40 40 } -
doc/theses/andrew_beach_MMath/code/resume-other.cfa
rc86ee4c rd83b266 16 16 unwind_other(frames - 1); 17 17 } catchResume (not_raised_exception *) { 18 // ...18 asm volatile ("# fixup block (stack)"); 19 19 } 20 20 } else { … … 38 38 unwind_other(total_frames); 39 39 } catchResume (empty_exception *) { 40 // ...40 asm volatile ("# fixup block (base)"); 41 41 } 42 42 } -
doc/theses/andrew_beach_MMath/code/test.sh
rc86ee4c rd83b266 1 1 #!/usr/bin/env bash 2 2 3 # Usage: LANGUAGE TEST | -b SOURCE_FILE 3 # Usage: 4 # test.sh LANGUAGE TEST 5 # Run the TEST in LANGUAGE. 6 # test.sh -b SOURCE_FILE... 7 # Build a test from SOURCE_FILE(s). 8 # test.sh -v LANGUAGE TEST FILE 9 # View the result from TEST in LANGUAGE stored in FILE. 4 10 5 11 readonly ITERATIONS=1000000 # 1 000 000, one million … … 18 24 *.cfa) 19 25 # Requires a symbolic link. 20 mmake "${1%.cfa}" "$1" ./cfa "$1" -o "${1%.cfa}"26 mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}" 21 27 ;; 22 28 *.cpp) 23 mmake "${1%.cpp}-cpp" "$1" g++ "$1" -o "${1%.cpp}-cpp"29 mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp" 24 30 ;; 25 31 *.java) … … 38 44 done 39 45 exit 0 46 elif [ "-v" = "$1" -a 4 = "$#" ]; then 47 TEST_LANG="$2" 48 TEST_CASE="$3" 49 VIEW_FILE="$4" 50 elif [ 2 -eq "$#" ]; then 51 TEST_LANG="$1" 52 TEST_CASE="$2" 53 else 54 echo "Unknown call pattern." >&2 55 exit 2 40 56 fi 41 57 … … 46 62 } 47 63 48 case "$ 2" in64 case "$TEST_CASE" in 49 65 cond-match-all) 50 66 CFAT="./cond-catch $ITERATIONS 1" … … 52 68 CPP="./cond-catch-cpp $ITERATIONS 1" 53 69 JAVA="java CondCatch $ITERATIONS 1" 70 PYTHON="./cond_catch.py $ITERATIONS 1" 54 71 ;; 55 72 cond-match-none) … … 58 75 CPP="./cond-catch-cpp $ITERATIONS 0" 59 76 JAVA="java CondCatch $ITERATIONS 0" 77 PYTHON="./cond_catch.py $ITERATIONS 0" 60 78 ;; 61 79 cross-catch) … … 64 82 CPP="./cross-catch-cpp $ITERATIONS" 65 83 JAVA="java CrossCatch $ITERATIONS" 84 PYTHON="./cross_catch.py $ITERATIONS" 66 85 ;; 67 86 cross-finally) … … 70 89 CPP=unsupported 71 90 JAVA="java CrossFinally $ITERATIONS" 91 PYTHON="./cross_finally.py $ITERATIONS" 72 92 ;; 73 93 raise-detor) … … 76 96 CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT" 77 97 JAVA=unsupported 98 PYTHON=unsupported 78 99 ;; 79 100 raise-empty) … … 82 103 CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT" 83 104 JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT" 105 PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT" 84 106 ;; 85 107 raise-finally) … … 88 110 CPP=unsupported 89 111 JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT" 112 PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT" 90 113 ;; 91 114 raise-other) … … 94 117 CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT" 95 118 JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT" 119 PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT" 96 120 ;; 97 121 *) 98 echo "No such test ." >&2122 echo "No such test: $TEST_CASE" >&2 99 123 exit 2 100 124 ;; 101 125 esac 102 126 103 case "$1" in 104 cfa-t) echo $CFAT; $CFAT;; 105 cfa-r) echo $CFAR; $CFAR;; 106 cpp) echo $CPP; $CPP;; 107 java) echo $JAVA; $JAVA;; 127 case "$TEST_LANG" in 128 cfa-t) CALL="$CFAT";; 129 cfa-r) CALL="$CFAR";; 130 cpp) CALL="$CPP";; 131 java) CALL="$JAVA";; 132 python) CALL="$PYTHON";; 133 *) 134 echo "No such language: $TEST_LANG" >&2 135 exit 2 136 ;; 108 137 esac 138 139 echo $CALL 140 141 if [ -n "$VIEW_FILE" ]; then 142 grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p' 143 exit 144 fi 145 146 $CALL -
doc/theses/andrew_beach_MMath/code/throw-detor.cfa
rc86ee4c rd83b266 12 12 13 13 void ^?{}(WithDestructor & this) { 14 // ...14 asm volatile ("# destructor body"); 15 15 } 16 16 … … 39 39 unwind_destructor(total_frames); 40 40 } catch (empty_exception *) { 41 // ...41 asm volatile ("# catch block"); 42 42 } 43 43 } -
doc/theses/andrew_beach_MMath/code/throw-detor.cpp
rc86ee4c rd83b266 10 10 11 11 struct WithDestructor { 12 ~WithDestructor() {} 12 ~WithDestructor() { 13 asm volatile ("# destructor body"); 14 } 13 15 }; 14 16 … … 37 39 unwind_destructor(total_frames); 38 40 } catch (EmptyException &) { 39 // ...41 asm volatile ("# catch block"); 40 42 } 41 43 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cfa
rc86ee4c rd83b266 32 32 unwind_empty(total_frames); 33 33 } catch (empty_exception *) { 34 // ...34 asm volatile ("# catch block"); 35 35 } 36 36 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cpp
rc86ee4c rd83b266 32 32 unwind_empty(total_frames); 33 33 } catch (EmptyException &) { 34 // ...34 asm volatile ("# catch block"); 35 35 } 36 36 } -
doc/theses/andrew_beach_MMath/code/throw-finally.cfa
rc86ee4c rd83b266 14 14 unwind_finally(frames - 1); 15 15 } finally { 16 // ...16 asm volatile ("# finally block"); 17 17 } 18 18 } else { … … 36 36 unwind_finally(total_frames); 37 37 } catch (empty_exception *) { 38 // ...38 asm volatile ("# catch block"); 39 39 } 40 40 } -
doc/theses/andrew_beach_MMath/code/throw-other.cfa
rc86ee4c rd83b266 16 16 unwind_other(frames - 1); 17 17 } catch (not_raised_exception *) { 18 // ...18 asm volatile ("# catch block (stack)"); 19 19 } 20 20 } else { … … 38 38 unwind_other(total_frames); 39 39 } catch (empty_exception *) { 40 // ...40 asm volatile ("# catch block (base)"); 41 41 } 42 42 } -
doc/theses/andrew_beach_MMath/code/throw-other.cpp
rc86ee4c rd83b266 16 16 unwind_other(frames - 1); 17 17 } catch (NotRaisedException &) { 18 // ...18 asm volatile ("# catch block (stack)"); 19 19 } 20 20 } else { … … 38 38 unwind_other(total_frames); 39 39 } catch (EmptyException &) { 40 // ...40 asm volatile ("# catch block (base)"); 41 41 } 42 42 }
Note:
See TracChangeset
for help on using the changeset viewer.