Tracking globals (#4542)
This commit is contained in:
committed by
Stanislav Erokhin
parent
66de5dceb9
commit
2057e5c8f1
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "Memory.h"
|
||||
|
||||
#include "GlobalsRegistry.hpp"
|
||||
#include "ThreadData.hpp"
|
||||
#include "ThreadRegistry.hpp"
|
||||
#include "Utils.hpp"
|
||||
@@ -39,3 +40,18 @@ extern "C" MemoryState* InitMemory(bool firstRuntime) {
|
||||
extern "C" void DeinitMemory(MemoryState* state, bool destroyRuntime) {
|
||||
mm::ThreadRegistry::Instance().Unregister(FromMemoryState(state));
|
||||
}
|
||||
|
||||
extern "C" OBJ_GETTER(InitSingleton, ObjHeader** location, const TypeInfo* typeInfo, void (*ctor)(ObjHeader*)) {
|
||||
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
|
||||
// TODO: This should only be called if singleton is actually created here. It's possible that the
|
||||
// singleton will be created on a different thread and here we should check that, instead of creating
|
||||
// another one (and registering `location` twice).
|
||||
mm::GlobalsRegistry::Instance().RegisterStorageForGlobal(threadData, location);
|
||||
RuntimeCheck(false, "Unimplemented");
|
||||
}
|
||||
|
||||
extern "C" RUNTIME_NOTHROW void InitAndRegisterGlobal(ObjHeader** location, const ObjHeader* initialValue) {
|
||||
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
|
||||
mm::GlobalsRegistry::Instance().RegisterStorageForGlobal(threadData, location);
|
||||
RuntimeCheck(false, "Unimplemented");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user