[K/N][New MM] Support thread state switching
Including * Support thread state switching in codegen * Introduce and use GCUnsafeCall annotation * Switch thread state in C++ runtime code Also * Register current thread in Mark&Sweep tests * Store MemoryState in Worker instance * Set worker tid in WorkerInit
This commit is contained in:
@@ -110,8 +110,12 @@ int Konan_DebugBufferSizeWithObjectImpl(KRef obj) {
|
||||
|
||||
// Auxilary function which can be called by developer/debugger to inspect an object.
|
||||
int32_t Konan_DebugObjectToUtf8ArrayImpl(KRef obj, char* buffer, int32_t bufferSize) {
|
||||
// We need the runnable thread state to call the Kotlin function 'KonanObjectToUtf8Array' and operate with it's result.
|
||||
// But the current thread can be in any state when this function is called by the debugger. So we use the reentrant state switch.
|
||||
kotlin::ThreadStateGuard guard(kotlin::ThreadState::kRunnable, /* reentrant */ true);
|
||||
ObjHolder stringHolder;
|
||||
auto data = KonanObjectToUtf8Array(obj, stringHolder.slot())->array();
|
||||
// Kotlin call.
|
||||
ArrayHeader* data = KonanObjectToUtf8Array(obj, stringHolder.slot())->array();
|
||||
if (data == nullptr) return 0;
|
||||
if (bufferSize < 1) return 0;
|
||||
KInt toCopy = data->count_ > static_cast<uint32_t>(bufferSize - 1) ? bufferSize - 1 : data->count_;
|
||||
|
||||
Reference in New Issue
Block a user