Changeset f79ee0d for doc/theses/andrew_beach_MMath
- Timestamp:
- Aug 19, 2021, 1:58:46 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
- Children:
- 262deda0
- Parents:
- 8a1d95af
- Location:
- doc/theses/andrew_beach_MMath/code
- Files:
-
- 10 added
- 20 edited
- 13 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/CondCatch.java
r8a1d95af rf79ee0d 6 6 static boolean should_catch = false; 7 7 8 static void throw_exception() throws EmptyException {9 throw new EmptyException();10 }11 12 static void cond_catch() throws EmptyException {13 try {14 throw_exception();15 } catch (EmptyException exc) {16 if (!should_catch) {17 throw exc;18 }19 }20 }21 22 8 private static long loop(int times) { 23 9 long startTime = System.nanoTime(); 24 10 for (int count = 0 ; count < times ; ++count) { 25 11 try { 26 cond_catch(); 12 try { 13 throw new EmptyException(); 14 } catch (EmptyException exc) { 15 if (!should_catch) { 16 throw exc; 17 } 18 } 27 19 } catch (EmptyException exc) { 28 20 // ... … … 46 38 47 39 long time = loop(times); 48 System.out. println("Run-Time (ns): " + time);40 System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); 49 41 } 50 42 } -
doc/theses/andrew_beach_MMath/code/ThrowEmpty.java
r8a1d95af rf79ee0d 39 39 40 40 long time = loop(times, total_frames); 41 System.out. println("Run-Time (ns): " + time);41 System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); 42 42 } 43 43 } -
doc/theses/andrew_beach_MMath/code/ThrowFinally.java
r8a1d95af rf79ee0d 44 44 45 45 long time = loop(times, total_frames); 46 System.out. println("Run-Time (ns): " + time);46 System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); 47 47 } 48 48 } -
doc/theses/andrew_beach_MMath/code/ThrowOther.java
r8a1d95af rf79ee0d 52 52 53 53 long time = loop(times, total_frames); 54 System.out. println("Run-Time (ns): " + time);54 System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); 55 55 } 56 56 } -
doc/theses/andrew_beach_MMath/code/TryCatch.java
r8a1d95af rf79ee0d 3 3 class NotRaisedException extends Exception {} 4 4 5 public class CrossCatch {5 public class TryCatch { 6 6 private static boolean shouldThrow = false; 7 7 … … 31 31 32 32 long time = loop(times); 33 System.out. println("Run-Time (ns): " + time);33 System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); 34 34 } 35 35 } -
doc/theses/andrew_beach_MMath/code/TryFinally.java
r8a1d95af rf79ee0d 1 // Cross a Try Statement with a Finally Clause1 // Enter and Leave a Try Statement with a Finally Handler 2 2 3 public class CrossFinally {3 public class TryFinally { 4 4 private static boolean shouldThrow = false; 5 5 … … 27 27 28 28 long time = loop(times); 29 System.out. println("Run-Time (ns): " + time);29 System.out.format("Run-Time (s): %.1f%n", time / 1_000_000_000.); 30 30 } 31 31 } -
doc/theses/andrew_beach_MMath/code/cond-catch.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.h >5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 8 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 10 9 11 10 bool should_catch = false; 12 13 void throw_exception() {14 throw (empty_exception){&empty_vt};15 }16 17 void cond_catch() {18 try {19 throw_exception();20 } catch (empty_exception * exc ; should_catch) {21 asm volatile ("# catch block (conditional)");22 }23 }24 11 25 12 int main(int argc, char * argv[]) { 26 13 unsigned int times = 1; 27 14 if (1 < argc) { 28 times = strto l(argv[1], 0p, 10);15 times = strto(argv[1], 0p, 10); 29 16 } 30 17 if (2 < argc) { 31 should_catch = strtol(argv[2], 0p, 10);18 should_catch = (unsigned int)strto(argv[2], 0p, 2); 32 19 } 33 20 … … 35 22 for (unsigned int count = 0 ; count < times ; ++count) { 36 23 try { 37 cond_catch(); 24 throw (empty_exception){&empty_vt}; 25 } catch (empty_exception * exc ; should_catch) { 26 asm volatile ("# catch block (conditional)"); 38 27 } catch (empty_exception * exc) { 39 28 asm volatile ("# catch block (unconditional)"); … … 41 30 } 42 31 Time end_time = timeHiRes(); 43 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;32 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 44 33 } -
doc/theses/andrew_beach_MMath/code/cond-catch.cpp
r8a1d95af rf79ee0d 4 4 #include <exception> 5 5 #include <iostream> 6 #include <iomanip> 6 7 8 using namespace std; 7 9 using namespace std::chrono; 8 10 … … 10 12 11 13 bool should_catch = false; 12 13 void throw_exception() {14 throw EmptyException();15 }16 17 void cond_catch() {18 try {19 throw_exception();20 } catch (EmptyException & exc) {21 if (!should_catch) {22 throw;23 }24 asm volatile ("# catch block (conditional)");25 }26 }27 14 28 15 int main(int argc, char * argv[]) { … … 38 25 for (unsigned int count = 0 ; count < times ; ++count) { 39 26 try { 40 cond_catch(); 27 try { 28 throw EmptyException(); 29 } catch (EmptyException & exc) { 30 if (!should_catch) { 31 throw; 32 } 33 asm volatile ("# catch block (conditional)"); 34 } 41 35 } catch (EmptyException &) { 42 36 asm volatile ("# catch block (unconditional)"); … … 45 39 time_point<steady_clock> end_time = steady_clock::now(); 46 40 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 47 std::cout << "Run-Time (ns): " << duration.count() << std::endl;41 cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl; 48 42 } -
doc/theses/andrew_beach_MMath/code/cond-catch.py
r8a1d95af rf79ee0d 13 13 14 14 15 def throw_exception():16 raise EmptyException()17 18 19 def cond_catch():20 try:21 throw_exception()22 except EmptyException as exc:23 if not should_catch:24 raise25 26 27 15 def main(argv): 28 16 times = 1 … … 35 23 for count in range(times): 36 24 try: 37 cond_catch(); 25 try: 26 raise EmptyException() 27 except EmptyException as exc: 28 if not should_catch: 29 raise 38 30 except EmptyException: 39 31 pass 40 32 41 33 end_time = thread_time_ns() 42 print('Run-Time ( ns):', end_time - start_time)34 print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.)) 43 35 44 36 -
doc/theses/andrew_beach_MMath/code/cond-fixup.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 8 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 10 9 11 10 bool should_catch = false; 12 13 void throw_exception() {14 throwResume (empty_exception){&empty_vt};15 }16 17 void cond_catch() {18 try {19 throw_exception();20 } catchResume (empty_exception * exc ; should_catch) {21 asm volatile ("# fixup block (conditional)");22 }23 }24 11 25 12 int main(int argc, char * argv[]) { 26 13 unsigned int times = 1; 27 14 if (1 < argc) { 28 times = strto l(argv[1], 0p, 10);15 times = strto(argv[1], 0p, 10); 29 16 } 30 17 if (2 < argc) { 31 should_catch = strtol(argv[2], 0p, 10);18 should_catch = (unsigned int)strto(argv[2], 0p, 2); 32 19 } 33 20 … … 35 22 for (unsigned int count = 0 ; count < times ; ++count) { 36 23 try { 37 cond_catch(); 24 throwResume (empty_exception){&empty_vt}; 25 } catchResume (empty_exception * exc ; should_catch) { 26 asm volatile ("# fixup block (conditional)"); 38 27 } catchResume (empty_exception * exc) { 39 28 asm volatile ("# fixup block (unconditional)"); … … 41 30 } 42 31 Time end_time = timeHiRes(); 43 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;32 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 44 33 } -
doc/theses/andrew_beach_MMath/code/resume-detor.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 8 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 10 9 11 10 struct WithDestructor {}; … … 17 16 void unwind_destructor(unsigned int frames) { 18 17 if (frames) { 19 20 18 WithDestructor object; 21 19 unwind_destructor(frames - 1); … … 29 27 unsigned int total_frames = 1; 30 28 if (1 < argc) { 31 times = strto l(argv[1], 0p, 10);29 times = strto(argv[1], 0p, 10); 32 30 } 33 31 if (2 < argc) { 34 total_frames = strto l(argv[2], 0p, 10);32 total_frames = strto(argv[2], 0p, 10); 35 33 } 36 34 … … 44 42 } 45 43 Time end_time = timeHiRes(); 46 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;44 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 47 45 } -
doc/theses/andrew_beach_MMath/code/resume-empty.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 8 9 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 10 11 void unwind_empty(unsigned int frames) { 10 void nounwind_empty(unsigned int frames) { 12 11 if (frames) { 13 unwind_empty(frames - 1);12 nounwind_empty(frames - 1); 14 13 } else { 15 14 throwResume (empty_exception){&empty_vt}; … … 21 20 unsigned int total_frames = 1; 22 21 if (1 < argc) { 23 times = strto l(argv[1], 0p, 10);22 times = strto(argv[1], 0p, 10); 24 23 } 25 24 if (2 < argc) { 26 total_frames = strto l(argv[2], 0p, 10);25 total_frames = strto(argv[2], 0p, 10); 27 26 } 28 27 29 28 Time start_time = timeHiRes(); 30 for ( int count = 0 ; count < times ; ++count) {29 for (unsigned int count = 0 ; count < times ; ++count) { 31 30 try { 32 unwind_empty(total_frames);31 nounwind_empty(total_frames); 33 32 } catchResume (empty_exception *) { 34 33 asm volatile ("# fixup block"); … … 36 35 } 37 36 Time end_time = timeHiRes(); 38 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;37 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 39 38 } -
doc/theses/andrew_beach_MMath/code/resume-finally.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 8 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 10 9 11 10 void unwind_finally(unsigned int frames) { … … 25 24 unsigned int total_frames = 1; 26 25 if (1 < argc) { 27 times = strto l(argv[1], 0p, 10);26 times = strto(argv[1], 0p, 10); 28 27 } 29 28 if (2 < argc) { 30 total_frames = strto l(argv[2], 0p, 10);29 total_frames = strto(argv[2], 0p, 10); 31 30 } 32 31 … … 40 39 } 41 40 Time end_time = timeHiRes(); 42 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;41 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 43 42 } -
doc/theses/andrew_beach_MMath/code/resume-other.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 9 exception not_raised_exception; 8 10 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 10 11 EHM_EXCEPTION(not_raised_exception)(); 12 13 void unwind_other(unsigned int frames) { 11 void nounwind_other(unsigned int frames) { 14 12 if (frames) { 15 13 try { 16 unwind_other(frames - 1);14 nounwind_other(frames - 1); 17 15 } catchResume (not_raised_exception *) { 18 16 asm volatile ("# fixup block (stack)"); … … 27 25 unsigned int total_frames = 1; 28 26 if (1 < argc) { 29 times = strto l(argv[1], 0p, 10);27 times = strto(argv[1], 0p, 10); 30 28 } 31 29 if (2 < argc) { 32 total_frames = strto l(argv[2], 0p, 10);30 total_frames = strto(argv[2], 0p, 10); 33 31 } 34 32 … … 36 34 for (int count = 0 ; count < times ; ++count) { 37 35 try { 38 unwind_other(total_frames);36 nounwind_other(total_frames); 39 37 } catchResume (empty_exception *) { 40 38 asm volatile ("# fixup block (base)"); … … 42 40 } 43 41 Time end_time = timeHiRes(); 44 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;42 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 45 43 } -
doc/theses/andrew_beach_MMath/code/run.sh
r8a1d95af rf79ee0d 1 1 #!/usr/bin/env bash 2 2 3 readonly ALL_TESTS=( cond-match-{all,none} cross-{catch,finally} \4 raise-{detor,empty,finally,other})3 readonly ALL_TESTS=(raise-{empty,detor,finally,other} try-{catch,finally} cond-match-{all,none} \ 4 raise-{fixup-empty,fixup-other}) 5 5 6 6 gen-file-name() ( … … 18 18 ) 19 19 20 readonly N=${1:-5} 20 #readonly N=${1:-5} 21 readonly N=${1:-1} 21 22 readonly OUT_FILE=$(gen-file-name ${2:-run-%-$N}) 22 23 -
doc/theses/andrew_beach_MMath/code/test.sh
r8a1d95af rf79ee0d 4 4 # test.sh LANGUAGE TEST 5 5 # Run the TEST in LANGUAGE. 6 # test.sh -a 7 # Build all tests. 6 8 # test.sh -b SOURCE_FILE... 7 9 # Build a test from SOURCE_FILE(s). 10 # test.sh -c 11 # Clean all executables. 8 12 # test.sh -v LANGUAGE TEST FILE 9 13 # View the result from TEST in LANGUAGE stored in FILE. 10 14 11 readonly ITERATIONS=1000000 # 1 000 000, one million 15 readonly ITERS_1M=1000000 # 1 000 000, one million 16 readonly ITERS_10M=10000000 # 10 000 000, ten million 17 readonly ITERS_100M=100000000 # 100 000 000, hundred million 18 readonly ITERS_1000M=1000000000 # 1 000 000 000, billion 12 19 readonly STACK_HEIGHT=100 13 20 … … 24 31 *.cfa) 25 32 # Requires a symbolic link. 26 mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"33 mmake "${1%.cfa}" "$1" cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}" 27 34 ;; 28 35 *.cpp) 29 mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"36 mmake "${1%.cpp}-cpp" "$1" g++-10 -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp" 30 37 ;; 31 38 *.java) … … 39 46 ) 40 47 41 if [ "-b" = "$1" ]; then 48 if [ "-a" = "$1" ]; then # build all 49 for file in *.cfa *.cpp *.java; do 50 build $file 51 done 52 exit 0 53 elif [ "-b" = "$1" ]; then # build given 42 54 for file in "${@:2}"; do 43 55 build $file 44 56 done 45 57 exit 0 58 elif [ "-c" = "$1" ]; then # clean all 59 rm -f `basename -s ".cfa" -a *.cfa` 60 rm -f `basename -s ".cpp" -a *.cpp` 61 rm -f *-cpp 62 rm -f *.class 63 exit 0 46 64 elif [ "-v" = "$1" -a 4 = "$#" ]; then 47 48 49 65 TEST_LANG="$2" 66 TEST_CASE="$3" 67 VIEW_FILE="$4" 50 68 elif [ 2 -eq "$#" ]; then 51 69 TEST_LANG="$1" … … 63 81 64 82 case "$TEST_CASE" in 65 cond-match-all) 66 CFAT="./cond-catch $ITERATIONS 1" 67 CFAR="./cond-fixup $ITERATIONS 1" 68 CPP="./cond-catch-cpp $ITERATIONS 1" 69 JAVA="java CondCatch $ITERATIONS 1" 70 PYTHON="./cond_catch.py $ITERATIONS 1" 71 ;; 72 cond-match-none) 73 CFAT="./cond-catch $ITERATIONS 0" 74 CFAR="./cond-fixup $ITERATIONS 0" 75 CPP="./cond-catch-cpp $ITERATIONS 0" 76 JAVA="java CondCatch $ITERATIONS 0" 77 PYTHON="./cond_catch.py $ITERATIONS 0" 78 ;; 79 cross-catch) 80 CFAT="./cross-catch $ITERATIONS" 81 CFAR="./cross-resume $ITERATIONS" 82 CPP="./cross-catch-cpp $ITERATIONS" 83 JAVA="java CrossCatch $ITERATIONS" 84 PYTHON="./cross_catch.py $ITERATIONS" 85 ;; 86 cross-finally) 87 CFAT="./cross-finally $ITERATIONS" 88 CFAR=unsupported 89 CPP=unsupported 90 JAVA="java CrossFinally $ITERATIONS" 91 PYTHON="./cross_finally.py $ITERATIONS" 83 raise-empty) 84 CFAT="./throw-empty $ITERS_1M $STACK_HEIGHT" 85 # see resume-fixup-empty-r CFAR="./resume-empty $ITERS_1M $STACK_HEIGHT" 86 CPP="./throw-empty-cpp $ITERS_1M $STACK_HEIGHT" 87 JAVA="java ThrowEmpty $ITERS_1M $STACK_HEIGHT" 88 PYTHON="./throw-empty.py $ITERS_1M $STACK_HEIGHT" 92 89 ;; 93 90 raise-detor) 94 CFAT="./throw-detor $ITER ATIONS$STACK_HEIGHT"95 CFAR="./resume-detor $ITERATIONS$STACK_HEIGHT"96 CPP="./throw-detor-cpp $ITER ATIONS$STACK_HEIGHT"91 CFAT="./throw-detor $ITERS_1M $STACK_HEIGHT" 92 # N/A CFAR="./resume-detor $ITERS_1M $STACK_HEIGHT" 93 CPP="./throw-detor-cpp $ITERS_1M $STACK_HEIGHT" 97 94 JAVA=unsupported 98 95 PYTHON=unsupported 99 96 ;; 100 raise-empty)101 CFAT="./throw-empty $ITERATIONS $STACK_HEIGHT"102 CFAR="./resume-empty $ITERATIONS $STACK_HEIGHT"103 CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT"104 JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT"105 PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"106 ;;107 97 raise-finally) 108 CFAT="./throw-finally $ITER ATIONS$STACK_HEIGHT"109 CFAR="./resume-finally $ITERATIONS$STACK_HEIGHT"98 CFAT="./throw-finally $ITERS_1M $STACK_HEIGHT" 99 # N/A CFAR="./resume-finally $ITERS_1M $STACK_HEIGHT" 110 100 CPP=unsupported 111 JAVA="java ThrowFinally $ITER ATIONS$STACK_HEIGHT"112 PYTHON="./throw _finally.py $ITERATIONS$STACK_HEIGHT"101 JAVA="java ThrowFinally $ITERS_1M $STACK_HEIGHT" 102 PYTHON="./throw-finally.py $ITERS_1M $STACK_HEIGHT" 113 103 ;; 114 104 raise-other) 115 CFAT="./throw-other $ITERATIONS $STACK_HEIGHT" 116 CFAR="./resume-other $ITERATIONS $STACK_HEIGHT" 117 CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT" 118 JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT" 119 PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT" 105 CFAT="./throw-other $ITERS_1M $STACK_HEIGHT" 106 # N/A CFAR="./resume-other $ITERS_1M $STACK_HEIGHT" 107 CPP="./throw-other-cpp $ITERS_1M $STACK_HEIGHT" 108 JAVA="java ThrowOther $ITERS_1M $STACK_HEIGHT" 109 PYTHON="./throw-other.py $ITERS_1M $STACK_HEIGHT" 110 ;; 111 try-catch) 112 CFAT="./try-catch $ITERS_1000M" 113 CFAR="./try-resume $ITERS_1000M" 114 CPP="./try-catch-cpp $ITERS_1000M" 115 JAVA="java TryCatch $ITERS_1000M" 116 PYTHON="./try-catch.py $ITERS_1000M" 117 ;; 118 try-finally) 119 CFAT="./try-finally $ITERS_1000M" 120 CFAR=unsupported 121 CPP=unsupported 122 JAVA="java TryFinally $ITERS_1000M" 123 PYTHON="./try-finally.py $ITERS_1000M" 124 ;; 125 cond-match-all) 126 CFAT="./cond-catch $ITERS_10M 1" 127 CFAR="./cond-fixup $ITERS_10M 1" 128 CPP="./cond-catch-cpp $ITERS_10M 1" 129 JAVA="java CondCatch $ITERS_10M 1" 130 PYTHON="./cond-catch.py $ITERS_10M 1" 131 ;; 132 cond-match-none) 133 CFAT="./cond-catch $ITERS_10M 0" 134 CFAR="./cond-fixup $ITERS_10M 0" 135 CPP="./cond-catch-cpp $ITERS_10M 0" 136 JAVA="java CondCatch $ITERS_10M 0" 137 PYTHON="./cond-catch.py $ITERS_10M 0" 138 ;; 139 raise-fixup-empty) 140 CFAT="./resume-fixup-empty-f $ITERS_10M $STACK_HEIGHT" 141 CFAR="./resume-fixup-empty-r $ITERS_10M $STACK_HEIGHT" 142 CPP="./resume-fixup-empty-cpp $ITERS_10M $STACK_HEIGHT" 143 JAVA="java ResumeFixupEmpty $ITERS_10M $STACK_HEIGHT" 144 PYTHON="./resume-fixup-empty.py $ITERS_10M $STACK_HEIGHT" 145 ;; 146 raise-fixup-other) 147 CFAT="./resume-fixup-other-f $ITERS_10M $STACK_HEIGHT" 148 CFAR="./resume-fixup-other-r $ITERS_10M $STACK_HEIGHT" 149 CPP="./resume-fixup-other-cpp $ITERS_10M $STACK_HEIGHT" 150 JAVA="java ResumeFixupOther $ITERS_10M $STACK_HEIGHT" 151 PYTHON="./resume-fixup-other.py $ITERS_10M $STACK_HEIGHT" 120 152 ;; 121 153 *) … … 126 158 127 159 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" >&2135 exit 2160 cfa-t) CALL="$CFAT";; 161 cfa-r) CALL="$CFAR";; 162 cpp) CALL="$CPP";; 163 java) CALL="$JAVA";; 164 python) CALL="$PYTHON";; 165 *) 166 echo "No such language: $TEST_LANG" >&2 167 exit 2 136 168 ;; 137 169 esac … … 140 172 141 173 if [ -n "$VIEW_FILE" ]; then 142 143 174 grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p' 175 exit 144 176 fi 145 177 -
doc/theses/andrew_beach_MMath/code/throw-detor.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 8 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 10 9 11 10 struct WithDestructor {}; … … 28 27 unsigned int total_frames = 1; 29 28 if (1 < argc) { 30 times = strto l(argv[1], 0p, 10);29 times = strto(argv[1], 0p, 10); 31 30 } 32 31 if (2 < argc) { 33 total_frames = strto l(argv[2], 0p, 10);32 total_frames = strto(argv[2], 0p, 10); 34 33 } 35 34 … … 43 42 } 44 43 Time end_time = timeHiRes(); 45 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;44 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 46 45 } -
doc/theses/andrew_beach_MMath/code/throw-detor.cpp
r8a1d95af rf79ee0d 4 4 #include <exception> 5 5 #include <iostream> 6 #include <iomanip> 6 7 8 using namespace std; 7 9 using namespace std::chrono; 8 10 … … 44 46 time_point<steady_clock> end_time = steady_clock::now(); 45 47 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 46 std::cout << "Run-Time (ns): " << duration.count() << std::endl;48 cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl; 47 49 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 8 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 10 9 11 10 void unwind_empty(unsigned int frames) { … … 21 20 unsigned int total_frames = 1; 22 21 if (1 < argc) { 23 times = strto l(argv[1], 0p, 10);22 times = strto(argv[1], 0p, 10); 24 23 } 25 24 if (2 < argc) { 26 total_frames = strto l(argv[2], 0p, 10);25 total_frames = strto(argv[2], 0p, 10); 27 26 } 28 27 … … 36 35 } 37 36 Time end_time = timeHiRes(); 38 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;37 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 39 38 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cpp
r8a1d95af rf79ee0d 4 4 #include <exception> 5 5 #include <iostream> 6 #include <iomanip> 6 7 8 using namespace std; 7 9 using namespace std::chrono; 8 10 … … 37 39 time_point<steady_clock> end_time = steady_clock::now(); 38 40 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 39 std::cout << "Run-Time (ns): " << duration.count() << std::endl;41 cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl; 40 42 } -
doc/theses/andrew_beach_MMath/code/throw-empty.py
r8a1d95af rf79ee0d 33 33 34 34 end_time = thread_time_ns() 35 print('Run-Time ( ns):', end_time - start_time)35 print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.)) 36 36 37 37 -
doc/theses/andrew_beach_MMath/code/throw-finally.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 8 9 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 10 unsigned int frames; // use global because of gcc thunk problem 10 11 11 void unwind_finally(unsigned int frames) {12 void unwind_finally(unsigned int dummy) { 12 13 if (frames) { 14 frames -= 1; 13 15 try { 14 unwind_finally( frames - 1);16 unwind_finally(42); 15 17 } finally { 16 18 asm volatile ("# finally block"); 17 19 } 18 20 } else { 21 dummy = 42; 19 22 throw (empty_exception){&empty_vt}; 20 23 } … … 25 28 unsigned int total_frames = 1; 26 29 if (1 < argc) { 27 times = strto l(argv[1], 0p, 10);30 times = strto(argv[1], 0p, 10); 28 31 } 29 32 if (2 < argc) { 30 total_frames = strto l(argv[2], 0p, 10);33 total_frames = strto(argv[2], 0p, 10); 31 34 } 35 frames = total_frames; 32 36 33 37 Time start_time = timeHiRes(); 34 38 for (int count = 0 ; count < times ; ++count) { 35 39 try { 36 unwind_finally( total_frames);40 unwind_finally(42); 37 41 } catch (empty_exception *) { 38 42 asm volatile ("# catch block"); … … 40 44 } 41 45 Time end_time = timeHiRes(); 42 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;46 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 43 47 } -
doc/theses/andrew_beach_MMath/code/throw-finally.py
r8a1d95af rf79ee0d 36 36 37 37 end_time = thread_time_ns() 38 print('Run-Time ( ns):', end_time - start_time)38 print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.)) 39 39 40 40 -
doc/theses/andrew_beach_MMath/code/throw-other.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(empty_exception)(); 7 exception empty_exception; 8 vtable(empty_exception) empty_vt; 9 exception not_raised_exception; 8 10 9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt); 11 unsigned int frames; // use global because of gcc thunk problem 10 12 11 EHM_EXCEPTION(not_raised_exception)(); 12 13 void unwind_other(unsigned int frames) { 13 void unwind_other(unsigned int dummy) { 14 14 if (frames) { 15 frames -= 1; 15 16 try { 16 unwind_other( frames - 1);17 unwind_other(42); 17 18 } catch (not_raised_exception *) { 18 19 asm volatile ("# catch block (stack)"); 19 20 } 20 21 } else { 22 dummy = 42; 21 23 throw (empty_exception){&empty_vt}; 22 24 } … … 27 29 unsigned int total_frames = 1; 28 30 if (1 < argc) { 29 times = strto l(argv[1], 0p, 10);31 times = strto(argv[1], 0p, 10); 30 32 } 31 33 if (2 < argc) { 32 total_frames = strto l(argv[2], 0p, 10);34 total_frames = strto(argv[2], 0p, 10); 33 35 } 36 frames = total_frames; 34 37 35 38 Time start_time = timeHiRes(); 36 39 for (int count = 0 ; count < times ; ++count) { 37 40 try { 38 unwind_other( total_frames);41 unwind_other(42); 39 42 } catch (empty_exception *) { 40 43 asm volatile ("# catch block (base)"); … … 42 45 } 43 46 Time end_time = timeHiRes(); 44 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;47 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 45 48 } -
doc/theses/andrew_beach_MMath/code/throw-other.cpp
r8a1d95af rf79ee0d 4 4 #include <exception> 5 5 #include <iostream> 6 #include <iomanip> 6 7 8 using namespace std; 7 9 using namespace std::chrono; 8 10 … … 43 45 time_point<steady_clock> end_time = steady_clock::now(); 44 46 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 45 std::cout << "Run-Time (ns): " << duration.count() << std::endl;47 cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl; 46 48 } -
doc/theses/andrew_beach_MMath/code/throw-other.py
r8a1d95af rf79ee0d 40 40 41 41 end_time = thread_time_ns() 42 print('Run-Time ( ns):', end_time - start_time)42 print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.)) 43 43 44 44 -
doc/theses/andrew_beach_MMath/code/throw-with.py
r8a1d95af rf79ee0d 43 43 44 44 end_time = thread_time_ns() 45 print('Run-Time ( ns):', end_time - start_time)45 print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.)) 46 46 47 47 -
doc/theses/andrew_beach_MMath/code/try-catch.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(not_raised_exception)(); 8 9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt); 7 exception not_raised_exception; 8 vtable(not_raised_exception) not_vt; 10 9 11 10 int main(int argc, char * argv[]) { … … 13 12 volatile bool should_throw = false; 14 13 if (1 < argc) { 15 times = strto l(argv[1], 0p, 10);14 times = strto(argv[1], 0p, 10); 16 15 } 17 16 … … 28 27 } 29 28 Time end_time = timeHiRes(); 30 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;29 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 31 30 } -
doc/theses/andrew_beach_MMath/code/try-catch.cpp
r8a1d95af rf79ee0d 4 4 #include <exception> 5 5 #include <iostream> 6 #include <iomanip> 6 7 8 using namespace std; 7 9 using namespace std::chrono; 8 10 … … 29 31 time_point<steady_clock> end_time = steady_clock::now(); 30 32 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 31 std::cout << "Run-Time (ns): " << duration.count() << std::endl;33 cout << "Run-Time (s): " << fixed << setprecision(1) << duration.count() / 1'000'000'000. << endl; 32 34 } -
doc/theses/andrew_beach_MMath/code/try-catch.py
r8a1d95af rf79ee0d 23 23 24 24 end_time = thread_time_ns() 25 print('Run-Time ( ns):', end_time - start_time)25 print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.)) 26 26 27 27 -
doc/theses/andrew_beach_MMath/code/try-finally.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(not_raised_exception)(); 8 9 EHM_VIRTUAL_TABLE(not_raised_exception, not_vt); 7 exception not_raised_exception; 8 vtable(not_raised_exception) not_vt; 10 9 11 10 int main(int argc, char * argv[]) { … … 13 12 volatile bool should_throw = false; 14 13 if (1 < argc) { 15 times = strto l(argv[1], 0p, 10);14 times = strto(argv[1], 0p, 10); 16 15 } 17 16 … … 28 27 } 29 28 Time end_time = timeHiRes(); 30 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;29 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 31 30 } -
doc/theses/andrew_beach_MMath/code/try-finally.py
r8a1d95af rf79ee0d 22 22 23 23 end_time = thread_time_ns() 24 print('Run-Time ( ns):', end_time - start_time)24 print('Run-Time (s) {:.1f}:'.format((end_time - start_time) / 1_000_000_000.)) 25 25 26 26 -
doc/theses/andrew_beach_MMath/code/try-resume.cfa
r8a1d95af rf79ee0d 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> 5 #include <stdlib.hfa> // strto 6 6 7 EHM_EXCEPTION(not_raised_exception)();7 exception not_raised_exception; 8 8 9 9 int main(int argc, char * argv[]) { … … 11 11 unsigned int total_frames = 1; 12 12 if (1 < argc) { 13 times = strto l(argv[1], 0p, 10);13 times = strto(argv[1], 0p, 10); 14 14 } 15 15 if (2 < argc) { 16 total_frames = strto l(argv[2], 0p, 10);16 total_frames = strto(argv[2], 0p, 10); 17 17 } 18 18 … … 26 26 } 27 27 Time end_time = timeHiRes(); 28 sout | "Run-Time ( ns): " | (end_time - start_time)`ns;28 sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); 29 29 }
Note: See TracChangeset
for help on using the changeset viewer.