JVM_IR generate range-based loop closer to Java counter loop
KT-48435 KT-48507
This commit is contained in:
-6
@@ -10093,12 +10093,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("debuggerMetadata_ir.kt")
|
|
||||||
public void testDebuggerMetadata_ir() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata_ir.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("elvisLineNumber.kt")
|
@TestMetadata("elvisLineNumber.kt")
|
||||||
public void testElvisLineNumber() throws Exception {
|
public void testElvisLineNumber() throws Exception {
|
||||||
|
|||||||
+11
@@ -11,9 +11,11 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope
|
import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope
|
||||||
import org.jetbrains.kotlin.ir.builders.irCall
|
import org.jetbrains.kotlin.ir.builders.irCall
|
||||||
import org.jetbrains.kotlin.ir.builders.irString
|
import org.jetbrains.kotlin.ir.builders.irString
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
@@ -53,4 +55,13 @@ interface CommonBackendContext : BackendContext, LoggingContext {
|
|||||||
|
|
||||||
val preferJavaLikeCounterLoop: Boolean
|
val preferJavaLikeCounterLoop: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
|
|
||||||
|
val reuseLoopVariableAsInductionVariable: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
val doWhileCounterLoopOrigin: IrStatementOrigin?
|
||||||
|
get() = null
|
||||||
|
|
||||||
|
val inductionVariableOrigin: IrDeclarationOrigin
|
||||||
|
get() = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ abstract class AbstractVariableRemapper : IrElementTransformerVoid() {
|
|||||||
override fun visitSetValue(expression: IrSetValue): IrExpression {
|
override fun visitSetValue(expression: IrSetValue): IrExpression {
|
||||||
expression.transformChildrenVoid()
|
expression.transformChildrenVoid()
|
||||||
return remapVariable(expression.symbol.owner)?.let {
|
return remapVariable(expression.symbol.owner)?.let {
|
||||||
IrSetValueImpl(expression.startOffset, expression.endOffset, it.type, it.symbol, expression.value, expression.origin)
|
IrSetValueImpl(expression.startOffset, expression.endOffset, expression.type, it.symbol, expression.value, expression.origin)
|
||||||
} ?: expression
|
} ?: expression
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+125
-24
@@ -8,16 +8,18 @@ package org.jetbrains.kotlin.backend.common.lower.loops
|
|||||||
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
|
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||||
|
import org.jetbrains.kotlin.backend.common.lower.AbstractVariableRemapper
|
||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
||||||
|
import org.jetbrains.kotlin.ir.types.classifierOrNull
|
||||||
|
import org.jetbrains.kotlin.ir.types.isNullable
|
||||||
import org.jetbrains.kotlin.ir.util.dump
|
import org.jetbrains.kotlin.ir.util.dump
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
import org.jetbrains.kotlin.ir.visitors.*
|
import org.jetbrains.kotlin.ir.visitors.*
|
||||||
@@ -97,7 +99,10 @@ val forLoopsPhase = makeIrFilePhase(
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class ForLoopsLowering(val context: CommonBackendContext, val loopBodyTransformer: ForLoopBodyTransformer? = null) : BodyLoweringPass {
|
class ForLoopsLowering(
|
||||||
|
val context: CommonBackendContext,
|
||||||
|
private val loopBodyTransformer: ForLoopBodyTransformer? = null
|
||||||
|
) : BodyLoweringPass {
|
||||||
|
|
||||||
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||||
val oldLoopToNewLoop = mutableMapOf<IrLoop, IrLoop>()
|
val oldLoopToNewLoop = mutableMapOf<IrLoop, IrLoop>()
|
||||||
@@ -160,30 +165,127 @@ private class RangeLoopTransformer(
|
|||||||
return super.visitBlock(expression) // Not a for-loop block.
|
return super.visitBlock(expression) // Not a for-loop block.
|
||||||
}
|
}
|
||||||
|
|
||||||
with(expression.statements) {
|
val statements = expression.statements
|
||||||
assert(size == 2) { "Expected 2 statements in for-loop block, was:\n${expression.dump()}" }
|
assert(statements.size == 2) { "Expected 2 statements in for-loop block, was:\n${expression.dump()}" }
|
||||||
val iteratorVariable = get(0) as IrVariable
|
val iteratorVariable = statements[0] as IrVariable
|
||||||
assert(iteratorVariable.origin == IrDeclarationOrigin.FOR_LOOP_ITERATOR) { "Expected FOR_LOOP_ITERATOR origin for iterator variable, was:\n${iteratorVariable.dump()}" }
|
assert(iteratorVariable.origin == IrDeclarationOrigin.FOR_LOOP_ITERATOR) {
|
||||||
val loopHeader = headerProcessor.extractHeader(iteratorVariable)
|
"Expected FOR_LOOP_ITERATOR origin for iterator variable, was:\n${iteratorVariable.dump()}"
|
||||||
?: return super.visitBlock(expression) // The iterable in the header is not supported.
|
}
|
||||||
val loweredHeader = lowerHeader(iteratorVariable, loopHeader)
|
val oldLoop = statements[1] as IrWhileLoop
|
||||||
|
assert(oldLoop.origin == IrStatementOrigin.FOR_LOOP_INNER_WHILE) {
|
||||||
|
"Expected FOR_LOOP_INNER_WHILE origin for while loop, was:\n${oldLoop.dump()}"
|
||||||
|
}
|
||||||
|
|
||||||
val oldLoop = get(1) as IrWhileLoop
|
val loopHeader = headerProcessor.extractHeader(iteratorVariable)
|
||||||
assert(oldLoop.origin == IrStatementOrigin.FOR_LOOP_INNER_WHILE) { "Expected FOR_LOOP_INNER_WHILE origin for while loop, was:\n${oldLoop.dump()}" }
|
?: return super.visitBlock(expression) // The iterable in the header is not supported.
|
||||||
val (newLoop, loopReplacementExpression) = lowerWhileLoop(oldLoop, loopHeader)
|
val loweredHeader = lowerHeader(iteratorVariable, loopHeader)
|
||||||
?: return super.visitBlock(expression) // Cannot lower the loop.
|
|
||||||
|
|
||||||
// We can lower both the header and while loop.
|
val (newLoop, loopReplacementExpression) = lowerWhileLoop(oldLoop, loopHeader)
|
||||||
// Update mapping from old to new loop so we can later update references in break/continue.
|
?: return super.visitBlock(expression) // Cannot lower the loop.
|
||||||
oldLoopToNewLoop[oldLoop] = newLoop
|
|
||||||
|
|
||||||
set(0, loweredHeader)
|
// We can lower both the header and while loop.
|
||||||
set(1, loopReplacementExpression)
|
// Update mapping from old to new loop so we can later update references in break/continue.
|
||||||
|
oldLoopToNewLoop[oldLoop] = newLoop
|
||||||
|
|
||||||
|
statements[0] = loweredHeader
|
||||||
|
statements[1] = loopReplacementExpression
|
||||||
|
|
||||||
|
if (context.reuseLoopVariableAsInductionVariable && loopHeader.canReuseLoopVariableAsInductionVariable) {
|
||||||
|
reuseLoopVariableAsInductionVariable(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.visitBlock(expression)
|
return super.visitBlock(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun reuseLoopVariableAsInductionVariable(irBlock: IrBlock) {
|
||||||
|
// Given a loop in the form:
|
||||||
|
// {
|
||||||
|
// var inductionVariable = <start>
|
||||||
|
// }
|
||||||
|
// do {
|
||||||
|
// if (!(<whileLoopCondition>)) break
|
||||||
|
// val loopVariable = inductionVariable
|
||||||
|
// <originalLoopBody>
|
||||||
|
// } while ( { inductionVariable += <step>; true } )
|
||||||
|
// replace it with:
|
||||||
|
// {
|
||||||
|
// var loopVariable' = <start>
|
||||||
|
// }
|
||||||
|
// do {
|
||||||
|
// if (!(<whileLoopCondition'>)) break
|
||||||
|
// <originalLoopBody'>
|
||||||
|
// } while ( { loopVariable' += <step>; true } )
|
||||||
|
// where whenLoopCondition' and originalLoopBody' are corresponding statements
|
||||||
|
// with inductionVariable and loopVariable remapped to loopVariable'.
|
||||||
|
//
|
||||||
|
// NB we can do so only with a do-while counter loop as described above,
|
||||||
|
// otherwise it changes semantics of 'continue' inside the loop.
|
||||||
|
|
||||||
|
val header = irBlock.statements[0] as? IrStatementContainer ?: return
|
||||||
|
|
||||||
|
val inductionVariableIndex = header.statements.indexOfFirst { it.isInductionVariable(context) }
|
||||||
|
if (inductionVariableIndex < 0) return
|
||||||
|
val inductionVariable = header.statements[inductionVariableIndex] as IrVariable
|
||||||
|
|
||||||
|
val innerLoop = findInnerDoWhileLoop(irBlock.statements[1]) ?: return
|
||||||
|
if (innerLoop.origin != context.doWhileCounterLoopOrigin) return
|
||||||
|
val loopVariableContainerAndIndex = findLoopVariable(innerLoop) ?: return
|
||||||
|
val (loopVariableContainer, loopVariableIndex) = loopVariableContainerAndIndex
|
||||||
|
val loopVariable = loopVariableContainer.statements[loopVariableIndex] as IrVariable
|
||||||
|
|
||||||
|
val inductionVariableType = inductionVariable.type
|
||||||
|
val loopVariableType = loopVariable.type
|
||||||
|
if (loopVariableType.isNullable()) return
|
||||||
|
if (loopVariableType.classifierOrNull != inductionVariableType.classifierOrNull) return
|
||||||
|
|
||||||
|
val newLoopVariable = IrVariableImpl(
|
||||||
|
loopVariable.startOffset, loopVariable.endOffset, loopVariable.origin,
|
||||||
|
IrVariableSymbolImpl(),
|
||||||
|
loopVariable.name, loopVariableType,
|
||||||
|
isVar = true, // NB original loop variable is 'val'
|
||||||
|
isConst = false, isLateinit = false
|
||||||
|
)
|
||||||
|
newLoopVariable.initializer = inductionVariable.initializer
|
||||||
|
|
||||||
|
header.statements[inductionVariableIndex] = newLoopVariable
|
||||||
|
loopVariableContainer.statements.removeAt(loopVariableIndex)
|
||||||
|
|
||||||
|
val remapper = object : AbstractVariableRemapper() {
|
||||||
|
override fun remapVariable(value: IrValueDeclaration): IrValueDeclaration? =
|
||||||
|
if (value == inductionVariable || value == loopVariable) newLoopVariable else null
|
||||||
|
}
|
||||||
|
irBlock.statements[1].transformChildren(remapper, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findInnerDoWhileLoop(statement: IrStatement): IrDoWhileLoop? {
|
||||||
|
if (statement is IrDoWhileLoop) {
|
||||||
|
return statement
|
||||||
|
}
|
||||||
|
if (statement is IrWhen) {
|
||||||
|
val branch0Result = statement.branches[0].result
|
||||||
|
if (branch0Result is IrDoWhileLoop)
|
||||||
|
return branch0Result
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findLoopVariable(doWhileLoop: IrDoWhileLoop): Pair<IrContainerExpression, Int>? {
|
||||||
|
val loopBody = doWhileLoop.body as? IrContainerExpression ?: return null
|
||||||
|
for ((index, statement) in loopBody.statements.withIndex()) {
|
||||||
|
if (statement.isLoopVariable())
|
||||||
|
return Pair(loopBody, index)
|
||||||
|
else if (statement is IrContainerExpression && statement.origin == IrStatementOrigin.FOR_LOOP_NEXT) {
|
||||||
|
val loopVarIndex = statement.statements.indexOfFirst { it.isLoopVariable() }
|
||||||
|
if (loopVarIndex < 0) return null
|
||||||
|
return Pair(statement, loopVarIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun IrStatement.isLoopVariable() =
|
||||||
|
this is IrVariable && origin == IrDeclarationOrigin.FOR_LOOP_VARIABLE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lowers the "header" statement that stores the iterator into the loop variable
|
* Lowers the "header" statement that stores the iterator into the loop variable
|
||||||
* (e.g., `val it = someIterable.iterator()`) and gather information for building the for-loop
|
* (e.g., `val it = someIterable.iterator()`) and gather information for building the for-loop
|
||||||
@@ -204,9 +306,8 @@ private class RangeLoopTransformer(
|
|||||||
|
|
||||||
private fun lowerWhileLoop(loop: IrWhileLoop, loopHeader: ForLoopHeader): LoopReplacement? {
|
private fun lowerWhileLoop(loop: IrWhileLoop, loopHeader: ForLoopHeader): LoopReplacement? {
|
||||||
val loopBodyStatements = (loop.body as? IrContainerExpression)?.statements ?: return null
|
val loopBodyStatements = (loop.body as? IrContainerExpression)?.statements ?: return null
|
||||||
val (mainLoopVariable, mainLoopVariableIndex, loopVariableComponents, loopVariableComponentIndices) = gatherLoopVariableInfo(
|
val (mainLoopVariable, mainLoopVariableIndex, loopVariableComponents, loopVariableComponentIndices) =
|
||||||
loopBodyStatements
|
gatherLoopVariableInfo(loopBodyStatements)
|
||||||
)
|
|
||||||
|
|
||||||
if (loopHeader.consumesLoopVariableComponents && mainLoopVariable.origin != IrDeclarationOrigin.IR_TEMPORARY_VARIABLE) {
|
if (loopHeader.consumesLoopVariableComponents && mainLoopVariable.origin != IrDeclarationOrigin.IR_TEMPORARY_VARIABLE) {
|
||||||
// We determine if there is a destructuring declaration by checking if the main loop variable is temporary.
|
// We determine if there is a destructuring declaration by checking if the main loop variable is temporary.
|
||||||
|
|||||||
+95
-50
@@ -44,6 +44,10 @@ interface ForLoopHeader {
|
|||||||
*/
|
*/
|
||||||
val consumesLoopVariableComponents: Boolean
|
val consumesLoopVariableComponents: Boolean
|
||||||
|
|
||||||
|
/** `true` if it's possible to use loop variable as induction variable in this kind of loop */
|
||||||
|
val canReuseLoopVariableAsInductionVariable: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
/** Statements used to initialize an iteration of the loop (e.g., assign loop variable). */
|
/** Statements used to initialize an iteration of the loop (e.g., assign loop variable). */
|
||||||
fun initializeIteration(
|
fun initializeIteration(
|
||||||
loopVariable: IrVariable?,
|
loopVariable: IrVariable?,
|
||||||
@@ -56,6 +60,13 @@ interface ForLoopHeader {
|
|||||||
fun buildLoop(builder: DeclarationIrBuilder, oldLoop: IrLoop, newBody: IrExpression?): LoopReplacement
|
fun buildLoop(builder: DeclarationIrBuilder, oldLoop: IrLoop, newBody: IrExpression?): LoopReplacement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal const val inductionVariableName = "inductionVariable"
|
||||||
|
|
||||||
|
internal fun IrStatement.isInductionVariable(context: CommonBackendContext) =
|
||||||
|
this is IrVariable &&
|
||||||
|
origin == context.inductionVariableOrigin &&
|
||||||
|
name.asString() == inductionVariableName
|
||||||
|
|
||||||
abstract class NumericForLoopHeader<T : NumericHeaderInfo>(
|
abstract class NumericForLoopHeader<T : NumericHeaderInfo>(
|
||||||
val headerInfo: T,
|
val headerInfo: T,
|
||||||
builder: DeclarationIrBuilder,
|
builder: DeclarationIrBuilder,
|
||||||
@@ -64,6 +75,8 @@ abstract class NumericForLoopHeader<T : NumericHeaderInfo>(
|
|||||||
|
|
||||||
override val consumesLoopVariableComponents = false
|
override val consumesLoopVariableComponents = false
|
||||||
|
|
||||||
|
override val canReuseLoopVariableAsInductionVariable get() = true
|
||||||
|
|
||||||
val inductionVariable: IrVariable
|
val inductionVariable: IrVariable
|
||||||
|
|
||||||
protected val stepVariable: IrVariable?
|
protected val stepVariable: IrVariable?
|
||||||
@@ -92,8 +105,9 @@ abstract class NumericForLoopHeader<T : NumericHeaderInfo>(
|
|||||||
inductionVariable =
|
inductionVariable =
|
||||||
scope.createTmpVariable(
|
scope.createTmpVariable(
|
||||||
headerInfo.first.asElementType(),
|
headerInfo.first.asElementType(),
|
||||||
nameHint = "inductionVariable",
|
nameHint = inductionVariableName,
|
||||||
isMutable = true,
|
isMutable = true,
|
||||||
|
origin = this@NumericForLoopHeader.context.inductionVariableOrigin,
|
||||||
irType = elementClass.defaultType
|
irType = elementClass.defaultType
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -317,7 +331,11 @@ class ProgressionLoopHeader(
|
|||||||
// // Loop body
|
// // Loop body
|
||||||
// } while (loopVar != last)
|
// } while (loopVar != last)
|
||||||
// }
|
// }
|
||||||
val newLoop = IrDoWhileLoopImpl(oldLoop.startOffset, oldLoop.endOffset, oldLoop.type, oldLoop.origin).apply {
|
val newLoopOrigin = if (preferJavaLikeCounterLoop)
|
||||||
|
this@ProgressionLoopHeader.context.doWhileCounterLoopOrigin
|
||||||
|
else
|
||||||
|
oldLoop.origin
|
||||||
|
val newLoop = IrDoWhileLoopImpl(oldLoop.startOffset, oldLoop.endOffset, oldLoop.type, newLoopOrigin).apply {
|
||||||
val loopVariableExpression = irGet(loopVariable!!).let {
|
val loopVariableExpression = irGet(loopVariable!!).let {
|
||||||
headerInfo.progressionType.run {
|
headerInfo.progressionType.run {
|
||||||
if (this is UnsignedProgressionType) {
|
if (this is UnsignedProgressionType) {
|
||||||
@@ -331,6 +349,10 @@ class ProgressionLoopHeader(
|
|||||||
body = newBody
|
body = newBody
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preferJavaLikeCounterLoop) {
|
||||||
|
moveInductionVariableUpdateToLoopCondition(newLoop)
|
||||||
|
}
|
||||||
|
|
||||||
val loopCondition = buildLoopCondition(this@with)
|
val loopCondition = buildLoopCondition(this@with)
|
||||||
LoopReplacement(newLoop, irIfThen(loopCondition, newLoop))
|
LoopReplacement(newLoop, irIfThen(loopCondition, newLoop))
|
||||||
} else if (preferJavaLikeCounterLoop && !headerInfo.isLastInclusive) {
|
} else if (preferJavaLikeCounterLoop && !headerInfo.isLastInclusive) {
|
||||||
@@ -338,25 +360,17 @@ class ProgressionLoopHeader(
|
|||||||
// (`for (int i = first; i < lastExclusive; ++i) { ... }`).
|
// (`for (int i = first; i < lastExclusive; ++i) { ... }`).
|
||||||
// Otherwise loop-related optimizations will not kick in, resulting in significant performance degradation.
|
// Otherwise loop-related optimizations will not kick in, resulting in significant performance degradation.
|
||||||
//
|
//
|
||||||
// If possible, use a do-while loop:
|
// Use a do-while loop:
|
||||||
// do {
|
// do {
|
||||||
// if ( !( inductionVariable < last ) ) break
|
// if ( !( inductionVariable < last ) ) break
|
||||||
// val loopVariable = inductionVariable
|
// val loopVariable = inductionVariable
|
||||||
// <body>
|
// <body>
|
||||||
// } while ( { inductionVariable += step; true } )
|
// } while ( { inductionVariable += step; true } )
|
||||||
// This loop form is equivalent to the Java counter loop shown above.
|
// This loop form is equivalent to the Java counter loop shown above.
|
||||||
//
|
|
||||||
// Otherwise, use a simple while loop:
|
|
||||||
// while (inductionVar < last) {
|
|
||||||
// val loopVar = inductionVar
|
|
||||||
// inductionVar += step
|
|
||||||
// // Loop body
|
|
||||||
// }
|
|
||||||
|
|
||||||
val newLoopCondition = buildLoopCondition(this@with)
|
val newLoopCondition = buildLoopCondition(this@with)
|
||||||
|
|
||||||
buildJavaLikeDoWhileCounterLoop(oldLoop, newLoopCondition, newBody)
|
buildJavaLikeDoWhileCounterLoop(oldLoop, newLoopCondition, newBody)
|
||||||
?: buildJavaLikeWhileCounterLoop(oldLoop, newLoopCondition, newBody)
|
|
||||||
} else {
|
} else {
|
||||||
// Use an if-guarded do-while loop (note the difference in loop condition):
|
// Use an if-guarded do-while loop (note the difference in loop condition):
|
||||||
//
|
//
|
||||||
@@ -383,11 +397,52 @@ class ProgressionLoopHeader(
|
|||||||
it.name == OperatorNameConventions.NOT
|
it.name == OperatorNameConventions.NOT
|
||||||
} ?: error("No '${OperatorNameConventions.NOT}' in ${context.irBuiltIns.booleanClass.owner.render()}")
|
} ?: error("No '${OperatorNameConventions.NOT}' in ${context.irBuiltIns.booleanClass.owner.render()}")
|
||||||
|
|
||||||
|
private fun moveInductionVariableUpdateToLoopCondition(doWhileLoop: IrDoWhileLoop) {
|
||||||
|
// On JVM, it's important that induction variable update happens in the end of the loop
|
||||||
|
// (otherwise HotSpot will not treat it as a counter loop).
|
||||||
|
// Moving induction variable update to loop condition (instead of just placing it in the end of loop body)
|
||||||
|
// also allows reusing loop variable as induction variable later.
|
||||||
|
//
|
||||||
|
// Transform a loop in the form:
|
||||||
|
// do {
|
||||||
|
// { <next> }
|
||||||
|
// <body>
|
||||||
|
// } while (<condition>)
|
||||||
|
// to
|
||||||
|
// do {
|
||||||
|
// { <next'> }
|
||||||
|
// <body>
|
||||||
|
// } while ( { if (!<condition>) break; <updateInductionVar>; true } )
|
||||||
|
val doWhileBody = doWhileLoop.body as? IrContainerExpression ?: return
|
||||||
|
if (doWhileBody.origin != IrStatementOrigin.FOR_LOOP_INNER_WHILE) return
|
||||||
|
val doWhileLoopNext = doWhileBody.statements[0] as? IrContainerExpression ?: return
|
||||||
|
if (doWhileLoopNext.origin != IrStatementOrigin.FOR_LOOP_NEXT) return
|
||||||
|
|
||||||
|
val updateInductionVarIndex = doWhileLoopNext.statements
|
||||||
|
.indexOfFirst { it is IrSetValue && it.symbol.owner.isInductionVariable(context) }
|
||||||
|
if (updateInductionVarIndex < 0) return
|
||||||
|
val updateInductionVar = doWhileLoopNext.statements[updateInductionVarIndex]
|
||||||
|
doWhileLoopNext.statements.removeAt(updateInductionVarIndex)
|
||||||
|
|
||||||
|
val loopCondition = doWhileLoop.condition
|
||||||
|
val loopConditionStartOffset = loopCondition.startOffset
|
||||||
|
val loopConditionEndOffset = loopCondition.endOffset
|
||||||
|
doWhileLoop.condition = IrCompositeImpl(
|
||||||
|
loopConditionStartOffset, loopConditionEndOffset, loopCondition.type,
|
||||||
|
origin = null,
|
||||||
|
statements = listOf(
|
||||||
|
createNegatedConditionCheck(doWhileLoop.condition, doWhileLoop),
|
||||||
|
updateInductionVar,
|
||||||
|
IrConstImpl.boolean(loopConditionStartOffset, loopConditionEndOffset, context.irBuiltIns.booleanType, true)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun buildJavaLikeDoWhileCounterLoop(
|
private fun buildJavaLikeDoWhileCounterLoop(
|
||||||
oldLoop: IrLoop,
|
oldLoop: IrLoop,
|
||||||
newLoopCondition: IrExpression,
|
newLoopCondition: IrExpression,
|
||||||
newBody: IrExpression?
|
newBody: IrExpression?
|
||||||
): LoopReplacement? {
|
): LoopReplacement {
|
||||||
// Transform loop:
|
// Transform loop:
|
||||||
// while (<newLoopCondition>) {
|
// while (<newLoopCondition>) {
|
||||||
// {
|
// {
|
||||||
@@ -402,31 +457,19 @@ class ProgressionLoopHeader(
|
|||||||
// val forLoopVariable = inductionVariable
|
// val forLoopVariable = inductionVariable
|
||||||
// <originalLoopBody>
|
// <originalLoopBody>
|
||||||
// } while ( { inductionVariable += step; true } )
|
// } while ( { inductionVariable += step; true } )
|
||||||
val bodyBlock = newBody as? IrContainerExpression ?: return null
|
val bodyBlock = newBody as? IrContainerExpression
|
||||||
val forLoopNextBlock = bodyBlock.statements[0] as? IrContainerExpression ?: return null
|
?: throw AssertionError("newBody: ${newBody?.dump()}")
|
||||||
if (forLoopNextBlock.origin != IrStatementOrigin.FOR_LOOP_NEXT) return null
|
val forLoopNextBlock = bodyBlock.statements[0] as? IrContainerExpression
|
||||||
val loopStep = forLoopNextBlock.statements.last() as? IrSetValue ?: return null
|
?: throw AssertionError("bodyBlock[0]: ${bodyBlock.statements[0].dump()}")
|
||||||
|
if (forLoopNextBlock.origin != IrStatementOrigin.FOR_LOOP_NEXT)
|
||||||
|
throw AssertionError("FOR_LOOP_NEXT expected: ${forLoopNextBlock.dump()}")
|
||||||
|
val loopStep = forLoopNextBlock.statements.last() as? IrSetValue
|
||||||
|
?: throw AssertionError("forLoopNextBlock.last: ${forLoopNextBlock.statements.last().dump()}")
|
||||||
|
|
||||||
val doWhileLoop = IrDoWhileLoopImpl(oldLoop.startOffset, oldLoop.endOffset, oldLoop.type, oldLoop.origin)
|
val doWhileLoop = IrDoWhileLoopImpl(oldLoop.startOffset, oldLoop.endOffset, oldLoop.type, context.doWhileCounterLoopOrigin)
|
||||||
doWhileLoop.label = oldLoop.label
|
doWhileLoop.label = oldLoop.label
|
||||||
|
|
||||||
val conditionStartOffset = newLoopCondition.startOffset
|
val negatedConditionCheck = createNegatedConditionCheck(newLoopCondition, doWhileLoop)
|
||||||
val conditionEndOffset = newLoopCondition.endOffset
|
|
||||||
val negatedCondition =
|
|
||||||
IrCallImpl.fromSymbolOwner(conditionStartOffset, conditionEndOffset, booleanNot.symbol).apply {
|
|
||||||
dispatchReceiver = newLoopCondition
|
|
||||||
}
|
|
||||||
|
|
||||||
val negatedConditionCheck =
|
|
||||||
IrWhenImpl(
|
|
||||||
conditionStartOffset, conditionEndOffset, context.irBuiltIns.unitType, null,
|
|
||||||
listOf(
|
|
||||||
IrBranchImpl(
|
|
||||||
negatedCondition,
|
|
||||||
IrBreakImpl(conditionStartOffset, conditionEndOffset, context.irBuiltIns.nothingType, doWhileLoop)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
bodyBlock.statements[0] = negatedConditionCheck
|
bodyBlock.statements[0] = negatedConditionCheck
|
||||||
val loopVarAssignments =
|
val loopVarAssignments =
|
||||||
@@ -455,23 +498,25 @@ class ProgressionLoopHeader(
|
|||||||
return LoopReplacement(doWhileLoop, doWhileLoop)
|
return LoopReplacement(doWhileLoop, doWhileLoop)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildJavaLikeWhileCounterLoop(
|
private fun createNegatedConditionCheck(newLoopCondition: IrExpression, doWhileLoop: IrDoWhileLoop): IrWhenImpl {
|
||||||
oldLoop: IrLoop,
|
val conditionStartOffset = newLoopCondition.startOffset
|
||||||
newLoopCondition: IrExpression,
|
val conditionEndOffset = newLoopCondition.endOffset
|
||||||
newBody: IrExpression?
|
val negatedCondition =
|
||||||
): LoopReplacement {
|
IrCallImpl.fromSymbolOwner(conditionStartOffset, conditionEndOffset, booleanNot.symbol).apply {
|
||||||
// while (inductionVar < last) {
|
dispatchReceiver = newLoopCondition
|
||||||
// val loopVar = inductionVar
|
}
|
||||||
// inductionVar += step
|
|
||||||
// // Loop body
|
return IrWhenImpl(
|
||||||
// }
|
conditionStartOffset, conditionEndOffset, context.irBuiltIns.unitType, null,
|
||||||
val newLoop = IrWhileLoopImpl(oldLoop.startOffset, oldLoop.endOffset, oldLoop.type, oldLoop.origin).apply {
|
listOf(
|
||||||
label = oldLoop.label
|
IrBranchImpl(
|
||||||
condition = newLoopCondition
|
negatedCondition,
|
||||||
body = newBody
|
IrBreakImpl(conditionStartOffset, conditionEndOffset, context.irBuiltIns.nothingType, doWhileLoop)
|
||||||
}
|
)
|
||||||
return LoopReplacement(newLoop, newLoop)
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class InitializerCallReplacer(val replacementCall: IrCall) : IrElementTransformerVoid() {
|
private class InitializerCallReplacer(val replacementCall: IrCall) : IrElementTransformerVoid() {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
|
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
|
||||||
@@ -217,6 +218,12 @@ class JvmBackendContext(
|
|||||||
override val preferJavaLikeCounterLoop: Boolean
|
override val preferJavaLikeCounterLoop: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
|
||||||
|
override val reuseLoopVariableAsInductionVariable: Boolean
|
||||||
|
get() = true
|
||||||
|
|
||||||
|
override val doWhileCounterLoopOrigin: IrStatementOrigin
|
||||||
|
get() = JvmLoweredStatementOrigin.DO_WHILE_COUNTER_LOOP
|
||||||
|
|
||||||
inner class JvmIr(
|
inner class JvmIr(
|
||||||
irModuleFragment: IrModuleFragment,
|
irModuleFragment: IrModuleFragment,
|
||||||
symbolTable: SymbolTable
|
symbolTable: SymbolTable
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOriginImpl
|
|||||||
|
|
||||||
interface JvmLoweredStatementOrigin {
|
interface JvmLoweredStatementOrigin {
|
||||||
object DEFAULT_STUB_CALL_TO_IMPLEMENTATION : IrStatementOriginImpl("DEFAULT_STUB_CALL_TO_IMPLEMENTATION")
|
object DEFAULT_STUB_CALL_TO_IMPLEMENTATION : IrStatementOriginImpl("DEFAULT_STUB_CALL_TO_IMPLEMENTATION")
|
||||||
|
object DO_WHILE_COUNTER_LOOP: IrStatementOriginImpl("DO_WHILE_COUNTER_LOOP")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// WITH_COROUTINES
|
// WITH_COROUTINES
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// IGNORE_BACKEND: JVM
|
|
||||||
// TARGET_BACKEND: JVM
|
|
||||||
// WITH_RUNTIME
|
|
||||||
// WITH_COROUTINES
|
|
||||||
|
|
||||||
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER")
|
|
||||||
|
|
||||||
import helpers.*
|
|
||||||
import kotlin.coroutines.*
|
|
||||||
import kotlin.coroutines.intrinsics.*
|
|
||||||
import kotlin.coroutines.jvm.internal.*
|
|
||||||
|
|
||||||
suspend fun getSpilledToVariable() = suspendCoroutineUninterceptedOrReturn<Array<String>> {
|
|
||||||
(it as BaseContinuationImpl).getSpilledVariableFieldMapping()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Array<String>.toMap(): Map<String, String> {
|
|
||||||
val res = hashMapOf<String, String>()
|
|
||||||
for (i in 0..(size - 1) step 2) {
|
|
||||||
res[get(i)] = get(i + 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
var continuation: Continuation<Unit>? = null
|
|
||||||
|
|
||||||
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
|
|
||||||
continuation = it
|
|
||||||
COROUTINE_SUSPENDED
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun dummy() {}
|
|
||||||
|
|
||||||
suspend fun named(): String {
|
|
||||||
dummy()
|
|
||||||
val s1 = ""
|
|
||||||
val s2 = ""
|
|
||||||
val s3 = ""
|
|
||||||
val s4 = ""
|
|
||||||
val s5 = ""
|
|
||||||
val s6 = ""
|
|
||||||
val s7 = ""
|
|
||||||
val s8 = ""
|
|
||||||
val s9 = ""
|
|
||||||
val map = getSpilledToVariable().toMap()
|
|
||||||
println(s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9)
|
|
||||||
return map["L$0"] + map["L$1"] + map["L$2"] + map["L$3"] + map["L$4"] + map["L$5"] + map["L$6"] + map["L$7"] + map["L$8"]
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun suspended() {
|
|
||||||
dummy()
|
|
||||||
val ss = ""
|
|
||||||
suspendHere()
|
|
||||||
println(ss)
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun multipleLocalsInOneSlot() {
|
|
||||||
for (first in 0 until 1) {
|
|
||||||
suspendHere()
|
|
||||||
println(first)
|
|
||||||
}
|
|
||||||
for (second in 0 until 1) {
|
|
||||||
suspendHere()
|
|
||||||
println(second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
|
||||||
c.startCoroutine(EmptyContinuation)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun box(): String {
|
|
||||||
var res: String = ""
|
|
||||||
builder {
|
|
||||||
res = named()
|
|
||||||
}
|
|
||||||
if (res != "s1s2s3s4s5s6s7s8s9") {
|
|
||||||
return "" + res
|
|
||||||
}
|
|
||||||
builder {
|
|
||||||
dummy()
|
|
||||||
val a = ""
|
|
||||||
res = getSpilledToVariable().toMap()["L$0"] ?: "lambda fail"
|
|
||||||
println(a)
|
|
||||||
}
|
|
||||||
if (res != "a") {
|
|
||||||
return "" + res
|
|
||||||
}
|
|
||||||
|
|
||||||
builder {
|
|
||||||
suspended()
|
|
||||||
}
|
|
||||||
res = (continuation!! as BaseContinuationImpl).getSpilledVariableFieldMapping()!!.toMap()["L$0"] ?: "suspended fail"
|
|
||||||
if (res != "ss") {
|
|
||||||
return "" + res
|
|
||||||
}
|
|
||||||
|
|
||||||
builder {
|
|
||||||
multipleLocalsInOneSlot()
|
|
||||||
}
|
|
||||||
res = (continuation!! as BaseContinuationImpl).getSpilledVariableFieldMapping()!!.toMap()["I$1"] ?: "multipleLocalsInOneSlot fail 1"
|
|
||||||
if (res != "first") {
|
|
||||||
return "" + res
|
|
||||||
}
|
|
||||||
continuation!!.resumeWith(Result.success(Unit))
|
|
||||||
res = (continuation!! as BaseContinuationImpl).getSpilledVariableFieldMapping()!!.toMap()["I$1"] ?: "multipleLocalsInOneSlot fail 2"
|
|
||||||
if (res != "second") {
|
|
||||||
return "" + res
|
|
||||||
}
|
|
||||||
|
|
||||||
return "OK"
|
|
||||||
}
|
|
||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val arr = arrayOf("a", "b", "c", "d")
|
val arr = arrayOf("a", "b", "c", "d")
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val arr = arrayOf("a", "b", "c", "d")
|
val arr = arrayOf("a", "b", "c", "d")
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val arr = intArrayOf()
|
val arr = intArrayOf()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val arr = intArrayOf(10, 20, 30, 40)
|
val arr = intArrayOf(10, 20, 30, 40)
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val arr = arrayOf("a", "b", "c", "d")
|
val arr = arrayOf("a", "b", "c", "d")
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
var s = ""
|
var s = ""
|
||||||
for (c in "testString") {
|
for (c in "testString") {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun <T : CharSequence> test(sequence: T) {
|
fun <T : CharSequence> test(sequence: T) {
|
||||||
var s = ""
|
var s = ""
|
||||||
for (c in sequence) {
|
for (c in sequence) {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val cs: CharSequence = "abcd"
|
val cs: CharSequence = "abcd"
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((index, x) in "".withIndex()) {
|
for ((index, x) in "".withIndex()) {
|
||||||
return "Loop over empty String should not be executed"
|
return "Loop over empty String should not be executed"
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val s = StringBuilder()
|
val s = StringBuilder()
|
||||||
|
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = "abcd"
|
val xs = "abcd"
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = "abcd"
|
val xs = "abcd"
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = "abcd"
|
val xs = "abcd"
|
||||||
|
|
||||||
fun useAny(x: Any) {}
|
fun useAny(x: Any) {}
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Char.MIN_VALUE
|
const val M = Char.MIN_VALUE
|
||||||
|
|
||||||
fun f(a: Char): Int {
|
fun f(a: Char): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Int.MIN_VALUE
|
const val M = Int.MIN_VALUE
|
||||||
|
|
||||||
fun f(a: Int): Int {
|
fun f(a: Int): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Long.MIN_VALUE
|
const val M = Long.MIN_VALUE
|
||||||
|
|
||||||
fun f(a: Long): Int {
|
fun f(a: Long): Int {
|
||||||
|
|||||||
+9
@@ -1,5 +1,14 @@
|
|||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val a = ArrayList<String>()
|
val a = ArrayList<String>()
|
||||||
a.add("OK")
|
a.add("OK")
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test(s: CharSequence): Int {
|
fun test(s: CharSequence): Int {
|
||||||
var result = 0
|
var result = 0
|
||||||
for (i in s.indices) {
|
for (i in s.indices) {
|
||||||
|
|||||||
compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInCharSequenceTypeParameterIndices.kt
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun <T : CharSequence> test(s: T): Int {
|
fun <T : CharSequence> test(s: T): Int {
|
||||||
var result = 0
|
var result = 0
|
||||||
for (i in s.indices) {
|
for (i in s.indices) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun Collection<Int>.sumIndices(): Int {
|
fun Collection<Int>.sumIndices(): Int {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in indices) {
|
for (i in indices) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in listOf(0, 0, 0, 0).indices) {
|
for (i in listOf(0, 0, 0, 0).indices) {
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun <T : Collection<*>> test(c: T) {
|
fun <T : Collection<*>> test(c: T) {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in c.indices) {
|
for (i in c.indices) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
fun test(coll: Collection<*>?): Int {
|
fun test(coll: Collection<*>?): Int {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in arrayOf("", "", "", "").indices) {
|
for (i in arrayOf("", "", "", "").indices) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in intArrayOf(0, 0, 0, 0).indices) {
|
for (i in intArrayOf(0, 0, 0, 0).indices) {
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf<Any>()
|
val xs = listOf<Any>()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun <T : Iterable<*>> test(iterable: T): String {
|
fun <T : Iterable<*>> test(iterable: T): String {
|
||||||
val s = StringBuilder()
|
val s = StringBuilder()
|
||||||
|
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d")
|
val xs = listOf("a", "b", "c", "d")
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d")
|
val xs = listOf("a", "b", "c", "d")
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d")
|
val xs = listOf("a", "b", "c", "d")
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d")
|
val xs = listOf("a", "b", "c", "d")
|
||||||
|
|
||||||
fun useAny(x: Any) {}
|
fun useAny(x: Any) {}
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun array() = arrayOfNulls<Any>(4)
|
fun array() = arrayOfNulls<Any>(4)
|
||||||
|
|
||||||
fun f(): Int {
|
fun f(): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun intArray() = intArrayOf(0, 0, 0, 0)
|
fun intArray() = intArrayOf(0, 0, 0, 0)
|
||||||
fun longArray() = longArrayOf(0, 0, 0, 0)
|
fun longArray() = longArrayOf(0, 0, 0, 0)
|
||||||
|
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in (7 downTo 4).withIndex()) {
|
for ((i, v) in (7 downTo 4).withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in listOf(4, 5, 6, 7).indices.withIndex()) {
|
for ((i, v) in listOf(4, 5, 6, 7).indices.withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in (4..7).withIndex()) {
|
for ((i, v) in (4..7).withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in ((4..11).reversed() step 2).withIndex()) {
|
for ((i, v) in ((4..11).reversed() step 2).withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in (4..7).reversed().withIndex()) {
|
for ((i, v) in (4..7).reversed().withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in (4..11 step 2).reversed().withIndex()) {
|
for ((i, v) in (4..11 step 2).reversed().withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in (4..11 step 2).withIndex()) {
|
for ((i, v) in (4..11 step 2).withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in (4 until 8).withIndex()) {
|
for ((i, v) in (4 until 8).withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((_, _) in (4..7).withIndex()) {
|
for ((_, _) in (4..7).withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for (iv in (4..7).withIndex()) {
|
for (iv in (4..7).withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((i, v) in (4..7).withIndex().reversed()) {
|
for ((i, v) in (4..7).withIndex().reversed()) {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for ((outer, iv) in (4..7).withIndex().withIndex()) {
|
for ((outer, iv) in (4..7).withIndex().withIndex()) {
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -23,5 +23,10 @@ fun test(): Int {
|
|||||||
|
|
||||||
// JVM_IR_TEMPLATES
|
// JVM_IR_TEMPLATES
|
||||||
// 1 IF_ICMPGT
|
// 1 IF_ICMPGT
|
||||||
// 1 IF_ICMPNE
|
// 1 IF_ICMPEQ
|
||||||
// 2 IF
|
// 2 IF
|
||||||
|
// 7 ILOAD
|
||||||
|
// 4 ISTORE
|
||||||
|
// 1 IINC
|
||||||
|
// 1 IADD
|
||||||
|
// 1 ISUB
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val N = 'Z'
|
const val N = 'Z'
|
||||||
|
|
||||||
fun test(): Int {
|
fun test(): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Char.MAX_VALUE
|
const val M = Char.MAX_VALUE
|
||||||
|
|
||||||
fun f(a: Char): Int {
|
fun f(a: Char): Int {
|
||||||
|
|||||||
@@ -18,7 +18,13 @@ fun test(): Int {
|
|||||||
// JVM_TEMPLATES
|
// JVM_TEMPLATES
|
||||||
// 1 IF_ICMPGT
|
// 1 IF_ICMPGT
|
||||||
// 1 IF
|
// 1 IF
|
||||||
|
// 5 ILOAD
|
||||||
|
// 4 ISTORE
|
||||||
|
// 1 IINC
|
||||||
|
|
||||||
// JVM_IR_TEMPLATES
|
// JVM_IR_TEMPLATES
|
||||||
// 1 IF_ICMPGE
|
// 1 IF_ICMPGE
|
||||||
// 1 IF
|
// 1 IF
|
||||||
|
// 4 ILOAD
|
||||||
|
// 3 ISTORE
|
||||||
|
// 1 IINC
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Int.MAX_VALUE
|
const val M = Int.MAX_VALUE
|
||||||
|
|
||||||
fun f(a: Int): Int {
|
fun f(a: Int): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val N = 42L
|
const val N = 42L
|
||||||
|
|
||||||
fun test(): Long {
|
fun test(): Long {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Long.MAX_VALUE
|
const val M = Long.MAX_VALUE
|
||||||
|
|
||||||
fun f(a: Long): Int {
|
fun f(a: Long): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
object Host {
|
object Host {
|
||||||
const val M = 1
|
const val M = 1
|
||||||
const val N = 4
|
const val N = 4
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun Int.digitsUpto(end: Int): Int {
|
fun Int.digitsUpto(end: Int): Int {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in rangeTo(end)) {
|
for (i in rangeTo(end)) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun intRange() = 1 .. 4
|
fun intRange() = 1 .. 4
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
for (i in (4 .. 1).reversed()) {
|
for (i in (4 .. 1).reversed()) {
|
||||||
throw AssertionError("Loop should not be executed")
|
throw AssertionError("Loop should not be executed")
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun intRange() = 1 .. 4
|
fun intRange() = 1 .. 4
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun intRange() = 1 .. 4
|
fun intRange() = 1 .. 4
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex/forInEmptySequenceWithIndex.kt
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf<Any>().asSequence()
|
val xs = listOf<Any>().asSequence()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun <T : Sequence<*>> test(sequence: T): String {
|
fun <T : Sequence<*>> test(sequence: T): String {
|
||||||
val s = StringBuilder()
|
val s = StringBuilder()
|
||||||
|
|
||||||
|
|||||||
Vendored
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+9
@@ -1,6 +1,15 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xsl = arrayListOf("a", "b", "c", "d")
|
val xsl = arrayListOf("a", "b", "c", "d")
|
||||||
val xs = xsl.asSequence()
|
val xs = xsl.asSequence()
|
||||||
|
|
||||||
|
|||||||
+10
@@ -1,4 +1,14 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
val xs = listOf("a", "b", "c", "d").asSequence()
|
val xs = listOf("a", "b", "c", "d").asSequence()
|
||||||
|
|
||||||
fun useAny(x: Any) {}
|
fun useAny(x: Any) {}
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
var s = ""
|
var s = ""
|
||||||
for (c in "testString") {
|
for (c in "testString") {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test(a: Char, b: Char): String {
|
fun test(a: Char, b: Char): String {
|
||||||
var s = ""
|
var s = ""
|
||||||
for (i in a until b) {
|
for (i in a until b) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Char.MAX_VALUE
|
const val M = Char.MAX_VALUE
|
||||||
|
|
||||||
fun f(a: Char): Int {
|
fun f(a: Char): Int {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Char.MIN_VALUE
|
const val M = Char.MIN_VALUE
|
||||||
|
|
||||||
fun f(a: Char): Int {
|
fun f(a: Char): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test(a: Int, b: Int): Int {
|
fun test(a: Int, b: Int): Int {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in a until b) {
|
for (i in a until b) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Int.MAX_VALUE
|
const val M = Int.MAX_VALUE
|
||||||
|
|
||||||
fun f(a: Int): Int {
|
fun f(a: Int): Int {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Int.MIN_VALUE
|
const val M = Int.MIN_VALUE
|
||||||
|
|
||||||
fun f(a: Int): Int {
|
fun f(a: Int): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test(a: Long, b: Long): Long {
|
fun test(a: Long, b: Long): Long {
|
||||||
var sum = 0L
|
var sum = 0L
|
||||||
for (i in a until b) {
|
for (i in a until b) {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Long.MAX_VALUE
|
const val M = Long.MAX_VALUE
|
||||||
|
|
||||||
fun f(a: Long): Int {
|
fun f(a: Long): Int {
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
const val M = Long.MIN_VALUE
|
const val M = Long.MIN_VALUE
|
||||||
|
|
||||||
fun f(a: Long): Int {
|
fun f(a: Long): Int {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun test(): Int {
|
fun test(): Int {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
for (i in 4 downTo 1) {
|
for (i in 4 downTo 1) {
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
fun intRangeTo(a: Int, b: Int) { for (i in a .. b) {} }
|
fun intRangeTo(a: Int, b: Int) { for (i in a .. b) {} }
|
||||||
|
|||||||
+9
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun Int.toTrue() = true
|
fun Int.toTrue() = true
|
||||||
|
|
||||||
fun testBooleanArray(n: Int) =
|
fun testBooleanArray(n: Int) =
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun f() {
|
fun f() {
|
||||||
for (c in "123") {
|
for (c in "123") {
|
||||||
print(c)
|
print(c)
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun f() {
|
fun f() {
|
||||||
for (i in 1..2) {
|
for (i in 1..2) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun f(a: Int, b: Int) {
|
fun f(a: Int, b: Int) {
|
||||||
for (i in a..b) {
|
for (i in a..b) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
// IMPORTANT!
|
||||||
|
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||||
|
// examine the resulting bytecode shape carefully.
|
||||||
|
// Range and progression-based loops generated with Kotlin compiler should be
|
||||||
|
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||||
|
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||||
|
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||||
|
// with compiler built from your changes if you are not sure.
|
||||||
|
|
||||||
fun f() {
|
fun f() {
|
||||||
for (i in 0..5 step 2) {
|
for (i in 0..5 step 2) {
|
||||||
}
|
}
|
||||||
@@ -11,36 +20,6 @@ fun f() {
|
|||||||
// JVM non-IR does NOT specifically handle "step" progressions. The stepped progressions in the above code are constructed and their
|
// JVM non-IR does NOT specifically handle "step" progressions. The stepped progressions in the above code are constructed and their
|
||||||
// first/last/step properties are retrieved.
|
// first/last/step properties are retrieved.
|
||||||
// JVM IR has an optimized handler for "step" progressions and elides the construction of the stepped progressions.
|
// JVM IR has an optimized handler for "step" progressions and elides the construction of the stepped progressions.
|
||||||
//
|
|
||||||
// Expected lowered form of `for (i in 0..5 step 2)`:
|
|
||||||
//
|
|
||||||
// // Standard form of loop over progression
|
|
||||||
// var inductionVar = 0
|
|
||||||
// val last = getProgressionLastElement(0, 5, 2)
|
|
||||||
// val step = 2
|
|
||||||
// if (inductionVar <= last) {
|
|
||||||
// // Loop is not empty
|
|
||||||
// do {
|
|
||||||
// val i = inductionVar
|
|
||||||
// inductionVar += step
|
|
||||||
// // Loop body
|
|
||||||
// } while (i != last)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Expected lowered form of `for (i in 5 downTo 1 step 1)`:
|
|
||||||
//
|
|
||||||
// // Standard form of loop over progression
|
|
||||||
// var inductionVar = 5
|
|
||||||
// val last = 1
|
|
||||||
// val step = -1
|
|
||||||
// if (last <= inductionVar) { // Optimized out in bytecode
|
|
||||||
// // Loop is not empty
|
|
||||||
// do {
|
|
||||||
// val i = inductionVar
|
|
||||||
// inductionVar += step
|
|
||||||
// // Loop body
|
|
||||||
// } while (last <= inductionVar)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 0 iterator
|
// 0 iterator
|
||||||
|
|
||||||
@@ -56,7 +35,12 @@ fun f() {
|
|||||||
// 0 getLast
|
// 0 getLast
|
||||||
// 0 getStep
|
// 0 getStep
|
||||||
// 1 IF_ICMPGT
|
// 1 IF_ICMPGT
|
||||||
// 1 IF_ICMPNE
|
// 1 IF_ICMPEQ
|
||||||
// 1 IF_ICMPLE
|
// 1 IF_ICMPLE
|
||||||
// 3 IF
|
// 3 IF
|
||||||
// 1 INVOKESTATIC kotlin/internal/ProgressionUtilKt.getProgressionLastElement \(III\)I
|
// 1 INVOKESTATIC kotlin/internal/ProgressionUtilKt.getProgressionLastElement \(III\)I
|
||||||
|
// 6 ILOAD
|
||||||
|
// 4 ISTORE
|
||||||
|
// 2 IINC
|
||||||
|
// 0 IADD
|
||||||
|
// 0 ISUB
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user