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

Last change on this file since dd78dbc was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

update exception benchmarks

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