ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since a5a6a1a8 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:
771 bytes
|
Line | |
---|
1 | // Cross a Try Statement with a Termination Handler |
---|
2 | #include <clock.hfa> |
---|
3 | #include <exception.hfa> |
---|
4 | #include <fstream.hfa> |
---|
5 | #include <stdlib.hfa> |
---|
6 | |
---|
7 | EHM_EXCEPTION(not_raised_exception)(); |
---|
8 | |
---|
9 | EHM_VIRTUAL_TABLE(not_raised_exception, not_vt); |
---|
10 | |
---|
11 | int main(int argc, char * argv[]) { |
---|
12 | unsigned int times = 1; |
---|
13 | bool should_throw = false; |
---|
14 | if (1 < argc) { |
---|
15 | times = strtol(argv[1], 0p, 10); |
---|
16 | } |
---|
17 | |
---|
18 | Time start_time = timeHiRes(); |
---|
19 | for (unsigned int count = 0 ; count < times ; ++count) { |
---|
20 | try { |
---|
21 | asm volatile ("# try block" : "=rm" (should_throw)); |
---|
22 | if (should_throw) { |
---|
23 | throw (not_raised_exception){¬_vt}; |
---|
24 | } |
---|
25 | } catch (not_raised_exception *) { |
---|
26 | asm volatile ("# catch block"); |
---|
27 | } |
---|
28 | } |
---|
29 | Time end_time = timeHiRes(); |
---|
30 | sout | "Run-Time (ns): " | (end_time - start_time)`ns; |
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.