-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate deoptimisation into guard failures. #460
Conversation
c_tests/run.rs
Outdated
@@ -103,6 +103,8 @@ fn mk_compiler(exe: &Path, src: &Path, opt: &str, extra_objs: &[PathBuf]) -> Com | |||
"-Wall", | |||
// Enable LTO with lld. | |||
"-fuse-ld=lld", | |||
// Don't remove frame pointers as we'll need them for guard failures. | |||
"-fno-omit-frame-pointer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we couldn't address from the stack pointer? I guess it complicates things a lot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly this is needed so we can get the return address with __builtin_return_address(0)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we turn frame pointers off (which, AIUI, can have a big effect on optimisations), we should see if there's another way of doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a RA
register on x64 which supposedly contains the return address. Let me see if that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the first I've heard of this. Got a link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so fno-omit-frame-pointer
stores the return address in the RA
register. With fomit-frame-pointer
this register can be used as general purpose register, which explains why this may have a performance implication. So we may have to read the return address from the stack manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4cd89ad
Think that's all comments addressed. Should we squash and then wait for @ltratt to have a look? |
@ltratt is bound to have queries and comments. I think we should let him have at least a quick look. |
Yes, I just thought it's less distracting for him if we squash away the already addressed stuff first. |
addr: *const usize, | ||
} | ||
|
||
impl Registers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the functions in here, especially as they're unsafe
, need doc strings (even if short ones).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a8383f5
ykcapi/src/lib.rs
Outdated
} | ||
} | ||
|
||
fn get(&self, id: u16) -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this function (and maybe others?) should be #[cfg(target_arch = "x86_64")]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a8383f5
ykcapi/src/lib.rs
Outdated
for l in locs { | ||
match l { | ||
SMLocation::Register(reg, size) => { | ||
eprintln!("Register: {} ({} {})", registers.get(*reg), reg, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add FIXME
s before all of these println
s so that they're more likely to be removed sooner rather than later. As you know, I am allergic to debug prints, which are like zombies: they don't die unless extra effort is put into killing them!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a8383f5
ykcapi/yk.h
Outdated
@@ -48,4 +48,43 @@ YkLocation yk_location_new(void); | |||
// will occur. | |||
void yk_location_drop(YkLocation); | |||
|
|||
void yk_stopgap(void *addr, uintptr_t size, uintptr_t retaddr, void *rsp); | |||
|
|||
void __llvm_deoptimize(void* addr, uintptr_t size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be #[cfg(target_arch = "x86_64")]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0a14653.
ykllvmwrap/src/ykllvmwrap.cc
Outdated
// Allocate space for compiled trace address, stackmap address, and stackmap | ||
// size (plus padding). | ||
// FIXME This is a temporary hack until the redesigned hot location is up. | ||
uintptr_t *ptr = (uintptr_t *) malloc(32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's at least make this malloc(sizeof(uintptr_t) * 3)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that the other 8 bytes are the padding the comment mentions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the padding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, seems like padding isn't needed for malloc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f5ca58d.
Ah, let's reference that PDF then! Also it's probably worth clearing up why we have both |
The doc string for |
With @vext01's help found a way to keep Ready for re-review I think. |
I have no comments beyond @vext01's comments. |
As and when @vext01 is happy, please squash. |
Just 3 more commits for you to review @ltratt and we are ready. |
Please squash. |
Okay to squash? |
Ready for re-review. |
LGTM. |
You need to resolve merge conflicts. |
Squashed and rebased. |
bors r= |
bors r+ |
Build failed: |
Huh, this is odd. The tests succeed if I run them manually. Investigating. |
The failing tests are release tests. Could it be that we don't set the debug printing flag in release mode? |
This should fix it. |
Please squash. |
Squashed! |
bors r+ |
Build failed: |
Of course I only checked the rust formatting, not the C formatting. Sorry. Ok to squash? |
Please squash. |
Until now we've simply crashed when we encountered a guard failure. This commit integrates the previously added stackmap parser into our guard failures so we can read out the live variables at that point. This is another step towards proper stopgapping, though until we have a stopgap interpreter we only print out the live variables we've found.
Squashed. |
bors r+ |
Build succeeded: |
Until now we've simply crashed when we encountered a guard failure. This
PR integrates the previously added stackmap parser into our guard
failures so we can read out the live variables at that point. This is
another step towards proper stopgapping, though until we have a stopgap
interpreter we only print out the live variables we've found.