Move daemon jar from compiler
This commit is contained in:
@@ -10,11 +10,12 @@ dependencies {
|
||||
compile(project(":core:descriptors.jvm"))
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:cli-common"))
|
||||
compile(project(":kotlin-build-common"))
|
||||
compile(kotlinStdlib())
|
||||
compileOnly(project(":js:js.frontend"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
||||
compile(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8")) {
|
||||
compile(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) {
|
||||
isTransitive = false
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.daemon.common
|
||||
|
||||
import org.jetbrains.kotlin.incremental.IncrementalModuleInfo
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.daemon.common
|
||||
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
|
||||
data class IncrementalModuleEntry(
|
||||
private val projectPath: String,
|
||||
val name: String,
|
||||
val buildDir: File,
|
||||
val buildHistoryFile: File
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = 0L
|
||||
}
|
||||
}
|
||||
|
||||
class IncrementalModuleInfo(
|
||||
val projectRoot: File,
|
||||
val dirToModule: Map<File, IncrementalModuleEntry>,
|
||||
val nameToModules: Map<String, Set<IncrementalModuleEntry>>,
|
||||
val jarToClassListFile: Map<File, File>,
|
||||
// only for js and mpp
|
||||
val jarToModule: Map<File, IncrementalModuleEntry>
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = 0L
|
||||
}
|
||||
}
|
||||
+12
-6
@@ -73,25 +73,31 @@ object LoopbackNetworkInterface {
|
||||
override fun createServerSocket(port: Int): ServerSocket = ServerSocket(port, SERVER_SOCKET_BACKLOG_SIZE, InetAddress.getByName(null))
|
||||
}
|
||||
|
||||
|
||||
class ClientLoopbackSocketFactory : RMIClientSocketFactory, Serializable {
|
||||
abstract class AbstractClientLoopbackSocketFactory<SocketType> : Serializable {
|
||||
override fun equals(other: Any?): Boolean = other === this || super.equals(other)
|
||||
override fun hashCode(): Int = super.hashCode()
|
||||
|
||||
abstract protected fun socketCreate(host: String, port: Int): SocketType
|
||||
|
||||
@Throws(IOException::class)
|
||||
override fun createSocket(host: String, port: Int): Socket {
|
||||
fun createSocket(host: String, port: Int): SocketType {
|
||||
var attemptsLeft = SOCKET_CONNECT_ATTEMPTS
|
||||
while (true) {
|
||||
try {
|
||||
return Socket(InetAddress.getByName(null), port)
|
||||
}
|
||||
catch (e: ConnectException) {
|
||||
return socketCreate(host, port)
|
||||
} catch (e: ConnectException) {
|
||||
if (--attemptsLeft <= 0) throw e
|
||||
}
|
||||
Thread.sleep(SOCKET_CONNECT_INTERVAL_MS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ClientLoopbackSocketFactory : AbstractClientLoopbackSocketFactory<java.net.Socket>(), RMIClientSocketFactory {
|
||||
override fun socketCreate(host: String, port: Int): Socket = Socket(InetAddress.getByName(null), port)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -93,22 +93,22 @@ inline fun usedMemory(withGC: Boolean): Long {
|
||||
}
|
||||
|
||||
|
||||
inline fun<R> beginWithMeasureWallTime(perfCounters: PerfCounters) = listOf(System.nanoTime())
|
||||
inline fun beginMeasureWallTime() = listOf(System.nanoTime())
|
||||
|
||||
inline fun<R> endWithMeasureWallTime(perfCounters: PerfCounters, startState: List<Long>) {
|
||||
inline fun endMeasureWallTime(perfCounters: PerfCounters, startState: List<Long>) {
|
||||
val (startTime) = startState
|
||||
perfCounters.addMeasurement(time = System.nanoTime() - startTime) // TODO: add support for time wrapping
|
||||
}
|
||||
|
||||
|
||||
inline fun beginWithMeasureWallAndThreadTimes(perfCounters: PerfCounters, threadMXBean: ThreadMXBean): List<Long> {
|
||||
inline fun beginMeasureWallAndThreadTimes(perfCounters: PerfCounters, threadMXBean: ThreadMXBean): List<Long> {
|
||||
val startTime = System.nanoTime()
|
||||
val startThreadTime = threadMXBean.threadCpuTime()
|
||||
val startThreadUserTime = threadMXBean.threadUserTime()
|
||||
return listOf(startTime, startThreadTime, startThreadUserTime)
|
||||
}
|
||||
|
||||
inline fun endWithMeasureWallAndThreadTimes(perfCounters: PerfCounters, threadMXBean: ThreadMXBean, startState: List<Long>) {
|
||||
inline fun endMeasureWallAndThreadTimes(perfCounters: PerfCounters, threadMXBean: ThreadMXBean, startState: List<Long>) {
|
||||
val (startTime, startThreadTime, startThreadUserTime) = startState
|
||||
|
||||
// TODO: add support for time wrapping
|
||||
@@ -117,12 +117,12 @@ inline fun endWithMeasureWallAndThreadTimes(perfCounters: PerfCounters, threadMX
|
||||
threadUser = threadMXBean.threadUserTime() - startThreadUserTime)
|
||||
}
|
||||
|
||||
inline fun beginWithMeasureWallAndThreadTimes(perfCounters: PerfCounters) =
|
||||
beginWithMeasureWallAndThreadTimes(perfCounters, ManagementFactory.getThreadMXBean())
|
||||
inline fun endWithMeasureWallAndThreadTimes(perfCounters: PerfCounters, startState: List<Long>) =
|
||||
endWithMeasureWallAndThreadTimes(perfCounters, ManagementFactory.getThreadMXBean(), startState)
|
||||
inline fun beginMeasureWallAndThreadTimes(perfCounters: PerfCounters) =
|
||||
beginMeasureWallAndThreadTimes(perfCounters, ManagementFactory.getThreadMXBean())
|
||||
inline fun endMeasureWallAndThreadTimes(perfCounters: PerfCounters, startState: List<Long>) =
|
||||
endMeasureWallAndThreadTimes(perfCounters, ManagementFactory.getThreadMXBean(), startState)
|
||||
|
||||
inline fun beginWithMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean = false, threadMXBean: ThreadMXBean): List<Long> {
|
||||
inline fun beginMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean = false, threadMXBean: ThreadMXBean): List<Long> {
|
||||
val startMem = usedMemory(withGC)
|
||||
val startTime = System.nanoTime()
|
||||
val startThreadTime = threadMXBean.threadCpuTime()
|
||||
@@ -131,7 +131,7 @@ inline fun beginWithMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounter
|
||||
return listOf(startMem, startTime, startThreadTime, startThreadUserTime)
|
||||
}
|
||||
|
||||
inline fun endWithMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean = false, threadMXBean: ThreadMXBean, startState: List<Long>){
|
||||
inline fun endMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean = false, threadMXBean: ThreadMXBean, startState: List<Long>){
|
||||
val (startMem, startTime, startThreadTime, startThreadUserTime) = startState
|
||||
|
||||
// TODO: add support for time wrapping
|
||||
@@ -141,11 +141,11 @@ inline fun endWithMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters,
|
||||
memory = usedMemory(withGC) - startMem)
|
||||
}
|
||||
|
||||
inline fun<R> beginWithMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean) =
|
||||
beginWithMeasureWallAndThreadTimesAndMemory(perfCounters, withGC, ManagementFactory.getThreadMXBean())
|
||||
inline fun<R> beginMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean) =
|
||||
beginMeasureWallAndThreadTimesAndMemory(perfCounters, withGC, ManagementFactory.getThreadMXBean())
|
||||
|
||||
inline fun<R> endWithMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean, startState: List<Long>) =
|
||||
endWithMeasureWallAndThreadTimesAndMemory(perfCounters, withGC, ManagementFactory.getThreadMXBean(), startState)
|
||||
inline fun<R> endMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean, startState: List<Long>) =
|
||||
endMeasureWallAndThreadTimesAndMemory(perfCounters, withGC, ManagementFactory.getThreadMXBean(), startState)
|
||||
|
||||
|
||||
class DummyProfiler : Profiler {
|
||||
@@ -166,27 +166,27 @@ abstract class TotalProfiler : Profiler {
|
||||
|
||||
class WallTotalProfiler : TotalProfiler() {
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun beginMeasure(obj: Any?) = beginWithMeasureWallTime(total)
|
||||
override inline fun beginMeasure(obj: Any?) = beginMeasureWallTime()
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun endMeasure(obj: Any?, startState: List<Long>) = endWithMeasureWallTime(total, startState)
|
||||
override inline fun endMeasure(obj: Any?, startState: List<Long>) = endMeasureWallTime(total, startState)
|
||||
}
|
||||
|
||||
|
||||
class WallAndThreadTotalProfiler : TotalProfiler() {
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun beginMeasure(obj: Any?) = beginWithMeasureWallAndThreadTimes(total, threadMXBean)
|
||||
override inline fun beginMeasure(obj: Any?) = beginMeasureWallAndThreadTimes(total, threadMXBean)
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun endMeasure(obj: Any?, startState: List<Long>) = endWithMeasureWallAndThreadTimes(total, threadMXBean, startState)
|
||||
override inline fun endMeasure(obj: Any?, startState: List<Long>) = endMeasureWallAndThreadTimes(total, threadMXBean, startState)
|
||||
}
|
||||
|
||||
|
||||
class WallAndThreadAndMemoryTotalProfiler(val withGC: Boolean) : TotalProfiler() {
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun beginMeasure(obj: Any?) =
|
||||
beginWithMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean)
|
||||
beginMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean)
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun endMeasure(obj: Any?, startState: List<Long>) =
|
||||
endWithMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean, startState)
|
||||
endMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean, startState)
|
||||
}
|
||||
|
||||
|
||||
@@ -198,8 +198,8 @@ class WallAndThreadByClassProfiler() : TotalProfiler() {
|
||||
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun beginMeasure(obj: Any?) =
|
||||
beginWithMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean)
|
||||
beginMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean)
|
||||
@Suppress("OVERRIDE_BY_INLINE")
|
||||
override inline fun endMeasure(obj: Any?, startState: List<Long>) =
|
||||
endWithMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean, startState)
|
||||
endMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean, startState)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user