ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change
on this file since 41870a5 was
812ba3d,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Some clean-up to make Peter's changes to the exception benchmarks fit in better. And make test.sh a bit more robust.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[f79ee0d] | 1 | // Resume Across Fixup |
---|
| 2 | #include <clock.hfa> |
---|
| 3 | #include <fstream.hfa> |
---|
[812ba3d] | 4 | #include <stdlib.hfa> |
---|
[f79ee0d] | 5 | |
---|
[812ba3d] | 6 | // Using a global value to allow hoisting (and avoid thunks). |
---|
| 7 | unsigned int frames; |
---|
[f79ee0d] | 8 | |
---|
| 9 | void nounwind_fixup(unsigned int dummy, void (*raised_rtn)(int &), void (*not_raised_rtn)(int &)) { |
---|
| 10 | void not_raised(int & fixup) { |
---|
[812ba3d] | 11 | fixup = frames + 42; |
---|
[f79ee0d] | 12 | } |
---|
| 13 | |
---|
| 14 | if (frames) { |
---|
| 15 | frames -= 1; |
---|
| 16 | nounwind_fixup(42, raised_rtn, not_raised); |
---|
[812ba3d] | 17 | // Always false, but prevents recursion elimination. |
---|
| 18 | if (-1 == frames) printf("~"); |
---|
[f79ee0d] | 19 | } else { |
---|
| 20 | int fixup = dummy; |
---|
| 21 | raised_rtn(fixup); |
---|
| 22 | } |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | int main(int argc, char * argv[]) { |
---|
| 26 | unsigned int times = 1; |
---|
| 27 | unsigned int total_frames = 1; |
---|
| 28 | if (1 < argc) { |
---|
| 29 | times = strto(argv[1], 0p, 10); |
---|
| 30 | } |
---|
| 31 | if (2 < argc) { |
---|
| 32 | total_frames = strto(argv[2], 0p, 10); |
---|
| 33 | } |
---|
| 34 | frames = total_frames; |
---|
| 35 | |
---|
[812ba3d] | 36 | // Closures at the top level are allowed to be true closures. |
---|
[f79ee0d] | 37 | void raised(int & fixup) { |
---|
[812ba3d] | 38 | fixup = total_frames + 42; |
---|
[f79ee0d] | 39 | } |
---|
| 40 | void not_raised(int & fixup) { |
---|
[812ba3d] | 41 | fixup = total_frames + 42; |
---|
[f79ee0d] | 42 | } |
---|
| 43 | |
---|
| 44 | Time start_time = timeHiRes(); |
---|
| 45 | for (int count = 0 ; count < times ; ++count) { |
---|
| 46 | nounwind_fixup(42, raised, not_raised); |
---|
| 47 | } |
---|
| 48 | Time end_time = timeHiRes(); |
---|
| 49 | sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); |
---|
| 50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.