JVM_IR. Don't compare with 0 defaultFlag
This commit is contained in:
+4
-4
@@ -84,7 +84,7 @@ open class DefaultArgumentStubGenerator(
|
|||||||
val remapped = if (valueParameter.defaultValue != null) {
|
val remapped = if (valueParameter.defaultValue != null) {
|
||||||
val mask = irGet(newIrFunction.valueParameters[irFunction.valueParameters.size + valueParameter.index / 32])
|
val mask = irGet(newIrFunction.valueParameters[irFunction.valueParameters.size + valueParameter.index / 32])
|
||||||
val bit = irInt(1 shl (valueParameter.index % 32))
|
val bit = irInt(1 shl (valueParameter.index % 32))
|
||||||
val test = irCallOp(this@DefaultArgumentStubGenerator.context.ir.symbols.intAnd, context.irBuiltIns.intType, mask, bit)
|
val defaultFlag = irCallOp(this@DefaultArgumentStubGenerator.context.ir.symbols.intAnd, context.irBuiltIns.intType, mask, bit)
|
||||||
|
|
||||||
val expressionBody = valueParameter.defaultValue!!
|
val expressionBody = valueParameter.defaultValue!!
|
||||||
expressionBody.patchDeclarationParents(newIrFunction)
|
expressionBody.patchDeclarationParents(newIrFunction)
|
||||||
@@ -96,7 +96,7 @@ open class DefaultArgumentStubGenerator(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
selectArgumentOrDefault(irNotEquals(test, irInt(0)), parameter, expressionBody.expression)
|
selectArgumentOrDefault(defaultFlag, parameter, expressionBody.expression)
|
||||||
} else {
|
} else {
|
||||||
parameter
|
parameter
|
||||||
}
|
}
|
||||||
@@ -128,11 +128,11 @@ open class DefaultArgumentStubGenerator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected open fun IrBlockBodyBuilder.selectArgumentOrDefault(
|
protected open fun IrBlockBodyBuilder.selectArgumentOrDefault(
|
||||||
shouldUseDefault: IrExpression,
|
defaultFlag: IrExpression,
|
||||||
parameter: IrValueParameter,
|
parameter: IrValueParameter,
|
||||||
default: IrExpression
|
default: IrExpression
|
||||||
): IrValueDeclaration {
|
): IrValueDeclaration {
|
||||||
val value = irIfThenElse(parameter.type, shouldUseDefault, default, irGet(parameter))
|
val value = irIfThenElse(parameter.type, irNotEquals(defaultFlag, irInt(0)), default, irGet(parameter))
|
||||||
return createTmpVariable(value, nameHint = parameter.name.asString())
|
return createTmpVariable(value, nameHint = parameter.name.asString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
|||||||
|
|
||||||
class JvmDefaultArgumentStubGenerator(override val context: JvmBackendContext) : DefaultArgumentStubGenerator(context, false, false) {
|
class JvmDefaultArgumentStubGenerator(override val context: JvmBackendContext) : DefaultArgumentStubGenerator(context, false, false) {
|
||||||
override fun IrBlockBodyBuilder.selectArgumentOrDefault(
|
override fun IrBlockBodyBuilder.selectArgumentOrDefault(
|
||||||
shouldUseDefault: IrExpression,
|
defaultFlag: IrExpression,
|
||||||
parameter: IrValueParameter,
|
parameter: IrValueParameter,
|
||||||
default: IrExpression
|
default: IrExpression
|
||||||
): IrValueDeclaration {
|
): IrValueDeclaration {
|
||||||
@@ -36,7 +36,7 @@ class JvmDefaultArgumentStubGenerator(override val context: JvmBackendContext) :
|
|||||||
//
|
//
|
||||||
// This control flow limits us to an if-then (without an else), and this together with the
|
// This control flow limits us to an if-then (without an else), and this together with the
|
||||||
// restriction on loading the parameter in the default case means we cannot create any temporaries.
|
// restriction on loading the parameter in the default case means we cannot create any temporaries.
|
||||||
+irIfThen(shouldUseDefault, irCall(this@JvmDefaultArgumentStubGenerator.context.ir.symbols.reassignParameterIntrinsic).apply {
|
+irIfThen(defaultFlag, irCall(this@JvmDefaultArgumentStubGenerator.context.ir.symbols.reassignParameterIntrinsic).apply {
|
||||||
putTypeArgument(0, parameter.type)
|
putTypeArgument(0, parameter.type)
|
||||||
putValueArgument(0, irGet(parameter))
|
putValueArgument(0, irGet(parameter))
|
||||||
putValueArgument(1, default)
|
putValueArgument(1, default)
|
||||||
|
|||||||
Reference in New Issue
Block a user