Fix "Should be replaced with Kotlin function" warnings
This commit is contained in:
+2
-1
@@ -34,6 +34,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue
|
||||
import kotlin.math.max
|
||||
|
||||
private const val COROUTINES_DEBUG_METADATA_VERSION = 1
|
||||
|
||||
@@ -628,7 +629,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
spilledToVariableMapping.add(spilledToVariable)
|
||||
|
||||
varsCountByType.forEach {
|
||||
maxVarsCountByType[it.key] = Math.max(maxVarsCountByType[it.key] ?: 0, it.value)
|
||||
maxVarsCountByType[it.key] = max(maxVarsCountByType[it.key] ?: 0, it.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* In cases like:
|
||||
@@ -135,7 +136,7 @@ class UninitializedStoresProcessor(
|
||||
nextVarIndex += type.size
|
||||
storedTypes.add(type)
|
||||
}
|
||||
methodNode.maxLocals = Math.max(methodNode.maxLocals, nextVarIndex)
|
||||
methodNode.maxLocals = max(methodNode.maxLocals, nextVarIndex)
|
||||
|
||||
methodNode.instructions.insertBefore(insn, insnListOf(
|
||||
TypeInsnNode(Opcodes.NEW, newInsn.desc),
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
import kotlin.collections.LinkedHashSet
|
||||
import kotlin.math.max
|
||||
|
||||
abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) {
|
||||
val tryBlocksMetaInfo: IntervalMetaInfo<TryCatchBlockNodeInfo> = IntervalMetaInfo(this)
|
||||
@@ -42,7 +43,7 @@ abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) {
|
||||
if (curInstr is VarInsnNode || curInstr is IincInsnNode) {
|
||||
val argSize = getLoadStoreArgSize(curInstr.opcode)
|
||||
val varIndex = if (curInstr is VarInsnNode) curInstr.`var` else (curInstr as IincInsnNode).`var`
|
||||
nextFreeLocalIndex = Math.max(nextFreeLocalIndex, varIndex + argSize)
|
||||
nextFreeLocalIndex = max(nextFreeLocalIndex, varIndex + argSize)
|
||||
}
|
||||
|
||||
if (curInstr is LabelNode) {
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
import kotlin.math.max
|
||||
|
||||
abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
protected val codegen: T,
|
||||
@@ -340,9 +341,9 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
var marker = -1
|
||||
val intervals = processor.localVarsMetaInfo.currentIntervals
|
||||
for (interval in intervals) {
|
||||
marker = Math.max(interval.node.index + 1, marker)
|
||||
marker = max(interval.node.index + 1, marker)
|
||||
}
|
||||
while (frameMap.currentSize < Math.max(processor.nextFreeLocalIndex, offsetForFinallyLocalVar + marker)) {
|
||||
while (frameMap.currentSize < max(processor.nextFreeLocalIndex, offsetForFinallyLocalVar + marker)) {
|
||||
frameMap.enterTemp(Type.INT_TYPE)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.*
|
||||
import org.jetbrains.org.objectweb.asm.util.Printer
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
class MethodInliner(
|
||||
private val node: MethodNode,
|
||||
@@ -259,7 +260,7 @@ class MethodInliner(
|
||||
val erasedInvokeFunction = ClosureCodegen.getErasedInvokeFunction(actualInvokeDescriptor)
|
||||
val invokeParameters = erasedInvokeFunction.valueParameters
|
||||
|
||||
val valueParamShift = Math.max(nextLocalIndex, markerShift)//NB: don't inline cause it changes
|
||||
val valueParamShift = max(nextLocalIndex, markerShift)//NB: don't inline cause it changes
|
||||
putStackValuesIntoLocalsForLambdaOnInvoke(
|
||||
listOf(*info.invokeMethod.argumentTypes), valueParameters, invokeParameters, valueParamShift, this, coroutineDesc
|
||||
)
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import kotlin.math.max
|
||||
|
||||
class ReificationArgument(
|
||||
val parameterName: String, val nullable: Boolean, private val arrayDepth: Int
|
||||
@@ -194,7 +195,7 @@ class ReifiedTypeInliner(
|
||||
instructions.remove(stubCheckcast)
|
||||
|
||||
// TODO: refine max stack calculation (it's not always as big as +4)
|
||||
maxStackSize = Math.max(maxStackSize, 4)
|
||||
maxStackSize = max(maxStackSize, 4)
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -214,7 +215,7 @@ class ReifiedTypeInliner(
|
||||
instructions.remove(stubInstanceOf)
|
||||
|
||||
// TODO: refine max stack calculation (it's not always as big as +2)
|
||||
maxStackSize = Math.max(maxStackSize, 2)
|
||||
maxStackSize = max(maxStackSize, 2)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -229,7 +230,7 @@ class ReifiedTypeInliner(
|
||||
instructions.insert(insn, newMethodNode.instructions)
|
||||
instructions.remove(stubConstNull)
|
||||
|
||||
maxStackSize = Math.max(maxStackSize, stackSize)
|
||||
maxStackSize = max(maxStackSize, stackSize)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.FILE_SECTION
|
||||
import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.LINE_SECTION
|
||||
import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.STRATA_SECTION
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
const val KOTLIN_STRATA_NAME = "Kotlin"
|
||||
const val KOTLIN_DEBUG_STRATA_NAME = "KotlinDebug"
|
||||
@@ -217,7 +218,7 @@ open class DefaultSourceMapper(val sourceInfo: SourceInfo) : SourceMapper {
|
||||
val newFileMapping = getOrRegisterNewSource(fileMapping.name, fileMapping.path)
|
||||
fileMapping.lineMappings.forEach {
|
||||
newFileMapping.mapNewInterval(it.source, it.dest, it.range)
|
||||
maxUsedValue = Math.max(it.maxDest, maxUsedValue)
|
||||
maxUsedValue = max(it.maxDest, maxUsedValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ import org.jetbrains.org.objectweb.asm.util.Textifier
|
||||
import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
const val GENERATE_SMAP = true
|
||||
const val NUMBERED_FUNCTION_PREFIX = "kotlin/jvm/functions/Function"
|
||||
@@ -121,8 +123,8 @@ internal fun getMethodNode(
|
||||
return object : MethodNode(Opcodes.API_VERSION, access, name, desc, signature, exceptions) {
|
||||
override fun visitLineNumber(line: Int, start: Label) {
|
||||
super.visitLineNumber(line, start)
|
||||
lines[0] = Math.min(lines[0], line)
|
||||
lines[1] = Math.max(lines[1], line)
|
||||
lines[0] = min(lines[0], line)
|
||||
lines[1] = max(lines[1], line)
|
||||
}
|
||||
}.also {
|
||||
node = it
|
||||
@@ -509,7 +511,7 @@ private fun getIndexAfterLastMarker(node: MethodNode): Int {
|
||||
var result = -1
|
||||
for (variable in node.localVariables) {
|
||||
if (isFakeLocalVariableForInline(variable.name)) {
|
||||
result = Math.max(result, variable.index + 1)
|
||||
result = max(result, variable.index + 1)
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter
|
||||
import kotlin.math.max
|
||||
|
||||
internal class FixStackAnalyzer(
|
||||
owner: String,
|
||||
@@ -133,7 +134,7 @@ internal class FixStackAnalyzer(
|
||||
super.push(value)
|
||||
} else {
|
||||
extraStack.add(value)
|
||||
maxExtraStackSize = Math.max(maxExtraStackSize, extraStack.size)
|
||||
maxExtraStackSize = max(maxExtraStackSize, extraStack.size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.optimization.fixStack
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import kotlin.math.max
|
||||
|
||||
internal class LocalVariablesManager(val context: FixStackContext, val methodNode: MethodNode) {
|
||||
private class AllocatedHandle(val savedStackDescriptor: SavedStackDescriptor, var numRestoreMarkers: Int) {
|
||||
@@ -35,7 +36,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
private val allocatedHandles = hashMapOf<AbstractInsnNode, AllocatedHandle>()
|
||||
|
||||
private fun updateMaxLocals(newValue: Int) {
|
||||
methodNode.maxLocals = Math.max(methodNode.maxLocals, newValue)
|
||||
methodNode.maxLocals = max(methodNode.maxLocals, newValue)
|
||||
}
|
||||
|
||||
fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List<BasicValue>): SavedStackDescriptor {
|
||||
@@ -67,7 +68,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
|
||||
private fun getFirstUnusedLocalVariableIndex(): Int =
|
||||
allocatedHandles.values.fold(initialMaxLocals) { index, handle ->
|
||||
Math.max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex)
|
||||
max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex)
|
||||
}
|
||||
|
||||
fun markRestoreStackMarkerEmitted(restoreStackMarker: AbstractInsnNode) {
|
||||
|
||||
Reference in New Issue
Block a user