[K/N] Fix currentFrame in smaller scope, to avoid gc while having incorrect shadow stack
This commit is contained in:
@@ -498,6 +498,14 @@ private:
|
|||||||
bool reentrant_;
|
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>
|
template <ThreadState state, typename R, typename... Args>
|
||||||
ALWAYS_INLINE inline R CallWithThreadState(R(*function)(Args...), Args... args) {
|
ALWAYS_INLINE inline R CallWithThreadState(R(*function)(Args...), Args... args) {
|
||||||
ThreadStateGuard guard(state);
|
ThreadStateGuard guard(state);
|
||||||
|
|||||||
@@ -1106,21 +1106,18 @@ JobKind Worker::processQueueElement(bool blocking) {
|
|||||||
ObjHolder argumentHolder;
|
ObjHolder argumentHolder;
|
||||||
ObjHolder resultHolder;
|
ObjHolder resultHolder;
|
||||||
KRef argument = AdoptStablePointer(job.regularJob.argument, argumentHolder.slot());
|
KRef argument = AdoptStablePointer(job.regularJob.argument, argumentHolder.slot());
|
||||||
#if !KONAN_NO_EXCEPTIONS
|
|
||||||
FrameOverlay* currentFrame = getCurrentFrame();
|
|
||||||
#else
|
|
||||||
#error "Exceptions aren't supported!"
|
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
#if KONAN_OBJC_INTEROP
|
#if KONAN_OBJC_INTEROP
|
||||||
konan::AutoreleasePool autoreleasePool;
|
konan::AutoreleasePool autoreleasePool;
|
||||||
#endif
|
#endif
|
||||||
job.regularJob.function(argument, resultHolder.slot());
|
{
|
||||||
|
CurrentFrameGuard guard;
|
||||||
|
job.regularJob.function(argument, resultHolder.slot());
|
||||||
|
}
|
||||||
argumentHolder.clear();
|
argumentHolder.clear();
|
||||||
// Transfer the result.
|
// Transfer the result.
|
||||||
result = transfer(&resultHolder, job.regularJob.transferMode);
|
result = transfer(&resultHolder, job.regularJob.transferMode);
|
||||||
} catch (ExceptionObjHolder& e) {
|
} catch (ExceptionObjHolder& e) {
|
||||||
SetCurrentFrame(reinterpret_cast<ObjHeader**>(currentFrame));
|
|
||||||
ok = false;
|
ok = false;
|
||||||
switch (exceptionHandling()) {
|
switch (exceptionHandling()) {
|
||||||
case WorkerExceptionHandling::kIgnore:
|
case WorkerExceptionHandling::kIgnore:
|
||||||
|
|||||||
Reference in New Issue
Block a user