Merge ES6 pipeline
This commit is contained in:
@@ -637,86 +637,6 @@ private val cleanupLoweringPhase = makeBodyLoweringPhase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
val loweringList = listOf<Lowering>(
|
val loweringList = listOf<Lowering>(
|
||||||
scriptRemoveReceiverLowering,
|
|
||||||
validateIrBeforeLowering,
|
|
||||||
testGenerationPhase,
|
|
||||||
expectDeclarationsRemovingPhase,
|
|
||||||
stripTypeAliasDeclarationsPhase,
|
|
||||||
arrayConstructorPhase,
|
|
||||||
lateinitNullableFieldsPhase,
|
|
||||||
lateinitDeclarationLoweringPhase,
|
|
||||||
lateinitUsageLoweringPhase,
|
|
||||||
sharedVariablesLoweringPhase,
|
|
||||||
localClassesInInlineLambdasPhase,
|
|
||||||
localClassesInInlineFunctionsPhase,
|
|
||||||
localClassesExtractionFromInlineFunctionsPhase,
|
|
||||||
functionInliningPhase,
|
|
||||||
copyInlineFunctionBodyLoweringPhase,
|
|
||||||
createScriptFunctionsPhase,
|
|
||||||
callableReferenceLowering,
|
|
||||||
singleAbstractMethodPhase,
|
|
||||||
tailrecLoweringPhase,
|
|
||||||
enumClassConstructorLoweringPhase,
|
|
||||||
enumClassConstructorBodyLoweringPhase,
|
|
||||||
localDelegatedPropertiesLoweringPhase,
|
|
||||||
localDeclarationsLoweringPhase,
|
|
||||||
localClassExtractionPhase,
|
|
||||||
innerClassesLoweringPhase,
|
|
||||||
innerClassesMemberBodyLoweringPhase,
|
|
||||||
innerClassConstructorCallsLoweringPhase,
|
|
||||||
propertiesLoweringPhase,
|
|
||||||
primaryConstructorLoweringPhase,
|
|
||||||
delegateToPrimaryConstructorLoweringPhase,
|
|
||||||
annotationConstructorLowering,
|
|
||||||
initializersLoweringPhase,
|
|
||||||
initializersCleanupLoweringPhase,
|
|
||||||
kotlinNothingValueExceptionPhase,
|
|
||||||
// Common prefix ends
|
|
||||||
enumEntryInstancesLoweringPhase,
|
|
||||||
enumEntryInstancesBodyLoweringPhase,
|
|
||||||
enumClassCreateInitializerLoweringPhase,
|
|
||||||
enumEntryCreateGetInstancesFunsLoweringPhase,
|
|
||||||
enumSyntheticFunsLoweringPhase,
|
|
||||||
enumUsageLoweringPhase,
|
|
||||||
enumEntryRemovalLoweringPhase,
|
|
||||||
suspendFunctionsLoweringPhase,
|
|
||||||
propertyReferenceLoweringPhase,
|
|
||||||
interopCallableReferenceLoweringPhase,
|
|
||||||
returnableBlockLoweringPhase,
|
|
||||||
forLoopsLoweringPhase,
|
|
||||||
primitiveCompanionLoweringPhase,
|
|
||||||
propertyAccessorInlinerLoweringPhase,
|
|
||||||
foldConstantLoweringPhase,
|
|
||||||
privateMembersLoweringPhase,
|
|
||||||
privateMemberUsagesLoweringPhase,
|
|
||||||
defaultArgumentStubGeneratorPhase,
|
|
||||||
defaultArgumentPatchOverridesPhase,
|
|
||||||
defaultParameterInjectorPhase,
|
|
||||||
defaultParameterCleanerPhase,
|
|
||||||
jsDefaultCallbackGeneratorPhase,
|
|
||||||
removeInlineFunctionsWithReifiedTypeParametersLoweringPhase,
|
|
||||||
throwableSuccessorsLoweringPhase,
|
|
||||||
varargLoweringPhase,
|
|
||||||
multipleCatchesLoweringPhase,
|
|
||||||
bridgesConstructionPhase,
|
|
||||||
typeOperatorLoweringPhase,
|
|
||||||
secondaryConstructorLoweringPhase,
|
|
||||||
secondaryFactoryInjectorLoweringPhase,
|
|
||||||
classReferenceLoweringPhase,
|
|
||||||
inlineClassDeclarationLoweringPhase,
|
|
||||||
inlineClassUsageLoweringPhase,
|
|
||||||
autoboxingTransformerPhase,
|
|
||||||
blockDecomposerLoweringPhase,
|
|
||||||
constLoweringPhase,
|
|
||||||
objectDeclarationLoweringPhase,
|
|
||||||
objectUsageLoweringPhase,
|
|
||||||
captureStackTraceInThrowablesPhase,
|
|
||||||
callsLoweringPhase,
|
|
||||||
cleanupLoweringPhase,
|
|
||||||
validateIrAfterLowering
|
|
||||||
)
|
|
||||||
|
|
||||||
val es6LoweringList = listOf<Lowering>(
|
|
||||||
scriptRemoveReceiverLowering,
|
scriptRemoveReceiverLowering,
|
||||||
validateIrBeforeLowering,
|
validateIrBeforeLowering,
|
||||||
testGenerationPhase,
|
testGenerationPhase,
|
||||||
@@ -782,6 +702,7 @@ val es6LoweringList = listOf<Lowering>(
|
|||||||
multipleCatchesLoweringPhase,
|
multipleCatchesLoweringPhase,
|
||||||
bridgesConstructionPhase,
|
bridgesConstructionPhase,
|
||||||
typeOperatorLoweringPhase,
|
typeOperatorLoweringPhase,
|
||||||
|
secondaryConstructorLoweringPhase,
|
||||||
secondaryFactoryInjectorLoweringPhase,
|
secondaryFactoryInjectorLoweringPhase,
|
||||||
classReferenceLoweringPhase,
|
classReferenceLoweringPhase,
|
||||||
inlineClassDeclarationLoweringPhase,
|
inlineClassDeclarationLoweringPhase,
|
||||||
@@ -808,11 +729,3 @@ val jsPhases = namedIrModulePhase(
|
|||||||
acc.then(lowering.modulePhase)
|
acc.then(lowering.modulePhase)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val jsEs6Phases = namedIrModulePhase(
|
|
||||||
name = "ES6IrModuleLowering",
|
|
||||||
description = "ES6 IR module lowering",
|
|
||||||
lower = es6LoweringList.drop(1).fold(es6LoweringList[0].modulePhase) { acc: CompilerPhase<JsIrBackendContext, IrModuleFragment, IrModuleFragment>, lowering ->
|
|
||||||
acc.then(lowering.modulePhase)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -98,8 +98,7 @@ fun compile(
|
|||||||
val transformer = IrModuleToJsTransformer(context, mainFunction, mainArguments)
|
val transformer = IrModuleToJsTransformer(context, mainFunction, mainArguments)
|
||||||
return transformer.generateModule(moduleFragment, fullJs = true, dceJs = false)
|
return transformer.generateModule(moduleFragment, fullJs = true, dceJs = false)
|
||||||
} else {
|
} else {
|
||||||
val phases = if (es6mode) jsEs6Phases else jsPhases
|
jsPhases.invokeToplevel(phaseConfig, context, moduleFragment)
|
||||||
phases.invokeToplevel(phaseConfig, context, moduleFragment)
|
|
||||||
val transformer = IrModuleToJsTransformer(context, mainFunction, mainArguments)
|
val transformer = IrModuleToJsTransformer(context, mainFunction, mainArguments)
|
||||||
return transformer.generateModule(moduleFragment, generateFullJs, generateDceJs)
|
return transformer.generateModule(moduleFragment, generateFullJs, generateDceJs)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ class ES6AddInternalParametersToConstructorPhase(val context: JsIrBackendContext
|
|||||||
object ES6_RESULT_TYPE_PARAMETER : IrDeclarationOriginImpl("ES6_RESULT_TYPE_PARAMETER")
|
object ES6_RESULT_TYPE_PARAMETER : IrDeclarationOriginImpl("ES6_RESULT_TYPE_PARAMETER")
|
||||||
|
|
||||||
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||||
assert(context.es6mode)
|
if (!context.es6mode) return
|
||||||
|
|
||||||
container.transform(CallSiteTransformer(), null)
|
container.transform(CallSiteTransformer(), null)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ object ES6_THIS_VARIABLE_ORIGIN : IrDeclarationOriginImpl("ES6_THIS_VARIABLE_ORI
|
|||||||
|
|
||||||
class ES6ConstructorLowering(val context: JsIrBackendContext) : BodyLoweringPass {
|
class ES6ConstructorLowering(val context: JsIrBackendContext) : BodyLoweringPass {
|
||||||
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||||
assert(context.es6mode)
|
if (!context.es6mode) return
|
||||||
|
|
||||||
if (container !is IrConstructor) return
|
if (container !is IrConstructor) return
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
|||||||
class SecondaryConstructorLowering(val context: JsIrBackendContext) : DeclarationTransformer {
|
class SecondaryConstructorLowering(val context: JsIrBackendContext) : DeclarationTransformer {
|
||||||
|
|
||||||
override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
|
override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
|
||||||
assert(!context.es6mode)
|
if (context.es6mode) return null
|
||||||
|
|
||||||
if (declaration is IrConstructor && !declaration.isPrimary) {
|
if (declaration is IrConstructor && !declaration.isPrimary) {
|
||||||
val irClass = declaration.parentAsClass
|
val irClass = declaration.parentAsClass
|
||||||
|
|||||||
@@ -107,20 +107,19 @@ abstract class BasicIrBoxTest(
|
|||||||
if (isMainModule) {
|
if (isMainModule) {
|
||||||
val debugMode = getBoolean("kotlin.js.debugMode")
|
val debugMode = getBoolean("kotlin.js.debugMode")
|
||||||
|
|
||||||
val phases = if (runEs6Mode) jsEs6Phases else jsPhases
|
|
||||||
val phaseConfig = if (debugMode) {
|
val phaseConfig = if (debugMode) {
|
||||||
val allPhasesSet = phases.toPhaseMap().values.toSet()
|
val allPhasesSet = jsPhases.toPhaseMap().values.toSet()
|
||||||
val dumpOutputDir = File(outputFile.parent, outputFile.nameWithoutExtension + "-irdump")
|
val dumpOutputDir = File(outputFile.parent, outputFile.nameWithoutExtension + "-irdump")
|
||||||
println("\n ------ Dumping phases to file://$dumpOutputDir")
|
println("\n ------ Dumping phases to file://$dumpOutputDir")
|
||||||
PhaseConfig(
|
PhaseConfig(
|
||||||
phases,
|
jsPhases,
|
||||||
dumpToDirectory = dumpOutputDir.path,
|
dumpToDirectory = dumpOutputDir.path,
|
||||||
toDumpStateAfter = allPhasesSet,
|
toDumpStateAfter = allPhasesSet,
|
||||||
toValidateStateAfter = allPhasesSet,
|
toValidateStateAfter = allPhasesSet,
|
||||||
dumpOnlyFqName = null
|
dumpOnlyFqName = null
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
PhaseConfig(phases)
|
PhaseConfig(jsPhases)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skipRegularMode) {
|
if (!skipRegularMode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user