diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java index cac66eca8d8..36e41963be1 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java @@ -43,6 +43,11 @@ public abstract class CommonCompilerArguments { @Argument(value = "Xno-inline", description = "Disable method inlining") public boolean noInline; + // TODO Remove in 1.0 + @Argument(value = "Xrepeat", description = "Repeat compilation (for performance analysis)") + @ValueDescription("") + public String repeat; + @Argument(value = "Xplugin", description = "Load plugins from the given classpath") @ValueDescription("") public String[] pluginClasspaths; diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java index 488d099be7a..721bf5b9ce0 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java @@ -144,15 +144,29 @@ public abstract class CLICompiler { GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector); try { - Disposable rootDisposable = Disposer.newDisposable(); - try { - MessageSeverityCollector severityCollector = new MessageSeverityCollector(groupingCollector); - ExitCode code = doExecute(arguments, services, severityCollector, rootDisposable); - return severityCollector.anyReported(CompilerMessageSeverity.ERROR) ? COMPILATION_ERROR : code; + ExitCode exitCode = OK; + + int repeatCount = 1; + if (arguments.repeat != null) { + try { + repeatCount = Integer.parseInt(arguments.repeat); + } + catch (NumberFormatException ignored) { + } } - finally { - Disposer.dispose(rootDisposable); + + for (int i = 0; i < repeatCount; i++) { + Disposable rootDisposable = Disposer.newDisposable(); + try { + MessageSeverityCollector severityCollector = new MessageSeverityCollector(groupingCollector); + ExitCode code = doExecute(arguments, services, severityCollector, rootDisposable); + exitCode = severityCollector.anyReported(CompilerMessageSeverity.ERROR) ? COMPILATION_ERROR : code; + } + finally { + Disposer.dispose(rootDisposable); + } } + return exitCode; } catch (Throwable t) { groupingCollector.report(CompilerMessageSeverity.EXCEPTION, OutputMessageUtil.renderException(t), diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 8906cbcd4e5..a0622d5f289 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -1,6 +1,7 @@ Usage: kotlinc-js where advanced options include: -Xno-inline Disable method inlining + -Xrepeat Repeat compilation (for performance analysis) -Xplugin Load plugins from the given classpath Advanced options are non-standard and may be changed or removed without any notice. diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 841cb7dc84a..5bc3a7a881d 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -5,6 +5,7 @@ where advanced options include: -Xno-optimize Disable optimizations -Xreport-perf Report detailed performance statistics -Xno-inline Disable method inlining + -Xrepeat Repeat compilation (for performance analysis) -Xplugin Load plugins from the given classpath Advanced options are non-standard and may be changed or removed without any notice.