Changes in / [bdfc032:aefb247]
- Files:
-
- 10 added
- 32 deleted
- 95 edited
-
benchmark/Makefile.am (modified) (10 diffs)
-
benchmark/Makefile.in (modified) (9 diffs)
-
benchmark/basic/fetch_add.c (deleted)
-
benchmark/basic/function.c (deleted)
-
benchmark/basic/loop.c (deleted)
-
benchmark/basic/tls_fetch_add.c (deleted)
-
benchmark/basic/ttst_lock.c (deleted)
-
benchmark/bench.h (modified) (3 diffs)
-
benchmark/creation/JavaThread.java (modified) (4 diffs)
-
benchmark/creation/cfa_cor.cfa (modified) (1 diff)
-
benchmark/creation/cfa_gen.cfa (deleted)
-
benchmark/creation/cfa_thrd.cfa (modified) (1 diff)
-
benchmark/creation/goroutine.go (modified) (2 diffs)
-
benchmark/creation/node_cor.js (deleted)
-
benchmark/creation/pthreads.c (modified) (3 diffs)
-
benchmark/creation/python_cor.py (deleted)
-
benchmark/creation/rust_thrd.rs (deleted)
-
benchmark/creation/upp_cor.cc (modified) (1 diff)
-
benchmark/creation/upp_thrd.cc (modified) (1 diff)
-
benchmark/ctxswitch/JavaThread.java (modified) (3 diffs)
-
benchmark/ctxswitch/cfa_cor.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_cor_then.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_gen.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_thrd.cfa (modified) (1 diff)
-
benchmark/ctxswitch/cfa_thrd2.cfa (modified) (1 diff)
-
benchmark/ctxswitch/goroutine.go (modified) (2 diffs)
-
benchmark/ctxswitch/kos_fibre.cpp (modified) (1 diff)
-
benchmark/ctxswitch/kos_fibre2.cpp (modified) (1 diff)
-
benchmark/ctxswitch/node_await.js (deleted)
-
benchmark/ctxswitch/node_cor.js (deleted)
-
benchmark/ctxswitch/pthreads.c (modified) (1 diff)
-
benchmark/ctxswitch/python_cor.py (deleted)
-
benchmark/ctxswitch/rust_thrd.rs (deleted)
-
benchmark/ctxswitch/upp_cor.cc (modified) (2 diffs)
-
benchmark/ctxswitch/upp_thrd.cc (modified) (1 diff)
-
benchmark/exclude (deleted)
-
benchmark/fetch_add.c (added)
-
benchmark/function.c (added)
-
benchmark/loop.c (added)
-
benchmark/mutex/JavaThread.java (modified) (4 diffs)
-
benchmark/mutex/cfa1.cfa (modified) (1 diff)
-
benchmark/mutex/cfa2.cfa (modified) (1 diff)
-
benchmark/mutex/cfa4.cfa (modified) (1 diff)
-
benchmark/mutex/goroutine.go (deleted)
-
benchmark/mutex/pthreads.c (modified) (1 diff)
-
benchmark/mutex/rust.rs (deleted)
-
benchmark/mutex/upp.cc (modified) (1 diff)
-
benchmark/mutexC/JavaThread.java (deleted)
-
benchmark/mutexC/cfa1.cfa (deleted)
-
benchmark/mutexC/cfa2.cfa (deleted)
-
benchmark/mutexC/cfa4.cfa (deleted)
-
benchmark/mutexC/pthreads.c (deleted)
-
benchmark/mutexC/rust.rs (deleted)
-
benchmark/mutexC/upp.cc (deleted)
-
benchmark/schedext/cfa1.cfa (modified) (1 diff)
-
benchmark/schedext/cfa2.cfa (modified) (1 diff)
-
benchmark/schedext/cfa4.cfa (modified) (1 diff)
-
benchmark/schedext/goroutine.go (deleted)
-
benchmark/schedext/upp.cc (modified) (1 diff)
-
benchmark/schedint/JavaThread.java (modified) (4 diffs)
-
benchmark/schedint/cfa1.cfa (modified) (1 diff)
-
benchmark/schedint/cfa2.cfa (modified) (1 diff)
-
benchmark/schedint/cfa4.cfa (modified) (1 diff)
-
benchmark/schedint/pthreads.c (modified) (1 diff)
-
benchmark/schedint/rust.rs (deleted)
-
benchmark/schedint/upp.cc (modified) (2 diffs)
-
benchmark/tls-fetch_add.c (added)
-
benchmark/ttst_lock.c (added)
-
driver/cfa.cc (modified) (2 diffs)
-
libcfa/src/Makefile.in (modified) (2 diffs)
-
libcfa/src/bits/containers.hfa (modified) (8 diffs)
-
libcfa/src/bits/defs.hfa (modified) (2 diffs)
-
libcfa/src/bits/signal.hfa (modified) (2 diffs)
-
libcfa/src/clock.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/CtxSwitch-x86_64.S (modified) (1 diff)
-
libcfa/src/concurrency/alarm.cfa (modified) (2 diffs)
-
libcfa/src/concurrency/coroutine.cfa (modified) (2 diffs)
-
libcfa/src/concurrency/coroutine.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/invoke.c (modified) (6 diffs)
-
libcfa/src/concurrency/kernel.cfa (modified) (5 diffs)
-
libcfa/src/concurrency/kernel_private.hfa (modified) (1 diff)
-
libcfa/src/concurrency/monitor.cfa (modified) (1 diff)
-
libcfa/src/concurrency/thread.cfa (modified) (3 diffs)
-
libcfa/src/concurrency/thread.hfa (modified) (1 diff)
-
libcfa/src/executor.cfa (modified) (2 diffs)
-
libcfa/src/interpose.cfa (modified) (11 diffs)
-
libcfa/src/startup.cfa (modified) (2 diffs)
-
libcfa/src/stdhdr/bfdlink.h (modified) (1 diff)
-
libcfa/src/stdhdr/hwloc.h (modified) (1 diff)
-
libcfa/src/stdhdr/krb5.h (modified) (1 diff)
-
libcfa/src/stdhdr/math.h (modified) (1 diff)
-
libcfa/src/stdhdr/sys/ucontext.h (modified) (1 diff)
-
libcfa/src/time.cfa (modified) (8 diffs)
-
libcfa/src/time.hfa (modified) (6 diffs)
-
libcfa/src/time_t.hfa (modified) (3 diffs)
-
longrun_tests/Makefile.in (modified) (2 diffs)
-
src/Common/Stats/Time.h (modified) (3 diffs)
-
src/Concurrency/Keywords.cc (modified) (1 diff)
-
src/Concurrency/Waitfor.cc (modified) (2 diffs)
-
src/ControlStruct/LabelFixer.cc (modified) (5 diffs)
-
src/ControlStruct/MLEMutator.cc (modified) (14 diffs)
-
src/ControlStruct/MLEMutator.h (modified) (4 diffs)
-
src/Parser/lex.ll (modified) (2 diffs)
-
src/Parser/parser.yy (modified) (15 diffs)
-
src/SymTab/Validate.cc (modified) (1 diff)
-
src/SynTree/Statement.cc (modified) (34 diffs)
-
src/SynTree/Statement.h (modified) (3 diffs)
-
src/cfa.make (modified) (3 diffs)
-
tests/.expect/time.txt (modified) (1 diff)
-
tests/Makefile.in (modified) (2 diffs)
-
tests/concurrent/examples/boundedBufferEXT.cfa (modified) (3 diffs)
-
tests/concurrent/examples/boundedBufferTHREAD.cfa (modified) (2 diffs)
-
tests/concurrent/examples/gortn.cfa (modified) (2 diffs)
-
tests/concurrent/waitfor/barge.cfa (modified) (1 diff)
-
tests/concurrent/waitfor/dtor.cfa (modified) (1 diff)
-
tests/concurrent/waitfor/else.cfa (modified) (4 diffs)
-
tests/concurrent/waitfor/parse.cfa (modified) (7 diffs)
-
tests/concurrent/waitfor/parse2.cfa (modified) (13 diffs)
-
tests/concurrent/waitfor/recurse.cfa (modified) (3 diffs)
-
tests/concurrent/waitfor/statment.cfa (modified) (1 diff)
-
tests/concurrent/waitfor/when.cfa (modified) (1 diff)
-
tests/except-0.cfa (added)
-
tests/except-1.cfa (added)
-
tests/except-2.cfa (added)
-
tests/except-3.cfa (added)
-
tests/except-mac.hfa (added)
-
tests/exceptions/.expect/finally-error.txt (deleted)
-
tests/exceptions/except-0.cfa (deleted)
-
tests/exceptions/except-1.cfa (deleted)
-
tests/exceptions/except-2.cfa (deleted)
-
tests/exceptions/except-3.cfa (deleted)
-
tests/exceptions/except-mac.hfa (deleted)
-
tests/exceptions/finally-error.cfa (deleted)
-
tests/expression.cfa (modified) (1 diff)
-
tests/quotedKeyword.cfa (modified) (2 diffs)
-
tests/time.cfa (modified) (4 diffs)
-
tools/stat.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Makefile.am
rbdfc032 raefb247 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:44 202014 ## Update Count : 25513 ## Last Modified On : Mon Jul 29 18:02:19 2019 14 ## Update Count : 54 15 15 ############################################################################### 16 16 … … 28 28 BENCH_V_CFA = $(__bench_v_CFA_$(__quiet)) 29 29 BENCH_V_CXX = $(__bench_v_CXX_$(__quiet)) 30 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet)) 31 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet)) 30 32 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet)) 31 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))32 BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))33 BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))34 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))35 33 36 34 __quiet = verbose … … 38 36 __bench_v_CFA_quiet = @ 39 37 __bench_v_CXX_quiet = @ 38 __bench_v_GOC_quiet = @ 39 __bench_v_JAVAC_quiet = @ 40 40 __bench_v_UPP_quiet = @ 41 __bench_v_GOC_quiet = @42 __bench_v_RUSTC_quiet = @43 __bench_v_JAVAC_quiet = @44 41 __bench_v_CC_verbose = $(AM_V_CC) 45 42 __bench_v_CFA_verbose = $(AM_V_CFA) 46 43 __bench_v_CXX_verbose = $(AM_V_CXX) 44 __bench_v_GOC_verbose = $(AM_V_GOC) 45 __bench_v_JAVAC_verbose = $(AM_V_JAVAC) 47 46 __bench_v_UPP_verbose = $(AM_V_UPP) 48 __bench_v_GOC_verbose = $(AM_V_GOC)49 __bench_v_RUSTC_verbose = $(AM_V_RUSTC)50 __bench_v_NODEJS_verbose = $(AM_V_NODEJS)51 __bench_v_JAVAC_verbose = $(AM_V_JAVAC)52 47 53 48 … … 56 51 STATS = ${abs_top_srcdir}/tools/stat.py 57 52 # NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED 58 repeats = 13# 31 for benchmarks53 repeats = 5 # 31 for benchmarks 59 54 arch = x64 60 55 skipcompile = no … … 67 62 68 63 dummyC.c: 69 echo "int main() { return 0; }" > ${@}64 @echo "int main() { return 0; }" > ${@} 70 65 71 66 dummyCXX.cpp: 72 echo "int main() { return 0; }" > ${@} 73 74 #.SILENT: # do not print recipe 75 .ONESHELL: # use one shell to execute recipe 67 @echo "int main() { return 0; }" > ${@} 68 76 69 .NOTPARALLEL: 77 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv 78 79 ## ========================================================================================================= 80 81 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT) 82 83 basic_loop_DURATION = 15000000000 84 basic_function_DURATION = 10000000000 85 basic_tls_fetch_add_DURATION = 10000000000 86 basic_DURATION = 250000000 87 88 ctxswitch_pthread_DURATION = 25000000 89 ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION) 90 ctxswitch_cfa_generator_DURATION = 5000000000 91 ctxswitch_nodejs_await_DURATION = 5000000 92 ctxswitch_DURATION = 100000000 93 94 #mutex_java_DURATION = 10000000 95 mutex_DURATION = 50000000 96 97 schedint_pthread_DURATION = 1000000 98 schedint_java_DURATION = $(schedint_pthread_DURATION) 99 schedint_rust_DURATION = $(schedint_pthread_DURATION) 100 schedint_DURATION = 10000000 101 102 schedext_DURATION = 10000000 103 104 creation_pthread_DURATION = 250000 105 creation_rust_thread_DURATION = ${creation_pthread_DURATION} 106 creation_java_thread_DURATION = ${creation_pthread_DURATION} 107 creation_cfa_coroutine_DURATION = 100000000 108 creation_cfa_coroutine_eager_DURATION = 10000000 109 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION} 110 creation_cfa_thread_DURATION = 10000000 111 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION} 112 creation_DURATION = 10000000 70 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv 71 72 ## ========================================================================================================= 73 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 113 74 114 75 %.run : %$(EXEEXT) ${REPEAT} 115 rm -f .result.log 116 echo "------------------------------------------------------" 117 echo $< 118 ${REPEAT} ${repeats} -- ./a.out\ 119 $(if ${$(subst -,_,$(basename $@))_DURATION},\ 120 ${$(subst -,_,$(basename $@))_DURATION},\ 121 ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log 122 ${STATS} .result.log 123 echo "------------------------------------------------------" 124 rm -f a.out .result.log *.class 125 126 # ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out 76 @rm -f .result.log 77 @echo "------------------------------------------------------" 78 @echo $< 79 @${REPEAT} ${repeats} ./a.out | tee -a .result.log 80 @${STATS} .result.log 81 @echo "------------------------------------------------------" 82 @rm -f a.out .result.log *.class 127 83 128 84 %.runquiet : 129 +make $(basename $@) CFLAGS="-w" __quiet=quiet130 taskset -c 1 ./a.out131 rm -f a.out85 @+make $(basename $@) CFLAGS="-w" __quiet=quiet 86 @taskset -c 1 ./a.out 87 @rm -f a.out 132 88 133 89 %.make : 134 printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))135 +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&190 @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@)) 91 @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1 136 92 137 93 ${REPEAT} : 138 +make -C ${abs_top_builddir}/tools repeat94 @+make -C ${abs_top_builddir}/tools repeat 139 95 140 96 ## ========================================================================================================= … … 144 100 jenkins$(EXEEXT): 145 101 @DOifskipcompile@ 146 +make compile.csv147 -+make compile.diff.csv102 @+make compile.csv 103 @-+make compile.diff.csv 148 104 @DOendif@ 149 +make basic.csv 150 -+make basic.diff.csv 151 +make ctxswitch.csv 152 -+make ctxswitch.diff.csv 153 +make mutex.csv 154 -+make mutex.diff.csv 155 +make schedint.csv 156 -+make schedint.diff.csv 105 @+make ctxswitch.csv 106 @-+make ctxswitch.diff.csv 107 @+make mutex.csv 108 @-+make mutex.diff.csv 109 @+make signal.csv 110 @-+make signal.diff.csv 157 111 @DOifskipcompile@ 158 112 cat compile.csv 159 113 -cat compile.diff.csv 160 114 @DOendif@ 161 cat basic.csv162 -cat basic.diff.csv163 115 cat ctxswitch.csv 164 116 -cat ctxswitch.diff.csv 165 117 cat mutex.csv 166 118 -cat mutex.diff.csv 167 cat s chedint.csv168 -cat s chedint.diff.csv119 cat signal.csv 120 -cat signal.diff.csv 169 121 170 122 compile.csv: 171 echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@ 172 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@ 173 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@ 174 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@ 175 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@ 176 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@ 177 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@ 178 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@ 179 +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@ 180 $(srcdir)/fixcsv.sh $@ 181 182 basic.csv: 183 echo "generator,coroutine,thread" > $@ 184 +make basic-cfa_generator.runquiet >> $@ && echo -n ',' >> $@ 185 +make basic-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@ 186 +make basic-cfa_thread.runquiet >> $@ 187 $(srcdir)/fixcsv.sh $@ 123 @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@ 124 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@ 125 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@ 126 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@ 127 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@ 128 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@ 129 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@ 130 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@ 131 @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@ 132 @$(srcdir)/fixcsv.sh $@ 188 133 189 134 ctxswitch.csv: 190 echo "generator,coroutine,thread" > $@191 +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@192 +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@193 +make ctxswitch-cfa_thread.runquiet >> $@194 $(srcdir)/fixcsv.sh $@135 @echo "generator,coroutine,thread" > $@ 136 @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@ 137 @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@ 138 @+make ctxswitch-cfa_thread.runquiet >> $@ 139 @$(srcdir)/fixcsv.sh $@ 195 140 196 141 mutex.csv: 197 echo "1-monitor,2-monitor" > $@198 +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@199 +make mutex-cfa2.runquiet >> $@200 $(srcdir)/fixcsv.sh $@201 202 s chedint.csv:203 echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@204 +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@205 +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@206 +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@207 +make schedext-cfa2.runquiet >> $@208 $(srcdir)/fixcsv.sh $@142 @echo "1-monitor,2-monitor" > $@ 143 @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@ 144 @+make mutex-cfa2.runquiet >> $@ 145 @$(srcdir)/fixcsv.sh $@ 146 147 signal.csv: 148 @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@ 149 @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@ 150 @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@ 151 @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@ 152 @+make waitfor-cfa2.runquiet >> $@ 153 @$(srcdir)/fixcsv.sh $@ 209 154 210 155 %.diff.csv: %.csv 211 test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false) 212 $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@ 213 214 ## ========================================================================================================= 215 216 BASIC_DEPEND = \ 217 basic-loop.run \ 218 basic-function.run \ 219 basic-fetch_add.run \ 220 basic-ttst_lock.run \ 221 basic-tls-fetch_add.run 222 223 basic-loop$(EXEEXT): 224 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c 225 226 basic-function$(EXEEXT): 227 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c 228 229 basic-fetch_add$(EXEEXT): 230 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c 231 232 basic-ttst_lock$(EXEEXT): 233 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c 234 235 basic-tls-fetch_add$(EXEEXT): 236 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c 237 238 basic$(EXEEXT): $(BASIC_DEPEND) 239 240 ## ========================================================================================================= 241 242 CTXSWITCH_DEPEND = \ 156 @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false) 157 @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@ 158 159 160 ## ========================================================================================================= 161 loop$(EXEEXT): 162 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c 163 164 function$(EXEEXT): 165 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c 166 167 fetch_add$(EXEEXT): 168 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/fetch_add.c 169 170 ttst_lock$(EXEEXT): 171 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/ttst_lock.c 172 173 tls-fetch_add$(EXEEXT): 174 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/tls-fetch_add.c 175 176 ## ========================================================================================================= 177 CTXSWITCH_DEPEND = \ 178 loop.run \ 179 function.run \ 180 fetch_add.run \ 181 ttst_lock.run \ 182 tls-fetch_add.run \ 183 ctxswitch-pthread.run \ 243 184 ctxswitch-cfa_generator.run \ 244 185 ctxswitch-cfa_coroutine.run \ … … 247 188 ctxswitch-upp_coroutine.run \ 248 189 ctxswitch-upp_thread.run \ 249 ctxswitch-python_coroutine.run \ 250 ctxswitch-nodejs_coroutine.run \ 251 ctxswitch-nodejs_await.run \ 252 ctxswitch-goroutine_thread.run \ 253 ctxswitch-rust_thread.run \ 254 ctxswitch-nodejs_coroutine.run \ 255 ctxswitch-java_thread.run \ 256 ctxswitch-pthread.run 190 ctxswitch-goroutine.run \ 191 ctxswitch-java_thread.run 192 257 193 258 194 if WITH_LIBFIBRE 259 CTXSWITCH_DEPEND += \260 ctxswitch-kos_fibre.run \195 CTXSWITCH_DEPEND += \ 196 ctxswitch-kos_fibre.run \ 261 197 ctxswitch-kos_fibre2.run 198 262 199 263 200 ctxswitch-kos_fibre$(EXEEXT): … … 270 207 ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND) 271 208 209 ctxswitch-pthread$(EXEEXT): 210 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c 211 272 212 ctxswitch-cfa_generator$(EXEEXT): 273 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa213 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa 274 214 275 215 ctxswitch-cfa_coroutine$(EXEEXT): 276 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa216 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa 277 217 278 218 ctxswitch-cfa_thread$(EXEEXT): 279 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa219 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa 280 220 281 221 ctxswitch-cfa_thread2$(EXEEXT): 282 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa222 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa 283 223 284 224 ctxswitch-upp_coroutine$(EXEEXT): 285 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc225 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc 286 226 287 227 ctxswitch-upp_thread$(EXEEXT): 288 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc 289 290 ctxswitch-python_coroutine$(EXEEXT): 291 echo "#!/bin/sh" > a.out 292 echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out 293 chmod a+x a.out 294 295 ctxswitch-nodejs_coroutine$(EXEEXT): 296 echo "#!/bin/sh" > a.out 297 echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out 298 chmod a+x a.out 299 300 ctxswitch-nodejs_await$(EXEEXT): 301 echo "#!/bin/sh" > a.out 302 echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out 303 chmod a+x a.out 304 305 ctxswitch-goroutine_thread$(EXEEXT): 228 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc 229 230 ctxswitch-goroutine$(EXEEXT): 306 231 $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go 307 308 ctxswitch-rust_thread$(EXEEXT):309 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs310 232 311 233 ctxswitch-java_thread$(EXEEXT): 312 234 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java 313 echo "#!/bin/sh" > a.out 314 echo "java JavaThread" >> a.out 315 chmod a+x a.out 316 317 ctxswitch-pthread$(EXEEXT): 318 $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c 319 320 ## ========================================================================================================= 321 322 mutex$(EXEEXT) : \ 235 @echo "#!/bin/sh" > a.out 236 @echo "java JavaThread" >> a.out 237 @chmod a+x a.out 238 239 ## ========================================================================================================= 240 mutex$(EXEEXT) :\ 241 loop.run \ 242 function.run \ 243 fetch_add.run \ 244 mutex-pthread_lock.run \ 245 mutex-upp.run \ 323 246 mutex-cfa1.run \ 324 247 mutex-cfa2.run \ 325 248 mutex-cfa4.run \ 326 mutex-upp.run \ 327 mutex-go.run \ 328 mutex-rust.run \ 329 mutex-java.run \ 330 mutex-pthread.run 331 332 mutex-pthread$(EXEEXT): 333 $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c 249 mutex-java_thread.run 250 251 mutex-pthread_lock$(EXEEXT): 252 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c 253 254 mutex-upp$(EXEEXT): 255 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc 334 256 335 257 mutex-cfa1$(EXEEXT): 336 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa258 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa1.cfa 337 259 338 260 mutex-cfa2$(EXEEXT): 339 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa261 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa2.cfa 340 262 341 263 mutex-cfa4$(EXEEXT): 342 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa 343 344 mutex-upp$(EXEEXT): 345 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc 346 347 mutex-go$(EXEEXT): 348 $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go 349 350 mutex-rust$(EXEEXT): 351 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs 352 353 mutex-java$(EXEEXT): 264 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa4.cfa 265 266 mutex-java_thread$(EXEEXT): 354 267 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java 355 echo "#!/bin/sh" > a.out 356 echo "java JavaThread" >> a.out 357 chmod a+x a.out 358 359 ## ========================================================================================================= 360 361 schedint$(EXEEXT) : \ 362 schedint-cfa1.run \ 363 schedint-cfa2.run \ 364 schedint-cfa4.run \ 365 schedint-upp.run \ 366 schedint-rust.run \ 367 schedint-java.run \ 368 schedint-pthread.run 369 370 schedint-cfa1$(EXEEXT): 371 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa 372 373 schedint-cfa2$(EXEEXT): 374 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa 375 376 schedint-cfa4$(EXEEXT): 377 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa 378 379 schedint-upp$(EXEEXT): 380 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 381 382 schedint-rust$(EXEEXT): 383 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs 384 385 schedint-java$(EXEEXT): 268 @echo "#!/bin/sh" > a.out 269 @echo "java JavaThread" >> a.out 270 @chmod a+x a.out 271 272 ## ========================================================================================================= 273 signal$(EXEEXT) :\ 274 signal-pthread_cond.run \ 275 signal-upp.run \ 276 signal-cfa1.run \ 277 signal-cfa2.run \ 278 signal-cfa4.run \ 279 signal-java_thread.run 280 281 signal-pthread_cond$(EXEEXT): 282 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000 $(srcdir)/schedint/pthreads.c 283 284 signal-upp$(EXEEXT): 285 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc 286 287 signal-cfa1$(EXEEXT): 288 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa1.cfa 289 290 signal-cfa2$(EXEEXT): 291 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa2.cfa 292 293 signal-cfa4$(EXEEXT): 294 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa4.cfa 295 296 signal-java_thread$(EXEEXT): 386 297 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java 387 echo "#!/bin/sh" > a.out 388 echo "java JavaThread" >> a.out 389 chmod a+x a.out 390 391 schedint-pthread$(EXEEXT): 392 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 393 394 ## ========================================================================================================= 395 396 schedext$(EXEEXT) : \ 397 schedext-cfa1.run \ 398 schedext-cfa2.run \ 399 schedext-cfa4.run \ 400 schedext-upp.run \ 401 schedext-goroutine.run 402 403 schedext-cfa1$(EXEEXT): 404 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa 405 406 schedext-cfa2$(EXEEXT): 407 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa 408 409 schedext-cfa4$(EXEEXT): 410 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa 411 412 schedext-upp$(EXEEXT): 413 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc 414 415 schedext-goroutine$(EXEEXT): 416 $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go 417 418 419 ## ========================================================================================================= 420 421 creation$(EXEEXT) : \ 422 creation-cfa_generator.run \ 298 @echo "#!/bin/sh" > a.out 299 @echo "java JavaThread" >> a.out 300 @chmod a+x a.out 301 302 303 ## ========================================================================================================= 304 waitfor$(EXEEXT) :\ 305 waitfor-upp.run \ 306 waitfor-cfa1.run \ 307 waitfor-cfa2.run \ 308 waitfor-cfa4.run 309 310 waitfor-upp$(EXEEXT): 311 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc 312 313 waitfor-cfa1$(EXEEXT): 314 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa1.cfa 315 316 waitfor-cfa2$(EXEEXT): 317 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa2.cfa 318 319 waitfor-cfa4$(EXEEXT): 320 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa4.cfa 321 322 ## ========================================================================================================= 323 creation$(EXEEXT) :\ 324 creation-pthread.run \ 423 325 creation-cfa_coroutine.run \ 424 326 creation-cfa_coroutine_eager.run \ … … 426 328 creation-upp_coroutine.run \ 427 329 creation-upp_thread.run \ 428 creation-python_coroutine.run \ 429 creation-nodejs_coroutine.run \ 430 creation-goroutine_thread.run \ 431 creation-rust_thread.run \ 432 creation-java_thread.run \ 433 creation-pthread.run 434 435 creation-cfa_generator$(EXEEXT): 436 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa 330 creation-goroutine.run \ 331 creation-java_thread.run 437 332 438 333 creation-cfa_coroutine$(EXEEXT): 439 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa334 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa 440 335 441 336 creation-cfa_coroutine_eager$(EXEEXT): 442 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa -DEAGER337 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa -DEAGER 443 338 444 339 creation-cfa_thread$(EXEEXT): 445 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa340 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa 446 341 447 342 creation-upp_coroutine$(EXEEXT): 448 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc343 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc 449 344 450 345 creation-upp_thread$(EXEEXT): 451 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc 452 453 creation-python_coroutine$(EXEEXT): 454 echo "#!/bin/sh" > a.out 455 echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out 456 chmod a+x a.out 457 458 creation-nodejs_coroutine$(EXEEXT): 459 echo "#!/bin/sh" > a.out 460 echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out 461 chmod a+x a.out 462 463 creation-goroutine_thread$(EXEEXT): 346 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc 347 348 creation-pthread$(EXEEXT): 349 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=250000 $(srcdir)/creation/pthreads.c 350 351 creation-goroutine$(EXEEXT): 464 352 $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go 465 466 creation-rust_thread$(EXEEXT):467 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs468 353 469 354 creation-java_thread$(EXEEXT): 470 355 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java 471 echo "#!/bin/sh" > a.out 472 echo "java JavaThread" >> a.out 473 chmod a+x a.out 474 475 creation-pthread$(EXEEXT): 476 $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c 477 478 ## ========================================================================================================= 479 480 compile$(EXEEXT) : \ 356 @echo "#!/bin/sh" > a.out 357 @echo "java JavaThread" >> a.out 358 @chmod a+x a.out 359 360 ## ========================================================================================================= 361 362 compile$(EXEEXT) :\ 481 363 compile-array.make \ 482 364 compile-attributes.make \ … … 488 370 compile-typeof.make 489 371 372 490 373 testdir = $(top_srcdir)/tests 491 374 492 375 compile-array$(EXEEXT): 493 $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa376 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa 494 377 495 378 compile-attributes$(EXEEXT): 496 $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa379 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa 497 380 498 381 compile-empty$(EXEEXT): 499 $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa382 @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa 500 383 501 384 compile-expression$(EXEEXT): 502 $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa385 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa 503 386 504 387 compile-io$(EXEEXT): 505 $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa388 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa 506 389 507 390 compile-monitor$(EXEEXT): 508 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa391 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa 509 392 510 393 compile-operators$(EXEEXT): 511 $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa394 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa 512 395 513 396 compile-thread$(EXEEXT): 514 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa397 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa 515 398 516 399 compile-typeof$(EXEEXT): 517 $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa400 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa -
benchmark/Makefile.in
rbdfc032 raefb247 93 93 EXTRA_PROGRAMS = dummy$(EXEEXT) 94 94 @WITH_LIBFIBRE_TRUE@am__append_1 = \ 95 @WITH_LIBFIBRE_TRUE@ ctxswitch-kos_fibre.run \95 @WITH_LIBFIBRE_TRUE@ ctxswitch-kos_fibre.run \ 96 96 @WITH_LIBFIBRE_TRUE@ ctxswitch-kos_fibre2.run 97 97 … … 358 358 am__v_CFA_0 = @echo " CFA " $@; 359 359 am__v_CFA_1 = 360 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 361 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 362 am__v_JAVAC_0 = @echo " JAVAC " $@; 363 am__v_JAVAC_1 = 364 AM_V_GOC = $(am__v_GOC_@AM_V@) 365 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 366 am__v_GOC_0 = @echo " GOC " $@; 367 am__v_GOC_1 = 360 368 UPPCC = u++ 361 369 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 364 372 am__v_UPP_0 = @echo " UPP " $@; 365 373 am__v_UPP_1 = 366 AM_V_GOC = $(am__v_GOC_@AM_V@)367 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)368 am__v_GOC_0 = @echo " GOC " $@;369 am__v_GOC_1 =370 AM_V_RUST = $(am__v_RUST_@AM_V@)371 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)372 am__v_RUST_0 = @echo " RUST " $@;373 am__v_RUST_1 =374 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)375 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)376 am__v_NODEJS_0 = @echo " NODEJS " $@;377 am__v_NODEJS_1 =378 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)379 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)380 am__v_JAVAC_0 = @echo " JAVAC " $@;381 am__v_JAVAC_1 =382 374 383 375 # applies to both programs … … 388 380 BENCH_V_CFA = $(__bench_v_CFA_$(__quiet)) 389 381 BENCH_V_CXX = $(__bench_v_CXX_$(__quiet)) 382 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet)) 383 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet)) 390 384 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet)) 391 BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))392 BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))393 BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))394 BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))395 385 __quiet = verbose 396 386 __bench_v_CC_quiet = @ 397 387 __bench_v_CFA_quiet = @ 398 388 __bench_v_CXX_quiet = @ 389 __bench_v_GOC_quiet = @ 390 __bench_v_JAVAC_quiet = @ 399 391 __bench_v_UPP_quiet = @ 400 __bench_v_GOC_quiet = @401 __bench_v_RUSTC_quiet = @402 __bench_v_JAVAC_quiet = @403 392 __bench_v_CC_verbose = $(AM_V_CC) 404 393 __bench_v_CFA_verbose = $(AM_V_CFA) 405 394 __bench_v_CXX_verbose = $(AM_V_CXX) 395 __bench_v_GOC_verbose = $(AM_V_GOC) 396 __bench_v_JAVAC_verbose = $(AM_V_JAVAC) 406 397 __bench_v_UPP_verbose = $(AM_V_UPP) 407 __bench_v_GOC_verbose = $(AM_V_GOC)408 __bench_v_RUSTC_verbose = $(AM_V_RUSTC)409 __bench_v_NODEJS_verbose = $(AM_V_NODEJS)410 __bench_v_JAVAC_verbose = $(AM_V_JAVAC)411 398 TOOLSDIR = ${abs_top_builddir}/tools/ 412 399 REPEAT = ${abs_top_builddir}/tools/repeat 413 400 STATS = ${abs_top_srcdir}/tools/stat.py 414 401 # NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED 415 repeats = 13# 31 for benchmarks402 repeats = 5 # 31 for benchmarks 416 403 arch = x64 417 404 skipcompile = no … … 419 406 PRINT_FORMAT = %20s: #Comments needed for spacing 420 407 dummy_SOURCES = dummyC.c dummyCXX.cpp 421 basic_loop_DURATION = 15000000000422 basic_function_DURATION = 10000000000423 basic_tls_fetch_add_DURATION = 10000000000424 basic_DURATION = 250000000425 ctxswitch_pthread_DURATION = 25000000426 ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)427 ctxswitch_cfa_generator_DURATION = 5000000000428 ctxswitch_nodejs_await_DURATION = 5000000429 ctxswitch_DURATION = 100000000430 431 #mutex_java_DURATION = 10000000432 mutex_DURATION = 50000000433 schedint_pthread_DURATION = 1000000434 schedint_java_DURATION = $(schedint_pthread_DURATION)435 schedint_rust_DURATION = $(schedint_pthread_DURATION)436 schedint_DURATION = 10000000437 schedext_DURATION = 10000000438 creation_pthread_DURATION = 250000439 creation_rust_thread_DURATION = ${creation_pthread_DURATION}440 creation_java_thread_DURATION = ${creation_pthread_DURATION}441 creation_cfa_coroutine_DURATION = 100000000442 creation_cfa_coroutine_eager_DURATION = 10000000443 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}444 creation_cfa_thread_DURATION = 10000000445 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}446 creation_DURATION = 10000000447 408 FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@ 448 BASIC_DEPEND = \ 449 basic-loop.run \ 450 basic-function.run \ 451 basic-fetch_add.run \ 452 basic-ttst_lock.run \ 453 basic-tls-fetch_add.run 454 455 CTXSWITCH_DEPEND = ctxswitch-cfa_generator.run \ 456 ctxswitch-cfa_coroutine.run ctxswitch-cfa_thread.run \ 457 ctxswitch-cfa_thread2.run ctxswitch-upp_coroutine.run \ 458 ctxswitch-upp_thread.run ctxswitch-python_coroutine.run \ 459 ctxswitch-nodejs_coroutine.run ctxswitch-nodejs_await.run \ 460 ctxswitch-goroutine_thread.run ctxswitch-rust_thread.run \ 461 ctxswitch-nodejs_coroutine.run ctxswitch-java_thread.run \ 462 ctxswitch-pthread.run $(am__append_1) 409 CTXSWITCH_DEPEND = loop.run function.run fetch_add.run ttst_lock.run \ 410 tls-fetch_add.run ctxswitch-pthread.run \ 411 ctxswitch-cfa_generator.run ctxswitch-cfa_coroutine.run \ 412 ctxswitch-cfa_thread.run ctxswitch-cfa_thread2.run \ 413 ctxswitch-upp_coroutine.run ctxswitch-upp_thread.run \ 414 ctxswitch-goroutine.run ctxswitch-java_thread.run \ 415 $(am__append_1) 463 416 testdir = $(top_srcdir)/tests 464 417 all: all-am … … 779 732 780 733 dummyC.c: 781 echo "int main() { return 0; }" > ${@}734 @echo "int main() { return 0; }" > ${@} 782 735 783 736 dummyCXX.cpp: 784 echo "int main() { return 0; }" > ${@} 785 786 #.SILENT: # do not print recipe 787 .ONESHELL: # use one shell to execute recipe 737 @echo "int main() { return 0; }" > ${@} 738 788 739 .NOTPARALLEL: 789 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv790 791 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)740 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv 741 742 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 792 743 793 744 %.run : %$(EXEEXT) ${REPEAT} 794 rm -f .result.log 795 echo "------------------------------------------------------" 796 echo $< 797 ${REPEAT} ${repeats} -- ./a.out\ 798 $(if ${$(subst -,_,$(basename $@))_DURATION},\ 799 ${$(subst -,_,$(basename $@))_DURATION},\ 800 ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log 801 ${STATS} .result.log 802 echo "------------------------------------------------------" 803 rm -f a.out .result.log *.class 804 805 # ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out 745 @rm -f .result.log 746 @echo "------------------------------------------------------" 747 @echo $< 748 @${REPEAT} ${repeats} ./a.out | tee -a .result.log 749 @${STATS} .result.log 750 @echo "------------------------------------------------------" 751 @rm -f a.out .result.log *.class 806 752 807 753 %.runquiet : 808 +make $(basename $@) CFLAGS="-w" __quiet=quiet809 taskset -c 1 ./a.out810 rm -f a.out754 @+make $(basename $@) CFLAGS="-w" __quiet=quiet 755 @taskset -c 1 ./a.out 756 @rm -f a.out 811 757 812 758 %.make : 813 printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))814 +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1759 @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@)) 760 @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1 815 761 816 762 ${REPEAT} : 817 +make -C ${abs_top_builddir}/tools repeat763 @+make -C ${abs_top_builddir}/tools repeat 818 764 819 765 jenkins$(EXEEXT): 820 766 @DOifskipcompile@ 821 +make compile.csv822 -+make compile.diff.csv767 @+make compile.csv 768 @-+make compile.diff.csv 823 769 @DOendif@ 824 +make basic.csv 825 -+make basic.diff.csv 826 +make ctxswitch.csv 827 -+make ctxswitch.diff.csv 828 +make mutex.csv 829 -+make mutex.diff.csv 830 +make schedint.csv 831 -+make schedint.diff.csv 770 @+make ctxswitch.csv 771 @-+make ctxswitch.diff.csv 772 @+make mutex.csv 773 @-+make mutex.diff.csv 774 @+make signal.csv 775 @-+make signal.diff.csv 832 776 @DOifskipcompile@ 833 777 cat compile.csv 834 778 -cat compile.diff.csv 835 779 @DOendif@ 836 cat basic.csv837 -cat basic.diff.csv838 780 cat ctxswitch.csv 839 781 -cat ctxswitch.diff.csv 840 782 cat mutex.csv 841 783 -cat mutex.diff.csv 842 cat s chedint.csv843 -cat s chedint.diff.csv784 cat signal.csv 785 -cat signal.diff.csv 844 786 845 787 compile.csv: 846 echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@ 847 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@ 848 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@ 849 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@ 850 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@ 851 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@ 852 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@ 853 +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@ 854 +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@ 855 $(srcdir)/fixcsv.sh $@ 856 857 basic.csv: 858 echo "generator,coroutine,thread" > $@ 859 +make basic-cfa_generator.runquiet >> $@ && echo -n ',' >> $@ 860 +make basic-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@ 861 +make basic-cfa_thread.runquiet >> $@ 862 $(srcdir)/fixcsv.sh $@ 788 @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@ 789 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@ 790 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@ 791 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@ 792 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@ 793 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@ 794 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@ 795 @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@ 796 @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@ 797 @$(srcdir)/fixcsv.sh $@ 863 798 864 799 ctxswitch.csv: 865 echo "generator,coroutine,thread" > $@866 +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@867 +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@868 +make ctxswitch-cfa_thread.runquiet >> $@869 $(srcdir)/fixcsv.sh $@800 @echo "generator,coroutine,thread" > $@ 801 @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@ 802 @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@ 803 @+make ctxswitch-cfa_thread.runquiet >> $@ 804 @$(srcdir)/fixcsv.sh $@ 870 805 871 806 mutex.csv: 872 echo "1-monitor,2-monitor" > $@873 +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@874 +make mutex-cfa2.runquiet >> $@875 $(srcdir)/fixcsv.sh $@876 877 s chedint.csv:878 echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@879 +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@880 +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@881 +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@882 +make schedext-cfa2.runquiet >> $@883 $(srcdir)/fixcsv.sh $@807 @echo "1-monitor,2-monitor" > $@ 808 @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@ 809 @+make mutex-cfa2.runquiet >> $@ 810 @$(srcdir)/fixcsv.sh $@ 811 812 signal.csv: 813 @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@ 814 @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@ 815 @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@ 816 @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@ 817 @+make waitfor-cfa2.runquiet >> $@ 818 @$(srcdir)/fixcsv.sh $@ 884 819 885 820 %.diff.csv: %.csv 886 test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false) 887 $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@ 888 889 basic-loop$(EXEEXT): 890 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c 891 892 basic-function$(EXEEXT): 893 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c 894 895 basic-fetch_add$(EXEEXT): 896 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c 897 898 basic-ttst_lock$(EXEEXT): 899 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c 900 901 basic-tls-fetch_add$(EXEEXT): 902 $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c 903 904 basic$(EXEEXT): $(BASIC_DEPEND) 821 @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false) 822 @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@ 823 824 loop$(EXEEXT): 825 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c 826 827 function$(EXEEXT): 828 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c 829 830 fetch_add$(EXEEXT): 831 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/fetch_add.c 832 833 ttst_lock$(EXEEXT): 834 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/ttst_lock.c 835 836 tls-fetch_add$(EXEEXT): 837 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000 $(srcdir)/tls-fetch_add.c 905 838 906 839 @WITH_LIBFIBRE_TRUE@ctxswitch-kos_fibre$(EXEEXT): … … 912 845 ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND) 913 846 847 ctxswitch-pthread$(EXEEXT): 848 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c 849 914 850 ctxswitch-cfa_generator$(EXEEXT): 915 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa851 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa 916 852 917 853 ctxswitch-cfa_coroutine$(EXEEXT): 918 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa854 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa 919 855 920 856 ctxswitch-cfa_thread$(EXEEXT): 921 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa857 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa 922 858 923 859 ctxswitch-cfa_thread2$(EXEEXT): 924 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa860 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa 925 861 926 862 ctxswitch-upp_coroutine$(EXEEXT): 927 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc863 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc 928 864 929 865 ctxswitch-upp_thread$(EXEEXT): 930 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc 931 932 ctxswitch-python_coroutine$(EXEEXT): 933 echo "#!/bin/sh" > a.out 934 echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out 935 chmod a+x a.out 936 937 ctxswitch-nodejs_coroutine$(EXEEXT): 938 echo "#!/bin/sh" > a.out 939 echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out 940 chmod a+x a.out 941 942 ctxswitch-nodejs_await$(EXEEXT): 943 echo "#!/bin/sh" > a.out 944 echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out 945 chmod a+x a.out 946 947 ctxswitch-goroutine_thread$(EXEEXT): 866 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc 867 868 ctxswitch-goroutine$(EXEEXT): 948 869 $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go 949 950 ctxswitch-rust_thread$(EXEEXT):951 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs952 870 953 871 ctxswitch-java_thread$(EXEEXT): 954 872 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java 955 echo "#!/bin/sh" > a.out 956 echo "java JavaThread" >> a.out 957 chmod a+x a.out 958 959 ctxswitch-pthread$(EXEEXT): 960 $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c 961 962 mutex$(EXEEXT) : \ 873 @echo "#!/bin/sh" > a.out 874 @echo "java JavaThread" >> a.out 875 @chmod a+x a.out 876 877 mutex$(EXEEXT) :\ 878 loop.run \ 879 function.run \ 880 fetch_add.run \ 881 mutex-pthread_lock.run \ 882 mutex-upp.run \ 963 883 mutex-cfa1.run \ 964 884 mutex-cfa2.run \ 965 885 mutex-cfa4.run \ 966 mutex-upp.run \ 967 mutex-go.run \ 968 mutex-rust.run \ 969 mutex-java.run \ 970 mutex-pthread.run 971 972 mutex-pthread$(EXEEXT): 973 $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c 886 mutex-java_thread.run 887 888 mutex-pthread_lock$(EXEEXT): 889 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c 890 891 mutex-upp$(EXEEXT): 892 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc 974 893 975 894 mutex-cfa1$(EXEEXT): 976 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa895 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa1.cfa 977 896 978 897 mutex-cfa2$(EXEEXT): 979 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa898 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa2.cfa 980 899 981 900 mutex-cfa4$(EXEEXT): 982 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa 983 984 mutex-upp$(EXEEXT): 985 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc 986 987 mutex-go$(EXEEXT): 988 $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go 989 990 mutex-rust$(EXEEXT): 991 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs 992 993 mutex-java$(EXEEXT): 901 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000 $(srcdir)/mutex/cfa4.cfa 902 903 mutex-java_thread$(EXEEXT): 994 904 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java 995 echo "#!/bin/sh" > a.out 996 echo "java JavaThread" >> a.out 997 chmod a+x a.out 998 999 schedint$(EXEEXT) : \ 1000 schedint-cfa1.run \ 1001 schedint-cfa2.run \ 1002 schedint-cfa4.run \ 1003 schedint-upp.run \ 1004 schedint-rust.run \ 1005 schedint-java.run \ 1006 schedint-pthread.run 1007 1008 schedint-cfa1$(EXEEXT): 1009 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa 1010 1011 schedint-cfa2$(EXEEXT): 1012 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa 1013 1014 schedint-cfa4$(EXEEXT): 1015 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa 1016 1017 schedint-upp$(EXEEXT): 1018 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 1019 1020 schedint-rust$(EXEEXT): 1021 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs 1022 1023 schedint-java$(EXEEXT): 905 @echo "#!/bin/sh" > a.out 906 @echo "java JavaThread" >> a.out 907 @chmod a+x a.out 908 909 signal$(EXEEXT) :\ 910 signal-pthread_cond.run \ 911 signal-upp.run \ 912 signal-cfa1.run \ 913 signal-cfa2.run \ 914 signal-cfa4.run \ 915 signal-java_thread.run 916 917 signal-pthread_cond$(EXEEXT): 918 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000 $(srcdir)/schedint/pthreads.c 919 920 signal-upp$(EXEEXT): 921 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc 922 923 signal-cfa1$(EXEEXT): 924 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa1.cfa 925 926 signal-cfa2$(EXEEXT): 927 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa2.cfa 928 929 signal-cfa4$(EXEEXT): 930 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedint/cfa4.cfa 931 932 signal-java_thread$(EXEEXT): 1024 933 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java 1025 echo "#!/bin/sh" > a.out 1026 echo "java JavaThread" >> a.out 1027 chmod a+x a.out 1028 1029 schedint-pthread$(EXEEXT): 1030 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 1031 1032 schedext$(EXEEXT) : \ 1033 schedext-cfa1.run \ 1034 schedext-cfa2.run \ 1035 schedext-cfa4.run \ 1036 schedext-upp.run \ 1037 schedext-goroutine.run 1038 1039 schedext-cfa1$(EXEEXT): 1040 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa 1041 1042 schedext-cfa2$(EXEEXT): 1043 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa 1044 1045 schedext-cfa4$(EXEEXT): 1046 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa 1047 1048 schedext-upp$(EXEEXT): 1049 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc 1050 1051 schedext-goroutine$(EXEEXT): 1052 $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go 1053 1054 creation$(EXEEXT) : \ 1055 creation-cfa_generator.run \ 934 @echo "#!/bin/sh" > a.out 935 @echo "java JavaThread" >> a.out 936 @chmod a+x a.out 937 938 waitfor$(EXEEXT) :\ 939 waitfor-upp.run \ 940 waitfor-cfa1.run \ 941 waitfor-cfa2.run \ 942 waitfor-cfa4.run 943 944 waitfor-upp$(EXEEXT): 945 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc 946 947 waitfor-cfa1$(EXEEXT): 948 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa1.cfa 949 950 waitfor-cfa2$(EXEEXT): 951 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa2.cfa 952 953 waitfor-cfa4$(EXEEXT): 954 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000 $(srcdir)/schedext/cfa4.cfa 955 956 creation$(EXEEXT) :\ 957 creation-pthread.run \ 1056 958 creation-cfa_coroutine.run \ 1057 959 creation-cfa_coroutine_eager.run \ … … 1059 961 creation-upp_coroutine.run \ 1060 962 creation-upp_thread.run \ 1061 creation-python_coroutine.run \ 1062 creation-nodejs_coroutine.run \ 1063 creation-goroutine_thread.run \ 1064 creation-rust_thread.run \ 1065 creation-java_thread.run \ 1066 creation-pthread.run 1067 1068 creation-cfa_generator$(EXEEXT): 1069 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa 963 creation-goroutine.run \ 964 creation-java_thread.run 1070 965 1071 966 creation-cfa_coroutine$(EXEEXT): 1072 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa967 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa 1073 968 1074 969 creation-cfa_coroutine_eager$(EXEEXT): 1075 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa -DEAGER970 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa -DEAGER 1076 971 1077 972 creation-cfa_thread$(EXEEXT): 1078 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa973 $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa 1079 974 1080 975 creation-upp_coroutine$(EXEEXT): 1081 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc976 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc 1082 977 1083 978 creation-upp_thread$(EXEEXT): 1084 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc 1085 1086 creation-python_coroutine$(EXEEXT): 1087 echo "#!/bin/sh" > a.out 1088 echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out 1089 chmod a+x a.out 1090 1091 creation-nodejs_coroutine$(EXEEXT): 1092 echo "#!/bin/sh" > a.out 1093 echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out 1094 chmod a+x a.out 1095 1096 creation-goroutine_thread$(EXEEXT): 979 $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc 980 981 creation-pthread$(EXEEXT): 982 $(BENCH_V_CC)$(COMPILE) -DBENCH_N=250000 $(srcdir)/creation/pthreads.c 983 984 creation-goroutine$(EXEEXT): 1097 985 $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go 1098 1099 creation-rust_thread$(EXEEXT):1100 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs1101 986 1102 987 creation-java_thread$(EXEEXT): 1103 988 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java 1104 echo "#!/bin/sh" > a.out 1105 echo "java JavaThread" >> a.out 1106 chmod a+x a.out 1107 1108 creation-pthread$(EXEEXT): 1109 $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c 1110 1111 compile$(EXEEXT) : \ 989 @echo "#!/bin/sh" > a.out 990 @echo "java JavaThread" >> a.out 991 @chmod a+x a.out 992 993 compile$(EXEEXT) :\ 1112 994 compile-array.make \ 1113 995 compile-attributes.make \ … … 1120 1002 1121 1003 compile-array$(EXEEXT): 1122 $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa1004 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa 1123 1005 1124 1006 compile-attributes$(EXEEXT): 1125 $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa1007 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa 1126 1008 1127 1009 compile-empty$(EXEEXT): 1128 $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa1010 @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa 1129 1011 1130 1012 compile-expression$(EXEEXT): 1131 $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa1013 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa 1132 1014 1133 1015 compile-io$(EXEEXT): 1134 $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa1016 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa 1135 1017 1136 1018 compile-monitor$(EXEEXT): 1137 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa1019 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa 1138 1020 1139 1021 compile-operators$(EXEEXT): 1140 $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa1022 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa 1141 1023 1142 1024 compile-thread$(EXEEXT): 1143 $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa1025 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa 1144 1026 1145 1027 compile-typeof$(EXEEXT): 1146 $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa1028 @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa 1147 1029 1148 1030 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
benchmark/bench.h
rbdfc032 raefb247 5 5 #endif 6 6 #include <stdlib.h> 7 #include <stdint.h> // uint64_t 8 #include <unistd.h> // sysconf 7 #include <unistd.h> // sysconf 9 8 #if ! defined(__cforall) 10 9 #include <time.h> … … 16 15 17 16 18 static inline uint64_t bench_time() { 19 struct timespec ts; 20 clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ); 21 return 1000000000LL * ts.tv_sec + ts.tv_nsec; 22 } // bench_time 17 static inline unsigned long long int bench_time() { 18 struct timespec ts; 19 clock_gettime( 20 #if defined( __linux__ ) 21 CLOCK_THREAD_CPUTIME_ID, 22 #elif defined( __freebsd__ ) 23 CLOCK_PROF, 24 #elif defined( __solaris__ ) 25 CLOCK_HIGHRES, 26 #else 27 #error uC++ : internal error, unsupported architecture 28 #endif 29 &ts ); 30 return 1000000000LL * ts.tv_sec + ts.tv_nsec; 31 } // Time 23 32 24 33 #ifndef BENCH_N 25 #define BENCH_N 1000000034 #define BENCH_N 500 //10000000 26 35 #endif 27 36 28 size_t times = BENCH_N;29 30 #define BENCH_START() \31 if ( argc > 2 ) exit( EXIT_FAILURE ); \32 if ( argc == 2 ) { \33 times = atoi( argv[1] ); \34 }35 36 37 #define BENCH(statement, output) \ 37 uint64_t StartTime, EndTime; \ 38 size_t n = BENCH_N; \ 39 if( argc > 2 ) return 1; \ 40 if( argc == 2 ) { \ 41 n = atoi(argv[1]); \ 42 } \ 43 long long int StartTime, EndTime; \ 38 44 StartTime = bench_time(); \ 39 statement; \45 statement; \ 40 46 EndTime = bench_time(); \ 41 double output = (double)( EndTime - StartTime ) / times;42 47 double output = \ 48 (double)( EndTime - StartTime ) / n; 43 49 44 50 #if defined(__cforall) … … 47 53 } 48 54 #endif 49 #if defined(__U_CPLUSPLUS__)50 unsigned int uDefaultPreemption() {51 return 0;52 }53 #endif -
benchmark/creation/JavaThread.java
rbdfc032 raefb247 26 26 static int x = 2; 27 27 28 static private int times = Integer.parseInt("10000") ;28 static private final int NoOfTimes = Integer.parseInt("10000") ; 29 29 30 30 public static class MyThread extends Thread { … … 33 33 } 34 34 public static void helper() throws InterruptedException { 35 for(int i = 1; i <= times; i += 1) {35 for(int i = 1; i <= NoOfTimes; i += 1) { 36 36 MyThread m = new MyThread(); 37 37 x = nextRandom( x ); … … 44 44 helper(); 45 45 long end = System.nanoTime(); 46 System.out.println( (end - start) / times );46 System.out.println( (end - start) / NoOfTimes ); 47 47 } 48 48 public static void main(String[] args) throws InterruptedException { 49 if ( args.length > 2 ) System.exit( 1 ); 50 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); } 51 52 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 49 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 53 50 InnerMain(); 54 Thread.sleep(2000); // 2 seconds51 Thread.sleep(2000); // 2 seconds 55 52 x = nextRandom(x); 56 53 } … … 58 55 } 59 56 } 60 61 // Local Variables: //62 // tab-width: 4 //63 // End: // -
benchmark/creation/cfa_cor.cfa
rbdfc032 raefb247 5 5 6 6 coroutine MyCoroutine {}; 7 void ?{} ( MyCoroutine & this) {7 void ?{} (MyCoroutine & this) { 8 8 #ifdef EAGER 9 resume( this);9 resume(this); 10 10 #endif 11 11 } 12 void main( MyCoroutine &) {}12 void main(MyCoroutine &) {} 13 13 14 int main( int argc, char * argv[] ) { 15 BENCH_START() 14 int main(int argc, char* argv[]) { 16 15 BENCH( 17 for ( times) {18 MyCoroutine c;16 for ( i; n ) { 17 MyCoroutine m; 19 18 }, 20 19 result 21 20 ) 22 printf( "%g\n", result ); 21 22 printf("%g\n", result); 23 23 } 24 25 // Local Variables: //26 // tab-width: 4 //27 // End: // -
benchmark/creation/cfa_thrd.cfa
rbdfc032 raefb247 7 7 void main(MyThread &) {} 8 8 9 int main( int argc, char * argv[] ) { 10 BENCH_START() 9 int main(int argc, char* argv[]) { 11 10 BENCH( 12 for ( times) {11 for ( i; n ) { 13 12 MyThread m; 14 13 }, 15 14 result 16 15 ) 17 printf( "%g\n", result ); 16 17 printf("%g\n", result); 18 18 } 19 20 // Local Variables: //21 // tab-width: 4 //22 // End: // -
benchmark/creation/goroutine.go
rbdfc032 raefb247 2 2 3 3 import ( 4 "fmt" 5 "time" 6 "os" 7 "strconv" 4 "fmt" 5 "time" 8 6 ) 9 7 … … 19 17 20 18 func main() { 21 var times int = 10000000 22 if len( os.Args ) > 2 { os.Exit( 1 ) } 23 if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) } 24 19 const NoOfTimes = 500000 25 20 start := time.Now() 26 for i := 1; i <= times; i += 1 {21 for i := 1; i <= NoOfTimes; i += 1 { 27 22 go noop() // creation 28 <- shake // wait for completion29 23 } 30 24 end := time.Now() 31 fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) ) 25 fmt.Printf("%d\n", end.Sub(start) / time.Duration(NoOfTimes)) 26 <- shake 32 27 } 33 34 // Local Variables: //35 // tab-width: 4 //36 // End: // -
benchmark/creation/pthreads.c
rbdfc032 raefb247 4 4 #include "bench.h" 5 5 6 static void * foo(void *arg) {6 static void *foo(void *arg) { 7 7 return arg; 8 8 } 9 9 10 int main( int argc, char * argv[] ) { 11 BENCH_START() 10 int main(int argc, char* argv[]) { 12 11 BENCH( 13 for (size_t i = 0; i < times; i++) {12 for (size_t i = 0; i < n; i++) { 14 13 pthread_t thread; 15 14 if (pthread_create(&thread, NULL, foo, NULL) < 0) { … … 17 16 return 1; 18 17 } 18 19 19 if (pthread_join( thread, NULL) < 0) { 20 20 perror( "failure" ); … … 24 24 result 25 25 ) 26 printf( "%g\n", result ); 26 27 printf("%g\n", result); 27 28 } 28 29 // Local Variables: //30 // tab-width: 4 //31 // End: // -
benchmark/creation/upp_cor.cc
rbdfc032 raefb247 5 5 _Coroutine MyCor { 6 6 void main() {} 7 public:8 MyCor() { resume(); }9 7 }; 10 8 11 int main( int argc, char * argv[] ) { 12 BENCH_START() 9 int main(int argc, char* argv[]) { 13 10 BENCH( 14 for (size_t i = 0; i < times; i++) {11 for (size_t i = 0; i < n; i++) { 15 12 MyCor m; 16 13 }, 17 14 result 18 15 ) 19 printf( "%g\n", result ); 16 17 printf("%g\n", result); 20 18 } 21 22 // Local Variables: //23 // tab-width: 4 //24 // End: // -
benchmark/creation/upp_thrd.cc
rbdfc032 raefb247 7 7 }; 8 8 9 int main( int argc, char * argv[] ) { 10 BENCH_START() 9 int main(int argc, char* argv[]) { 11 10 BENCH( 12 for (size_t i = 0; i < times; i++) {11 for (size_t i = 0; i < n; i++) { 13 12 MyThread m; 14 13 }, 15 14 result 16 15 ) 17 printf( "%g\n", result ); 16 17 printf("%g\n", result); 18 18 } 19 20 // Local Variables: //21 // tab-width: 4 //22 // End: // -
benchmark/ctxswitch/JavaThread.java
rbdfc032 raefb247 26 26 static int x = 2; 27 27 28 static private int times = Integer.parseInt("100000");28 static private final int NoOfTimes = Integer.parseInt("1000000") ; 29 29 30 30 public static void helper() { 31 for(int i = 1; i <= times; i += 1) {31 for(int i = 1; i <= NoOfTimes; i += 1) { 32 32 Thread.yield(); 33 33 } … … 37 37 helper(); 38 38 long end = System.nanoTime(); 39 System.out.println( (end - start) / times );39 System.out.println( (end - start) / NoOfTimes ); 40 40 } 41 41 public static void main(String[] args) throws InterruptedException { 42 if ( args.length > 2 ) System.exit( 1 ); 43 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); } 44 45 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { 42 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 46 43 InnerMain(); 47 Thread.sleep(2000); // 2 seconds44 Thread.sleep(2000); // 2 seconds 48 45 x = nextRandom(x); 49 46 } … … 51 48 } 52 49 } 53 54 // Local Variables: //55 // tab-width: 4 //56 // End: // -
benchmark/ctxswitch/cfa_cor.cfa
rbdfc032 raefb247 4 4 #include "bench.h" 5 5 6 coroutine C {} c; 7 void main( __attribute__((unused)) C & ) { 8 while () { 6 coroutine GreatSuspender {}; 7 8 void ?{}( GreatSuspender & this ) { 9 prime(this); 10 } 11 12 void main( __attribute__((unused)) GreatSuspender & this ) { 13 while( true ) { 9 14 suspend(); 10 15 } 11 16 } 12 int main( int argc, char * argv[] ) { 13 BENCH_START() 17 18 int main(int argc, char* argv[]) { 19 GreatSuspender s; 20 14 21 BENCH( 15 for ( times) {16 resume( c);22 for ( i; n ) { 23 resume( s ); 17 24 }, 18 25 result 19 26 ) 20 printf( "%g\n", result ); 27 28 printf("%g\n", result); 21 29 } 22 23 // Local Variables: //24 // tab-width: 4 //25 // End: // -
benchmark/ctxswitch/cfa_cor_then.cfa
rbdfc032 raefb247 6 6 void noOp(void) {} 7 7 8 coroutine C {} c;8 coroutine GreatSuspender {}; 9 9 10 void ?{}( C& this ) {10 void ?{}( GreatSuspender & this ) { 11 11 prime(this); 12 12 } 13 13 14 void main( __attribute__((unused)) C& this ) {15 while () {14 void main( __attribute__((unused)) GreatSuspender & this ) { 15 while( true ) { 16 16 suspend_then(noOp); 17 17 } 18 18 } 19 19 20 int main( int argc, char * argv[] ) { 21 BENCH_START() 20 int main(int argc, char* argv[]) { 21 GreatSuspender s; 22 22 23 BENCH( 23 for ( times) {24 resume( c);24 for ( i; n ) { 25 resume( s ); 25 26 }, 26 27 result 27 28 ) 28 printf( "%g\n", result ); 29 30 printf("%g\n", result); 29 31 } 30 31 // Local Variables: //32 // tab-width: 4 //33 // End: // -
benchmark/ctxswitch/cfa_gen.cfa
rbdfc032 raefb247 3 3 typedef struct { 4 4 void * next; 5 } C;5 } GreatSuspender; 6 6 7 void comain( C * c) {8 if ( __builtin_expect(c->next != 0, 1) ) goto *(c->next);9 c->next = &&s1;7 void comain( GreatSuspender * this ) { 8 if ( __builtin_expect(this->next != 0, 1) ) goto *(this->next); 9 this->next = &&s1; 10 10 for () { 11 return;11 return; 12 12 s1: ; 13 13 } 14 14 } 15 15 16 int main( int argc, char * argv[]) {17 BENCH_START() 18 C c = { 0 }; 16 int main(int argc, char* argv[]) { 17 GreatSuspender s = { 0 }; 18 19 19 BENCH( 20 for ( times) {21 comain( & c);20 for ( i; n ) { 21 comain( &s ); 22 22 }, 23 23 result 24 24 ) 25 printf( "%g\n", result ); 25 26 printf("%g\n", result); 26 27 } 27 28 // Local Variables: //29 // tab-width: 4 //30 // End: // -
benchmark/ctxswitch/cfa_thrd.cfa
rbdfc032 raefb247 3 3 #include "bench.h" 4 4 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 5 int main(int argc, char* argv[]) { 7 6 BENCH( 8 for ( times) {7 for ( i; n ) { 9 8 yield(); 10 9 }, 11 10 result 12 11 ) 13 printf( "%g\n", result ); 12 13 printf("%g\n", result); 14 14 } 15 16 // Local Variables: //17 // tab-width: 4 //18 // End: // -
benchmark/ctxswitch/cfa_thrd2.cfa
rbdfc032 raefb247 8 8 9 9 void main(__attribute__((unused)) Fibre & this) { 10 while ( ! done) {10 while(!done) { 11 11 yield(); 12 12 } 13 13 } 14 14 15 int main( int argc, char * argv[] ) { 16 BENCH_START() 15 int main(int argc, char* argv[]) { 17 16 Fibre f1; 18 17 BENCH( 19 for ( times) {18 for ( i; n ) { 20 19 yield(); 21 20 }, 22 21 result 23 22 ) 24 printf( "%g\n", result ); 23 24 printf("%g\n", result); 25 25 done = true; 26 return 0; 26 27 } 27 28 // Local Variables: //29 // tab-width: 4 //30 // End: // -
benchmark/ctxswitch/goroutine.go
rbdfc032 raefb247 2 2 3 3 import ( 4 "fmt" 5 "time" 6 "os" 7 "strconv" 8 "runtime" 4 "fmt" 5 "runtime" 6 "time" 9 7 ) 10 8 … … 30 28 31 29 func main() { 32 var times int = 10000000 33 if len( os.Args ) > 2 { os.Exit( 1 ) } 34 if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) } 35 go ContextSwitch( times ) // context switch 30 const NoOfTimes = 10000000 31 go ContextSwitch( NoOfTimes ) // context switch 36 32 <- shake 37 33 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/ctxswitch/kos_fibre.cpp
rbdfc032 raefb247 3 3 #include "bench.h" 4 4 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 5 int main(int argc, char* argv[]) { 7 6 BENCH( 8 for (size_t i = 0; i < times; i++) {7 for (size_t i = 0; i < n; i++) { 9 8 Fibre::yield(); 10 9 }, 11 10 result 12 11 ) 13 printf( "%g\n", result ); 12 printf("%g\n", result); 13 return 0; 14 14 } 15 16 // Local Variables: //17 // tab-width: 4 //18 // End: // -
benchmark/ctxswitch/kos_fibre2.cpp
rbdfc032 raefb247 11 11 } 12 12 13 int main( int argc, char * argv[] ) { 14 BENCH_START() 13 int main(int argc, char* argv[]) { 15 14 Fibre* f1 = (new Fibre)->run(f1main); 16 15 BENCH( 17 for (size_t i = 0; i < times; i++) {16 for (size_t i = 0; i < n; i++) { 18 17 Fibre::yield(); 19 18 }, 20 19 result 21 20 ) 22 printf( "%g\n", result);21 printf("%g\n", result); 23 22 done = true; 24 23 Fibre::yield(); 25 24 f1->join(); 25 return 0; 26 26 } 27 28 // Local Variables: //29 // tab-width: 4 //30 // End: // -
benchmark/ctxswitch/pthreads.c
rbdfc032 raefb247 6 6 #include "bench.h" 7 7 8 int main( int argc, char * argv[] ) { 9 BENCH_START() 8 int main(int argc, char* argv[]) { 10 9 BENCH( 11 for (size_t i = 0; i < times; i++) {10 for (size_t i = 0; i < n; i++) { 12 11 sched_yield(); 13 12 }, 14 13 result 15 14 ) 16 printf( "%g\n", result ); 15 16 printf("%g\n", result); 17 17 } -
benchmark/ctxswitch/upp_cor.cc
rbdfc032 raefb247 3 3 #include "bench.h" 4 4 5 _Coroutine C { 5 _Coroutine GreatSuspender { 6 public: 7 GreatSuspender() { 8 resume(); 9 } 10 11 void do_resume() { 12 resume(); 13 } 14 private: 6 15 void main() { 7 16 while( true ) { … … 9 18 } 10 19 } 11 public: 12 void do_resume() { 13 resume(); 14 } 15 } c; 16 int main( int argc, char * argv[] ) { 17 BENCH_START() 20 }; 21 22 int main(int argc, char* argv[]) { 23 GreatSuspender s; 24 18 25 BENCH( 19 for (size_t i = 0; i < times; i++) {20 c.do_resume();26 for (size_t i = 0; i < n; i++) { 27 s.do_resume(); 21 28 }, 22 29 result 23 30 ) 24 printf( "%g\n", result ); 31 32 printf("%g\n", result); 25 33 } 26 27 // Local Variables: //28 // tab-width: 4 //29 // End: // -
benchmark/ctxswitch/upp_thrd.cc
rbdfc032 raefb247 3 3 #include "bench.h" 4 4 5 int main( int argc, char * argv[] ) { 6 BENCH_START() 5 int main(int argc, char* argv[]) { 7 6 BENCH( 8 for (size_t i = 0; i < times; i++) {7 for (size_t i = 0; i < n; i++) { 9 8 uThisTask().yield(); 10 9 }, 11 10 result 12 11 ) 13 printf( "%g\n", result ); 12 13 printf("%g\n", result); 14 14 } 15 16 // Local Variables: //17 // tab-width: 4 //18 // End: // -
benchmark/mutex/JavaThread.java
rbdfc032 raefb247 26 26 static int x = 2; 27 27 28 static private int times = Integer.parseInt("100000000");28 static private final int NoOfTimes = Integer.parseInt("100000000") ; 29 29 30 30 public synchronized void noop() { … … 35 35 // Inhibit biased locking ... 36 36 x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ; 37 for(int i = 1; i <= times; i += 1) {37 for(int i = 1; i <= NoOfTimes; i += 1) { 38 38 x = nextRandom(x); 39 39 j.noop(); … … 44 44 helper(); 45 45 long end = System.nanoTime(); 46 System.out.println( (end - start) / times );46 System.out.println( (end - start) / NoOfTimes ); 47 47 } 48 48 public static void main(String[] args) throws InterruptedException { 49 if ( args.length > 2 ) System.exit( 1 );50 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }51 52 49 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 53 50 InnerMain(); … … 58 55 } 59 56 } 60 61 // Local Variables: //62 // tab-width: 4 //63 // End: // -
benchmark/mutex/cfa1.cfa
rbdfc032 raefb247 4 4 #include "bench.h" 5 5 6 monitor M {} m1;7 void __attribute__((noinline)) call( M & mutex p1) {}6 monitor M {}; 7 void __attribute__((noinline)) call( M & mutex m ) {} 8 8 9 int main( int argc, char * argv[]) {10 BENCH_START()9 int main(int argc, char* argv[]) { 10 M m; 11 11 BENCH( 12 for ( times) {13 call( m1);12 for ( i; n ) { 13 call(m); 14 14 }, 15 15 result 16 16 ) 17 printf( "%g\n", result ); 17 18 printf("%g\n", result); 18 19 } 19 20 // Local Variables: //21 // tab-width: 4 //22 // End: // -
benchmark/mutex/cfa2.cfa
rbdfc032 raefb247 4 4 #include "bench.h" 5 5 6 monitor M {} m1, m2; 6 monitor M {}; 7 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2 ) {} 7 8 8 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {} 9 10 int main( int argc, char * argv[] ) { 11 BENCH_START() 9 int main(int argc, char* argv[]) { 10 M m1, m2; 12 11 BENCH( 13 for ( times) {14 call( m1, m2);12 for ( i; n ) { 13 call(m1, m2); 15 14 }, 16 15 result 17 16 ) 18 printf( "%g\n", result ); 17 18 printf("%g\n", result); 19 19 } 20 21 // Local Variables: //22 // tab-width: 4 //23 // End: // -
benchmark/mutex/cfa4.cfa
rbdfc032 raefb247 5 5 6 6 7 monitor M {} m1, m2, m3, m4;8 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {}7 monitor M {}; 8 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2, M & mutex m3, M & mutex m4 ) {} 9 9 10 int main( int argc, char * argv[]) {11 BENCH_START()10 int main(int argc, char* argv[]) { 11 M m1, m2, m3, m4; 12 12 BENCH( 13 for ( times) {14 call( m1, m2, m3, m4);13 for ( i; n ) { 14 call(m1, m2, m3, m4); 15 15 }, 16 16 result 17 17 ) 18 printf( "%g\n", result ); 18 19 printf("%g\n", result); 19 20 } 20 21 // Local Variables: //22 // tab-width: 4 //23 // End: // -
benchmark/mutex/pthreads.c
rbdfc032 raefb247 7 7 8 8 void __attribute__((noinline)) call() { 9 pthread_mutex_lock ( &mutex);10 pthread_mutex_unlock( &mutex);9 pthread_mutex_lock (&mutex); 10 pthread_mutex_unlock(&mutex); 11 11 } 12 int main( int argc, char * argv[] ) { 13 BENCH_START() 12 13 int main(int argc, char* argv[]) { 14 14 BENCH( 15 for ( size_t i = 0; i < times; i++) {15 for (size_t i = 0; i < n; i++) { 16 16 call(); 17 17 }, 18 18 result 19 19 ) 20 printf( "%g\n", result ); 20 21 printf("%g\n", result); 21 22 } 22 23 // Local Variables: //24 // tab-width: 4 //25 // End: // -
benchmark/mutex/upp.cc
rbdfc032 raefb247 8 8 }; 9 9 10 int main( int argc, char * argv[] ) { 11 BENCH_START() 10 int main(int argc, char* argv[]) { 12 11 MyMonitor m; 13 12 BENCH( 14 for ( size_t i = 0; i < times; i++) {13 for (size_t i = 0; i < n; i++) { 15 14 m.call(); 16 15 }, 17 16 result 18 17 ) 19 printf( "%g\n", result ); 18 19 printf("%g\n", result); 20 20 } 21 22 // Local Variables: //23 // tab-width: 4 //24 // End: // -
benchmark/schedext/cfa1.cfa
rbdfc032 raefb247 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 monitor M {} m1; 8 int argc; 9 char** argv; 10 volatile int go = 0; 9 11 10 void __attribute__((noinline)) call( M & mutex p1 ) {} 11 void __attribute__((noinline)) wait( M & mutex p1 ) { 12 for ( times ) { 13 waitfor( call : p1 ); 14 } 12 monitor M {}; 13 M m1; 14 15 void __attribute__((noinline)) call( M & mutex a1 ) {} 16 17 int __attribute__((noinline)) wait( M & mutex a1 ) { 18 go = 1; 19 BENCH( 20 for ( i; n ) { 21 waitfor(call, a1); 22 }, 23 result 24 ) 25 26 printf("%g\n", result); 27 go = 0; 28 return 0; 15 29 } 16 30 17 31 thread T {}; 32 void ^?{}( T & mutex this ) {} 18 33 void main( T & ) { 19 BENCH( 20 for ( times ) { call( m1 ); }, 21 result 22 ) 23 printf( "%g\n", result ); 34 while(go == 0) { yield(); } 35 while(go == 1) { call(m1); } 36 24 37 } 25 38 26 int main( int argc, char * argv[] ) { 27 BENCH_START() 39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 28 40 T t; 29 wait( m1);41 return wait(m1); 30 42 } 31 32 // Local Variables: //33 // tab-width: 4 //34 // End: // -
benchmark/schedext/cfa2.cfa
rbdfc032 raefb247 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 monitor M {} m1, m2; 8 int argc; 9 char** argv; 10 volatile int go = 0; 9 11 10 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {} 11 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) { 12 for ( times ) { 13 waitfor( call : p1, p2 ); 14 } 15 } 16 thread T {}; 17 void main( T & ) { 12 monitor M {}; 13 M m1, m2; 14 15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {} 16 17 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) { 18 go = 1; 18 19 BENCH( 19 for ( times) {20 call( m1, m2);20 for ( i; n ) { 21 waitfor(call, a1, a2); 21 22 }, 22 23 result 23 24 ) 24 printf( "%g\n", result ); 25 26 printf("%g\n", result); 27 go = 0; 28 return 0; 25 29 } 26 30 27 int main( int argc, char * argv[] ) { 28 BENCH_START() 29 T t; 30 wait( m1, m2 ); 31 thread T {}; 32 void ^?{}( T & mutex this ) {} 33 void main( T & ) { 34 while(go == 0) { yield(); } 35 while(go == 1) { call(m1, m2); } 36 31 37 } 32 38 33 // Local Variables: // 34 // tab-width: 4 // 35 // End: // 39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 40 T t; 41 return wait(m1, m2); 42 } -
benchmark/schedext/cfa4.cfa
rbdfc032 raefb247 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 monitor M {} m1, m2, m3, m4; 8 int argc; 9 char** argv; 10 volatile int go = 0; 9 11 10 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {} 11 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) { 12 for ( times ) { 13 waitfor( call : p1, p2, p3, p4 ); 14 } 15 } 16 thread T {}; 17 void main( T & ) { 12 monitor M {}; 13 M m1, m2, m3, m4; 14 15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {} 16 17 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) { 18 go = 1; 18 19 BENCH( 19 for ( times) {20 call( m1, m2, m3, m4);20 for ( i; n ) { 21 waitfor(call, a1, a2, a3, a4); 21 22 }, 22 23 result 23 24 ) 24 printf( "%g\n", result ); 25 26 printf("%g\n", result); 27 go = 0; 28 return 0; 25 29 } 26 30 27 int main( int argc, char * argv[] ) { 28 BENCH_START() 29 T t; 30 wait( m1, m2, m3, m4 ); 31 thread T {}; 32 void ^?{}( T & mutex this ) {} 33 void main( T & ) { 34 while(go == 0) { yield(); } 35 while(go == 1) { call(m1, m2, m3, m4); } 36 31 37 } 32 38 33 // Local Variables: // 34 // tab-width: 4 // 35 // End: // 39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 40 T t; 41 return wait(m1, m2, m3, m4); 42 } -
benchmark/schedext/upp.cc
rbdfc032 raefb247 3 3 #include "bench.h" 4 4 5 int argc; 6 char** argv; 7 volatile int go = 0; 8 5 9 _Monitor M { 6 10 public: 7 11 void __attribute__((noinline)) call() {} 8 void __attribute__((noinline)) wait() { 9 for ( size_t i = 0; i < times; i++ ) { 10 _Accept(call); 11 } 12 13 int __attribute__((noinline)) wait() { 14 go = 1; 15 BENCH( 16 for (size_t i = 0; i < n; i++) { 17 _Accept(call); 18 }, 19 result 20 ) 21 22 printf("%g\n", result); 23 go = 0; 24 return 0; 12 25 } 13 } m; 26 }; 27 28 M m; 14 29 15 30 _Task T { 16 31 void main() { 17 BENCH( 18 for ( size_t i = 0; i < times; i++ ) { 19 m.call(); 20 }, 21 result 22 ) 23 printf( "%g\n", result ); 32 while(go == 0) { yield(); } 33 while(go == 1) { m.call(); } 34 24 35 } 25 36 }; 26 37 27 int main( int argc, char * argv[] ) { 28 BENCH_START() 38 int main(int margc, char* margv[]) { 39 argc = margc; 40 argv = margv; 29 41 T t; 30 m.wait();42 return m.wait(); 31 43 } 32 33 // Local Variables: //34 // tab-width: 4 //35 // End: // -
benchmark/schedint/JavaThread.java
rbdfc032 raefb247 49 49 static int x = 2; 50 50 51 static private int times = Integer.parseInt("1000000");51 static private final int NoOfTimes = Integer.parseInt("1000000") ; 52 52 53 53 public static void helper( Monitor m ) throws InterruptedException { 54 for(int i = 1; i <= times; i += 1) {54 for(int i = 1; i <= NoOfTimes; i += 1) { 55 55 m.wait(); // relase monitor lock 56 56 m.next = true; … … 63 63 synchronized(m) { 64 64 s.start(); 65 while( ! Monitor.go ) { // waiter must start first65 while( !Monitor.go ) { 66 66 Thread.yield(); 67 67 } … … 72 72 Monitor.go = false; 73 73 s.join(); 74 System.out.println( (end - start) / times);74 System.out.println( (end - start) / NoOfTimes); 75 75 } 76 76 public static void main(String[] args) throws InterruptedException { 77 if ( args.length > 2 ) System.exit( 1 );78 if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }79 80 77 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { 81 78 InnerMain(); … … 86 83 } 87 84 } 88 89 // Local Variables: //90 // tab-width: 4 //91 // End: // -
benchmark/schedint/cfa1.cfa
rbdfc032 raefb247 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 int argc; 9 char** argv; 8 10 volatile int go = 0; 9 11 10 12 condition c; 11 monitor M {} m1; 13 monitor M {}; 14 M m1; 12 15 13 void __attribute__((noinline)) call( M & mutex p1 ) {14 signal( c);16 void __attribute__((noinline)) call( M & mutex a1 ) { 17 signal(c); 15 18 } 16 void __attribute__((noinline)) wait( M & mutex p1 ) { 19 20 int __attribute__((noinline)) wait( M & mutex a1 ) { 17 21 go = 1; 18 for ( times ) { 19 wait( c ); 20 } 22 BENCH( 23 for ( i; n ) { 24 wait(c); 25 }, 26 result 27 ) 28 29 printf("%g\n", result); 30 go = 0; 31 return 0; 21 32 } 22 33 23 34 thread T {}; 35 void ^?{}( T & mutex ) {} 24 36 void main( T & ) { 25 while ( go == 0 ) { yield(); } // waiter must start first 26 BENCH( 27 for ( times ) { call( m1 ); }, 28 result 29 ) 30 printf( "%g\n", result ); 37 while(go == 0) { yield(); } 38 while(go == 1) { call(m1); } 39 31 40 } 32 41 33 int main( int argc, char * argv[] ) { 34 BENCH_START() 42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 35 43 T t; 36 wait( m1);44 return wait(m1); 37 45 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/schedint/cfa2.cfa
rbdfc032 raefb247 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 int argc; 9 char** argv; 8 10 volatile int go = 0; 9 11 10 12 condition c; 11 monitor M {} m1, m2; 13 monitor M {}; 14 M m1, m2; 12 15 13 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {14 signal( c);16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) { 17 signal(c); 15 18 } 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) { 19 20 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) { 17 21 go = 1; 18 for ( times ) { 19 wait( c ); 20 } 22 BENCH( 23 for ( i; n ) { 24 wait(c); 25 }, 26 result 27 ) 28 29 printf("%g\n", result); 30 go = 0; 31 return 0; 21 32 } 22 33 23 34 thread T {}; 35 void ^?{}( T & mutex this ) {} 24 36 void main( T & ) { 25 while ( go == 0 ) { yield(); } // waiter must start first 26 BENCH( 27 for ( times ) { call( m1, m2 ); }, 28 result 29 ) 30 printf( "%g\n", result ); 37 while(go == 0) { yield(); } 38 while(go == 1) { call(m1, m2); } 39 31 40 } 32 41 33 int main( int argc, char * argv[] ) { 34 BENCH_START() 42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 35 43 T t; 36 wait( m1, m2);44 return wait(m1, m2); 37 45 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/schedint/cfa4.cfa
rbdfc032 raefb247 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 int argc; 9 char** argv; 8 10 volatile int go = 0; 9 11 10 12 condition c; 11 monitor M {} m1, m2, m3, m4; 13 monitor M {}; 14 M m1, m2, m3, m4; 12 15 13 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {14 signal( c);16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) { 17 signal(c); 15 18 } 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) { 19 20 int __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) { 17 21 go = 1; 18 for ( times ) { 19 wait( c ); 20 } 22 BENCH( 23 for ( i; n ) { 24 wait(c); 25 }, 26 result 27 ) 28 29 printf("%g\n", result); 30 go = 0; 31 return 0; 21 32 } 22 33 23 34 thread T {}; 35 void ^?{}( T & mutex this ) {} 24 36 void main( T & ) { 25 while ( go == 0 ) { yield(); } // waiter must start first 26 BENCH( 27 for ( times ) { call( m1, m2, m3, m4 ); }, 28 result 29 ) 30 printf( "%g\n", result ); 37 while(go == 0) { yield(); } 38 while(go == 1) { call(m1, m2, m3, m4); } 39 31 40 } 32 41 33 int main( int argc, char * argv[] ) { 34 BENCH_START() 42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 35 43 T t; 36 wait( m1, m2, m3, m4);44 return wait(m1, m2, m3, m4); 37 45 } 38 39 // Local Variables: //40 // tab-width: 4 //41 // End: // -
benchmark/schedint/pthreads.c
rbdfc032 raefb247 4 4 #include "bench.h" 5 5 6 int argc; 7 char** argv; 6 8 volatile int go = 0; 7 9 10 pthread_cond_t c; 8 11 pthread_mutex_t m; 9 pthread_cond_t c;10 12 11 13 void __attribute__((noinline)) call() { 12 pthread_mutex_lock( &m);13 pthread_cond_signal( &c);14 pthread_mutex_unlock( &m);14 pthread_mutex_lock(&m); 15 pthread_cond_signal(&c); 16 pthread_mutex_unlock(&m); 15 17 } 16 18 17 void__attribute__((noinline)) wait() {19 int __attribute__((noinline)) wait() { 18 20 pthread_mutex_lock(&m); 19 21 go = 1; 20 for ( size_t i = 0; i < times; i++ ) { 21 pthread_cond_wait( &c, &m ); 22 } 22 BENCH( 23 for (size_t i = 0; i < n; i++) { 24 pthread_cond_wait(&c, &m); 25 }, 26 result 27 ) 28 29 printf("%g\n", result); 23 30 go = 0; 24 pthread_mutex_unlock( &m ); 31 pthread_mutex_unlock(&m); 32 return 0; 25 33 } 26 34 27 void * thread_main( __attribute__((unused)) void * arg ) { 28 while ( go == 0 ) { sched_yield(); } // waiter must start first 29 // barging for lock acquire => may not execute N times 30 BENCH( 31 while ( go == 1 ) { call(); }, 32 result 33 ) 34 printf( "%g\n", result ); 35 void* thread_main(__attribute__((unused)) void * arg ) { 36 while(go == 0) { sched_yield(); } 37 while(go == 1) { call(); } 35 38 return NULL; 36 39 } 37 40 38 int main( int argc, char * argv[] ) { 39 BENCH_START() 41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 40 42 pthread_t thread; 41 if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0) {43 if (pthread_create(&thread, NULL, thread_main, NULL) < 0) { 42 44 perror( "failure" ); 43 45 return 1; 44 46 } 45 47 wait(); 46 if ( pthread_join( thread, NULL ) < 0) {48 if (pthread_join( thread, NULL) < 0) { 47 49 perror( "failure" ); 48 50 return 1; 49 51 } 52 return 0; 50 53 } 51 52 // Local Variables: //53 // tab-width: 4 //54 // End: // -
benchmark/schedint/upp.cc
rbdfc032 raefb247 3 3 #include "bench.h" 4 4 5 int argc; 6 char** argv; 5 7 volatile int go = 0; 6 8 … … 11 13 cond.signal(); 12 14 } 13 void __attribute__((noinline)) wait() { 15 16 int __attribute__((noinline)) wait() { 14 17 go = 1; 15 for ( size_t i = 0; i < times; i++ ) { 16 cond.wait(); 17 } 18 BENCH( 19 for (size_t i = 0; i < n; i++) { 20 cond.wait(); 21 }, 22 result 23 ) 24 25 printf("%g\n", result); 26 go = 0; 27 return 0; 18 28 } 19 } m; 29 }; 30 31 M m; 20 32 21 33 _Task T { 22 34 void main() { 23 while ( go == 0 ) { yield(); } // waiter must start first 24 BENCH( 25 for ( size_t i = 0; i < times; i++ ) { 26 m.call(); 27 }, 28 result 29 ) 30 printf( "%g\n", result ); 35 while(go == 0) { yield(); } 36 while(go == 1) { m.call(); } 37 31 38 } 32 39 }; 33 40 34 int main( int argc, char * argv[] ) { 35 BENCH_START() 41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { 36 42 T t; 37 m.wait();43 return m.wait(); 38 44 } 39 40 // Local Variables: //41 // tab-width: 4 //42 // End: // -
driver/cfa.cc
rbdfc032 raefb247 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 31 16:48:03 202013 // Update Count : 42 112 // Last Modified On : Tue Sep 10 17:00:15 2019 13 // Update Count : 420 14 14 // 15 15 … … 187 187 } else if ( arg == "-XCFA" ) { // CFA pass through 188 188 i += 1; 189 if ( i == argc ) continue; // next argument available ?190 189 Putenv( argv, argv[i] ); 191 190 -
libcfa/src/Makefile.in
rbdfc032 raefb247 425 425 am__v_CFA_0 = @echo " CFA " $@; 426 426 am__v_CFA_1 = 427 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 428 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 429 am__v_JAVAC_0 = @echo " JAVAC " $@; 430 am__v_JAVAC_1 = 431 AM_V_GOC = $(am__v_GOC_@AM_V@) 432 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 433 am__v_GOC_0 = @echo " GOC " $@; 434 am__v_GOC_1 = 427 435 UPPCC = u++ 428 436 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 431 439 am__v_UPP_0 = @echo " UPP " $@; 432 440 am__v_UPP_1 = 433 AM_V_GOC = $(am__v_GOC_@AM_V@)434 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)435 am__v_GOC_0 = @echo " GOC " $@;436 am__v_GOC_1 =437 AM_V_RUST = $(am__v_RUST_@AM_V@)438 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)439 am__v_RUST_0 = @echo " RUST " $@;440 am__v_RUST_1 =441 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)442 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)443 am__v_NODEJS_0 = @echo " NODEJS " $@;444 am__v_NODEJS_1 =445 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)446 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)447 am__v_JAVAC_0 = @echo " JAVAC " $@;448 am__v_JAVAC_1 =449 441 lib_LTLIBRARIES = libcfa.la libcfathread.la 450 442 gdbwaittarget = "" -
libcfa/src/bits/containers.hfa
rbdfc032 raefb247 10 10 // Created On : Tue Oct 31 16:38:50 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed J an 15 07:42:35 202013 // Update Count : 2812 // Last Modified On : Wed Jun 26 08:52:20 2019 13 // Update Count : 4 14 14 15 15 #pragma once … … 44 44 45 45 forall(dtype T | sized(T)) 46 static inline T & ?[?]( __small_array(T) & this, __lock_size_t idx) {46 static inline T& ?[?]( __small_array(T) & this, __lock_size_t idx) { 47 47 return ((typeof(this.data))this.data)[idx]; 48 48 } 49 49 50 50 forall(dtype T | sized(T)) 51 static inline T & ?[?]( const __small_array(T) & this, __lock_size_t idx) {51 static inline T& ?[?]( const __small_array(T) & this, __lock_size_t idx) { 52 52 return ((typeof(this.data))this.data)[idx]; 53 53 } 54 54 55 forall(dtype T )56 static inline T * begin( const __small_array(T) & this ) {55 forall(dtype T | sized(T)) 56 static inline T* begin( const __small_array(T) & this ) { 57 57 return ((typeof(this.data))this.data); 58 58 } 59 59 60 60 forall(dtype T | sized(T)) 61 static inline T * end( const __small_array(T) & this ) {61 static inline T* end( const __small_array(T) & this ) { 62 62 return ((typeof(this.data))this.data) + this.size; 63 63 } … … 70 70 #ifdef __cforall 71 71 trait is_node(dtype T) { 72 T *& get_next( T& );72 T*& get_next( T& ); 73 73 }; 74 74 #endif … … 97 97 forall(dtype T) 98 98 static inline void ?{}( __stack(T) & this ) { 99 (this.top){ 0p }; 100 } 101 102 static inline forall( dtype T | is_node(T) ) { 103 void push( __stack(T) & this, T * val ) { 104 verify( !get_next( *val ) ); 105 get_next( *val ) = this.top; 106 this.top = val; 107 } 108 109 T * pop( __stack(T) & this ) { 110 T * top = this.top; 111 if( top ) { 112 this.top = get_next( *top ); 113 get_next( *top ) = 0p; 114 } 115 return top; 116 } 117 118 int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) { 119 return this.top != 0; 120 } 99 (this.top){ NULL }; 100 } 101 102 forall(dtype T | is_node(T) | sized(T)) 103 static inline void push( __stack(T) & this, T * val ) { 104 verify( !get_next( *val ) ); 105 get_next( *val ) = this.top; 106 this.top = val; 107 } 108 109 forall(dtype T | is_node(T) | sized(T)) 110 static inline T * pop( __stack(T) & this ) { 111 T * top = this.top; 112 if( top ) { 113 this.top = get_next( *top ); 114 get_next( *top ) = NULL; 115 } 116 return top; 117 } 118 119 forall(dtype T | is_node(T)) 120 static inline int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) { 121 return this.top != 0; 121 122 } 122 123 #endif … … 144 145 145 146 #ifdef __cforall 146 static inline forall( dtype T | is_node(T) ) { 147 void ?{}( __queue(T) & this ) with( this ) { 148 head{ 0p }; 149 tail{ &head }; 150 } 151 152 void append( __queue(T) & this, T * val ) with( this ) { 153 verify(tail != 0p); 154 *tail = val; 155 tail = &get_next( *val ); 156 } 157 158 T * pop_head( __queue(T) & this ) { 159 T * head = this.head; 160 if( head ) { 161 this.head = get_next( *head ); 162 if( !get_next( *head ) ) { 163 this.tail = &this.head; 164 } 165 get_next( *head ) = 0p; 147 148 forall(dtype T) 149 static inline void ?{}( __queue(T) & this ) with( this ) { 150 head{ NULL }; 151 tail{ &head }; 152 } 153 154 forall(dtype T | is_node(T) | sized(T)) 155 static inline void append( __queue(T) & this, T * val ) with( this ) { 156 verify(tail != NULL); 157 *tail = val; 158 tail = &get_next( *val ); 159 } 160 161 forall(dtype T | is_node(T) | sized(T)) 162 static inline T * pop_head( __queue(T) & this ) { 163 T * head = this.head; 164 if( head ) { 165 this.head = get_next( *head ); 166 if( !get_next( *head ) ) { 167 this.tail = &this.head; 166 168 } 167 return head; 168 } 169 170 T * remove( __queue(T) & this, T ** it ) with( this ) { 171 T * val = *it; 172 verify( val ); 173 174 (*it) = get_next( *val ); 175 176 if( tail == &get_next( *val ) ) { 177 tail = it; 178 } 179 180 get_next( *val ) = 0p; 181 182 verify( (head == 0p) == (&head == tail) ); 183 verify( *tail == 0p ); 184 return val; 185 } 186 187 int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) { 188 return this.head != 0; 189 } 169 get_next( *head ) = NULL; 170 } 171 return head; 172 } 173 174 forall(dtype T | is_node(T) | sized(T)) 175 static inline T * remove( __queue(T) & this, T ** it ) with( this ) { 176 T * val = *it; 177 verify( val ); 178 179 (*it) = get_next( *val ); 180 181 if( tail == &get_next( *val ) ) { 182 tail = it; 183 } 184 185 get_next( *val ) = NULL; 186 187 verify( (head == NULL) == (&head == tail) ); 188 verify( *tail == NULL ); 189 return val; 190 } 191 192 forall(dtype T | is_node(T)) 193 static inline int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) { 194 return this.head != 0; 190 195 } 191 196 #endif … … 218 223 219 224 #ifdef __cforall 220 forall(dtype T ) 225 226 forall(dtype T | sized(T)) 221 227 static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) { 222 this.head{ 0p};228 this.head{ NULL }; 223 229 this.__get = __get; 224 230 } … … 226 232 #define next 0 227 233 #define prev 1 228 static inline forall(dtype T) { 229 void push_front( __dllist(T) & this, T & node ) with( this ) { 230 verify(__get); 231 if ( head ) { 232 __get( node ).next = head; 233 __get( node ).prev = __get( *head ).prev; 234 // inserted node must be consistent before it is seen 235 // prevent code movement across barrier 236 asm( "" : : : "memory" ); 237 __get( *head ).prev = &node; 238 T & _prev = *__get( node ).prev; 239 __get( _prev ).next = &node; 240 } else { 241 __get( node ).next = &node; 242 __get( node ).prev = &node; 243 } 244 234 forall(dtype T | sized(T)) 235 static inline void push_front( __dllist(T) & this, T & node ) with( this ) { 236 verify(__get); 237 if ( head ) { 238 __get( node ).next = head; 239 __get( node ).prev = __get( *head ).prev; 240 // inserted node must be consistent before it is seen 245 241 // prevent code movement across barrier 246 242 asm( "" : : : "memory" ); 247 head = &node; 248 } 249 250 void remove( __dllist(T) & this, T & node ) with( this ) { 251 verify(__get); 252 if ( &node == head ) { 253 if ( __get( *head ).next == head ) { 254 head = 0p; 255 } else { 256 head = __get( *head ).next; 257 } 243 __get( *head ).prev = &node; 244 T & _prev = *__get( node ).prev; 245 __get( _prev ).next = &node; 246 } 247 else { 248 __get( node ).next = &node; 249 __get( node ).prev = &node; 250 } 251 252 // prevent code movement across barrier 253 asm( "" : : : "memory" ); 254 head = &node; 255 } 256 257 forall(dtype T | sized(T)) 258 static inline void remove( __dllist(T) & this, T & node ) with( this ) { 259 verify(__get); 260 if ( &node == head ) { 261 if ( __get( *head ).next == head ) { 262 head = NULL; 258 263 } 259 __get( *__get( node ).next ).prev = __get( node ).prev; 260 __get( *__get( node ).prev ).next = __get( node ).next; 261 __get( node ).next = 0p; 262 __get( node ).prev = 0p; 263 } 264 265 int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) { 266 return this.head != 0; 267 } 264 else { 265 head = __get( *head ).next; 266 } 267 } 268 __get( *__get( node ).next ).prev = __get( node ).prev; 269 __get( *__get( node ).prev ).next = __get( node ).next; 270 __get( node ).next = NULL; 271 __get( node ).prev = NULL; 272 } 273 274 forall(dtype T | sized(T)) 275 static inline int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) { 276 return this.head != 0; 268 277 } 269 278 #undef next … … 277 286 278 287 #endif 279 280 // Local Variables: //281 // tab-width: 4 //282 // End: // -
libcfa/src/bits/defs.hfa
rbdfc032 raefb247 10 10 // Created On : Thu Nov 9 13:24:10 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jan 28 22:38:27 202013 // Update Count : 912 // Last Modified On : Thu Feb 8 16:22:41 2018 13 // Update Count : 8 14 14 // 15 15 … … 34 34 35 35 #ifdef __cforall 36 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 37 void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 38 37 extern "C" { 39 38 #endif -
libcfa/src/bits/signal.hfa
rbdfc032 raefb247 40 40 sigaddset( &act.sa_mask, SIGALRM ); // disabled during signal handler 41 41 sigaddset( &act.sa_mask, SIGUSR1 ); 42 sigaddset( &act.sa_mask, SIGSEGV );43 sigaddset( &act.sa_mask, SIGBUS );44 sigaddset( &act.sa_mask, SIGILL );45 sigaddset( &act.sa_mask, SIGFPE );46 sigaddset( &act.sa_mask, SIGHUP ); // revert to default on second delivery47 sigaddset( &act.sa_mask, SIGTERM );48 sigaddset( &act.sa_mask, SIGINT );49 42 act.sa_flags = flags; 50 43 51 if ( sigaction( sig, &act, 0p) == -1 ) {44 if ( sigaction( sig, &act, NULL ) == -1 ) { 52 45 __cfaabi_dbg_print_buffer_decl( 53 46 " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n", … … 55 48 ); 56 49 _exit( EXIT_FAILURE ); 57 } // if50 } 58 51 } 52 53 // Sigaction wrapper : restore default handler 54 static void __cfaabi_sigdefault( int sig ) { 55 struct sigaction act; 56 57 act.sa_handler = SIG_DFL; 58 act.sa_flags = 0; 59 sigemptyset( &act.sa_mask ); 60 61 if ( sigaction( sig, &act, NULL ) == -1 ) { 62 __cfaabi_dbg_print_buffer_decl( 63 " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n", 64 sig, errno, strerror( errno ) 65 ); 66 _exit( EXIT_FAILURE ); 67 } 68 } -
libcfa/src/clock.hfa
rbdfc032 raefb247 10 10 // Created On : Thu Apr 12 14:36:06 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 6 12:49:58 202013 // Update Count : 912 // Last Modified On : Thu Jun 13 21:21:13 2019 13 // Update Count : 8 14 14 // 15 15 16 16 #include <time.hfa> 17 17 18 18 19 //######################### C time ######################### … … 25 26 static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); } 26 27 28 27 29 //######################### Clock ######################### 28 30 29 31 struct Clock { // private 30 32 Duration offset; // for virtual clock: contains offset from real-time 33 int clocktype; // implementation only -1 (virtual), CLOCK_REALTIME 31 34 }; 32 35 33 36 static inline { 37 void resetClock( Clock & clk ) with( clk ) { 38 clocktype = CLOCK_REALTIME_COARSE; 39 } // Clock::resetClock 40 34 41 void resetClock( Clock & clk, Duration adj ) with( clk ) { 42 clocktype = -1; 35 43 offset = adj + __timezone`s; // timezone (global) is (UTC - local time) in seconds 36 44 } // resetClock 37 45 46 void ?{}( Clock & clk ) { resetClock( clk ); } 38 47 void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); } 39 48 … … 80 89 return ret; 81 90 } // getTime 82 83 Time getCPUTime() {84 timespec ts;85 clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );86 return (Time){ ts };87 } // getCPUTime88 91 } // distribution 89 92 -
libcfa/src/concurrency/CtxSwitch-x86_64.S
rbdfc032 raefb247 87 87 CtxInvokeStub: 88 88 movq %rbx, %rdi 89 movq %r12, %rsi 90 jmp *%r13 89 jmp *%r12 91 90 .size CtxInvokeStub, .-CtxInvokeStub 92 91 -
libcfa/src/concurrency/alarm.cfa
rbdfc032 raefb247 10 10 // Created On : Fri Jun 2 11:31:25 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 08:41:36 202013 // Update Count : 6 912 // Last Modified On : Tue Dec 3 22:47:24 2019 13 // Update Count : 68 14 14 // 15 15 … … 39 39 40 40 void __kernel_set_timer( Duration alarm ) { 41 verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm `ns);41 verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv); 42 42 setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p ); 43 43 } -
libcfa/src/concurrency/coroutine.cfa
rbdfc032 raefb247 187 187 // is not inline (We can't inline Cforall in C) 188 188 extern "C" { 189 void __leave_coroutine( struct coroutine_desc * src ) { 189 void __suspend_internal(void) { 190 suspend(); 191 } 192 193 void __leave_coroutine( coroutine_desc * src ) { 190 194 coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter; 191 195 … … 203 207 CoroutineCtxSwitch( src, starter ); 204 208 } 205 206 struct coroutine_desc * __finish_coroutine(void) {207 struct coroutine_desc * cor = kernelTLS.this_thread->curr_cor;208 209 if(cor->state == Primed) {210 suspend();211 }212 213 cor->state = Active;214 215 return cor;216 }217 209 } 218 210 -
libcfa/src/concurrency/coroutine.hfa
rbdfc032 raefb247 61 61 // Start coroutine routines 62 62 extern "C" { 63 void CtxInvokeCoroutine(void (*main)(void *), void * this); 63 forall(dtype T | is_coroutine(T)) 64 void CtxInvokeCoroutine(T * this); 64 65 65 forall(dtype T)66 void CtxStart(void (*main)(T &), struct coroutine_desc * cor, T & this, void (*invoke)(void (*main)(void *), void*));66 forall(dtype T | is_coroutine(T)) 67 void CtxStart(T * this, void ( *invoke)(T *)); 67 68 68 69 extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__)); … … 128 129 129 130 if( unlikely(dst->context.SP == 0p) ) { 130 TL_GET( this_thread )->curr_cor = dst;131 131 __stack_prepare(&dst->stack, 65000); 132 CtxStart(main, dst, cor, CtxInvokeCoroutine); 133 TL_GET( this_thread )->curr_cor = src; 132 CtxStart(&cor, CtxInvokeCoroutine); 134 133 } 135 134 -
libcfa/src/concurrency/invoke.c
rbdfc032 raefb247 29 29 // Called from the kernel when starting a coroutine or task so must switch back to user mode. 30 30 31 extern void __leave_coroutine ( struct coroutine_desc * ); 32 extern struct coroutine_desc * __finish_coroutine(void); 33 extern void __leave_thread_monitor(); 31 extern void __suspend_internal(void); 32 extern void __leave_coroutine( struct coroutine_desc * ); 33 extern void __finish_creation( struct thread_desc * ); 34 extern void __leave_thread_monitor( struct thread_desc * this ); 34 35 extern void disable_interrupts() OPTIONAL_THREAD; 35 36 extern void enable_interrupts( __cfaabi_dbg_ctx_param ); … … 37 38 void CtxInvokeCoroutine( 38 39 void (*main)(void *), 40 struct coroutine_desc *(*get_coroutine)(void *), 39 41 void *this 40 42 ) { 41 // Finish setting up the coroutine by setting its state 42 struct coroutine_desc * cor = __finish_coroutine(); 43 struct coroutine_desc* cor = get_coroutine( this ); 43 44 44 // Call the main of the coroutine 45 if(cor->state == Primed) { 46 __suspend_internal(); 47 } 48 49 cor->state = Active; 50 45 51 main( this ); 46 52 … … 77 83 78 84 void CtxInvokeThread( 85 void (*dtor)(void *), 79 86 void (*main)(void *), 87 struct thread_desc *(*get_thread)(void *), 80 88 void *this 81 89 ) { 90 // Fetch the thread handle from the user defined thread structure 91 struct thread_desc* thrd = get_thread( this ); 92 93 // First suspend, once the thread arrives here, 94 // the function pointer to main can be invalidated without risk 95 __finish_creation( thrd ); 96 82 97 // Officially start the thread by enabling preemption 83 98 enable_interrupts( __cfaabi_dbg_ctx ); … … 93 108 // The order of these 4 operations is very important 94 109 //Final suspend, should never return 95 __leave_thread_monitor( );110 __leave_thread_monitor( thrd ); 96 111 __cabi_abort( "Resumed dead thread" ); 97 112 } 98 113 114 99 115 void CtxStart( 100 116 void (*main)(void *), 101 struct coroutine_desc * cor,117 struct coroutine_desc *(*get_coroutine)(void *), 102 118 void *this, 103 119 void (*invoke)(void *) 104 120 ) { 121 struct coroutine_desc * cor = get_coroutine( this ); 105 122 struct __stack_t * stack = cor->stack.storage; 106 123 … … 121 138 122 139 fs->dummyReturn = NULL; 123 fs->argument[0] = main; // argument to invoke 124 fs->argument[1] = this; // argument to invoke 140 fs->argument[0] = this; // argument to invoke 125 141 fs->rturn = invoke; 126 142 … … 140 156 fs->dummyReturn = NULL; 141 157 fs->rturn = CtxInvokeStub; 142 fs->fixedRegisters[0] = main; 143 fs->fixedRegisters[1] = this; 144 fs->fixedRegisters[2] = invoke; 158 fs->fixedRegisters[0] = this; 159 fs->fixedRegisters[1] = invoke; 145 160 146 161 #elif defined( __ARM_ARCH ) 147 #error ARM needs to be upgrade to use to parameters like X86/X64 (A.K.A. : I broke this and do not know how to fix it) 162 148 163 struct FakeStack { 149 164 float fpRegs[16]; // floating point registers -
libcfa/src/concurrency/kernel.cfa
rbdfc032 raefb247 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 30 22:55:50 202013 // Update Count : 5 612 // Last Modified On : Thu Dec 5 16:25:52 2019 13 // Update Count : 52 14 14 // 15 15 … … 469 469 ); 470 470 471 Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 471 Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 472 472 473 473 Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" ); … … 490 490 verify( ! kernelTLS.preemption_state.enabled ); 491 491 492 kernelTLS.this_thread->curr_cor = dst;493 492 __stack_prepare( &dst->stack, 65000 ); 494 CtxStart( main, dst,this->runner, CtxInvokeCoroutine);493 CtxStart(&this->runner, CtxInvokeCoroutine); 495 494 496 495 verify( ! kernelTLS.preemption_state.enabled ); … … 506 505 CtxSwitch( &src->context, &dst->context ); 507 506 // when CtxSwitch returns we are back in the src coroutine 508 509 mainThread->curr_cor = &mainThread->self_cor;510 507 511 508 // set state of new coroutine to active … … 844 841 sigemptyset( &mask ); 845 842 sigaddset( &mask, SIGALRM ); // block SIGALRM signals 846 sigaddset( &mask, SIGUSR1 ); // block SIGALRM signals 847 sigsuspend( &mask ); // block the processor to prevent further damage during abort 848 _exit( EXIT_FAILURE ); // if processor unblocks before it is killed, terminate it 843 sigsuspend( &mask ); // block the processor to prevent further damage during abort 844 _exit( EXIT_FAILURE ); // if processor unblocks before it is killed, terminate it 849 845 } 850 846 else { -
libcfa/src/concurrency/kernel_private.hfa
rbdfc032 raefb247 88 88 // Threads 89 89 extern "C" { 90 void CtxInvokeThread(void (*main)(void *), void * this); 90 forall(dtype T | is_thread(T)) 91 void CtxInvokeThread(T * this); 91 92 } 92 93 -
libcfa/src/concurrency/monitor.cfa
rbdfc032 raefb247 243 243 // last routine called by a thread. 244 244 // Should never return 245 void __leave_thread_monitor() { 246 thread_desc * thrd = TL_GET( this_thread ); 245 void __leave_thread_monitor( thread_desc * thrd ) { 247 246 monitor_desc * this = &thrd->self_mon; 248 247 -
libcfa/src/concurrency/thread.cfa
rbdfc032 raefb247 58 58 void ?{}( scoped(T)& this ) with( this ) { 59 59 handle{}; 60 __thrd_start(handle , main);60 __thrd_start(handle); 61 61 } 62 62 … … 64 64 void ?{}( scoped(T)& this, P params ) with( this ) { 65 65 handle{ params }; 66 __thrd_start(handle , main);66 __thrd_start(handle); 67 67 } 68 68 … … 75 75 // Starting and stopping threads 76 76 forall( dtype T | is_thread(T) ) 77 void __thrd_start( T & this, void (*main_p)(T &)) {77 void __thrd_start( T& this ) { 78 78 thread_desc * this_thrd = get_thread(this); 79 79 thread_desc * curr_thrd = TL_GET( this_thread ); 80 80 81 81 disable_interrupts(); 82 CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread); 83 82 CtxStart(&this, CtxInvokeThread); 84 83 this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP]; 85 84 verify( this_thrd->context.SP ); 86 //CtxSwitch( &curr_thrd->context, &this_thrd->context );85 CtxSwitch( &curr_thrd->context, &this_thrd->context ); 87 86 88 87 ScheduleThread(this_thrd); 89 88 enable_interrupts( __cfaabi_dbg_ctx ); 89 } 90 91 extern "C" { 92 // KERNEL ONLY 93 void __finish_creation(thread_desc * this) { 94 // set new coroutine that the processor is executing 95 // and context switch to it 96 verify( kernelTLS.this_thread != this ); 97 verify( kernelTLS.this_thread->context.SP ); 98 CtxSwitch( &this->context, &kernelTLS.this_thread->context ); 99 } 90 100 } 91 101 -
libcfa/src/concurrency/thread.hfa
rbdfc032 raefb247 54 54 55 55 forall( dtype T | is_thread(T) ) 56 void __thrd_start( T & this , void (*)(T &));56 void __thrd_start( T & this ); 57 57 58 58 //----------------------------------------------------------------------------- -
libcfa/src/executor.cfa
rbdfc032 raefb247 8 8 #include <stdio.h> 9 9 10 forall( dtype T )11 monitor Buffer { // unbounded buffer12 __queue_t( T ) queue; // unbounded list of work requests13 condition delay;14 }; // Buffer15 forall( dtype T | is_node(T) ) { 10 forall( otype T | is_node(T) | is_monitor(T) ) { 11 monitor Buffer { // unbounded buffer 12 __queue_t( T ) queue; // unbounded list of work requests 13 condition delay; 14 }; // Buffer 15 16 16 void insert( Buffer( T ) & mutex buf, T * elem ) with(buf) { 17 17 append( queue, elem ); // insert element into buffer … … 20 20 21 21 T * remove( Buffer( T ) & mutex buf ) with(buf) { 22 if ( queue.head != 0) wait( delay ); // no request to process ? => wait23 //return pop_head( queue );22 if ( ! queue ) wait( delay ); // no request to process ? => wait 23 return pop_head( queue ); 24 24 } // remove 25 25 } // distribution -
libcfa/src/interpose.cfa
rbdfc032 raefb247 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 30 17:47:32 202013 // Update Count : 1 5612 // Last Modified On : Fri Dec 13 13:45:21 2019 13 // Update Count : 121 14 14 // 15 15 … … 95 95 void __cfaabi_interpose_startup(void) __attribute__(( constructor( STARTUP_PRIORITY_CORE ) )); 96 96 void __cfaabi_interpose_startup( void ) { 97 const char *version = 0p;97 const char *version = NULL; 98 98 99 99 preload_libgcc(); … … 105 105 #pragma GCC diagnostic pop 106 106 107 // As a precaution (and necessity), errors that result in termination are delivered on a separate stack because108 // task stacks might be very small (4K) and the signal delivery corrupts memory to the point that a clean109 // shutdown is impossible. Also, when a stack overflow encounters the non-accessible sentinel page (debug only)110 // and generates a segment fault, the signal cannot be delivered on the sentinel page. Finally, calls to abort111 // print a stack trace that uses substantial stack space.112 113 #define MINSTKSZ SIGSTKSZ * 8114 static char stack[MINSTKSZ] __attribute__(( aligned (16) ));115 static stack_t ss;116 117 ss.ss_sp = stack;118 ss.ss_size = MINSTKSZ;119 ss.ss_flags = 0;120 if ( sigaltstack( &ss, 0p ) == -1 ) {121 abort( "__cfaabi_interpose_startup : internal error, sigaltstack error(%d) %s.", errno, strerror( errno ) );122 } // if123 124 107 // Failure handler 125 __cfaabi_sigaction( SIGSEGV, sigHandler_segv, SA_SIGINFO | SA_ONSTACK ); 126 __cfaabi_sigaction( SIGBUS , sigHandler_segv, SA_SIGINFO | SA_ONSTACK ); 127 __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO | SA_ONSTACK ); 128 __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO | SA_ONSTACK ); 129 __cfaabi_sigaction( SIGTERM, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // one shot handler, return to default 130 __cfaabi_sigaction( SIGINT , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); 131 __cfaabi_sigaction( SIGABRT, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); 132 __cfaabi_sigaction( SIGHUP , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // terminal hangup 108 __cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); 109 __cfaabi_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO ); 110 __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO ); 111 __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO ); 112 __cfaabi_sigaction( SIGABRT, sigHandler_abrt, SA_SIGINFO | SA_RESETHAND); 113 __cfaabi_sigaction( SIGTERM, sigHandler_term , SA_SIGINFO ); 114 __cfaabi_sigaction( SIGINT , sigHandler_term , SA_SIGINFO ); 133 115 } 134 116 } … … 141 123 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 142 124 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 143 void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));144 125 145 126 extern "C" { 146 127 void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) { 147 abort( false, NULL ); // FIX ME: 0p does not work128 abort( NULL ); 148 129 } 149 130 … … 151 132 va_list argp; 152 133 va_start( argp, fmt ); 153 abort( f alse, fmt, argp );134 abort( fmt, argp ); 154 135 va_end( argp ); 155 136 } … … 160 141 } 161 142 162 void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; } 163 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 164 // See concurrency/kernel.cfa for strong definition used in multi-processor mode. 143 void * kernel_abort ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; } 144 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 165 145 int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; } 166 146 167 147 enum { abort_text_size = 1024 }; 168 148 static char abort_text[ abort_text_size ]; 169 170 static void __cfaabi_backtrace( int start ) { 149 static int abort_lastframe; 150 151 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) { 152 va_list args; 153 va_start( args, fmt ); 154 vfprintf( stderr, fmt, args ); 155 va_end( args ); 156 __cabi_libc.exit( status ); 157 } 158 159 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) { 160 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 161 int len; 162 163 abort_lastframe = kernel_abort_lastframe(); 164 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 165 __cfaabi_dbg_write( abort_text, len ); 166 167 if ( fmt ) { 168 va_list args; 169 va_start( args, fmt ); 170 171 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 172 va_end( args ); 173 __cfaabi_dbg_write( abort_text, len ); 174 175 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 176 __cfaabi_dbg_write( "\n", 1 ); 177 } 178 } 179 180 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 181 __cabi_libc.abort(); 182 } 183 184 static void __cfaabi_backtrace() { 171 185 enum { 172 186 Frames = 50, // maximum number of stack frames 187 Start = 8, // skip first N stack frames 173 188 }; 174 int last = kernel_abort_lastframe(); // skip last N stack frames175 189 176 190 void * array[Frames]; … … 178 192 char ** messages = backtrace_symbols( array, size ); 179 193 180 *index( messages[0], '(' ) = '\0'; // find executable name 194 // find executable name 195 *index( messages[0], '(' ) = '\0'; 181 196 __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]); 182 197 183 for ( unsigned int i = start; i < size - last&& messages != 0p; i += 1 ) {198 for ( int i = Start; i < size - abort_lastframe && messages != 0p; i += 1 ) { 184 199 char * name = 0p, * offset_begin = 0p, * offset_end = 0p; 185 200 186 for ( char * p = messages[i]; *p; ++p ) { // find parantheses and +offset201 for ( char * p = messages[i]; *p; ++p ) { 187 202 //__cfaabi_bits_print_nolock( "X %s\n", p); 203 // find parantheses and +offset 188 204 if ( *p == '(' ) { 189 205 name = p; … … 196 212 } 197 213 198 // if line contains symbol ,print it199 int frameNo = i - start;214 // if line contains symbol print it 215 int frameNo = i - Start; 200 216 if ( name && offset_begin && offset_end && name < offset_begin ) { 201 *name++ = '\0'; // delimit strings 217 // delimit strings 218 *name++ = '\0'; 202 219 *offset_begin++ = '\0'; 203 220 *offset_end++ = '\0'; … … 211 228 } 212 229 213 void exit( int status, const char fmt[], ... ) {214 va_list args;215 va_start( args, fmt );216 vfprintf( stderr, fmt, args );217 va_end( args );218 __cabi_libc.exit( status );219 }220 221 void abort( bool signalAbort, const char fmt[], ... ) {222 void * kernel_data = kernel_abort(); // must be done here to lock down kernel223 int len;224 225 signal( SIGABRT, SIG_DFL ); // prevent final "real" abort from recursing to handler226 227 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)228 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );229 230 if ( fmt ) {231 va_list args;232 va_start( args, fmt );233 234 len = vsnprintf( abort_text, abort_text_size, fmt, args );235 va_end( args );236 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );237 238 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text239 __cfaabi_dbg_write( "\n", 1 );240 }241 }242 243 kernel_abort_msg( kernel_data, abort_text, abort_text_size );244 __cfaabi_backtrace( signalAbort ? 4 : 3 );245 246 __cabi_libc.abort(); // print stack trace in handler247 }248 249 void abort( const char fmt[], ... ) {250 va_list args;251 va_start( args, fmt );252 abort( false, fmt, args );253 va_end( args );254 }255 256 230 void sigHandler_segv( __CFA_SIGPARMS__ ) { 257 if ( sfp->si_addr == 0p) {258 abort( true,"Null pointer (0p) dereference.\n" );231 if ( sfp->si_addr == NULL ) { 232 abort( "Null pointer (0p) dereference.\n" ); 259 233 } else { 260 abort( true,"%s at memory location %p.\n"234 abort( "%s at memory location %p.\n" 261 235 "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n", 262 236 (sig == SIGSEGV ? "Segment fault" : "Bus error"), sfp->si_addr ); … … 265 239 266 240 void sigHandler_ill( __CFA_SIGPARMS__ ) { 267 abort( true,"Executing illegal instruction at location %p.\n"241 abort( "Executing illegal instruction at location %p.\n" 268 242 "Possible cause is stack corruption.\n", 269 243 sfp->si_addr ); … … 281 255 default: msg = "unknown"; 282 256 } // choose 283 abort( true, "Computation error %s at location %p.\n", msg, sfp->si_addr ); 257 abort( "Computation error %s at location %p.\n", msg, sfp->si_addr ); 258 } 259 260 void sigHandler_abrt( __CFA_SIGPARMS__ ) { 261 __cfaabi_backtrace(); 262 263 // reset default signal handler 264 __cfaabi_sigdefault( SIGABRT ); 265 266 raise( SIGABRT ); 284 267 } 285 268 286 269 void sigHandler_term( __CFA_SIGPARMS__ ) { 287 abort( true, "Application interrupted by signal: %s.\n", strsignal( sig ));270 abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)" ); 288 271 } 289 272 -
libcfa/src/startup.cfa
rbdfc032 raefb247 10 10 // Created On : Tue Jul 24 16:21:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 13:16:45201913 // Update Count : 2912 // Last Modified On : Sat Nov 30 07:07:56 2019 13 // Update Count : 13 14 14 // 15 15 16 #include "startup.hfa" 16 17 #include <time.h> // tzset 17 #include "startup.hfa"18 18 19 19 extern "C" { 20 void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));20 static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) )); 21 21 void __cfaabi_appready_startup( void ) { 22 22 tzset(); // initialize time global variables … … 27 27 } // __cfaabi_appready_startup 28 28 29 void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));29 static void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) )); 30 30 void __cfaabi_appready_shutdown( void ) { 31 31 #ifdef __CFA_DEBUG__ -
libcfa/src/stdhdr/bfdlink.h
rbdfc032 raefb247 10 10 // Created On : Tue Jul 18 07:26:04 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Feb 1 07:15:29 202013 // Update Count : 512 // Last Modified On : Sun Jul 22 13:49:30 2018 13 // Update Count : 4 14 14 // 15 15 16 16 // include file uses the CFA keyword "with". 17 17 #if ! defined( with ) // nesting ? 18 #define with ` `with``// make keyword an identifier18 #define with `with` // make keyword an identifier 19 19 #define __CFA_BFDLINK_H__ 20 20 #endif -
libcfa/src/stdhdr/hwloc.h
rbdfc032 raefb247 10 10 // Created On : Tue Jul 18 07:45:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Feb 1 07:15:39 202013 // Update Count : 512 // Last Modified On : Sun Jul 22 13:49:58 2018 13 // Update Count : 4 14 14 // 15 15 16 16 // include file uses the CFA keyword "thread". 17 17 #if ! defined( thread ) // nesting ? 18 #define thread ` `thread``// make keyword an identifier18 #define thread `thread` // make keyword an identifier 19 19 #define __CFA_HWLOC_H__ 20 20 #endif -
libcfa/src/stdhdr/krb5.h
rbdfc032 raefb247 10 10 // Created On : Tue Jul 18 07:55:44 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Feb 1 07:15:47 202013 // Update Count : 512 // Last Modified On : Sun Jul 22 13:50:24 2018 13 // Update Count : 4 14 14 // 15 15 16 16 // include file uses the CFA keyword "enable". 17 17 #if ! defined( enable ) // nesting ? 18 #define enable ` `enable``// make keyword an identifier18 #define enable `enable` // make keyword an identifier 19 19 #define __CFA_KRB5_H__ 20 20 #endif -
libcfa/src/stdhdr/math.h
rbdfc032 raefb247 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 07:15:58 202013 // Update Count : 1 412 // Last Modified On : Thu Feb 22 18:16:07 2018 13 // Update Count : 13 14 14 // 15 15 16 16 extern "C" { 17 17 #if ! defined( exception ) // nesting ? 18 #define exception ` `exception`` // make keyword an identifier18 #define exception `exception` // make keyword an identifier 19 19 #define __CFA_MATH_H__ 20 20 #endif -
libcfa/src/stdhdr/sys/ucontext.h
rbdfc032 raefb247 10 10 // Created On : Thu Feb 8 23:48:16 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 07:16:05 202013 // Update Count : 512 // Last Modified On : Thu Feb 8 23:50:44 2018 13 // Update Count : 4 14 14 // 15 15 16 16 #if ! defined( ftype ) // nesting ? 17 #define ftype ` `ftype`` // make keyword an identifier17 #define ftype `ftype` // make keyword an identifier 18 18 #define __CFA_UCONTEXT_H__ 19 19 #endif -
libcfa/src/time.cfa
rbdfc032 raefb247 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Jan 5 17:27:40 202013 // Update Count : 6 912 // Last Modified On : Sat Jul 13 08:41:55 2019 13 // Update Count : 65 14 14 // 15 15 … … 33 33 forall( dtype ostype | ostream( ostype ) ) { 34 34 ostype & ?|?( ostype & os, Duration dur ) with( dur ) { 35 (ostype &)(os | t n/ TIMEGRAN); // print seconds36 long int ns = (t n < 0 ? -tn : tn) % TIMEGRAN; // compute nanoseconds35 (ostype &)(os | tv / TIMEGRAN); // print seconds 36 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 37 37 if ( ns != 0 ) { // some ? 38 38 char buf[16]; … … 52 52 53 53 #ifdef __CFA_DEBUG__ 54 static void tabort( int year, int month, int day, int hour, int min, int sec, int 64_tnsec ) {54 static void tabort( int year, int month, int day, int hour, int min, int sec, int nsec ) { 55 55 abort | "Attempt to create Time( year=" | year | "(>=1970), month=" | month | "(1-12), day=" | day | "(1-31), hour=" | hour | "(0-23), min=" | min | "(0-59), sec=" | sec 56 | "(0-60), nsec=" | nsec | "(0-999_999_999), which is not in the range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038, where month and day have 1 origin.";56 | "(0-60), nsec=" | nsec | "(0-999_999_999), which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038."; 57 57 } // tabort 58 58 #endif // __CFA_DEBUG__ 59 59 60 void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int 64_tnsec ) with( time ) {60 void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) { 61 61 tm tm; 62 62 63 // Values can be in any range (+/-) but result must be in the epoch.63 tm.tm_isdst = -1; // let mktime determine if alternate timezone is in effect 64 64 tm.tm_year = year - 1900; // mktime uses 1900 as its starting point 65 // Make month in range 1-12 to match with day. 65 #ifdef __CFA_DEBUG__ 66 if ( month < 1 || 12 < month ) { 67 tabort( year, month, day, hour, min, sec, nsec ); 68 } // if 69 #endif // __CFA_DEBUG__ 66 70 tm.tm_mon = month - 1; // mktime uses range 0-11 71 #ifdef __CFA_DEBUG__ 72 if ( day < 1 || 31 < day ) { 73 tabort( year, month, day, hour, min, sec, nsec ); 74 } // if 75 #endif // __CFA_DEBUG__ 67 76 tm.tm_mday = day; // mktime uses range 1-31 68 77 tm.tm_hour = hour; 69 78 tm.tm_min = min; 70 79 tm.tm_sec = sec; 71 tm.tm_isdst = -1; // let mktime determine if alternate timezone is in effect72 80 time_t epochsec = mktime( &tm ); 73 81 #ifdef __CFA_DEBUG__ 74 if ( epochsec <= (time_t)-1 ) { // MUST BE LESS THAN OR EQUAL!82 if ( epochsec == (time_t)-1 ) { 75 83 tabort( year, month, day, hour, min, sec, nsec ); 76 84 } // if 77 85 #endif // __CFA_DEBUG__ 78 t n= (int64_t)(epochsec) * TIMEGRAN + nsec; // convert to nanoseconds86 tv = (int64_t)(epochsec) * TIMEGRAN + nsec; // convert to nanoseconds 79 87 #ifdef __CFA_DEBUG__ 80 if ( t n> 2147483647LL * TIMEGRAN ) { // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.88 if ( tv > 2147483647LL * TIMEGRAN ) { // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038. 81 89 tabort( year, month, day, hour, min, sec, nsec ); 82 90 } // if … … 85 93 86 94 char * yy_mm_dd( Time time, char * buf ) with( time ) { 87 time_t s = t n/ TIMEGRAN;95 time_t s = tv / TIMEGRAN; 88 96 tm tm; 89 97 gmtime_r( &s, &tm ); // tm_mon <= 11, tm_mday <= 31 … … 100 108 101 109 char * mm_dd_yy( Time time, char * buf ) with( time ) { 102 time_t s = t n/ TIMEGRAN;110 time_t s = tv / TIMEGRAN; 103 111 tm tm; 104 112 gmtime_r( &s, &tm ); // tm_mon <= 11, tm_mday <= 31 … … 115 123 116 124 char * dd_mm_yy( Time time, char * buf ) with( time ) { 117 time_t s = t n/ TIMEGRAN;125 time_t s = tv / TIMEGRAN; 118 126 tm tm; 119 127 gmtime_r( &s, &tm ); // tm_mon <= 11, tm_mday <= 31 … … 130 138 131 139 size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) { 132 time_t s = t n/ TIMEGRAN;140 time_t s = tv / TIMEGRAN; 133 141 tm tm; 134 142 gmtime_r( &s, &tm ); … … 139 147 ostype & ?|?( ostype & os, Time time ) with( time ) { 140 148 char buf[32]; // at least 26 141 time_t s = t n/ TIMEGRAN;149 time_t s = tv / TIMEGRAN; 142 150 ctime_r( &s, (char *)&buf ); // 26 characters: "Wed Jun 30 21:49:08 1993\n" 143 151 buf[24] = '\0'; // remove trailing '\n' 144 long int ns = (t n < 0 ? -tn : tn) % TIMEGRAN; // compute nanoseconds152 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 145 153 if ( ns == 0 ) { // none ? 146 154 (ostype &)(os | buf); // print date/time/year -
libcfa/src/time.hfa
rbdfc032 raefb247 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 6 12:50:16 202013 // Update Count : 6 5312 // Last Modified On : Sat Sep 22 12:25:34 2018 13 // Update Count : 643 14 14 // 15 15 … … 32 32 Duration ?=?( Duration & dur, __attribute__((unused)) zero_t ) { return dur{ 0 }; } 33 33 34 Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tn}; }35 Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.t n + rhs.tn}; }34 Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tv }; } 35 Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; } 36 36 Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; } 37 37 38 Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -t n}; }39 Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.t n - rhs.tn}; }38 Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; } 39 Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; } 40 40 Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; } 41 41 42 Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.t n* rhs }; }43 Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.t n}; }42 Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; } 43 Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; } 44 44 Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; } 45 45 46 int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.t n / rhs.tn; }47 Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.t n/ rhs }; }46 int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tv / rhs.tv; } 47 Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv / rhs }; } 48 48 Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; } 49 double div( Duration lhs, Duration rhs ) { return (double)lhs.t n / (double)rhs.tn; }50 51 Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.t n % rhs.tn}; }49 double div( Duration lhs, Duration rhs ) { return (double)lhs.tv / (double)rhs.tv; } 50 51 Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tv % rhs.tv }; } 52 52 Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; } 53 53 54 bool ?==?( Duration lhs, Duration rhs ) { return lhs.t n == rhs.tn; }55 bool ?!=?( Duration lhs, Duration rhs ) { return lhs.t n != rhs.tn; }56 bool ?<? ( Duration lhs, Duration rhs ) { return lhs.t n < rhs.tn; }57 bool ?<=?( Duration lhs, Duration rhs ) { return lhs.t n <= rhs.tn; }58 bool ?>? ( Duration lhs, Duration rhs ) { return lhs.t n > rhs.tn; }59 bool ?>=?( Duration lhs, Duration rhs ) { return lhs.t n >= rhs.tn; }60 61 bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n== 0; }62 bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n!= 0; }63 bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n< 0; }64 bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n<= 0; }65 bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n> 0; }66 bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.t n>= 0; }67 68 Duration abs( Duration rhs ) { return rhs.t n>= 0 ? rhs : -rhs; }54 bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; } 55 bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; } 56 bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tv < rhs.tv; } 57 bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; } 58 bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tv > rhs.tv; } 59 bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; } 60 61 bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv == 0; } 62 bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv != 0; } 63 bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv < 0; } 64 bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv <= 0; } 65 bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv > 0; } 66 bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv >= 0; } 67 68 Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; } 69 69 70 70 Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; } … … 82 82 Duration ?`w( double weeks ) { return (Duration)@{ weeks * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; } 83 83 84 int64_t ?`ns( Duration dur ) { return dur.t n; }85 int64_t ?`us( Duration dur ) { return dur.t n/ (TIMEGRAN / 1_000_000LL); }86 int64_t ?`ms( Duration dur ) { return dur.t n/ (TIMEGRAN / 1_000LL); }87 int64_t ?`s( Duration dur ) { return dur.t n/ TIMEGRAN; }88 int64_t ?`m( Duration dur ) { return dur.t n/ (60LL * TIMEGRAN); }89 int64_t ?`h( Duration dur ) { return dur.t n/ (60LL * 60LL * TIMEGRAN); }90 int64_t ?`d( Duration dur ) { return dur.t n/ (24LL * 60LL * 60LL * TIMEGRAN); }91 int64_t ?`w( Duration dur ) { return dur.t n/ (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }92 93 Duration max( Duration lhs, Duration rhs ) { return (lhs.t n < rhs.tn) ? rhs : lhs;}94 Duration min( Duration lhs, Duration rhs ) { return !(rhs.t n < lhs.tn) ? lhs : rhs;}84 int64_t ?`ns( Duration dur ) { return dur.tv; } 85 int64_t ?`us( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000_000LL); } 86 int64_t ?`ms( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000LL); } 87 int64_t ?`s( Duration dur ) { return dur.tv / TIMEGRAN; } 88 int64_t ?`m( Duration dur ) { return dur.tv / (60LL * TIMEGRAN); } 89 int64_t ?`h( Duration dur ) { return dur.tv / (60LL * 60LL * TIMEGRAN); } 90 int64_t ?`d( Duration dur ) { return dur.tv / (24LL * 60LL * 60LL * TIMEGRAN); } 91 int64_t ?`w( Duration dur ) { return dur.tv / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); } 92 93 Duration max( Duration lhs, Duration rhs ) { return (lhs.tv < rhs.tv) ? rhs : lhs;} 94 Duration min( Duration lhs, Duration rhs ) { return !(rhs.tv < lhs.tv) ? lhs : rhs;} 95 95 } // distribution 96 96 … … 143 143 //######################### Time ######################### 144 144 145 void ?{}( Time & time, int year, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0, int64_t nsec = 0 );145 void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 ); 146 146 static inline { 147 147 Time ?=?( Time & time, __attribute__((unused)) zero_t ) { return time{ 0 }; } 148 148 149 void ?{}( Time & time, timeval t ) with( time ) { t n= (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }149 void ?{}( Time & time, timeval t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; } 150 150 Time ?=?( Time & time, timeval t ) with( time ) { 151 t n= (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);151 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL); 152 152 return time; 153 153 } // ?=? 154 154 155 void ?{}( Time & time, timespec t ) with( time ) { t n= (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }155 void ?{}( Time & time, timespec t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; } 156 156 Time ?=?( Time & time, timespec t ) with( time ) { 157 t n= (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;157 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; 158 158 return time; 159 159 } // ?=? 160 160 161 Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.t n + rhs.tn}; }161 Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; } 162 162 Time ?+?( Duration lhs, Time rhs ) { return rhs + lhs; } 163 163 Time ?+=?( Time & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; } 164 164 165 Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.t n - rhs.tn}; }166 Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.t n - rhs.tn}; }165 Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; } 166 Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; } 167 167 Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; } 168 bool ?==?( Time lhs, Time rhs ) { return lhs.tn == rhs.tn; } 169 bool ?!=?( Time lhs, Time rhs ) { return lhs.tn != rhs.tn; } 170 bool ?<?( Time lhs, Time rhs ) { return lhs.tn < rhs.tn; } 171 bool ?<=?( Time lhs, Time rhs ) { return lhs.tn <= rhs.tn; } 172 bool ?>?( Time lhs, Time rhs ) { return lhs.tn > rhs.tn; } 173 bool ?>=?( Time lhs, Time rhs ) { return lhs.tn >= rhs.tn; } 174 175 int64_t ?`ns( Time t ) { return t.tn; } 168 bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; } 169 bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; } 170 bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; } 171 bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; } 172 bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; } 173 bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; } 176 174 } // distribution 177 175 … … 196 194 197 195 static inline void ?{}( timeval & t, Time time ) with( t, time ) { 198 tv_sec = t n/ TIMEGRAN; // seconds199 tv_usec = t n% TIMEGRAN / (TIMEGRAN / 1_000_000LL); // microseconds196 tv_sec = tv / TIMEGRAN; // seconds 197 tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL); // microseconds 200 198 } // ?{} 201 199 … … 203 201 204 202 static inline void ?{}( timespec & t, Time time ) with( t, time ) { 205 tv_sec = t n/ TIMEGRAN; // seconds206 tv_nsec = t n% TIMEGRAN; // nanoseconds203 tv_sec = tv / TIMEGRAN; // seconds 204 tv_nsec = tv % TIMEGRAN; // nanoseconds 207 205 } // ?{} 208 206 -
libcfa/src/time_t.hfa
rbdfc032 raefb247 10 10 // Created On : Tue Apr 10 14:42:03 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 08:22:46 202013 // Update Count : 712 // Last Modified On : Fri Apr 13 07:51:47 2018 13 // Update Count : 6 14 14 // 15 15 … … 20 20 21 21 struct Duration { // private 22 int64_t t n; // nanoseconds22 int64_t tv; // nanoseconds 23 23 }; // Duration 24 24 25 static inline void ?{}( Duration & dur ) with( dur ) { t n= 0; }26 static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { t n= 0; }25 static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; } 26 static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { tv = 0; } 27 27 28 28 … … 30 30 31 31 struct Time { // private 32 uint64_t t n; // nanoseconds since UNIX epoch32 uint64_t tv; // nanoseconds since UNIX epoch 33 33 }; // Time 34 34 35 static inline void ?{}( Time & time ) with( time ) { t n= 0; }36 static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { t n= 0; }35 static inline void ?{}( Time & time ) with( time ) { tv = 0; } 36 static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { tv = 0; } 37 37 38 38 // Local Variables: // -
longrun_tests/Makefile.in
rbdfc032 raefb247 492 492 am__v_CFA_0 = @echo " CFA " $@; 493 493 am__v_CFA_1 = 494 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 495 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 496 am__v_JAVAC_0 = @echo " JAVAC " $@; 497 am__v_JAVAC_1 = 498 AM_V_GOC = $(am__v_GOC_@AM_V@) 499 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 500 am__v_GOC_0 = @echo " GOC " $@; 501 am__v_GOC_1 = 494 502 UPPCC = u++ 495 503 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 498 506 am__v_UPP_0 = @echo " UPP " $@; 499 507 am__v_UPP_1 = 500 AM_V_GOC = $(am__v_GOC_@AM_V@)501 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)502 am__v_GOC_0 = @echo " GOC " $@;503 am__v_GOC_1 =504 AM_V_RUST = $(am__v_RUST_@AM_V@)505 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)506 am__v_RUST_0 = @echo " RUST " $@;507 am__v_RUST_1 =508 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)509 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)510 am__v_NODEJS_0 = @echo " NODEJS " $@;511 am__v_NODEJS_1 =512 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)513 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)514 am__v_JAVAC_0 = @echo " JAVAC " $@;515 am__v_JAVAC_1 =516 508 repeats = 10 517 509 max_time = 600 -
src/Common/Stats/Time.h
rbdfc032 raefb247 9 9 // Author : Thierry Delisle 10 10 // Created On : Fri Mar 01 15:14:11 2019 11 // Last Modified By : Andrew Beach11 // Last Modified By : 12 12 // Last Modified On : 13 13 // Update Count : … … 41 41 f(); 42 42 } 43 44 template<typename ret_t = void, typename func_t, typename... arg_t>45 inline ret_t TimeCall(46 const char *, func_t func, arg_t&&... arg) {47 return func(std::forward<arg_t>(arg)...);48 }49 43 # else 50 44 void StartGlobal(); … … 65 59 func(); 66 60 } 67 68 template<typename ret_t = void, typename func_t, typename... arg_t>69 inline ret_t TimeCall(70 const char * name, func_t func, arg_t&&... arg) {71 BlockGuard guard(name);72 return func(std::forward<arg_t>(arg)...);73 }74 61 # endif 75 62 } -
src/Concurrency/Keywords.cc
rbdfc032 raefb247 716 716 new UntypedExpr( 717 717 new NameExpr( "__thrd_start" ), 718 { new VariableExpr( param ) , new NameExpr("main")}718 { new VariableExpr( param ) } 719 719 ) 720 720 ) -
src/Concurrency/Waitfor.cc
rbdfc032 raefb247 11 11 // Last Modified By : 12 12 // Last Modified On : 13 // Update Count : 1 213 // Update Count : 11 14 14 // 15 15 … … 42 42 void foo() { 43 43 while( true ) { 44 when( a < 1 ) waitfor( f :a ) { bar(); }44 when( a < 1 ) waitfor( f, a ) { bar(); } 45 45 or timeout( swagl() ); 46 or waitfor( g :a ) { baz(); }47 or waitfor( ^?{} :a ) { break; }46 or waitfor( g, a ) { baz(); } 47 or waitfor( ^?{}, a ) { break; } 48 48 or waitfor( ^?{} ) { break; } 49 49 } -
src/ControlStruct/LabelFixer.cc
rbdfc032 raefb247 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Jan 21 10:32:00 202013 // Update Count : 1 6011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 11 22:26:02 2019 13 // Update Count : 159 14 14 // 15 15 … … 21 21 #include "ControlStruct/LabelGenerator.h" // for LabelGenerator 22 22 #include "LabelFixer.h" 23 #include "MLEMutator.h" // for M ultiLevelExitMutator23 #include "MLEMutator.h" // for MLEMutator 24 24 #include "SynTree/Declaration.h" // for FunctionDecl 25 25 #include "SynTree/Expression.h" // for NameExpr, Expression, Unty... … … 44 44 45 45 void LabelFixer::postvisit( FunctionDecl * functionDecl ) { 46 PassVisitor<MultiLevelExitMutator> mlem( resolveJumps(), generator ); 47 // We start in the body so we can stop when we hit another FunctionDecl. 48 maybeMutate( functionDecl->statements, mlem ); 46 PassVisitor<MLEMutator> mlemut( resolveJumps(), generator ); 47 functionDecl->acceptMutator( mlemut ); 49 48 } 50 49 … … 76 75 77 76 78 // Sets the definition of the labelTable entry to be the provided statement for every label in79 // the list parameter. Happens for every kind of statement.77 // sets the definition of the labelTable entry to be the provided statement for every label in the list 78 // parameter. Happens for every kind of statement 80 79 Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) { 81 80 assert( definition != 0 ); 82 81 assert( llabel.size() > 0 ); 82 83 Entry * e = new Entry( definition ); 83 84 84 85 for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) { … … 86 87 l.set_statement( definition ); // attach statement to the label to be used later 87 88 if ( labelTable.find( l ) == labelTable.end() ) { 88 // All labels on this statement need to use the same entry, 89 // so this should only be created once. 89 // all labels on this statement need to use the same entry, so this should only be created once 90 90 // undefined and unused until now, add an entry 91 labelTable[ l ] = new Entry( definition );91 labelTable[ l ] = e; 92 92 } else if ( labelTable[ l ]->defined() ) { 93 93 // defined twice, error 94 SemanticError( l.get_statement()->location, 95 "Duplicate definition of label: " + l.get_name() ); 96 } else { 94 SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() ); 95 } else { 97 96 // used previously, but undefined until now -> link with this entry 98 // Question: Is changing objects important?99 97 delete labelTable[ l ]; 100 labelTable[ l ] = new Entry( definition );98 labelTable[ l ] = e; 101 99 } // if 102 100 } // for 103 101 104 // Produce one of the labels attached to this statement to be temporarily used as the 105 // canonical label. 102 // produce one of the labels attached to this statement to be temporarily used as the canonical label 106 103 return labelTable[ llabel.front() ]->get_label(); 107 104 } -
src/ControlStruct/MLEMutator.cc
rbdfc032 raefb247 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jan 22 11:50:00 202013 // Update Count : 22 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 22 17:22:44 2019 13 // Update Count : 220 14 14 // 15 15 … … 33 33 34 34 namespace ControlStruct { 35 M ultiLevelExitMutator::~MultiLevelExitMutator() {35 MLEMutator::~MLEMutator() { 36 36 delete targetTable; 37 37 targetTable = 0; 38 38 } 39 39 namespace { 40 bool isLoop( const MultiLevelExitMutator::Entry & e ) { 41 return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) 42 || dynamic_cast< ForStmt * >( e.get_controlStructure() ); 43 } 44 bool isSwitch( const MultiLevelExitMutator::Entry & e ) { 45 return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); 46 } 47 48 bool isBreakTarget( const MultiLevelExitMutator::Entry & e ) { 49 return isLoop( e ) || isSwitch( e ) 50 || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); 51 } 52 bool isContinueTarget( const MultiLevelExitMutator::Entry & e ) { 53 return isLoop( e ); 54 } 55 bool isFallthroughTarget( const MultiLevelExitMutator::Entry & e ) { 56 return dynamic_cast< CaseStmt *>( e.get_controlStructure() ); 57 } 58 bool isFallthroughDefaultTarget( const MultiLevelExitMutator::Entry & e ) { 59 return isSwitch( e ); 60 } 40 bool isLoop( const MLEMutator::Entry & e ) { return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) || dynamic_cast< ForStmt * >( e.get_controlStructure() ); } 41 bool isSwitch( const MLEMutator::Entry & e ) { return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); } 42 43 bool isBreakTarget( const MLEMutator::Entry & e ) { return isLoop( e ) || isSwitch( e ) || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); } 44 bool isContinueTarget( const MLEMutator::Entry & e ) { return isLoop( e ); } 45 bool isFallthroughTarget( const MLEMutator::Entry & e ) { return dynamic_cast< CaseStmt *>( e.get_controlStructure() );; } 46 bool isFallthroughDefaultTarget( const MLEMutator::Entry & e ) { return isSwitch( e ); } 61 47 } // namespace 62 63 void MultiLevelExitMutator::premutate( FunctionDecl * ) {64 visit_children = false;65 }66 48 67 49 // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us 68 50 // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the 69 51 // body of statements 70 void M ultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {52 void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) { 71 53 SemanticErrorException errors; 72 54 … … 99 81 } 100 82 101 void M ultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {83 void MLEMutator::premutate( CompoundStmt *cmpndStmt ) { 102 84 visit_children = false; 103 85 bool labeledBlock = !(cmpndStmt->labels.empty()); … … 136 118 } 137 119 } 138 assertf( false, "Could not find label '%s' on statement %s", 139 originalTarget.get_name().c_str(), toString( stmt ).c_str() ); 140 } 141 142 143 Statement *MultiLevelExitMutator::postmutate( BranchStmt *branchStmt ) 144 throw ( SemanticErrorException ) { 120 assertf( false, "Could not find label '%s' on statement %s", originalTarget.get_name().c_str(), toString( stmt ).c_str() ); 121 } 122 123 124 Statement *MLEMutator::postmutate( BranchStmt *branchStmt ) throw ( SemanticErrorException ) { 145 125 std::string originalTarget = branchStmt->originalTarget; 146 126 … … 250 230 } 251 231 252 Statement *M ultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {232 Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) { 253 233 // only generate these when needed 254 234 if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop; … … 273 253 274 254 template< typename LoopClass > 275 void M ultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {255 void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) { 276 256 // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine 277 257 // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested … … 284 264 285 265 template< typename LoopClass > 286 Statement * M ultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {266 Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) { 287 267 assert( ! enclosingControlStructures.empty() ); 288 268 Entry &e = enclosingControlStructures.back(); … … 295 275 } 296 276 297 void M ultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {277 void MLEMutator::premutate( WhileStmt * whileStmt ) { 298 278 return prehandleLoopStmt( whileStmt ); 299 279 } 300 280 301 void M ultiLevelExitMutator::premutate( ForStmt * forStmt ) {281 void MLEMutator::premutate( ForStmt * forStmt ) { 302 282 return prehandleLoopStmt( forStmt ); 303 283 } 304 284 305 Statement * M ultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {285 Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) { 306 286 return posthandleLoopStmt( whileStmt ); 307 287 } 308 288 309 Statement * M ultiLevelExitMutator::postmutate( ForStmt * forStmt ) {289 Statement * MLEMutator::postmutate( ForStmt * forStmt ) { 310 290 return posthandleLoopStmt( forStmt ); 311 291 } 312 292 313 void M ultiLevelExitMutator::premutate( IfStmt * ifStmt ) {293 void MLEMutator::premutate( IfStmt * ifStmt ) { 314 294 // generate a label for breaking out of a labeled if 315 295 bool labeledBlock = !(ifStmt->get_labels().empty()); … … 321 301 } 322 302 323 Statement * M ultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {303 Statement * MLEMutator::postmutate( IfStmt * ifStmt ) { 324 304 bool labeledBlock = !(ifStmt->get_labels().empty()); 325 305 if ( labeledBlock ) { … … 331 311 } 332 312 333 void M ultiLevelExitMutator::premutate( TryStmt * tryStmt ) {313 void MLEMutator::premutate( TryStmt * tryStmt ) { 334 314 // generate a label for breaking out of a labeled if 335 315 bool labeledBlock = !(tryStmt->get_labels().empty()); … … 341 321 } 342 322 343 Statement * M ultiLevelExitMutator::postmutate( TryStmt * tryStmt ) {323 Statement * MLEMutator::postmutate( TryStmt * tryStmt ) { 344 324 bool labeledBlock = !(tryStmt->get_labels().empty()); 345 325 if ( labeledBlock ) { … … 351 331 } 352 332 353 void MultiLevelExitMutator::premutate( FinallyStmt * ) { 354 GuardAction([this, old = std::move(enclosingControlStructures)]() { 355 enclosingControlStructures = std::move(old); 356 }); 357 enclosingControlStructures = std::list<Entry>(); 358 GuardValue( inFinally ); 359 inFinally = true; 360 } 361 362 void MultiLevelExitMutator::premutate( ReturnStmt *returnStmt ) { 363 if ( inFinally ) { 364 SemanticError( returnStmt->location, "'return' may not appear in a finally clause" ); 365 } 366 } 367 368 void MultiLevelExitMutator::premutate( CaseStmt *caseStmt ) { 333 void MLEMutator::premutate( CaseStmt *caseStmt ) { 369 334 visit_children = false; 370 335 … … 405 370 } 406 371 407 void M ultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {372 void MLEMutator::premutate( SwitchStmt *switchStmt ) { 408 373 // generate a label for breaking out of a labeled switch 409 374 Label brkLabel = generator->newLabel("switchBreak", switchStmt); … … 431 396 } 432 397 433 Statement * M ultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {398 Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) { 434 399 Entry &e = enclosingControlStructures.back(); 435 400 assert ( e == switchStmt ); -
src/ControlStruct/MLEMutator.h
rbdfc032 raefb247 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jan 22 11:50:00 202013 // Update Count : 4 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 22 17:22:47 2019 13 // Update Count : 45 14 14 // 15 15 … … 30 30 class LabelGenerator; 31 31 32 class MultiLevelExitMutator : public WithVisitorRef<MultiLevelExitMutator>, 33 public WithShortCircuiting, public WithGuards { 32 class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards { 34 33 public: 35 34 class Entry; 36 MultiLevelExitMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : 37 targetTable( t ), breakLabel(std::string("")), generator( gen ) {} 38 ~MultiLevelExitMutator(); 39 40 void premutate( FunctionDecl * ); 35 MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {} 36 ~MLEMutator(); 41 37 42 38 void premutate( CompoundStmt *cmpndStmt ); … … 51 47 void premutate( SwitchStmt *switchStmt ); 52 48 Statement * postmutate( SwitchStmt *switchStmt ); 53 void premutate( ReturnStmt *returnStmt );54 49 void premutate( TryStmt *tryStmt ); 55 50 Statement * postmutate( TryStmt *tryStmt ); 56 void premutate( FinallyStmt *finallyStmt );57 51 58 52 Statement *mutateLoop( Statement *bodyLoop, Entry &e ); … … 116 110 Label breakLabel; 117 111 LabelGenerator *generator; 118 bool inFinally = false;119 112 120 113 template< typename LoopClass > -
src/Parser/lex.ll
rbdfc032 raefb247 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : S at Feb 1 07:16:44 202013 * Update Count : 7 2412 * Last Modified On : Sun Aug 4 20:53:47 2019 13 * Update Count : 719 14 14 */ 15 15 … … 330 330 /* identifier */ 331 331 {identifier} { IDENTIFIER_RETURN(); } 332 "` `"{identifier}"``" { // CFA333 yytext[yyleng - 2] = '\0'; yytext += 2; // SKULLDUGGERY: remove backquotes (ok to shorten?)332 "`"{identifier}"`" { // CFA 333 yytext[yyleng - 1] = '\0'; yytext += 1; // SKULLDUGGERY: remove backquotes (ok to shorten?) 334 334 IDENTIFIER_RETURN(); 335 335 } -
src/Parser/parser.yy
rbdfc032 raefb247 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 10:04:40 202013 // Update Count : 44 4012 // Last Modified On : Mon Dec 16 15:32:58 2019 13 // Update Count : 4409 14 14 // 15 15 … … 323 323 %type<op> ptrref_operator unary_operator assignment_operator 324 324 %type<en> primary_expression postfix_expression unary_expression 325 %type<en> cast_expression _list cast_expressionexponential_expression multiplicative_expression additive_expression325 %type<en> cast_expression exponential_expression multiplicative_expression additive_expression 326 326 %type<en> shift_expression relational_expression equality_expression 327 327 %type<en> AND_expression exclusive_OR_expression inclusive_OR_expression … … 579 579 | '(' compound_statement ')' // GCC, lambda expression 580 580 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 581 | constant '`' IDENTIFIER // CFA, postfix call 582 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 583 | string_literal '`' IDENTIFIER // CFA, postfix call 584 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); } 585 | IDENTIFIER '`' IDENTIFIER // CFA, postfix call 586 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); } 587 | tuple '`' IDENTIFIER // CFA, postfix call 588 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 589 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 590 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 581 591 | type_name '.' identifier // CFA, nested type 582 592 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } … … 632 642 | postfix_expression '(' argument_expression_list ')' 633 643 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 634 | postfix_expression '`' identifier // CFA, postfix call635 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }636 | constant '`' identifier // CFA, postfix call637 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }638 | string_literal '`' identifier // CFA, postfix call639 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }640 644 | postfix_expression '.' identifier 641 645 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } … … 662 666 | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal 663 667 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); } 664 | '^' primary_expression '{' argument_expression_list '}' // CFA , destructor call668 | '^' primary_expression '{' argument_expression_list '}' // CFA 665 669 { 666 670 Token fn; … … 675 679 | argument_expression 676 680 | argument_expression_list ',' argument_expression 677 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }681 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 678 682 ; 679 683 … … 687 691 field_name_list: // CFA, tuple field selector 688 692 field 689 | field_name_list ',' field { $$ = (ExpressionNode *) ($1->set_last( $3 )); }693 | field_name_list ',' field { $$ = (ExpressionNode *)$1->set_last( $3 ); } 690 694 ; 691 695 … … 956 960 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); } 957 961 | '[' push assignment_expression pop ',' tuple_expression_list ']' 958 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *) ($3->set_last( $6 ) ) )); }962 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); } 959 963 ; 960 964 … … 962 966 assignment_expression_opt 963 967 | tuple_expression_list ',' assignment_expression_opt 964 { $$ = (ExpressionNode *) ($1->set_last( $3 )); }968 { $$ = (ExpressionNode *)$1->set_last( $3 ); } 965 969 ; 966 970 … … 1303 1307 WAITFOR '(' cast_expression ')' 1304 1308 { $$ = $3; } 1305 // | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1306 // { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1307 | WAITFOR '(' cast_expression_list ':' argument_expression_list ')' 1308 { $$ = (ExpressionNode *)($3->set_last( $5 )); } 1309 ; 1310 1311 cast_expression_list: 1312 cast_expression 1313 | cast_expression_list ',' cast_expression 1314 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 1309 | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1310 { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1315 1311 ; 1316 1312 … … 1423 1419 asm_operand 1424 1420 | asm_operands_list ',' asm_operand 1425 { $$ = (ExpressionNode *) ($1->set_last( $3 )); }1421 { $$ = (ExpressionNode *)$1->set_last( $3 ); } 1426 1422 ; 1427 1423 … … 1439 1435 { $$ = new ExpressionNode( $1 ); } 1440 1436 | asm_clobbers_list_opt ',' string_literal 1441 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); } 1437 // set_last returns ParseNode * 1438 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); } 1442 1439 ; 1443 1440 … … 2362 2359 | initializer_list_opt ',' initializer { $$ = (InitializerNode *)( $1->set_last( $3 ) ); } 2363 2360 | initializer_list_opt ',' designation initializer 2364 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) )); }2361 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); } 2365 2362 ; 2366 2363 … … 2384 2381 designator 2385 2382 | designator_list designator 2386 { $$ = (ExpressionNode *)( $1->set_last( $2 )); }2383 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); } 2387 2384 //| designator_list designator { $$ = new ExpressionNode( $1, $2 ); } 2388 2385 ; … … 2481 2478 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; } 2482 2479 | type_list ',' type 2483 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }2480 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); } 2484 2481 | type_list ',' assignment_expression 2485 2482 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; } -
src/SymTab/Validate.cc
rbdfc032 raefb247 375 375 Stats::Heap::newPass("validate-F"); 376 376 Stats::Time::BlockGuard guard("validate-F"); 377 Stats::Time::TimeCall("Fix Object Type", 378 FixObjectType::fix, translationUnit); 379 Stats::Time::TimeCall("Array Length", 380 ArrayLength::computeLength, translationUnit); 381 Stats::Time::TimeCall("Find Special Declarations", 382 Validate::findSpecialDecls, translationUnit); 383 Stats::Time::TimeCall("Fix Label Address", 384 mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer); 385 Stats::Time::TimeCall("Handle Attributes", 386 Validate::handleAttributes, translationUnit); 377 Stats::Time::TimeBlock("Fix Object Type", [&]() { 378 FixObjectType::fix( translationUnit ); 379 }); 380 Stats::Time::TimeBlock("Array Length", [&]() { 381 ArrayLength::computeLength( translationUnit ); 382 }); 383 Stats::Time::TimeBlock("Find Special Declarations", [&]() { 384 Validate::findSpecialDecls( translationUnit ); 385 }); 386 Stats::Time::TimeBlock("Fix Label Address", [&]() { 387 mutateAll( translationUnit, labelAddrFixer ); 388 }); 389 Stats::Time::TimeBlock("Handle Attributes", [&]() { 390 Validate::handleAttributes( translationUnit ); 391 }); 387 392 } 388 393 } -
src/SynTree/Statement.cc
rbdfc032 raefb247 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jan 20 16:03:00 202013 // Update Count : 7111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 3 20:46:44 2017 13 // Update Count : 68 14 14 // 15 15 … … 46 46 Statement::~Statement() {} 47 47 48 ExprStmt::ExprStmt( Expression * expr ) : Statement(), expr( expr ) {}49 50 ExprStmt::ExprStmt( const ExprStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {} 49 50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 51 51 52 52 ExprStmt::~ExprStmt() { … … 54 54 } 55 55 56 void ExprStmt::print( std::ostream & os, Indenter indent ) const {56 void ExprStmt::print( std::ostream &os, Indenter indent ) const { 57 57 os << "Expression Statement:" << endl << indent+1; 58 58 expr->print( os, indent+1 ); … … 60 60 61 61 62 AsmStmt::AsmStmt( bool voltile, Expression * instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}62 AsmStmt::AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {} 63 63 64 64 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { … … 75 75 } 76 76 77 void AsmStmt::print( std::ostream & os, Indenter indent ) const {77 void AsmStmt::print( std::ostream &os, Indenter indent ) const { 78 78 os << "Assembler Statement:" << endl; 79 79 os << indent+1 << "instruction: " << endl << indent; … … 96 96 DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {} 97 97 98 void DirectiveStmt::print( std::ostream & os, Indenter ) const {98 void DirectiveStmt::print( std::ostream &os, Indenter ) const { 99 99 os << "GCC Directive:" << directive << endl; 100 100 } 101 101 102 102 103 const char * BranchStmt::brType[] = { 104 "Goto", "Break", "Continue", "Fall Through", "Fall Through Default", 105 }; 103 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 106 104 107 105 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) : … … 113 111 } 114 112 115 BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ) :113 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) : 116 114 Statement(), computedTarget( computedTarget ), type( type ) { 117 115 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { … … 120 118 } 121 119 122 void BranchStmt::print( std::ostream & os, Indenter indent ) const { 123 assert(type < 5); 120 void BranchStmt::print( std::ostream &os, Indenter indent ) const { 124 121 os << "Branch (" << brType[type] << ")" << endl ; 125 122 if ( target != "" ) os << indent+1 << "with target: " << target << endl; … … 128 125 } 129 126 130 ReturnStmt::ReturnStmt( Expression * expr ) : Statement(), expr( expr ) {}127 ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {} 131 128 132 129 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 136 133 } 137 134 138 void ReturnStmt::print( std::ostream & os, Indenter indent ) const {135 void ReturnStmt::print( std::ostream &os, Indenter indent ) const { 139 136 os << "Return Statement, returning: "; 140 137 if ( expr != nullptr ) { … … 145 142 } 146 143 147 IfStmt::IfStmt( Expression * condition, Statement * thenPart, Statement *elsePart, std::list<Statement *> initialization ):144 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ): 148 145 Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {} 149 146 … … 160 157 } 161 158 162 void IfStmt::print( std::ostream & os, Indenter indent ) const {159 void IfStmt::print( std::ostream &os, Indenter indent ) const { 163 160 os << "If on condition: " << endl; 164 161 os << indent+1; … … 179 176 thenPart->print( os, indent+1 ); 180 177 181 if ( elsePart != nullptr) {178 if ( elsePart != 0 ) { 182 179 os << indent << "... else: " << endl; 183 180 os << indent+1; … … 186 183 } 187 184 188 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ):185 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ): 189 186 Statement(), condition( condition ), statements( statements ) { 190 187 } … … 201 198 } 202 199 203 void SwitchStmt::print( std::ostream & os, Indenter indent ) const {200 void SwitchStmt::print( std::ostream &os, Indenter indent ) const { 204 201 os << "Switch on condition: "; 205 202 condition->print( os ); … … 211 208 } 212 209 213 CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :210 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) : 214 211 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) { 215 if ( isDefault() && condition != nullptr) SemanticError( condition, "default case with condition: " );212 if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " ); 216 213 } 217 214 … … 232 229 } 233 230 234 void CaseStmt::print( std::ostream & os, Indenter indent ) const {231 void CaseStmt::print( std::ostream &os, Indenter indent ) const { 235 232 if ( isDefault() ) os << indent << "Default "; 236 233 else { … … 246 243 } 247 244 248 WhileStmt::WhileStmt( Expression * condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):245 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ): 249 246 Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) { 250 247 } … … 259 256 } 260 257 261 void WhileStmt::print( std::ostream & os, Indenter indent ) const {258 void WhileStmt::print( std::ostream &os, Indenter indent ) const { 262 259 os << "While on condition: " << endl ; 263 260 condition->print( os, indent+1 ); … … 265 262 os << indent << "... with body: " << endl; 266 263 267 if ( body != nullptr) body->print( os, indent+1 );268 } 269 270 ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement *body ):264 if ( body != 0 ) body->print( os, indent+1 ); 265 } 266 267 ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ): 271 268 Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) { 272 269 } … … 285 282 } 286 283 287 void ForStmt::print( std::ostream & os, Indenter indent ) const {284 void ForStmt::print( std::ostream &os, Indenter indent ) const { 288 285 Statement::print( os, indent ); // print labels 289 286 … … 308 305 } 309 306 310 if ( body != nullptr) {307 if ( body != 0 ) { 311 308 os << "\n" << indent << "... with body: \n" << indent+1; 312 309 body->print( os, indent+1 ); … … 320 317 } 321 318 322 ThrowStmt::ThrowStmt( const ThrowStmt & other ) :319 ThrowStmt::ThrowStmt( const ThrowStmt &other ) : 323 320 Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { 324 321 } … … 329 326 } 330 327 331 void ThrowStmt::print( std::ostream & os, Indenter indent) const {328 void ThrowStmt::print( std::ostream &os, Indenter indent) const { 332 329 if ( target ) os << "Non-Local "; 333 330 os << "Throw Statement, raising: "; … … 339 336 } 340 337 341 TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt *finallyBlock ) :338 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) : 342 339 Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 343 340 } 344 341 345 TryStmt::TryStmt( const TryStmt & other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {342 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) { 346 343 cloneAll( other.handlers, handlers ); 347 344 } … … 353 350 } 354 351 355 void TryStmt::print( std::ostream & os, Indenter indent ) const {352 void TryStmt::print( std::ostream &os, Indenter indent ) const { 356 353 os << "Try Statement" << endl; 357 354 os << indent << "... with block:" << endl << indent+1; … … 366 363 367 364 // finally block 368 if ( finallyBlock != nullptr) {365 if ( finallyBlock != 0 ) { 369 366 os << indent << "... and finally:" << endl << indent+1; 370 367 finallyBlock->print( os, indent+1 ); … … 372 369 } 373 370 374 CatchStmt::CatchStmt( Kind kind, Declaration * decl, Expression * cond, Statement *body ) :371 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) : 375 372 Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { 376 373 assertf( decl, "Catch clause must have a declaration." ); … … 386 383 } 387 384 388 void CatchStmt::print( std::ostream & os, Indenter indent ) const {385 void CatchStmt::print( std::ostream &os, Indenter indent ) const { 389 386 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; 390 387 … … 404 401 405 402 406 FinallyStmt::FinallyStmt( CompoundStmt * block ) : Statement(), block( block ) {403 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) { 407 404 } 408 405 … … 414 411 } 415 412 416 void FinallyStmt::print( std::ostream & os, Indenter indent ) const {413 void FinallyStmt::print( std::ostream &os, Indenter indent ) const { 417 414 os << "Finally Statement" << endl; 418 415 os << indent << "... with block:" << endl << indent+1; … … 461 458 } 462 459 463 void WaitForStmt::print( std::ostream & os, Indenter indent ) const {460 void WaitForStmt::print( std::ostream &os, Indenter indent ) const { 464 461 os << "Waitfor Statement" << endl; 465 462 indent += 1; … … 517 514 } 518 515 519 void NullStmt::print( std::ostream & os, Indenter indent ) const {516 void NullStmt::print( std::ostream &os, Indenter indent ) const { 520 517 os << "Null Statement" << endl; 521 518 Statement::print( os, indent ); … … 533 530 } 534 531 535 void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const {532 void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const { 536 533 os << "Implicit Ctor Dtor Statement" << endl; 537 534 os << indent << "... with Ctor/Dtor: "; -
src/SynTree/Statement.h
rbdfc032 raefb247 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 10 14:13:24 202013 // Update Count : 8 512 // Last Modified On : Tue Mar 12 09:01:53 2019 13 // Update Count : 83 14 14 // 15 15 … … 257 257 Statement * body; 258 258 259 ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr);259 ForStmt( std::list<Statement *> initialization, Expression * condition = 0, Expression * increment = 0, Statement * body = 0 ); 260 260 ForStmt( const ForStmt & other ); 261 261 virtual ~ForStmt(); … … 357 357 FinallyStmt * finallyBlock; 358 358 359 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr);359 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = 0 ); 360 360 TryStmt( const TryStmt & other ); 361 361 virtual ~TryStmt(); -
src/cfa.make
rbdfc032 raefb247 1 2 1 3 CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS) 2 4 LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ … … 19 21 $(am__mv) $$depbase.Tpo $$depbase.Plo 20 22 23 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 24 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 25 am__v_JAVAC_0 = @echo " JAVAC " $@; 26 am__v_JAVAC_1 = 27 28 AM_V_GOC = $(am__v_GOC_@AM_V@) 29 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 30 am__v_GOC_0 = @echo " GOC " $@; 31 am__v_GOC_1 = 32 21 33 UPPCC = u++ 22 34 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 26 38 am__v_UPP_0 = @echo " UPP " $@; 27 39 am__v_UPP_1 = 28 29 AM_V_GOC = $(am__v_GOC_@AM_V@)30 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)31 am__v_GOC_0 = @echo " GOC " $@;32 am__v_GOC_1 =33 34 AM_V_RUST = $(am__v_RUST_@AM_V@)35 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)36 am__v_RUST_0 = @echo " RUST " $@;37 am__v_RUST_1 =38 39 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)40 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)41 am__v_NODEJS_0 = @echo " NODEJS " $@;42 am__v_NODEJS_1 =43 44 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)45 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)46 am__v_JAVAC_0 = @echo " JAVAC " $@;47 am__v_JAVAC_1 = -
tests/.expect/time.txt
rbdfc032 raefb247 18 18 Dividing that by 2 gives 2403.5 seconds 19 19 4807 seconds is 1 hours, 20 minutes, 7 seconds 20 2020 Jan 5 14:01:40 (GMT)21 1970 Jan 5 14:00:00 (GMT)22 1973 Jan 2 06:59:00 (GMT) -
tests/Makefile.in
rbdfc032 raefb247 364 364 am__v_CFA_0 = @echo " CFA " $@; 365 365 am__v_CFA_1 = 366 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@) 367 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@) 368 am__v_JAVAC_0 = @echo " JAVAC " $@; 369 am__v_JAVAC_1 = 370 AM_V_GOC = $(am__v_GOC_@AM_V@) 371 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@) 372 am__v_GOC_0 = @echo " GOC " $@; 373 am__v_GOC_1 = 366 374 UPPCC = u++ 367 375 UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS) … … 370 378 am__v_UPP_0 = @echo " UPP " $@; 371 379 am__v_UPP_1 = 372 AM_V_GOC = $(am__v_GOC_@AM_V@)373 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)374 am__v_GOC_0 = @echo " GOC " $@;375 am__v_GOC_1 =376 AM_V_RUST = $(am__v_RUST_@AM_V@)377 am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)378 am__v_RUST_0 = @echo " RUST " $@;379 am__v_RUST_1 =380 AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)381 am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)382 am__v_NODEJS_0 = @echo " NODEJS " $@;383 am__v_NODEJS_1 =384 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)385 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)386 am__v_JAVAC_0 = @echo " JAVAC " $@;387 am__v_JAVAC_1 =388 380 debug = yes 389 381 installed = no -
tests/concurrent/examples/boundedBufferEXT.cfa
rbdfc032 raefb247 10 10 // Created On : Wed Apr 18 22:52:12 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 22:36:34 202013 // Update Count : 1 512 // Last Modified On : Fri Jun 21 08:19:20 2019 13 // Update Count : 14 14 14 // 15 15 … … 37 37 38 38 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) { 39 if ( count == BufferSize ) waitfor( remove :buffer );39 if ( count == BufferSize ) waitfor( remove, buffer ); 40 40 elements[back] = elem; 41 41 back = ( back + 1 ) % BufferSize; … … 44 44 45 45 T remove( Buffer(T) & mutex buffer ) with( buffer ) { 46 if ( count == 0 ) waitfor( insert :buffer );46 if ( count == 0 ) waitfor( insert, buffer ); 47 47 T elem = elements[front]; 48 48 front = ( front + 1 ) % BufferSize; -
tests/concurrent/examples/boundedBufferTHREAD.cfa
rbdfc032 raefb247 10 10 // Created On : Wed Apr 18 22:52:12 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 23:09:43 202013 // Update Count : 2 512 // Last Modified On : Fri Jun 21 11:50:12 2019 13 // Update Count : 24 14 14 // 15 15 … … 44 44 void main( Buffer & buffer ) with( buffer ) { 45 45 for () { 46 waitfor( ^?{} :buffer ) {46 waitfor( ^?{}, buffer ) { 47 47 break; 48 } or when ( count != 20 ) waitfor( insert :buffer ) {48 } or when ( count != 20 ) waitfor( insert, buffer ) { 49 49 back = (back + 1) % 20; 50 50 count += 1; 51 } or when ( count != 0 ) waitfor( remove :buffer ) {51 } or when ( count != 0 ) waitfor( remove, buffer ) { 52 52 front = (front + 1) % 20; 53 53 count -= 1; -
tests/concurrent/examples/gortn.cfa
rbdfc032 raefb247 10 10 // Created On : Wed Feb 20 08:02:37 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 22:43:40 202013 // Update Count : 512 // Last Modified On : Fri Jun 21 08:25:03 2019 13 // Update Count : 4 14 14 // 15 15 … … 26 26 void main( GoRtn & gortn ) with( gortn ) { 27 27 for () { 28 waitfor( mem1 :gortn ) sout | i;29 or waitfor( mem2 :gortn ) sout | f;30 or waitfor( mem3 :gortn ) sout | m.i | m.j;31 or waitfor( ^?{} :gortn ) break;28 waitfor( mem1, gortn ) sout | i; 29 or waitfor( mem2, gortn ) sout | f; 30 or waitfor( mem3, gortn ) sout | m.i | m.j; 31 or waitfor( ^?{}, gortn ) break; 32 32 } 33 33 } -
tests/concurrent/waitfor/barge.cfa
rbdfc032 raefb247 65 65 yield(random( 10 )); 66 66 this.state = WAITFOR; 67 waitfor(do_call :this) {67 waitfor(do_call, this) { 68 68 sout | i; 69 69 } -
tests/concurrent/waitfor/dtor.cfa
rbdfc032 raefb247 47 47 yield(random( 10 )); 48 48 set_state( this, MAIN ); 49 waitfor( ^?{} :this ) {49 waitfor( ^?{}, this ) { 50 50 set_state( this, AFTER ); 51 51 } -
tests/concurrent/waitfor/else.cfa
rbdfc032 raefb247 14 14 sout | "Starting"; 15 15 16 when( false ) waitfor( notcalled :m );16 when( false ) waitfor( notcalled, m ); 17 17 18 18 sout | "Step" | i++; 19 19 20 waitfor( notcalled :m ); or else {20 waitfor( notcalled, m ); or else { 21 21 sout | "else called"; 22 22 } … … 24 24 sout | "Step" | i++; 25 25 26 when( true ) waitfor( notcalled :m ); or when( true ) else {26 when( true ) waitfor( notcalled, m ); or when( true ) else { 27 27 sout | "else called"; 28 28 } … … 30 30 sout | "Step" | i++; 31 31 32 when( false ) waitfor( notcalled :m ); or when( true ) else {32 when( false ) waitfor( notcalled, m ); or when( true ) else { 33 33 sout | "else called"; 34 34 } … … 36 36 sout | "Step" | i++; 37 37 38 when( false ) waitfor( notcalled :m ); or when( false ) else {38 when( false ) waitfor( notcalled, m ); or when( false ) else { 39 39 sout | "else called"; 40 40 } -
tests/concurrent/waitfor/parse.cfa
rbdfc032 raefb247 24 24 25 25 //--------------------------------------- 26 waitfor( f1 :a ) {26 waitfor( f1, a ) { 27 27 1; 28 28 } 29 29 30 30 //--------------------------------------- 31 waitfor( f1 :a ) {31 waitfor( f1, a ) { 32 32 2; 33 33 } 34 waitfor( f2 :a ) {34 waitfor( f2, a ) { 35 35 3; 36 36 } 37 37 38 38 //--------------------------------------- 39 when( 1 < 3 ) waitfor( f2 :a, a ) {39 when( 1 < 3 ) waitfor( f2, a, a ) { 40 40 4; 41 41 } … … 45 45 46 46 //--------------------------------------- 47 when( 2 < 3 ) waitfor( f3 :a ) {47 when( 2 < 3 ) waitfor( f3, a ) { 48 48 5; 49 49 } … … 53 53 54 54 //--------------------------------------- 55 when( 3 < 3 ) waitfor( f3 :a, a ) {55 when( 3 < 3 ) waitfor( f3, a, a ) { 56 56 7; 57 57 } … … 64 64 65 65 //--------------------------------------- 66 when( 6 < 3 ) waitfor( f3 :a, a, a ) {66 when( 6 < 3 ) waitfor( f3, a, a, a ) { 67 67 10; 68 68 } 69 or when( 7 < 3 ) waitfor( f1 :a ) {69 or when( 7 < 3 ) waitfor( f1, a ) { 70 70 11; 71 71 } … … 75 75 76 76 //--------------------------------------- 77 when( 8 < 3 ) waitfor( f3 :a, a ) {77 when( 8 < 3 ) waitfor( f3, a, a ) { 78 78 13; 79 79 } 80 or waitfor( f1 :a ) {80 or waitfor( f1, a ) { 81 81 14; 82 82 } … … 86 86 87 87 //--------------------------------------- 88 when( 10 < 3 ) waitfor( f1 :a ) {88 when( 10 < 3 ) waitfor( f1, a ) { 89 89 16; 90 90 } 91 or waitfor( f2 :a, a ) {91 or waitfor( f2, a, a ) { 92 92 17; 93 93 } … … 100 100 } 101 101 102 int main() {} 102 int main() { 103 104 } -
tests/concurrent/waitfor/parse2.cfa
rbdfc032 raefb247 10 10 // Created On : Wed Aug 30 17:53:29 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 23:13:37 202013 // Update Count : 612 // Last Modified On : Fri Mar 22 13:42:11 2019 13 // Update Count : 3 14 14 // 15 15 … … 26 26 } 27 27 28 waitfor( x :z ) {28 waitfor( x, z ) { 29 29 } 30 30 … … 37 37 or waitfor( y ); 38 38 39 waitfor( x :z );39 waitfor( x, z ); 40 40 or waitfor( y ); 41 41 … … 43 43 or when( true ) waitfor( y ); 44 44 45 when( true ) waitfor( x :z );45 when( true ) waitfor( x, z ); 46 46 or when( true ) waitfor( y ); 47 47 … … 50 50 } 51 51 52 waitfor( x :z ) {52 waitfor( x, z ) { 53 53 } or waitfor( y ) { 54 54 } … … 80 80 or else; 81 81 82 when( true ) waitfor( x :z );82 when( true ) waitfor( x, z ); 83 83 or else; 84 84 … … 99 99 } 100 100 101 when( true ) waitfor( x :z );101 when( true ) waitfor( x, z ); 102 102 or else { 103 103 } … … 115 115 or when( true ) else; 116 116 117 when( true ) waitfor( x :z );117 when( true ) waitfor( x, z ); 118 118 or when( true ) else; 119 119 … … 134 134 } 135 135 136 when( true ) waitfor( x :z );136 when( true ) waitfor( x, z ); 137 137 or when( true ) else { 138 138 } … … 149 149 or timeout( 3 ); 150 150 151 waitfor( x :z );151 waitfor( x, z ); 152 152 or timeout( 3 ); 153 153 … … 163 163 } 164 164 165 when( true ) waitfor( x :z ) {165 when( true ) waitfor( x, z ) { 166 166 } or timeout( 3 ) { 167 167 } … … 171 171 } 172 172 173 when( true ) waitfor( x :z ) {173 when( true ) waitfor( x, z ) { 174 174 } or when ( true ) timeout( 3 ) { 175 175 } … … 229 229 230 230 int or, timeout; 231 waitfor( timeout :7 ) 3;232 waitfor( timeout : 7 ) 3; or waitfor( timeout :7 ) 3;233 when( or ) waitfor( or :) { 4; } or timeout( 1 ) 3;234 when( 3 ) waitfor( or :2 ) 4; or else 4;235 when( 3 ) waitfor( or :3 ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout;236 when( 3 ) waitfor( or : or ) 3; or when( or ) waitfor( or :timeout ) 4; or else 4;237 when( 3 ) waitfor( or : or ) 3; or waitfor( or :9 ) 4; or when( or ) timeout( timeout ) 4;238 when( 3 ) waitfor( or : 3 ) 3; or waitfor( or :7 ) or; or timeout( 1 ) or; or when( 3 ) else or;231 waitfor( timeout, 7 ) 3; 232 waitfor( timeout, 7 ) 3; or waitfor( timeout, 7 ) 3; 233 when( or ) waitfor( or, ) { 4; } or timeout( 1 ) 3; 234 when( 3 ) waitfor( or, 2 ) 4; or else 4; 235 when( 3 ) waitfor( or, 3 ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout; 236 when( 3 ) waitfor( or, or ) 3; or when( or ) waitfor( or, timeout ) 4; or else 4; 237 when( 3 ) waitfor( or, or ) 3; or waitfor( or, 9 ) 4; or when( or ) timeout( timeout ) 4; 238 when( 3 ) waitfor( or, 3 ) 3; or waitfor( or, 7 ) or; or timeout( 1 ) or; or when( 3 ) else or; 239 239 240 240 // test else selection -
tests/concurrent/waitfor/recurse.cfa
rbdfc032 raefb247 66 66 67 67 rand_yield(); 68 waitfor( call4 :this );68 waitfor( call4, this ); 69 69 rand_yield(); 70 70 … … 78 78 79 79 rand_yield(); 80 waitfor( call3 :this );80 waitfor( call3, this ); 81 81 rand_yield(); 82 82 … … 92 92 93 93 rand_yield(); 94 waitfor( call2 :this );94 waitfor( call2, this ); 95 95 rand_yield(); 96 96 -
tests/concurrent/waitfor/statment.cfa
rbdfc032 raefb247 101 101 102 102 while( !done ) { 103 waitfor( get_index :this );104 or waitfor( call1 :this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } }105 or waitfor( call2 :this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } }106 or waitfor( call3 :this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } }107 or waitfor( call4 :this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } }108 or waitfor( call5 :this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } }109 or waitfor( call6 :this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } }110 or waitfor( call7 :this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } }103 waitfor( get_index, this ); 104 or waitfor( call1, this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } } 105 or waitfor( call2, this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } } 106 or waitfor( call3, this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } } 107 or waitfor( call4, this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } } 108 or waitfor( call5, this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } } 109 or waitfor( call6, this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } } 110 or waitfor( call7, this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } } 111 111 112 112 done = true; -
tests/concurrent/waitfor/when.cfa
rbdfc032 raefb247 58 58 void arbiter( global_t & mutex this ) { 59 59 for( int i = 0; i < N; i++ ) { 60 when( this.last_call == 6 ) waitfor( call1 :this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }61 or when( this.last_call == 1 ) waitfor( call2 :this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } }62 or when( this.last_call == 2 ) waitfor( call3 :this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } }63 or when( this.last_call == 3 ) waitfor( call4 :this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } }64 or when( this.last_call == 4 ) waitfor( call5 :this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } }65 or when( this.last_call == 5 ) waitfor( call6 :this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } }60 when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } } 61 or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } } 62 or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } } 63 or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } } 64 or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } } 65 or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } } 66 66 67 67 sout | this.last_call; -
tests/expression.cfa
rbdfc032 raefb247 1 struct S { int i; };2 void ?{}( S & s, int i ) { s.i = i; }3 int ?`mary( int );4 int ?`mary( S );5 [int] ?`mary( [int, int] );6 int & ?`jane( int & );7 int jack( int );8 9 1 int main() { 10 int a[3] = { 0, 0, 0 }; 11 S s = { 3 }, * ps = &s; 12 [int] t = { 3 }; 13 * [int] pt = &t; 14 int i = 1, j = 2; 2 struct s { int i; } x, *p = &x; 3 int i = 3; 15 4 16 5 // operators 17 6 18 ! i;7 ! i; 19 8 ~i; 20 9 +i; 21 10 -i; 22 *p s;23 ++p s;24 --p s;25 p s++;26 p s--;11 *p; 12 ++p; 13 --p; 14 p++; 15 p--; 27 16 28 i + j;29 i - j;30 i * j;17 i+i; 18 i-i; 19 i*i; 31 20 32 i / j;33 i % j;34 i ^ j;35 i & j;36 i | j;37 i < j;38 i > j;39 i = j;21 i/i; 22 i%i; 23 i^i; 24 i&i; 25 i|i; 26 i<i; 27 i>i; 28 i=i; 40 29 41 i == j; 42 i != j; 43 i << j; 44 i >> j; 45 i <= j; 46 i >= j; 47 i && j; 48 i || j; 49 ps->i; 30 i==i; 31 i!=i; 32 i<<i; 33 i>>i; 34 i<=i; 35 i>=i; 36 i&&i; 37 i||i; 38 p->i; 39 i*=i; 40 i/=i; 41 i%=i; 42 i+=i; 43 i-=i; 44 i&=i; 45 i|=i; 46 i^=i; 47 i<<=i; 48 i>>=i; 50 49 51 i *= j; 52 i /= j; 53 i %= j; 54 i += j; 55 i -= j; 56 i &= j; 57 i |= j; 58 i ^= j; 59 i <<= j; 60 i >>= j; 61 62 i ? i : j; 63 64 // postfix function call 65 66 (3 + 4)`mary; 67 ({3 + 4;})`mary; 68 [3, 4]`mary; 69 3`mary; 70 a[0]`mary; 71 a[0]`mary`mary; 72 s{0}`mary; 73 a[3]`jane++; 74 jack(3)`mary; 75 s.i`mary; 76 t.0`mary; 77 s.[i]`mary; 78 ps->i`mary; 79 pt->0`mary; 80 ps->[i]`mary; 81 i++`mary; 82 i--`mary; 83 (S){2}`mary; 84 (S)@{2}`mary; 50 i?i:i; 85 51 } // main -
tests/quotedKeyword.cfa
rbdfc032 raefb247 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 00:02:22 202013 // Update Count : 2 412 // Last Modified On : Tue Dec 4 21:45:53 2018 13 // Update Count : 23 14 14 // 15 15 … … 17 17 18 18 struct { 19 int ` `otype``;20 int ` `struct``;19 int `otype`; 20 int `struct`; 21 21 } st = { 10, 10 }; 22 22 23 typedef int ` `forall``;24 ` `forall`` xxx = 10;23 typedef int `forall`; 24 `forall` xxx = 10; 25 25 26 int ` `_Alignas``, ``_Alignof``, ``__alignof``, ``__alignof__``, ``asm``, ``__asm``, ``__asm__``, ``_At``, ``_Atomic``, ``__attribute``,27 ` `__attribute__``, ``auto``, ``_Bool``, ``break``, ``case``, ``catch``, ``catchResume``, ``char``, ``choose``, ``_Complex``, ``__complex``,28 ` `__complex__``, ``const``, ``__const``, ``__const__``, ``continue``, ``default``, ``disable``, ``do``, ``double``, ``dtype``, ``else``,29 ` `enable``, ``enum``, ``__extension__``, ``extern``, ``fallthru``, ``finally``, ``float``, ``__float128``, ``for``, ``forall``, ``fortran``,30 ` `ftype``, ``_Generic``, ``goto``, ``if``, ``_Imaginary``, ``__imag``, ``__imag__``, ``inline``, ``__inline``, ``__inline__``, ``int``,31 ` `__int128``, ``__label__``, ``long``, ``lvalue``, ``_Noreturn``, ``__builtin_offsetof``, ``otype``, ``register``, ``restrict``,32 ` `__restrict``, ``__restrict__``, ``return``, ``short``, ``signed``, ``__signed``, ``__signed__``, ``sizeof``, ``static``,33 ` `_Static_assert``, ``struct``, ``switch``, ``_Thread_local``, ``throw``, ``throwResume``, ``trait``, ``try``, ``typedef``,34 ` `typeof``, ``__typeof``, ``__typeof__``, ``union``, ``unsigned``, ``__builtin_va_list``, ``void``, ``volatile``, ``__volatile``,35 ` `__volatile__``, ``while``;26 int `_Alignas`, `_Alignof`, `__alignof`, `__alignof__`, `asm`, `__asm`, `__asm__`, `_At`, `_Atomic`, `__attribute`, 27 `__attribute__`, `auto`, `_Bool`, `break`, `case`, `catch`, `catchResume`, `char`, `choose`, `_Complex`, `__complex`, 28 `__complex__`, `const`, `__const`, `__const__`, `continue`, `default`, `disable`, `do`, `double`, `dtype`, `else`, 29 `enable`, `enum`, `__extension__`, `extern`, `fallthru`, `finally`, `float`, `__float128`, `for`, `forall`, `fortran`, 30 `ftype`, `_Generic`, `goto`, `if`, `_Imaginary`, `__imag`, `__imag__`, `inline`, `__inline`, `__inline__`, `int`, 31 `__int128`, `__label__`, `long`, `lvalue`, `_Noreturn`, `__builtin_offsetof`, `otype`, `register`, `restrict`, 32 `__restrict`, `__restrict__`, `return`, `short`, `signed`, `__signed`, `__signed__`, `sizeof`, `static`, 33 `_Static_assert`, `struct`, `switch`, `_Thread_local`, `throw`, `throwResume`, `trait`, `try`, `typedef`, 34 `typeof`, `__typeof`, `__typeof__`, `union`, `unsigned`, `__builtin_va_list`, `void`, `volatile`, `__volatile`, 35 `__volatile__`, `while`; 36 36 37 37 int main() { 38 int ` `if`` = 0;39 ` `catch`` = 1;40 st.` `otype`` = 2;41 st.` `struct`` = 3;42 ` `throw`` = 4;43 sout | ` `catch`` + st.``otype`` + st.``struct`` + ``throw``;38 int `if` = 0; 39 `catch` = 1; 40 st.`otype` = 2; 41 st.`struct` = 3; 42 `throw` = 4; 43 sout | `catch` + st.`otype` + st.`struct` + `throw`; 44 44 } 45 45 -
tests/time.cfa
rbdfc032 raefb247 10 10 // Created On : Tue Mar 27 17:24:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 18:27:37 202013 // Update Count : 3412 // Last Modified On : Fri Nov 29 23:05:30 2019 13 // Update Count : 24 14 14 // 15 15 … … 34 34 sout | t; 35 35 t = t + d1; 36 sout | t | t `ns;36 sout | t | t.tv; 37 37 Time t1 = (timespec){ 104_414, 10_000_000 }; 38 sout | t1 | t1 `ns;39 sout | t - t | t + d5 | t `ns;40 char buf[ 64];38 sout | t1 | t1.tv; 39 sout | t - t | t + d5 | t.tv; 40 char buf[16]; 41 41 sout | "yy/mm/dd" | [t, buf]`ymd | nonl; // shared buf => separate calls 42 42 sout | "mm/dd/yy" | mm_dd_yy( t, buf ) | nonl; … … 45 45 sout | "dd/yy/mm" | [t, buf]`dmy; 46 46 Time t2 = { 2001, 7, 4, 0, 0, 1, 0 }, t3 = (timeval){ 994_219_201 }; 47 sout | t2 | t2 `ns | nl | t3 | t3`ns;47 sout | t2 | t2.tv | nl | t3 | t3.tv; 48 48 sout | nl; 49 49 … … 62 62 sout | "Dividing that by 2 gives" | s / 2 | "seconds"; 63 63 sout | s | "seconds is" | s`h | "hours," | (s % 1`h)`m | "minutes," | (s % 1`m)`s | "seconds"; 64 65 t1 = (Time){ 2020, 1, 5, 9, 0, 0, 100000000000LL };66 t2 = (Time){ 1969, 13, 5, 9 };67 t3 = (Time){ 1970, 25, 366, 48, 120, -120, 60000000000LL };68 strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t1 );69 sout | buf;70 strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t2 );71 sout | buf;72 strftime( buf, 128, "%Y %b %e %H:%M:%S (GMT)", t3 );73 sout | buf;74 64 } // main 75 65 -
tools/stat.py
rbdfc032 raefb247 17 17 avg = numpy.mean (content) 18 18 std = numpy.std (content) 19 print "median {0:.1f} avg {1:.1f} stddev {2:. 1f}".format( med, avg, std )19 print "median {0:.1f} avg {1:.1f} stddev {2:.2f}".format( med, avg, std ) 20 20 21 21
Note:
See TracChangeset
for help on using the changeset viewer.