DFG: fixed debug output

This commit is contained in:
Igor Chevdar
2018-01-30 14:05:39 +03:00
parent 51801b9009
commit 5a57c40469
2 changed files with 20 additions and 10 deletions
@@ -240,7 +240,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
override fun visitFunction(declaration: IrFunction) { override fun visitFunction(declaration: IrFunction) {
declaration.body?.let { declaration.body?.let {
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("Analysing function ${declaration.descriptor}") println("Analysing function ${declaration.descriptor}")
println("IR: ${ir2stringWhole(declaration)}") println("IR: ${ir2stringWhole(declaration)}")
} }
@@ -250,7 +250,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
override fun visitField(declaration: IrField) { override fun visitField(declaration: IrField) {
declaration.initializer?.let { declaration.initializer?.let {
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("Analysing global field ${declaration.descriptor}") println("Analysing global field ${declaration.descriptor}")
println("IR: ${ir2stringWhole(declaration)}") println("IR: ${ir2stringWhole(declaration)}")
} }
@@ -263,7 +263,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
val visitor = ElementFinderVisitor() val visitor = ElementFinderVisitor()
body.acceptVoid(visitor) body.acceptVoid(visitor)
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("FIRST PHASE") println("FIRST PHASE")
visitor.variableValues.elementData.forEach { t, u -> visitor.variableValues.elementData.forEach { t, u ->
println("VAR $t:") println("VAR $t:")
@@ -279,7 +279,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
// Compute transitive closure of possible values for variables. // Compute transitive closure of possible values for variables.
visitor.variableValues.computeClosure() visitor.variableValues.computeClosure()
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("SECOND PHASE") println("SECOND PHASE")
visitor.variableValues.elementData.forEach { t, u -> visitor.variableValues.elementData.forEach { t, u ->
println("VAR $t:") println("VAR $t:")
@@ -292,7 +292,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
val function = FunctionDFGBuilder(expressionValuesExtractor, visitor.variableValues, val function = FunctionDFGBuilder(expressionValuesExtractor, visitor.variableValues,
descriptor, visitor.expressions, visitor.returnValues, visitor.thrownValues).build() descriptor, visitor.expressions, visitor.returnValues, visitor.thrownValues).build()
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
function.debugOutput() function.debugOutput()
} }
@@ -300,7 +300,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
} }
}, data = null) }, data = null)
DEBUG_OUTPUT(2) { DEBUG_OUTPUT(1) {
println("SYMBOL TABLE:") println("SYMBOL TABLE:")
symbolTable.classMap.forEach { descriptor, type -> symbolTable.classMap.forEach { descriptor, type ->
println(" DESCRIPTOR: $descriptor") println(" DESCRIPTOR: $descriptor")
@@ -481,7 +481,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
return variables[descriptor as VariableDescriptor]!! return variables[descriptor as VariableDescriptor]!!
} }
return nodes.getOrPut(expression) { return nodes.getOrPut(expression) {
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("Converting expression") println("Converting expression")
println(ir2stringWhole(expression)) println(ir2stringWhole(expression))
} }
@@ -694,7 +694,7 @@ internal object DFGSerializer {
val symbolTable = moduleDFG.symbolTable val symbolTable = moduleDFG.symbolTable
val typeMap = (symbolTable.classMap.values + DataFlowIR.Type.Virtual).distinct().withIndex().associateBy({ it.value }, { it.index }) val typeMap = (symbolTable.classMap.values + DataFlowIR.Type.Virtual).distinct().withIndex().associateBy({ it.value }, { it.index })
val functionSymbolMap = symbolTable.functionMap.values.distinct().withIndex().associateBy({ it.value }, { it.index }) val functionSymbolMap = symbolTable.functionMap.values.distinct().withIndex().associateBy({ it.value }, { it.index })
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("TYPES: ${typeMap.size}, " + println("TYPES: ${typeMap.size}, " +
"FUNCTIONS: ${functionSymbolMap.size}, " + "FUNCTIONS: ${functionSymbolMap.size}, " +
"PRIVATE FUNCTIONS: ${functionSymbolMap.keys.count { it is DataFlowIR.FunctionSymbol.Private }}, " + "PRIVATE FUNCTIONS: ${functionSymbolMap.keys.count { it is DataFlowIR.FunctionSymbol.Private }}, " +
@@ -841,7 +841,7 @@ internal object DFGSerializer {
context.librariesWithDependencies.forEach { library -> context.librariesWithDependencies.forEach { library ->
val libraryDataFlowGraph = library.dataFlowGraph val libraryDataFlowGraph = library.dataFlowGraph
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("Data flow graph size for lib '${library.libraryName}': ${libraryDataFlowGraph?.size ?: 0}") println("Data flow graph size for lib '${library.libraryName}': ${libraryDataFlowGraph?.size ?: 0}")
} }
@@ -909,7 +909,7 @@ internal object DFGSerializer {
} }
} }
DEBUG_OUTPUT(1) { DEBUG_OUTPUT(0) {
println("Lib: ${library.libraryName}, types: ${types.size}, functions: ${functionSymbols.size}") println("Lib: ${library.libraryName}, types: ${types.size}, functions: ${functionSymbols.size}")
} }
@@ -1110,6 +1110,16 @@ internal object DFGSerializer {
} }
} }
DEBUG_OUTPUT(1) {
allTypes.forEach {
println(it)
println(" SUPER TYPES:")
it.superTypes.forEach {
println(" $it")
}
}
}
return ExternalModulesDFG(allTypes, publicTypesMap, publicFunctionsMap, functions) return ExternalModulesDFG(allTypes, publicTypesMap, publicFunctionsMap, functions)
} }
} }