[K/N] Fix currentFrame in smaller scope, to avoid gc while having incorrect shadow stack

This commit is contained in:
Pavel Kunyavskiy
2022-03-10 12:18:33 +03:00
committed by Space
parent 779aa75855
commit 42a2ce1610
2 changed files with 12 additions and 7 deletions
@@ -498,6 +498,14 @@ private:
bool reentrant_;
};
class CurrentFrameGuard : Pinned {
public:
CurrentFrameGuard() : frame_(getCurrentFrame()) {}
~CurrentFrameGuard() { SetCurrentFrame(reinterpret_cast<ObjHeader**>(frame_)); }
private:
FrameOverlay* frame_;
};
template <ThreadState state, typename R, typename... Args>
ALWAYS_INLINE inline R CallWithThreadState(R(*function)(Args...), Args... args) {
ThreadStateGuard guard(state);