Fixed bug in DFG building with workers + test
This commit is contained in:
+8
-2
@@ -380,11 +380,17 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
|
||||
}
|
||||
|
||||
if (expression is IrCall && expression.symbol == scheduleImplSymbol) {
|
||||
// Producer of scheduleImpl is called externally, we need to reflect this somehow.
|
||||
// Producer and job of scheduleImpl are called externally, we need to reflect this somehow.
|
||||
val producerInvocation = IrCallImpl(expression.startOffset, expression.endOffset,
|
||||
scheduleImplProducerInvoke.symbol, scheduleImplProducerInvoke.descriptor)
|
||||
producerInvocation.dispatchReceiver = expression.getValueArgument(2)
|
||||
expressions += producerInvocation
|
||||
val jobFunctionReference = expression.getValueArgument(3) as? IrFunctionReference
|
||||
?: error("A function reference expected")
|
||||
val jobInvocation = IrCallImpl(expression.startOffset, expression.endOffset,
|
||||
jobFunctionReference.symbol, jobFunctionReference.descriptor)
|
||||
jobInvocation.putValueArgument(0, producerInvocation)
|
||||
|
||||
expressions += jobInvocation
|
||||
}
|
||||
|
||||
if (expression is IrReturnableBlock) {
|
||||
|
||||
@@ -631,6 +631,12 @@ task worker8(type: RunKonanTest) {
|
||||
source = "runtime/workers/worker8.kt"
|
||||
}
|
||||
|
||||
task worker9(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // Workers need pthreads.
|
||||
goldValue = "zzz\n42\nOK\n"
|
||||
source = "runtime/workers/worker9.kt"
|
||||
}
|
||||
|
||||
task freeze0(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // No workers on WASM.
|
||||
goldValue = "frozen bit is true\n" +
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package runtime.workers.worker9
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import konan.worker.*
|
||||
|
||||
@Test fun runTest() {
|
||||
withLock { println("zzz") }
|
||||
val worker = startWorker()
|
||||
val future = worker.schedule(TransferMode.CHECKED, {}) {
|
||||
withLock {
|
||||
println("42")
|
||||
}
|
||||
}
|
||||
future.result()
|
||||
worker.requestTermination().result()
|
||||
println("OK")
|
||||
}
|
||||
|
||||
fun withLock(op: () -> Unit) {
|
||||
op()
|
||||
}
|
||||
Reference in New Issue
Block a user