Support ObjC blocks in the new MM

This commit is contained in:
Alexander Shabalin
2021-05-19 07:31:12 +00:00
committed by Space
parent 94076300ec
commit 3388ca2536
3 changed files with 10 additions and 7 deletions
@@ -444,6 +444,12 @@ extern "C" void EnsureNeverFrozen(ObjHeader* obj) {
}
}
extern "C" ForeignRefContext InitLocalForeignRef(ObjHeader* object) {
// TODO: Remove when legacy MM is gone.
// Nothing to do.
return nullptr;
}
extern "C" ForeignRefContext InitForeignRef(ObjHeader* object) {
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
auto* node = mm::StableRefRegistry::Instance().RegisterStableRef(threadData, object);
@@ -451,6 +457,7 @@ extern "C" ForeignRefContext InitForeignRef(ObjHeader* object) {
}
extern "C" void DeinitForeignRef(ObjHeader* object, ForeignRefContext context) {
RuntimeAssert(context != nullptr, "DeinitForeignRef must not be called for InitLocalForeignRef");
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
auto* node = FromForeignRefManager(context);
RuntimeAssert(object == **node, "Must correspond to the same object");