Native: support reentrant mode for CalledFromNativeGuard
This commit is contained in:
committed by
Space
parent
1bcafd3cd0
commit
85ab4f68df
@@ -3746,7 +3746,7 @@ kotlin::ThreadState kotlin::GetThreadState(MemoryState* thread) noexcept {
|
|||||||
return ThreadState::kRunnable;
|
return ThreadState::kRunnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE kotlin::CalledFromNativeGuard::CalledFromNativeGuard() noexcept {
|
ALWAYS_INLINE kotlin::CalledFromNativeGuard::CalledFromNativeGuard(bool reentrant) noexcept {
|
||||||
// no-op, used by the new MM only.
|
// no-op, used by the new MM only.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -447,13 +447,15 @@ private:
|
|||||||
// No-op for old GC.
|
// No-op for old GC.
|
||||||
class CalledFromNativeGuard final : private Pinned {
|
class CalledFromNativeGuard final : private Pinned {
|
||||||
public:
|
public:
|
||||||
ALWAYS_INLINE CalledFromNativeGuard() noexcept;
|
ALWAYS_INLINE CalledFromNativeGuard(bool reentrant = false) noexcept;
|
||||||
|
|
||||||
~CalledFromNativeGuard() noexcept {
|
~CalledFromNativeGuard() noexcept {
|
||||||
SwitchThreadState(thread_, ThreadState::kNative);
|
SwitchThreadState(thread_, oldState_, reentrant_);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
MemoryState* thread_;
|
MemoryState* thread_;
|
||||||
|
ThreadState oldState_;
|
||||||
|
bool reentrant_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <ThreadState state, typename R, typename... Args>
|
template <ThreadState state, typename R, typename... Args>
|
||||||
|
|||||||
@@ -532,10 +532,10 @@ MemoryState* kotlin::mm::GetMemoryState() {
|
|||||||
return ToMemoryState(ThreadRegistry::Instance().CurrentThreadDataNode());
|
return ToMemoryState(ThreadRegistry::Instance().CurrentThreadDataNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE kotlin::CalledFromNativeGuard::CalledFromNativeGuard() noexcept {
|
ALWAYS_INLINE kotlin::CalledFromNativeGuard::CalledFromNativeGuard(bool reentrant) noexcept : reentrant_(reentrant) {
|
||||||
Kotlin_initRuntimeIfNeeded();
|
Kotlin_initRuntimeIfNeeded();
|
||||||
thread_ = mm::GetMemoryState();
|
thread_ = mm::GetMemoryState();
|
||||||
SwitchThreadState(thread_, ThreadState::kRunnable);
|
oldState_ = SwitchThreadState(thread_, ThreadState::kRunnable, reentrant_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool kotlin::kSupportsMultipleMutators = kotlin::gc::kSupportsMultipleMutators;
|
const bool kotlin::kSupportsMultipleMutators = kotlin::gc::kSupportsMultipleMutators;
|
||||||
|
|||||||
Reference in New Issue
Block a user