Fix mutation attempts for primitive globals. (#3796)
This commit is contained in:
+1
-1
@@ -1600,7 +1600,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
val globalAddress = context.llvmDeclarations.forStaticField(value.symbol.owner).storageAddressAccess.getAddress(
|
val globalAddress = context.llvmDeclarations.forStaticField(value.symbol.owner).storageAddressAccess.getAddress(
|
||||||
functionGenerationContext
|
functionGenerationContext
|
||||||
)
|
)
|
||||||
if (context.config.threadsAreAllowed && value.symbol.owner.isMainOnlyNonPrimitive)
|
if (context.config.threadsAreAllowed && value.symbol.owner.storageKind == FieldStorageKind.MAIN_THREAD)
|
||||||
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
|
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
|
||||||
if (value.symbol.owner.storageKind == FieldStorageKind.SHARED)
|
if (value.symbol.owner.storageKind == FieldStorageKind.SHARED)
|
||||||
functionGenerationContext.freeze(valueToAssign, currentCodeContext.exceptionHandler)
|
functionGenerationContext.freeze(valueToAssign, currentCodeContext.exceptionHandler)
|
||||||
|
|||||||
@@ -9,14 +9,30 @@ import kotlin.test.*
|
|||||||
|
|
||||||
import kotlin.native.concurrent.*
|
import kotlin.native.concurrent.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest1() {
|
||||||
val worker = Worker.start()
|
withWorker {
|
||||||
val future = worker.execute(TransferMode.SAFE, { 42 }) {
|
val future = execute(TransferMode.SAFE, { 42 }) { input ->
|
||||||
input -> input.toString()
|
input.toString()
|
||||||
|
}
|
||||||
|
future.consume { result ->
|
||||||
|
println("Got $result")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
future.consume {
|
|
||||||
result -> println("Got $result")
|
|
||||||
}
|
|
||||||
worker.requestTermination().result
|
|
||||||
println("OK")
|
println("OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var int1 = 1
|
||||||
|
val int2 = 77
|
||||||
|
|
||||||
|
@Test fun runTest2() {
|
||||||
|
int1++
|
||||||
|
withWorker {
|
||||||
|
executeAfter(0, {
|
||||||
|
assertFailsWith<IncorrectDereferenceException> {
|
||||||
|
int1++
|
||||||
|
}
|
||||||
|
assertEquals(2, int1)
|
||||||
|
assertEquals(77, int2)
|
||||||
|
}.freeze())
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user