[Wasm] Enable for loops optimization
This commit is contained in:
committed by
Svyatoslav Kuzmich
parent
233bb47b99
commit
7f26deb5e6
+3
-1
@@ -382,7 +382,9 @@ internal class IndexedGetLoopHeader(
|
||||
with(builder) {
|
||||
// loopVariable = objectVariable[inductionVariable]
|
||||
val indexedGetFun = with(headerInfo.expressionHandler) { headerInfo.objectVariable.type.getFunction }
|
||||
val get = irCall(indexedGetFun.symbol).apply {
|
||||
// Making sure that expression type has type of the variable when it exists.
|
||||
// Return type of get function can be a type parameter (for example Array<T>::get) which is not a subtype of loopVariable type.
|
||||
val get = irCall(indexedGetFun.symbol, type = loopVariable?.type ?: indexedGetFun.returnType).apply {
|
||||
dispatchReceiver = irGet(headerInfo.objectVariable)
|
||||
putValueArgument(0, irGet(inductionVariable))
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.backend.wasm
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.lower.*
|
||||
import org.jetbrains.kotlin.backend.common.lower.inline.FunctionInlining
|
||||
import org.jetbrains.kotlin.backend.common.lower.loops.ForLoopsLowering
|
||||
import org.jetbrains.kotlin.backend.common.phaser.*
|
||||
import org.jetbrains.kotlin.backend.wasm.lower.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.*
|
||||
@@ -399,6 +400,12 @@ private val virtualDispatchReceiverExtractionPhase = makeWasmModulePhase(
|
||||
description = "Eliminate side-effects in dispatch receivers of virtual function calls"
|
||||
)
|
||||
|
||||
private val forLoopsLoweringPhase = makeWasmModulePhase(
|
||||
::ForLoopsLowering,
|
||||
name = "ForLoopsLowering",
|
||||
description = "[Optimization] For loops lowering"
|
||||
)
|
||||
|
||||
val wasmPhases = NamedCompilerPhase(
|
||||
name = "IrModuleLowering",
|
||||
description = "IR module lowering",
|
||||
@@ -447,6 +454,9 @@ val wasmPhases = NamedCompilerPhase(
|
||||
|
||||
stringConstructorLowering then
|
||||
returnableBlockLoweringPhase then
|
||||
|
||||
forLoopsLoweringPhase then
|
||||
|
||||
defaultArgumentStubGeneratorPhase then
|
||||
defaultArgumentPatchOverridesPhase then
|
||||
defaultParameterInjectorPhase then
|
||||
|
||||
Reference in New Issue
Block a user