Revert "IJPL-166 coroutine dump without byte-buddy (final variant #10)"

This reverts commit 4c661ba2

GitOrigin-RevId: dfc8542b326af558428adbb9a403fdd65a6fe313
This commit is contained in:
Vladimir Krivosheev
2024-03-04 13:16:52 +01:00
committed by intellij-monorepo-bot
parent 6a26cd0e03
commit 82fc2d4219
11 changed files with 23 additions and 99 deletions

1
.idea/modules.xml generated
View File

@@ -904,7 +904,6 @@
<module fileurl="file://$PROJECT_DIR$/platform/platform-tests/benchmarks/intellij.platform.benchmarks.iml" filepath="$PROJECT_DIR$/platform/platform-tests/benchmarks/intellij.platform.benchmarks.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/boot/intellij.platform.boot.iml" filepath="$PROJECT_DIR$/platform/boot/intellij.platform.boot.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/bootstrap/intellij.platform.bootstrap.iml" filepath="$PROJECT_DIR$/platform/bootstrap/intellij.platform.bootstrap.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/bootstrap/coroutine/intellij.platform.bootstrap.coroutine.iml" filepath="$PROJECT_DIR$/platform/bootstrap/coroutine/intellij.platform.bootstrap.coroutine.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/bootstrap/dev/intellij.platform.bootstrap.dev.iml" filepath="$PROJECT_DIR$/platform/bootstrap/dev/intellij.platform.bootstrap.dev.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/build-scripts/intellij.platform.buildScripts.iml" filepath="$PROJECT_DIR$/platform/build-scripts/intellij.platform.buildScripts.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/build-scripts/codeOptimizer/intellij.platform.buildScripts.codeOptimizer.iml" filepath="$PROJECT_DIR$/platform/build-scripts/codeOptimizer/intellij.platform.buildScripts.codeOptimizer.iml" />

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="5" platform="JVM 1.8" allPlatforms="JVM [1.8]" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-Xjvm-default=all" />
</compilerSettings>
<compilerArguments>
<stringArguments>
<stringArg name="jvmTarget" arg="1.8" />
<stringArg name="apiVersion" arg="1.9" />
<stringArg name="languageVersion" arg="1.9" />
</stringArguments>
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-debug" level="project" />
</component>
</module>

View File

@@ -1,23 +0,0 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package kotlin.coroutines.jvm.internal;
// cannot be in DebugProbesKt - in some context our override of class DebugProbesKt maybe not loaded
@SuppressWarnings({"KotlinInternalInJava", "UnnecessaryFullyQualifiedName", "RedundantSuppression"})
public final class CoroutineDumpState {
// not volatile - that's ok to miss something
static boolean INSTALLED = false;
public static void install() {
if (INSTALLED) {
return;
}
// set to true - otherwise, install will try to load byte-buddy
kotlinx.coroutines.debug.internal.AgentInstallationType.INSTANCE.setInstalledStatically$kotlinx_coroutines_core(true);
kotlinx.coroutines.debug.internal.DebugProbesImpl debugProbes = kotlinx.coroutines.debug.internal.DebugProbesImpl.INSTANCE;
debugProbes.setEnableCreationStackTraces$kotlinx_coroutines_core(false);
debugProbes.install$kotlinx_coroutines_core();
INSTALLED = true;
}
}

View File

@@ -1,28 +0,0 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package kotlin.coroutines.jvm.internal;
import kotlin.coroutines.Continuation;
@SuppressWarnings({"KotlinInternalInJava", "RedundantSuppression", "unchecked", "UnnecessaryFullyQualifiedName", "unused", "rawtypes"})
public final class DebugProbesKt {
public static <T> Continuation<T> probeCoroutineCreated(Continuation completion) {
if (CoroutineDumpState.INSTALLED) {
return kotlinx.coroutines.debug.internal.DebugProbesImpl.INSTANCE.probeCoroutineCreated$kotlinx_coroutines_core(completion);
}
else {
return completion;
}
}
public static void probeCoroutineResumed(Continuation frame) {
if (CoroutineDumpState.INSTALLED) {
kotlinx.coroutines.debug.internal.DebugProbesImpl.INSTANCE.probeCoroutineResumed$kotlinx_coroutines_core(frame);
}
}
public static void probeCoroutineSuspended(Continuation frame) {
if (CoroutineDumpState.INSTALLED) {
kotlinx.coroutines.debug.internal.DebugProbesImpl.INSTANCE.probeCoroutineSuspended$kotlinx_coroutines_core(frame);
}
}
}

View File

@@ -18,6 +18,7 @@
<orderEntry type="module" module-name="intellij.platform.runtime.product" />
<orderEntry type="module" module-name="intellij.platform.diagnostic" />
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry.impl" />
<orderEntry type="library" name="kotlinx-coroutines-debug" level="project" />
</component>
<component name="copyright">
<Base>

View File

@@ -200,9 +200,6 @@ internal suspend fun createPlatformLayout(addPlatformCoverage: Boolean,
"intellij.platform.diagnostic",
"intellij.platform.util",
"intellij.platform.core",
// it has package `kotlin.coroutines.jvm.internal` - should be packed into the same JAR as coroutine lib,
// to ensure that package index will not report one more JAR in a search path
"intellij.platform.bootstrap.coroutine",
), productLayout = productLayout, layout = layout)
// used by jdom - pack to the same JAR
layout.withProjectLibrary(libraryName = "aalto-xml", jarName = UTIL_8_JAR)

View File

@@ -375,8 +375,8 @@ private fun getIgnoredNames(): Set<String> {
set.add("META-INF/$name.md")
}
}
set.add("kotlinx/coroutines/debug/internal/ByteBuddyDynamicAttach.class")
set.add("kotlin/coroutines/jvm/internal/DebugProbesKt.class")
//set.add("kotlinx/coroutines/debug/internal/ByteBuddyDynamicAttach.class")
//set.add("kotlin/coroutines/jvm/internal/DebugProbesKt.class")
return java.util.Set.copyOf(set)
}
@@ -429,7 +429,7 @@ private fun checkNameForZipSource(name: String, excludes: List<Regex>, includeMa
!name.startsWith("META-INF/versions/10/org/bouncycastle/") &&
!name.startsWith("META-INF/versions/15/org/bouncycastle/") &&
!name.startsWith("kotlinx/coroutines/repackaged/") &&
//!name.startsWith("kotlinx/coroutines/repackaged/") &&
!name.startsWith("native/") &&
!name.startsWith("licenses/") &&

View File

@@ -141,7 +141,6 @@
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
<orderEntry type="library" name="jetbrains.intellij.deps.rwmutex.idea" level="project" />
<orderEntry type="module" module-name="intellij.platform.bootstrap.coroutine" />
<orderEntry type="library" name="lz4-java" level="project" />
<orderEntry type="module" module-name="intellij.platform.ml" />
</component>

View File

@@ -7,6 +7,7 @@ package com.intellij.platform.ide.bootstrap
import com.intellij.diagnostic.COROUTINE_DUMP_HEADER
import com.intellij.diagnostic.LoadingState
import com.intellij.diagnostic.dumpCoroutines
import com.intellij.diagnostic.enableCoroutineDump
import com.intellij.diagnostic.logs.LogLevelConfigurationManager
import com.intellij.ide.*
import com.intellij.ide.bootstrap.InitAppContext
@@ -56,6 +57,7 @@ import com.intellij.util.PlatformUtils
import com.intellij.util.io.URLUtil
import com.intellij.util.io.createDirectories
import com.intellij.util.lang.ZipFilePool
import com.intellij.util.system.CpuArch
import com.jetbrains.JBR
import kotlinx.coroutines.*
import org.jetbrains.annotations.ApiStatus.Internal
@@ -66,7 +68,6 @@ import java.nio.file.Files
import java.nio.file.Path
import java.util.concurrent.CancellationException
import java.util.function.BiFunction
import kotlin.coroutines.jvm.internal.CoroutineDumpState
import kotlin.system.exitProcess
@Suppress("SSBasedInspection")
@@ -203,7 +204,7 @@ internal suspend fun loadApp(app: ApplicationImpl,
appRegisteredJob.join()
initConfigurationStoreJob.join()
launch {
val appInitializedListenerJob = launch {
val appInitializedListeners = appInitListeners.await()
span("app initialized callback") {
// An async scope here is intended for FLOW. FLOW!!! DO NOT USE the surrounding main scope.
@@ -226,6 +227,8 @@ internal suspend fun loadApp(app: ApplicationImpl,
addActivateAndWindowsCliListeners()
}
appInitializedListenerJob.join()
applicationStarter.await()
}
}
@@ -274,15 +277,25 @@ private suspend fun preloadNonHeadlessServices(
}
private suspend fun enableCoroutineDumpAndJstack() {
if (!System.getProperty("idea.enable.coroutine.dump", "true").toBoolean()) {
if (!System.getProperty("idea.enable.coroutine.dump", "true").toBoolean() || (SystemInfoRt.isWindows && CpuArch.isArm64())) {
return
}
var isInstalled = false
span("coroutine debug probes init") {
try {
CoroutineDumpState.install()
isInstalled = true
enableCoroutineDump()
.onFailure { e ->
if (ApplicationManager.getApplication().isHeadlessEnvironment) {
LOG.warn("Cannot enable coroutine debug dump", e)
}
else {
LOG.error("Cannot enable coroutine debug dump", e)
}
}
.onSuccess {
isInstalled = true
}
}
catch (e: Throwable) {
LOG.error("Cannot enable coroutine debug dump", e)

View File

@@ -7,7 +7,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.bootstrap.coroutine" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="jbr-api" level="project" />
@@ -23,6 +23,5 @@
<orderEntry type="module" module-name="intellij.platform.testFramework.core" />
<orderEntry type="module" module-name="intellij.platform.diagnostic" />
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
</component>
</module>

View File

@@ -75,7 +75,6 @@ import org.jetbrains.annotations.TestOnly
import sun.awt.AWTAutoShutdown
import java.time.Duration
import java.util.concurrent.TimeUnit
import kotlin.coroutines.jvm.internal.CoroutineDumpState
private var appInitResult: Result<Unit>? = null
const val LEAKED_PROJECTS: String = "leakedProjects"
@@ -116,9 +115,7 @@ fun loadApp(setupEventQueue: Runnable) {
System.setProperty("idea.diagnostic.opentelemetry.file",
PathManager.getLogDir().resolve("opentelemetry.json").toAbsolutePath().toString())
// if BB in classpath
enableCoroutineDump()
CoroutineDumpState.install()
JBR.getJstack()?.includeInfoFrom {
"""
$COROUTINE_DUMP_HEADER