Changeset 4d8fbf4 for doc/theses/andrew_beach_MMath/code
- Timestamp:
- Sep 16, 2021, 2:22:01 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 432bffe, 7e7a076
- Parents:
- a8367eb (diff), 140eb16 (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 edited
-
fixup-empty-f.cfa (modified) (2 diffs)
-
fixup-empty-r.cfa (modified) (2 diffs)
-
fixup-other-f.cfa (modified) (3 diffs)
-
fixup-other-r.cfa (modified) (3 diffs)
-
resume-empty.cfa (modified) (1 diff)
-
test.sh (modified) (10 diffs)
-
throw-empty.cfa (modified) (1 diff)
-
throw-empty.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/fixup-empty-f.cfa
ra8367eb r4d8fbf4 2 2 #include <clock.hfa> 3 3 #include <fstream.hfa> 4 #include <stdlib.hfa> // strto4 #include <stdlib.hfa> 5 5 6 intnounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) {6 void nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) { 7 7 if (frames) { 8 int rtn = nounwind_fixup(frames - 1, raised_rtn); 9 if ( rtn == 42 ) printf( "42" ); // make non-tail recursive 10 return rtn; 11 8 nounwind_fixup(frames - 1, raised_rtn); 9 // "Always" false, but prevents recursion elimination. 10 if (-1 == frames) printf("~"); 12 11 } else { 13 12 int fixup = 17; 14 13 raised_rtn(fixup); 15 return fixup;16 14 } 17 15 } … … 27 25 } 28 26 27 // Closures at the top level are allowed to be true closures. 29 28 void raised(int & fixup) { 30 fixup = total_frames + 42; // use local scope => lexical link31 if ( total_frames == 42 ) printf( "42");29 fixup = total_frames + 42; 30 if (total_frames == 42) printf("42"); 32 31 } 33 32 -
doc/theses/andrew_beach_MMath/code/fixup-empty-r.cfa
ra8367eb r4d8fbf4 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> // strto5 #include <stdlib.hfa> 6 6 7 7 exception fixup_exception { … … 10 10 vtable(fixup_exception) fixup_vt; 11 11 12 intnounwind_empty(unsigned int frames) {12 void nounwind_empty(unsigned int frames) { 13 13 if (frames) { 14 int rtn =nounwind_empty(frames - 1);15 if ( rtn == 42 ) printf( "42" ); // make non-tail recursive16 return rtn;14 nounwind_empty(frames - 1); 15 // "Always" false, but prevents recursion elimination. 16 if (-1 == frames) printf("~"); 17 17 } else { 18 18 int fixup = 17; 19 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup 20 return fixup; 19 throwResume (fixup_exception){&fixup_vt, fixup}; 21 20 } 22 21 } -
doc/theses/andrew_beach_MMath/code/fixup-other-f.cfa
ra8367eb r4d8fbf4 2 2 #include <clock.hfa> 3 3 #include <fstream.hfa> 4 #include <stdlib.hfa> // strto4 #include <stdlib.hfa> 5 5 6 unsigned int frames; // use global because of gcc thunk problem 6 // Using a global value to allow hoisting (and avoid thunks). 7 unsigned int frames; 7 8 8 9 void nounwind_fixup(unsigned int dummy, void (*raised_rtn)(int &), void (*not_raised_rtn)(int &)) { 9 10 void not_raised(int & fixup) { 10 fixup = frames + 42; // use local scope => lexical link11 fixup = frames + 42; 11 12 } 12 13 … … 14 15 frames -= 1; 15 16 nounwind_fixup(42, raised_rtn, not_raised); 17 // Always false, but prevents recursion elimination. 18 if (-1 == frames) printf("~"); 16 19 } else { 17 20 int fixup = dummy; … … 31 34 frames = total_frames; 32 35 36 // Closures at the top level are allowed to be true closures. 33 37 void raised(int & fixup) { 34 fixup = total_frames + 42; // use local scope => lexical link38 fixup = total_frames + 42; 35 39 } 36 40 void not_raised(int & fixup) { 37 fixup = total_frames + 42; // use local scope => lexical link41 fixup = total_frames + 42; 38 42 } 39 43 -
doc/theses/andrew_beach_MMath/code/fixup-other-r.cfa
ra8367eb r4d8fbf4 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> // strto5 #include <stdlib.hfa> 6 6 7 7 exception fixup_exception { … … 13 13 }; 14 14 15 unsigned int frames; // use global because of gcc thunk problem 15 // Using a global value to allow hoisting (and avoid thunks). 16 unsigned int frames; 16 17 17 18 void nounwind_other(unsigned int dummy) { … … 20 21 try { 21 22 nounwind_other(42); 23 // Always false, but prevents recursion elimination. 24 if (-1 == frames) printf("~"); 22 25 } catchResume (not_raised_exception * ex) { 23 ex->fixup = frames + 42; // use local scope => lexical link26 ex->fixup = frames + 42; 24 27 } 25 28 } else { 26 29 int fixup = dummy; 27 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup30 throwResume (fixup_exception){&fixup_vt, fixup}; 28 31 } 29 32 } -
doc/theses/andrew_beach_MMath/code/resume-empty.cfa
ra8367eb r4d8fbf4 11 11 if (frames) { 12 12 nounwind_empty(frames - 1); 13 if ( frames == -1 ) printf( "42" ); // prevent recursion optimizations 13 14 } else { 14 15 throwResume (empty_exception){&empty_vt}; -
doc/theses/andrew_beach_MMath/code/test.sh
ra8367eb r4d8fbf4 12 12 # test.sh -v LANGUAGE TEST FILE 13 13 # View the result from TEST in LANGUAGE stored in FILE. 14 15 readonly DIR=$(dirname "$(readlink -f "$0")") 16 cd $DIR 14 17 15 18 readonly MIL=000000 … … 52 55 ) 53 56 54 if [ "-a" = "$1" ]; then # build all57 if [ "-a" = "$1" ]; then 55 58 for file in *.cfa *.cpp *.java; do 56 59 build $file 57 60 done 58 61 exit 0 59 elif [ "-b" = "$1" ]; then # build given62 elif [ "-b" = "$1" ]; then 60 63 for file in "${@:2}"; do 61 64 build $file 62 65 done 63 66 exit 0 64 elif [ "-c" = "$1" ]; then # clean all67 elif [ "-c" = "$1" ]; then 65 68 rm $(basename -s ".cfa" -a *.cfa) 66 69 rm $(basename -s ".cpp" -a *.cpp) … … 89 92 raise-empty) 90 93 CFAT="./throw-empty $ITERS_1M $STACK_HEIGHT" 91 CFAR="./resume-empty $ITERS_1 M $STACK_HEIGHT"94 CFAR="./resume-empty $ITERS_10M $STACK_HEIGHT" 92 95 CPP="./throw-empty-cpp $ITERS_1M $STACK_HEIGHT" 93 96 JAVA="java ThrowEmpty $ITERS_1M $STACK_HEIGHT" … … 96 99 raise-detor) 97 100 CFAT="./throw-detor $ITERS_1M $STACK_HEIGHT" 98 CFAR="./resume-detor $ITERS_1 M $STACK_HEIGHT"101 CFAR="./resume-detor $ITERS_10M $STACK_HEIGHT" 99 102 CPP="./throw-detor-cpp $ITERS_1M $STACK_HEIGHT" 100 103 JAVA=unsupported … … 103 106 raise-finally) 104 107 CFAT="./throw-finally $ITERS_1M $STACK_HEIGHT" 105 CFAR="./resume-finally $ITERS_1 M $STACK_HEIGHT"108 CFAR="./resume-finally $ITERS_10M $STACK_HEIGHT" 106 109 CPP=unsupported 107 110 JAVA="java ThrowFinally $ITERS_1M $STACK_HEIGHT" … … 110 113 raise-other) 111 114 CFAT="./throw-other $ITERS_1M $STACK_HEIGHT" 112 CFAR="./resume-other $ITERS_1 M $STACK_HEIGHT"115 CFAR="./resume-other $ITERS_10M $STACK_HEIGHT" 113 116 CPP="./throw-other-cpp $ITERS_1M $STACK_HEIGHT" 114 117 JAVA="java ThrowOther $ITERS_1M $STACK_HEIGHT" … … 131 134 cond-match-all) 132 135 CFAT="./cond-catch $ITERS_10M 1" 133 CFAR="./cond-fixup $ITERS_10 M 1"136 CFAR="./cond-fixup $ITERS_100M 1" 134 137 CPP="./cond-catch-cpp $ITERS_10M 1" 135 138 JAVA="java CondCatch $ITERS_10M 1" … … 138 141 cond-match-none) 139 142 CFAT="./cond-catch $ITERS_10M 0" 140 CFAR="./cond-fixup $ITERS_10 M 0"143 CFAR="./cond-fixup $ITERS_100M 0" 141 144 CPP="./cond-catch-cpp $ITERS_10M 0" 142 145 JAVA="java CondCatch $ITERS_10M 0" … … 164 167 165 168 case "$TEST_LANG" in 166 cfa-t) CALL="$CFAT";;167 cfa-r) CALL="$CFAR";;168 cpp) CALL="$CPP";;169 java) CALL="$JAVA";;170 python) CALL="$PYTHON";;171 *)172 echo "No such language: $TEST_LANG" >&2173 exit 2169 cfa-t) CALL="$CFAT";; 170 cfa-r) CALL="$CFAR";; 171 cpp) CALL="$CPP";; 172 java) CALL="$JAVA";; 173 python) CALL="$PYTHON";; 174 *) 175 echo "No such language: $TEST_LANG" >&2 176 exit 2 174 177 ;; 175 178 esac … … 178 181 179 182 if [ -n "$VIEW_FILE" ]; then 180 grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p'183 grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time.*: !!;T;p' 181 184 exit 182 185 fi -
doc/theses/andrew_beach_MMath/code/throw-empty.cfa
ra8367eb r4d8fbf4 11 11 if (frames) { 12 12 unwind_empty(frames - 1); 13 if ( frames == -1 ) printf( "42" ); // prevent recursion optimizations 13 14 } else { 14 15 throw (empty_exception){&empty_vt}; -
doc/theses/andrew_beach_MMath/code/throw-empty.cpp
ra8367eb r4d8fbf4 1 1 // Throw Across Empty Function 2 2 #include <chrono> 3 #include <cstdio> 3 4 #include <cstdlib> 4 5 #include <exception> … … 14 15 if (frames) { 15 16 unwind_empty(frames - 1); 17 if (-1 == frames) printf("~"); 16 18 } else { 17 19 throw (EmptyException){};
Note:
See TracChangeset
for help on using the changeset viewer.