diff --git a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt index 1c6c9c2443f..7c59b6c054d 100644 --- a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt +++ b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt @@ -523,7 +523,7 @@ public fun CPointer.toKStringFromUtf16(): String { chars[index] = nativeBytes[index].toChar() ++index } - return String(chars) + return chars.concatToString() } /** @@ -555,7 +555,7 @@ public fun CPointer.toKStringFromUtf32(): String { chars[toIndex++] = value.toChar() } } - return String(chars) + return chars.concatToString() } /** diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt index 88e69256436..1130f0dd355 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt @@ -143,7 +143,7 @@ public fun CPointer.toKStringFromUtf16(): String { chars[index] = nativeBytes[index].toShort().toChar() ++index } - return String(chars) + return chars.concatToString() } public fun CPointer.toKString(): String = this.toKStringFromUtf16() diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt index 8b1d65f5ffd..1f52e7d1ac5 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt @@ -98,7 +98,7 @@ class ObjCNotImplementedVar(rawPtr: NativePtr) : CVariable(rawPtr) { var ObjCNotImplementedVar.value: T get() = TODO() - set(value) = TODO() + set(_) = TODO() typealias ObjCStringVarOf = ObjCNotImplementedVar typealias ObjCBlockVar = ObjCNotImplementedVar diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 1728c8ba0a5..7ed4bb224ef 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -29,8 +29,16 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$gradlePluginVersion" } - ext.useCustomDist = project.hasProperty("konan.home") + ext.useCustomDist = project.hasProperty("kotlin.native.home") || + project.hasProperty("org.jetbrains.kotlin.native.home") || + project.hasProperty("konan.home") + ext.kotlinNativeDist = project.findProperty("kotlin.native.home") + ?: project.findProperty("org.jetbrains.kotlin.native.home") + ?: project.findProperty("konan.home") + ?: distDir.absolutePath if (!useCustomDist) { + ext.setProperty("kotlin.native.home", distDir.absolutePath) + ext.setProperty("org.jetbrains.kotlin.native.home", distDir.absolutePath) ext.setProperty("konan.home", distDir.absolutePath) } } @@ -96,7 +104,7 @@ externalStdlibTestsDir.mkdirs() ext.platformManager = project.rootProject.platformManager ext.target = platformManager.targetManager(project.testTarget).target -ext.testLibraryDir = "${project.property("konan.home")}/klib/platform/${project.target.name}" +ext.testLibraryDir = "${ext.kotlinNativeDist}/klib/platform/${project.target.name}" // Add executor to run tests depending on a target project.convention.plugins.executor = ExecutorServiceKt.create(project) diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecClang.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecClang.kt index 5b587b77f69..4e4c3e259c0 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecClang.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecClang.kt @@ -39,8 +39,8 @@ class ExecClang(private val project: Project) { return konanArgs(target) } - fun resolveExecutable(executable: String?): String { - val executable = executable ?: "clang" + fun resolveExecutable(executableOrNull: String?): String { + val executable = executableOrNull ?: "clang" if (listOf("clang", "clang++").contains(executable)) { val llvmDir = project.findProperty("llvmDir") diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt index b2e7fe01e89..95bcacc4fd0 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt @@ -179,10 +179,10 @@ val Project.executor: ExecutorService */ fun ExecutorService.add(actionParameter: Action) = object : ExecutorService { override fun execute(action: Action): ExecResult? = - this@add.execute(Action { + this@add.execute { action.execute(it) actionParameter.execute(it) - }) + } } /** @@ -221,6 +221,7 @@ fun localExecutorService(project: Project): ExecutorService = object : ExecutorS * @param iosDevice an optional project property used to control simulator's device type * Specify -PiosDevice=iPhone X to set it */ +@Suppress("KDocUnresolvedReference") private fun simulator(project: Project): ExecutorService = object : ExecutorService { private val target = project.testTarget @@ -269,6 +270,7 @@ private fun simulator(project: Project): ExecutorService = object : ExecutorServ * @param remote makes binaries be executed on a remote host * Specify it as -Premote=user@host */ +@Suppress("KDocUnresolvedReference") private fun sshExecutor(project: Project): ExecutorService = object : ExecutorService { private val remote: String = project.property("remote").toString() @@ -332,14 +334,15 @@ private fun deviceLauncher(project: Project) = object : ExecutorService { private val deviceName = project.findProperty("device_name") as? String + private val bundleID = "org.jetbrains.kotlin.KonanTestLauncher" + override fun execute(action: Action): ExecResult? { - var result: ExecResult? = null + val result: ExecResult? try { val udid = targetUDID() println("Found device UDID: $udid") install(udid, xcProject.resolve("build/KonanTestLauncher.ipa").toString()) - val bundleId = "org.jetbrains.kotlin.KonanTestLauncher" - val commands = startDebugServer(udid, bundleId) + val commands = startDebugServer(udid) .split("\n") .filter { it.isNotBlank() } .flatMap { listOf("-o", it) } @@ -377,7 +380,7 @@ private fun deviceLauncher(project: Project) = object : ExecutorService { savedOut?.write(it.toByteArray()) } - uninstall(udid, bundleId) + uninstall(udid) } catch (exc: Exception) { throw RuntimeException("iOS-device execution failed", exc) } finally { @@ -463,12 +466,12 @@ private fun deviceLauncher(project: Project) = object : ExecutorService { check(result.exitValue == 0) { "Installation of $bundlePath failed: $out" } } - private fun uninstall(udid: String, bundleId: String) { + private fun uninstall(udid: String) { val out = ByteArrayOutputStream() project.exec { it.workingDir = xcProject.toFile() - it.commandLine = listOf(idb, "uninstall", "--udid", udid, bundleId) + it.commandLine = listOf(idb, "uninstall", "--udid", udid, bundleID) it.standardOutput = out it.errorOutput = out it.isIgnoreExitValue = true @@ -476,12 +479,12 @@ private fun deviceLauncher(project: Project) = object : ExecutorService { println(out.toString()) } - private fun startDebugServer(udid: String, bundleId: String): String { + private fun startDebugServer(udid: String): String { val out = ByteArrayOutputStream() val result = project.exec { it.workingDir = xcProject.toFile() - it.commandLine = listOf(idb, "debugserver", "start", "--udid", udid, bundleId) + it.commandLine = listOf(idb, "debugserver", "start", "--udid", udid, bundleID) it.standardOutput = out it.errorOutput = out it.isIgnoreExitValue = true diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/MPPTools.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/MPPTools.kt index 050da54140a..2258508cfd6 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/MPPTools.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/MPPTools.kt @@ -98,14 +98,14 @@ fun createJsonReport(projectProperties: Map): String { val machine = Environment.Machine(getValue("cpu"), getValue("os")) val jdk = Environment.JDKInstance(getValue("jdkVersion"), getValue("jdkVendor")) val env = Environment(machine, jdk) - val flags = (projectProperties["flags"] ?: emptyList()) as List + val flags: List = (projectProperties["flags"] as? List<*>)?.filterIsInstance() ?: emptyList() val backend = Compiler.Backend(Compiler.backendTypeFromString(getValue("type"))!! , getValue("compilerVersion"), flags) val kotlin = Compiler(backend, getValue("kotlinVersion")) val benchDesc = getValue("benchmarks") val benchmarksArray = JsonTreeParser.parse(benchDesc) val benchmarks = parseBenchmarksArray(benchmarksArray) - .union(projectProperties["compileTime"] as List).union( + .union((projectProperties["compileTime"] as? List<*>)?.filterIsInstance() ?: emptyList()).union( listOf(projectProperties["codeSize"] as? BenchmarkResult).filterNotNull()).toList() val report = BenchmarksReport(env, benchmarks, kotlin) return report.toJson() @@ -184,7 +184,6 @@ fun sendUploadRequest(url: String, fileName: String, username: String? = null, p } // A short-cut to add a Kotlin/Native run task. -@JvmOverloads fun createRunTask( subproject: Project, name: String, diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RegressionsReporter.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RegressionsReporter.kt index 5159a9b8e47..787bafc3124 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RegressionsReporter.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/RegressionsReporter.kt @@ -100,8 +100,7 @@ open class RegressionsReporter : DefaultTask() { val teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE") ?: error("Can't load teamcity config!") - val buildProperties = Properties() - buildProperties.load(FileInputStream(teamcityConfig)) + val buildProperties = Properties().apply { load(FileInputStream(teamcityConfig)) } val buildId = buildProperties.getProperty("teamcity.build.id") val buildTypeId = buildProperties.getProperty("teamcity.buildType.id") val buildNumber = buildProperties.getProperty("build.number") @@ -115,7 +114,7 @@ open class RegressionsReporter : DefaultTask() { val testReportUrl = testReportUrl(buildId, buildTypeId) // Get previous build on branch. - val builds = getBuild(previousBuildLocator(buildTypeId,branch), user, password) + getBuild(previousBuildLocator(buildTypeId,branch), user, password) // Get changes description. val changesList = getCommits("id:$buildId", user, password) @@ -135,7 +134,7 @@ open class RegressionsReporter : DefaultTask() { val target = System.getProperty("os.name").replace("\\s".toRegex(), "") // Generate comparison report. - val output = arrayOf("$analyzer", "-r", "html", "$currentBenchmarksReportFile", "artifactory:$compareToBuildNumber:$target:$artifactoryFileName", "-o", "$htmlReport") + val output = arrayOf(analyzer, "-r", "html", currentBenchmarksReportFile, "artifactory:$compareToBuildNumber:$target:$artifactoryFileName", "-o", htmlReport) .runCommand() if (output.contains("Uncaught exception")) { @@ -170,4 +169,4 @@ open class RegressionsReporter : DefaultTask() { } session.disconnect() } -} \ No newline at end of file +} diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/XcRunRuntimeUtils.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/XcRunRuntimeUtils.kt index 84828a6723b..49ce5d00033 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/XcRunRuntimeUtils.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/XcRunRuntimeUtils.kt @@ -10,14 +10,14 @@ import kotlin.math.min * Examples of numeric version strings: "12.4.1.2", "9", "0.5". */ private fun compareStringsAsVersions(version1: String, version2: String): Int { - val version1 = version1.split('.').map { it.toInt() } - val version2 = version2.split('.').map { it.toInt() } - val minimalLength = min(version1.size, version2.size) + val splitVersion1 = version1.split('.').map { it.toInt() } + val splitVersion2 = version2.split('.').map { it.toInt() } + val minimalLength = min(splitVersion1.size, splitVersion2.size) for (index in 0 until minimalLength) { - if (version1[index] < version2[index]) return -1 - if (version1[index] > version2[index]) return 1 + if (splitVersion1[index] < splitVersion2[index]) return -1 + if (splitVersion1[index] > splitVersion2[index]) return 1 } - return version1.size.compareTo(version2.size) + return splitVersion1.size.compareTo(splitVersion2.size) } /** diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt index 79ca911f97c..b96f928921b 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/CompileBenchmarkingPlugin.kt @@ -110,9 +110,7 @@ open class CompileBenchmarkingPlugin : Plugin { private fun getCompilerFlags(benchmarkExtension: CompileBenchmarkExtension) = benchmarkExtension.compilerOpts - private fun Project.configureJvmRun( - benchmarkExtension: CompileBenchmarkExtension - ) { + private fun Project.configureJvmRun() { val jvmRun = tasks.create("jvmRun") { it.group = BenchmarkingPlugin.BENCHMARKING_GROUP it.description = "Runs the compile only benchmark for Kotlin/JVM." @@ -139,7 +137,7 @@ open class CompileBenchmarkingPlugin : Plugin { // Create tasks. configureUtilityTasks() configureKonanRun(benchmarkExtension) - configureJvmRun(benchmarkExtension) + configureJvmRun() } companion object { diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/SwiftBenchmarkingPlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/SwiftBenchmarkingPlugin.kt index 5f0c8bdadbb..ee5f7d51b06 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/SwiftBenchmarkingPlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/benchmark/SwiftBenchmarkingPlugin.kt @@ -79,7 +79,7 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() { val nativeTarget = kotlin.targets.getByName(NATIVE_TARGET_NAME) as KotlinNativeTarget // Build executable from swift code. framework = nativeTarget.binaries.getFramework(nativeFrameworkName, benchmark.buildType) - val buildSwift = tasks.create("buildSwift") { task -> + tasks.create("buildSwift") { task -> task.dependsOn(framework.linkTaskName) task.doLast { val frameworkParentDirPath = framework.outputDirectory.absolutePath @@ -104,4 +104,4 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() { } else { listOf("-O", "-wmo") } -} \ No newline at end of file +} diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt index 85af1c8a588..349ce47ea22 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt @@ -35,7 +35,7 @@ open class CompileToBitcodePlugin: Plugin { open class CompileToBitcodeExtension @Inject constructor(val project: Project) { private val targetList = with(project) { - provider { rootProject.property("targetList") as List } // TODO: Can we make it better? + provider { (rootProject.property("targetList") as? List<*>)?.filterIsInstance() ?: emptyList() } // TODO: Can we make it better? } fun create( diff --git a/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp b/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp index 8f3928b4a2c..7fd0c69bea2 100644 --- a/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp +++ b/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp @@ -3193,17 +3193,17 @@ bool TryAddHeapRef(const ObjHeader* object) { return tryAddHeapRef(object); } -void ReleaseHeapRefStrict(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRefStrict(const ObjHeader* object) { releaseHeapRef(const_cast(object)); } -void ReleaseHeapRefRelaxed(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRefRelaxed(const ObjHeader* object) { releaseHeapRef(const_cast(object)); } -void ReleaseHeapRefNoCollectStrict(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRefNoCollectStrict(const ObjHeader* object) { releaseHeapRef(const_cast(object)); } -void ReleaseHeapRefNoCollectRelaxed(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRefNoCollectRelaxed(const ObjHeader* object) { releaseHeapRef(const_cast(object)); } @@ -3276,60 +3276,60 @@ OBJ_GETTER(InitSharedInstanceRelaxed, RETURN_RESULT_OF(initSharedInstance, location, typeInfo, ctor); } -void SetStackRefStrict(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetStackRefStrict(ObjHeader** location, const ObjHeader* object) { setStackRef(location, object); } -void SetStackRefRelaxed(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetStackRefRelaxed(ObjHeader** location, const ObjHeader* object) { setStackRef(location, object); } -void SetHeapRefStrict(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetHeapRefStrict(ObjHeader** location, const ObjHeader* object) { setHeapRef(location, object); } -void SetHeapRefRelaxed(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetHeapRefRelaxed(ObjHeader** location, const ObjHeader* object) { setHeapRef(location, object); } -void ZeroHeapRef(ObjHeader** location) { +RUNTIME_NOTHROW void ZeroHeapRef(ObjHeader** location) { zeroHeapRef(location); } -void ZeroStackRefStrict(ObjHeader** location) { +RUNTIME_NOTHROW void ZeroStackRefStrict(ObjHeader** location) { zeroStackRef(location); } -void ZeroStackRefRelaxed(ObjHeader** location) { +RUNTIME_NOTHROW void ZeroStackRefRelaxed(ObjHeader** location) { zeroStackRef(location); } -void UpdateStackRefStrict(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateStackRefStrict(ObjHeader** location, const ObjHeader* object) { updateStackRef(location, object); } -void UpdateStackRefRelaxed(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateStackRefRelaxed(ObjHeader** location, const ObjHeader* object) { updateStackRef(location, object); } -void UpdateHeapRefStrict(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateHeapRefStrict(ObjHeader** location, const ObjHeader* object) { updateHeapRef(location, object); } -void UpdateHeapRefRelaxed(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateHeapRefRelaxed(ObjHeader** location, const ObjHeader* object) { updateHeapRef(location, object); } -void UpdateReturnRefStrict(ObjHeader** returnSlot, const ObjHeader* value) { +RUNTIME_NOTHROW void UpdateReturnRefStrict(ObjHeader** returnSlot, const ObjHeader* value) { updateReturnRef(returnSlot, value); } -void UpdateReturnRefRelaxed(ObjHeader** returnSlot, const ObjHeader* value) { +RUNTIME_NOTHROW void UpdateReturnRefRelaxed(ObjHeader** returnSlot, const ObjHeader* value) { updateReturnRef(returnSlot, value); } -void ZeroArrayRefs(ArrayHeader* array) { +RUNTIME_NOTHROW void ZeroArrayRefs(ArrayHeader* array) { for (uint32_t index = 0; index < array->count_; ++index) { ObjHeader** location = ArrayAddressOfElementAt(array, index); zeroHeapRef(location); } } -void UpdateHeapRefIfNull(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateHeapRefIfNull(ObjHeader** location, const ObjHeader* object) { updateHeapRefIfNull(location, object); } @@ -3338,7 +3338,7 @@ OBJ_GETTER(SwapHeapRefLocked, RETURN_RESULT_OF(swapHeapRefLocked, location, expectedValue, newValue, spinlock, cookie); } -void SetHeapRefLocked(ObjHeader** location, ObjHeader* newValue, int32_t* spinlock, int32_t* cookie) { +RUNTIME_NOTHROW void SetHeapRefLocked(ObjHeader** location, ObjHeader* newValue, int32_t* spinlock, int32_t* cookie) { setHeapRefLocked(location, newValue, spinlock, cookie); } @@ -3350,17 +3350,17 @@ OBJ_GETTER(ReadHeapRefNoLock, ObjHeader* object, KInt index) { RETURN_RESULT_OF(readHeapRefNoLock, object, index); } -void EnterFrameStrict(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void EnterFrameStrict(ObjHeader** start, int parameters, int count) { enterFrame(start, parameters, count); } -void EnterFrameRelaxed(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void EnterFrameRelaxed(ObjHeader** start, int parameters, int count) { enterFrame(start, parameters, count); } -void LeaveFrameStrict(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void LeaveFrameStrict(ObjHeader** start, int parameters, int count) { leaveFrame(start, parameters, count); } -void LeaveFrameRelaxed(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void LeaveFrameRelaxed(ObjHeader** start, int parameters, int count) { leaveFrame(start, parameters, count); } @@ -3476,11 +3476,11 @@ OBJ_GETTER(Kotlin_native_internal_GC_findCycle, KRef, KRef root) { #endif } -KNativePtr CreateStablePointer(KRef any) { +RUNTIME_NOTHROW KNativePtr CreateStablePointer(KRef any) { return createStablePointer(any); } -void DisposeStablePointer(KNativePtr pointer) { +RUNTIME_NOTHROW void DisposeStablePointer(KNativePtr pointer) { disposeStablePointer(pointer); } @@ -3492,7 +3492,7 @@ OBJ_GETTER(AdoptStablePointer, KNativePtr pointer) { RETURN_RESULT_OF(adoptStablePointer, pointer); } -bool ClearSubgraphReferences(ObjHeader* root, bool checked) { +RUNTIME_NOTHROW bool ClearSubgraphReferences(ObjHeader* root, bool checked) { return clearSubgraphReferences(root, checked); } @@ -3509,7 +3509,7 @@ void MutationCheck(ObjHeader* obj) { ThrowInvalidMutabilityException(obj); } -void CheckLifetimesConstraint(ObjHeader* obj, ObjHeader* pointee) { +RUNTIME_NOTHROW void CheckLifetimesConstraint(ObjHeader* obj, ObjHeader* pointee) { if (!obj->local() && pointee != nullptr && pointee->local()) { konan::consolePrintf("Attempt to store a stack object %p into a heap object %p\n", pointee, obj); konan::consolePrintf("This is a compiler bug, please report it to https://kotl.in/issue\n"); @@ -3525,7 +3525,7 @@ void Kotlin_Any_share(ObjHeader* obj) { shareAny(obj); } -void AddTLSRecord(MemoryState* memory, void** key, int size) { +RUNTIME_NOTHROW void AddTLSRecord(MemoryState* memory, void** key, int size) { auto* tlsMap = memory->tlsMap; auto it = tlsMap->find(key); if (it != tlsMap->end()) { @@ -3536,7 +3536,7 @@ void AddTLSRecord(MemoryState* memory, void** key, int size) { tlsMap->emplace(key, std::make_pair(start, size)); } -void ClearTLSRecord(MemoryState* memory, void** key) { +RUNTIME_NOTHROW void ClearTLSRecord(MemoryState* memory, void** key) { auto* tlsMap = memory->tlsMap; auto it = tlsMap->find(key); if (it != tlsMap->end()) { @@ -3550,7 +3550,7 @@ void ClearTLSRecord(MemoryState* memory, void** key) { } } -KRef* LookupTLS(void** key, int index) { +RUNTIME_NOTHROW KRef* LookupTLS(void** key, int index) { auto* state = memoryState; auto* tlsMap = state->tlsMap; // In many cases there is only one module, so this one element cache. @@ -3567,19 +3567,19 @@ KRef* LookupTLS(void** key, int index) { } -void GC_RegisterWorker(void* worker) { +RUNTIME_NOTHROW void GC_RegisterWorker(void* worker) { #if USE_CYCLIC_GC cyclicAddWorker(worker); #endif // USE_CYCLIC_GC } -void GC_UnregisterWorker(void* worker) { +RUNTIME_NOTHROW void GC_UnregisterWorker(void* worker) { #if USE_CYCLIC_GC cyclicRemoveWorker(worker, g_hasCyclicCollector); #endif // USE_CYCLIC_GC } -void GC_CollectorCallback(void* worker) { +RUNTIME_NOTHROW void GC_CollectorCallback(void* worker) { #if USE_CYCLIC_GC if (g_hasCyclicCollector) cyclicCollectorCallback(worker); @@ -3607,7 +3607,7 @@ bool Kotlin_Any_isShareable(KRef thiz) { return thiz == nullptr || isShareable(containerFor(thiz)); } -void PerformFullGC() { +RUNTIME_NOTHROW void PerformFullGC() { garbageCollect(::memoryState, true); } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt index 55dc6e660cb..391a1ba273a 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt @@ -69,7 +69,7 @@ public open class Throwable(open val message: String?, open val cause: Throwable println(this) clear() } else { - appendln() + appendLine() } } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Lazy.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Lazy.kt index 767d8d2f17c..e71e6ffc4b5 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Lazy.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Lazy.kt @@ -41,8 +41,7 @@ internal class FreezeAwareLazyImpl(initializer: () -> T) : Lazy { } // Set value_ to actual one. value_.value = result - @Suppress("UNCHECKED_CAST") - return result as T + return result } override val value: T @@ -118,4 +117,4 @@ internal class AtomicLazyImpl(initializer: () -> T) : Lazy { * leak memory, so it is recommended to use `atomicLazy` in cases of objects living forever, * such as object signletons, or in cases where it's guaranteed not to have cyclical garbage. */ -public fun atomicLazy(initializer: () -> T): Lazy = AtomicLazyImpl(initializer) \ No newline at end of file +public fun atomicLazy(initializer: () -> T): Lazy = AtomicLazyImpl(initializer) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Lexer.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Lexer.kt index fe7ccd23f08..ccb088c87f3 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Lexer.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Lexer.kt @@ -457,7 +457,7 @@ internal class Lexer(val patternString: String, flags: Int) { // Word/whitespace/digit. 'w', 's', 'd', 'W', 'S', 'D' -> { lookAheadSpecialToken = AbstractCharClass.getPredefinedClass( - String(pattern, prevNonWhitespaceIndex, 1), + pattern.concatToString(prevNonWhitespaceIndex, prevNonWhitespaceIndex + 1), false ) lookAhead = 0 @@ -724,12 +724,12 @@ internal class Lexer(val patternString: String, flags: Int) { val CHAR_PREVIOUS_MATCH = 0x80000000.toInt() or 'G'.toInt() val CHAR_END_OF_INPUT = 0x80000000.toInt() or 'z'.toInt() val CHAR_END_OF_LINE = 0x80000000.toInt() or 'Z'.toInt() - + // Quantifier modes. val QMOD_GREEDY = 0xe0000000.toInt() val QMOD_RELUCTANT = 0xc0000000.toInt() val QMOD_POSSESSIVE = 0x80000000.toInt() - + // Quantifiers. val QUANT_STAR = QMOD_GREEDY or '*'.toInt() val QUANT_STAR_P = QMOD_POSSESSIVE or '*'.toInt() diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Pattern.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Pattern.kt index e114670218d..c1a46eb0f76 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Pattern.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/Pattern.kt @@ -794,7 +794,7 @@ internal class Pattern(val pattern: String, flags: Int = 0) { val isSupplCodePoint = Char.isSupplementaryCodePoint(ch) return when { - isSupplCodePoint -> SequenceSet(String(Char.toChars(ch), 0, 2), hasFlag(CASE_INSENSITIVE)) + isSupplCodePoint -> SequenceSet(Char.toChars(ch).concatToString(0, 2), hasFlag(CASE_INSENSITIVE)) ch.toChar().isLowSurrogate() -> LowSurrogateCharSet(ch.toChar()) ch.toChar().isHighSurrogate() -> HighSurrogateCharSet(ch.toChar()) else -> CharSet(ch.toChar(), hasFlag(CASE_INSENSITIVE)) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/FSets.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/FSets.kt index 701b70f65ca..f197ce213d5 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/FSets.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/FSets.kt @@ -67,7 +67,7 @@ open internal class FSet(val groupIndex: Int) : SimpleSet() { } companion object { - var possessiveFSet = PossessiveFSet() + val possessiveFSet = PossessiveFSet() } } @@ -156,4 +156,4 @@ internal class AtomicFSet(groupIndex: Int) : FSet(groupIndex) { override fun hasConsumed(matchResult: MatchResultImpl): Boolean { return false } -} \ No newline at end of file +} diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/HangulDecomposedCharSet.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/HangulDecomposedCharSet.kt index 39a6101ceb5..058d0bcaddc 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/HangulDecomposedCharSet.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/HangulDecomposedCharSet.kt @@ -43,7 +43,7 @@ internal class HangulDecomposedCharSet( * String representing syllable */ private val decomposedCharUTF16: String by lazy { - String(decomposedChar, 0, decomposedChar.size) + decomposedChar.concatToString(0, decomposedChar.size) } override val name: String diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/SupplementaryCharSet.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/SupplementaryCharSet.kt index 089baf9d571..b6b9b9dc427 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/SupplementaryCharSet.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/regex/sets/SupplementaryCharSet.kt @@ -91,7 +91,7 @@ package kotlin.text.regex * Represents node accepting single supplementary codepoint. */ internal class SupplementaryCharSet(val codePoint: Int, ignoreCase: Boolean) - : SequenceSet(String(Char.toChars(codePoint), 0, 2), ignoreCase) { + : SequenceSet(Char.toChars(codePoint).concatToString(0, 2), ignoreCase) { override val name: String get() = patternString diff --git a/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp b/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp index 09993333d4e..c0b0b074faf 100644 --- a/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp +++ b/kotlin-native/runtime/src/relaxed/cpp/MemoryImpl.cpp @@ -29,43 +29,43 @@ OBJ_GETTER(InitSharedInstance, RETURN_RESULT_OF(InitSharedInstanceRelaxed, location, typeInfo, ctor); } -void ReleaseHeapRef(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRef(const ObjHeader* object) { ReleaseHeapRefRelaxed(object); } -void ReleaseHeapRefNoCollect(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRefNoCollect(const ObjHeader* object) { ReleaseHeapRefNoCollectRelaxed(object); } -void ZeroStackRef(ObjHeader** location) { +RUNTIME_NOTHROW void ZeroStackRef(ObjHeader** location) { ZeroStackRefRelaxed(location); } -void SetStackRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetStackRef(ObjHeader** location, const ObjHeader* object) { SetStackRefRelaxed(location, object); } -void SetHeapRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetHeapRef(ObjHeader** location, const ObjHeader* object) { SetHeapRefRelaxed(location, object); } -void UpdateHeapRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateHeapRef(ObjHeader** location, const ObjHeader* object) { UpdateHeapRefRelaxed(location, object); } -void UpdateReturnRef(ObjHeader** returnSlot, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateReturnRef(ObjHeader** returnSlot, const ObjHeader* object) { UpdateReturnRefRelaxed(returnSlot, object); } -void EnterFrame(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void EnterFrame(ObjHeader** start, int parameters, int count) { EnterFrameRelaxed(start, parameters, count); } -void LeaveFrame(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void LeaveFrame(ObjHeader** start, int parameters, int count) { LeaveFrameRelaxed(start, parameters, count); } -void UpdateStackRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateStackRef(ObjHeader** location, const ObjHeader* object) { UpdateStackRefRelaxed(location, object); } diff --git a/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp b/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp index ce7af356dc1..0b46ae9c20e 100644 --- a/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp +++ b/kotlin-native/runtime/src/strict/cpp/MemoryImpl.cpp @@ -29,43 +29,43 @@ OBJ_GETTER(InitSharedInstance, RETURN_RESULT_OF(InitSharedInstanceStrict, location, typeInfo, ctor); } -void ReleaseHeapRef(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRef(const ObjHeader* object) { ReleaseHeapRefStrict(object); } -void ReleaseHeapRefNoCollect(const ObjHeader* object) { +RUNTIME_NOTHROW void ReleaseHeapRefNoCollect(const ObjHeader* object) { ReleaseHeapRefNoCollectStrict(object); } -void SetStackRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetStackRef(ObjHeader** location, const ObjHeader* object) { SetStackRefStrict(location, object); } -void SetHeapRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void SetHeapRef(ObjHeader** location, const ObjHeader* object) { SetHeapRefStrict(location, object); } -void ZeroStackRef(ObjHeader** location) { +RUNTIME_NOTHROW void ZeroStackRef(ObjHeader** location) { ZeroStackRefStrict(location); } -void UpdateHeapRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateHeapRef(ObjHeader** location, const ObjHeader* object) { UpdateHeapRefStrict(location, object); } -void UpdateReturnRef(ObjHeader** returnSlot, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateReturnRef(ObjHeader** returnSlot, const ObjHeader* object) { UpdateReturnRefStrict(returnSlot, object); } -void EnterFrame(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void EnterFrame(ObjHeader** start, int parameters, int count) { EnterFrameStrict(start, parameters, count); } -void LeaveFrame(ObjHeader** start, int parameters, int count) { +RUNTIME_NOTHROW void LeaveFrame(ObjHeader** start, int parameters, int count) { LeaveFrameStrict(start, parameters, count); } -void UpdateStackRef(ObjHeader** location, const ObjHeader* object) { +RUNTIME_NOTHROW void UpdateStackRef(ObjHeader** location, const ObjHeader* object) { UpdateStackRefStrict(location, object); }