source: doc/theses/andrew_beach_MMath/code/resume-other.cfa @ e4da70b

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since e4da70b was 54651005, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Added asm statements to the exception benchmarks to prevent unwanted optimizations.

  • Property mode set to 100644
File size: 994 bytes
Line 
1// Resume Across Other Handler
2#include <clock.hfa>
3#include <exception.hfa>
4#include <fstream.hfa>
5#include <stdlib.hfa>
6
7EHM_EXCEPTION(empty_exception)();
8
9EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
10
11EHM_EXCEPTION(not_raised_exception)();
12
13void unwind_other(unsigned int frames) {
14        if (frames) {
15                try {
16                        unwind_other(frames - 1);
17                } catchResume (not_raised_exception *) {
18                        asm volatile ("# fixup block (stack)");
19                }
20        } else {
21                throwResume (empty_exception){&empty_vt};
22        }
23}
24
25int main(int argc, char * argv[]) {
26        unsigned int times = 1;
27        unsigned int total_frames = 1;
28        if (1 < argc) {
29                times = strtol(argv[1], 0p, 10);
30        }
31        if (2 < argc) {
32                total_frames = strtol(argv[2], 0p, 10);
33        }
34
35        Time start_time = timeHiRes();
36        for (int count = 0 ; count < times ; ++count) {
37                try {
38                        unwind_other(total_frames);
39                } catchResume (empty_exception *) {
40                        asm volatile ("# fixup block (base)");
41                }
42        }
43        Time end_time = timeHiRes();
44        sout | "Run-Time (ns): " | (end_time - start_time)`ns;
45}
Note: See TracBrowser for help on using the repository browser.