-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When adding support for loop peeling, we forgot that loops are only peeled when optimisations are turned on. When they were turned off, we generated code with no backjump e.g.: ``` ; %294: ptr = load %293 mov rsi, [rdi+0x588] ; header_end [...] ; Deopt ID for guard 0 push rsi mov rsi, 0x00 ``` Notice no `jmp` between `header_end` and `Deopt`. That meant that we fell through to whichever guard's deopt happened to come first, with confusing results. For example, before this commit the new test `ykd_opt_off` would print: ``` 10 9 8 7: 7 ``` even though the code shows this is clearly "impossible": ```rust if (i < 7) printf("7: "); ``` This commit not only fixes that, but brings a bit more order to three kinds of traces we can compile: "header only" traces (most tests, and when `YKD_OPT=0`); "header and body" traces (with loop peeling); and "side traces". A new `TraceKind` captures these, and allows us to simplify quite a bit of code in the x64 backend, which no longer has to guess what kind of trace it has. Perhaps inevitably this also showed up a few tests where we'd muddled header and body.
- Loading branch information
Showing
6 changed files
with
192 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Run-time: | ||
// env-var: YKD_OPT=0 | ||
// env-var: YKD_SERIALISE_COMPILATION=1 | ||
// stdout: | ||
// 10 | ||
// 9 | ||
// 8 | ||
// 7 | ||
// 7: 6 | ||
// 7: 5 | ||
// 7: 4 | ||
// 7: 4: 3 | ||
// 7: 4: 2 | ||
// 7: 4: 1 | ||
|
||
|
||
// Check that basic trace compilation works. | ||
|
||
#include <assert.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <yk.h> | ||
#include <yk_testing.h> | ||
|
||
int main(int argc, char **argv) { | ||
YkMT *mt = yk_mt_new(NULL); | ||
yk_mt_hot_threshold_set(mt, 0); | ||
yk_mt_sidetrace_threshold_set(mt, 1); | ||
YkLocation loc = yk_location_new(); | ||
|
||
int i = 10; | ||
NOOPT_VAL(loc); | ||
NOOPT_VAL(i); | ||
while (i > 0) { | ||
yk_mt_control_point(mt, &loc); | ||
if (i < 7) | ||
printf("7: "); | ||
if (i < 4) | ||
printf("4: "); | ||
printf("%d\n", i); | ||
i--; | ||
} | ||
yk_location_drop(loc); | ||
yk_mt_shutdown(mt); | ||
return (EXIT_SUCCESS); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.