source: doc/theses/andrew_beach_MMath/code/resume-empty.cfa @ f93d7fc

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since f93d7fc was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

update exception benchmarks

  • Property mode set to 100644
File size: 884 bytes
RevLine 
[ea593a3]1// Resume Across Empty Function
[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;
[ea593a3]9
[f79ee0d]10void nounwind_empty(unsigned int frames) {
[ea593a3]11        if (frames) {
[f79ee0d]12                nounwind_empty(frames - 1);
[ea593a3]13        } else {
[d2278e9]14                throwResume (empty_exception){&empty_vt};
[ea593a3]15        }
16}
17
18int main(int argc, char * argv[]) {
19        unsigned int times = 1;
20        unsigned int total_frames = 1;
[ee23a8d]21        if (1 < argc) {
[f79ee0d]22                times = strto(argv[1], 0p, 10);
[ea593a3]23        }
[ee23a8d]24        if (2 < argc) {
[f79ee0d]25                total_frames = strto(argv[2], 0p, 10);
[ea593a3]26        }
27
[ee23a8d]28        Time start_time = timeHiRes();
[f79ee0d]29        for (unsigned int count = 0 ; count < times ; ++count) {
[ea593a3]30                try {
[f79ee0d]31                        nounwind_empty(total_frames);
[d2278e9]32                } catchResume (empty_exception *) {
[54651005]33                        asm volatile ("# fixup block");
[ea593a3]34                }
35        }
[ee23a8d]36        Time end_time = timeHiRes();
[f79ee0d]37        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
[ea593a3]38}
Note: See TracBrowser for help on using the repository browser.