Implement freezing in the new MM
Currently, it uses suboptimal storage for the freeze bit. This'll be revised later when we finalize stack objects handling in the new MM.
This commit is contained in:
committed by
Space
parent
295858cf5c
commit
770401801b
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Exceptions.h"
|
||||
#include "ExtraObjectData.hpp"
|
||||
#include "Freezing.hpp"
|
||||
#include "GlobalsRegistry.hpp"
|
||||
#include "InitializationScheme.hpp"
|
||||
#include "KAssert.h"
|
||||
@@ -78,7 +79,7 @@ void ObjHeader::destroyMetaObject(ObjHeader* object) {
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool isPermanentOrFrozen(const ObjHeader* obj) {
|
||||
return obj->permanent() || isFrozen(obj);
|
||||
return mm::IsFrozen(obj);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool isShareable(const ObjHeader* obj) {
|
||||
@@ -375,6 +376,13 @@ extern "C" RUNTIME_NOTHROW OBJ_GETTER(AdoptStablePointer, void* pointer) {
|
||||
return object;
|
||||
}
|
||||
|
||||
extern "C" void MutationCheck(ObjHeader* obj) {
|
||||
if (obj->local()) return;
|
||||
if (!isPermanentOrFrozen(obj)) return;
|
||||
|
||||
ThrowInvalidMutabilityException(obj);
|
||||
}
|
||||
|
||||
extern "C" RUNTIME_NOTHROW void CheckLifetimesConstraint(ObjHeader* obj, ObjHeader* pointee) {
|
||||
// TODO: Consider making it a `RuntimeCheck`. Probably all `RuntimeCheck`s and `RuntimeAssert`s should specify
|
||||
// that their firing is a compiler bug and should be reported.
|
||||
@@ -385,6 +393,18 @@ extern "C" RUNTIME_NOTHROW void CheckLifetimesConstraint(ObjHeader* obj, ObjHead
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void FreezeSubgraph(ObjHeader* obj) {
|
||||
if (auto* blocker = mm::FreezeSubgraph(obj)) {
|
||||
ThrowFreezingException(obj, blocker);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void EnsureNeverFrozen(ObjHeader* obj) {
|
||||
if (!mm::EnsureNeverFrozen(obj)) {
|
||||
ThrowFreezingException(obj, obj);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" ForeignRefContext InitForeignRef(ObjHeader* object) {
|
||||
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
|
||||
auto* node = mm::StableRefRegistry::Instance().RegisterStableRef(threadData, object);
|
||||
|
||||
Reference in New Issue
Block a user