Separate bits combination in object header for local variables on stack (#3659)
This commit is contained in:
+2
-2
@@ -520,8 +520,8 @@ internal class FunctionGenerationContext(val function: LLVMValueRef,
|
||||
|
||||
fun setTypeInfoForLocalObject(objectHeader: LLVMValueRef) {
|
||||
val typeInfo = structGep(objectHeader, 0, "typeInfoOrMeta_")
|
||||
// Set tag OBJECT_TAG_PERMANENT_CONTAINER.
|
||||
val typeInfoValue = intToPtr(or(ptrToInt(alloca(kTypeInfo), int32Type), Int32(1).llvm), kTypeInfoPtr)
|
||||
// Set tag OBJECT_TAG_PERMANENT_CONTAINER | OBJECT_TAG_NONTRIVIAL_CONTAINER.
|
||||
val typeInfoValue = intToPtr(or(ptrToInt(alloca(kTypeInfo), int32Type), Int32(3).llvm), kTypeInfoPtr)
|
||||
store(typeInfoValue, typeInfo)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace {
|
||||
|
||||
ALWAYS_INLINE inline void mutabilityCheck(KConstRef thiz) {
|
||||
// TODO: optimize it!
|
||||
if (thiz->container() != nullptr && thiz->container()->frozen()) {
|
||||
if (!thiz->local() && thiz->container()->frozen()) {
|
||||
ThrowInvalidMutabilityException(thiz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,6 +371,12 @@ struct ObjHeader {
|
||||
return (reinterpret_cast<MetaObjHeader*>(clearPointerBits(typeInfoOrMeta_, OBJECT_TAG_MASK)))->container_;
|
||||
}
|
||||
|
||||
inline bool local() const {
|
||||
unsigned bits = getPointerBits(typeInfoOrMeta_, OBJECT_TAG_MASK);
|
||||
return (bits & (OBJECT_TAG_PERMANENT_CONTAINER | OBJECT_TAG_NONTRIVIAL_CONTAINER)) ==
|
||||
(OBJECT_TAG_PERMANENT_CONTAINER | OBJECT_TAG_NONTRIVIAL_CONTAINER);
|
||||
}
|
||||
|
||||
// Unsafe cast to ArrayHeader. Use carefully!
|
||||
ArrayHeader* array() { return reinterpret_cast<ArrayHeader*>(this); }
|
||||
const ArrayHeader* array() const { return reinterpret_cast<const ArrayHeader*>(this); }
|
||||
|
||||
Reference in New Issue
Block a user