Supported cycles during object subgraph freezing

This commit is contained in:
Igor Chevdar
2018-03-29 19:14:49 +03:00
parent 513794ede3
commit e84e76107f
6 changed files with 162 additions and 77 deletions
@@ -259,7 +259,7 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable): Sym
context.getInternalFunctions("initInstance").single())
val freeze = symbolTable.referenceSimpleFunction(
builtInsPackage("konan", "worker").getContributedFunctions(Name.identifier("freezeAllowCycles"), NoLookupLocation.FROM_BACKEND).single())
builtInsPackage("konan", "worker").getContributedFunctions(Name.identifier("freeze"), NoLookupLocation.FROM_BACKEND).single())
val getContinuation = symbolTable.referenceSimpleFunction(
context.getInternalFunctions("getContinuation").single())
@@ -42,6 +42,7 @@ class Runtime(bitcodeFile: String) {
val objHeaderType = getStructType("ObjHeader")
val objHeaderPtrType = pointerType(objHeaderType)
val arrayHeaderType = getStructType("ArrayHeader")
val containerHeaderType = getStructType("ContainerHeader")
val frameOverlayType = getStructType("FrameOverlay")
@@ -32,14 +32,14 @@ import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.types.replace
private fun StaticData.objHeader(typeInfo: ConstPointer): Struct {
val containerOffsetNegative = 0 // Static object mark.
return Struct(runtime.objHeaderType, typeInfo, Int32(containerOffsetNegative))
val container = NullPointer(runtime.containerHeaderType) // Static object mark.
return Struct(runtime.objHeaderType, typeInfo, container)
}
private fun StaticData.arrayHeader(typeInfo: ConstPointer, length: Int): Struct {
assert (length >= 0)
val containerOffsetNegative = 0 // Static object mark.
return Struct(runtime.arrayHeaderType, typeInfo, Int32(containerOffsetNegative), Int32(length))
val container = NullPointer(runtime.containerHeaderType) // Static object mark.
return Struct(runtime.arrayHeaderType, typeInfo, container, Int32(length))
}
internal fun StaticData.createKotlinStringLiteral(value: String): ConstPointer {