Skip to content
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

Simplify inline exit frames. #345

Merged
merged 1 commit into from Jul 24, 2019

Conversation

@dvander
Copy link
Member

dvander commented Jul 22, 2019

When invoking C++ from JIT code, we need to construct an "exit frame"
so that FrameIterator can recover a stack trace. The normal way of
creating an exit frame is implicitly, via a call. The call pushes a
return address, and the new prologue configures the frame pointer and
stores it in the Environment.

Notably, this means there is a small inline helper function every time
we transition to C++. For performance-sensitive code, like native calls,
this is not ideal. Instead we create an "inline" exit frame. Instead of
calling, we derive the return address at compile-time, push it, and thus
avoid the call instructions.

This patch makes additional improves to the inline-exit path by also
eliding "leave" instructions. It also preserves ebp, which should
improve stack walking by Breakpad.

@dvander dvander requested a review from asherkin Jul 22, 2019
Copy link
Member

asherkin left a comment

This has indeed massively improved breakpad stack walking, and the stack layout is a lot easier to grok, thanks! Tested the new unbound native error path and that all seems fine too.

Does the x64 JIT need the same additions before this can be merged? I'll take a look into the Emscripten build failure.

When invoking C++ from JIT code, we need to construct an "exit frame"
so that FrameIterator can recover a stack trace. The normal way of
creating an exit frame is implicitly, via a call. The call pushes a
return address, and the new prologue configures the frame pointer and
stores it in the Environment.

Notably, this means there is a small inline helper function every time
we transition to C++. For performance-sensitive code, like native calls,
this is not ideal. Instead we create an "inline" exit frame. Instead of
calling, we derive the return address at compile-time, push it, and thus
avoid the call instructions.

This patch makes additional improves to the inline-exit path by also
eliding "leave" instructions. It also preserves ebp, which should
improve stack walking by Breakpad.
@dvander dvander force-pushed the fix-exit-frames branch from afca90e to 47478ba Jul 24, 2019
@dvander

This comment has been minimized.

Copy link
Member Author

dvander commented Jul 24, 2019

re: x64 - no JIT yet, so I just removed some unused functions.

@dvander dvander merged commit 093edef into master Jul 24, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dvander dvander deleted the fix-exit-frames branch Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.