Fix InitAndRegisterGlobal in new MM (#4673)

This commit is contained in:
Alexander Shabalin
2021-02-02 16:00:54 +03:00
committed by Vasily Levchenko
parent c01ad100a3
commit 2b69a0d03a
3 changed files with 22 additions and 1 deletions
+4 -1
View File
@@ -144,7 +144,10 @@ extern "C" ALWAYS_INLINE OBJ_GETTER(InitSingleton, ObjHeader** location, const T
extern "C" RUNTIME_NOTHROW void InitAndRegisterGlobal(ObjHeader** location, const ObjHeader* initialValue) {
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
mm::GlobalsRegistry::Instance().RegisterStorageForGlobal(threadData, location);
mm::SetHeapRef(location, const_cast<ObjHeader*>(initialValue));
// Null `initialValue` means that the appropriate value was already set by static initialization.
if (initialValue != nullptr) {
mm::SetHeapRef(location, const_cast<ObjHeader*>(initialValue));
}
}
extern "C" const MemoryModel CurrentMemoryModel = MemoryModel::kExperimental;