From bff6e9b9725566cdc0e167d9beb9b4c4f04c9910 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Thu, 18 Feb 2021 15:02:07 +0300 Subject: [PATCH] IR: document lock priority. --- compiler/ir/backend.jvm/LockPriority.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 compiler/ir/backend.jvm/LockPriority.md diff --git a/compiler/ir/backend.jvm/LockPriority.md b/compiler/ir/backend.jvm/LockPriority.md new file mode 100644 index 00000000000..dfda035e000 --- /dev/null +++ b/compiler/ir/backend.jvm/LockPriority.md @@ -0,0 +1,12 @@ +# Priority of locks in parallel runs of the JVM IR backend + +To avoid deadlocks in backend code, please make sure that a lock that comes earlier in the list +never gets acquired by a thread that already holds one of the locks that come later. + +1. `JvmBackendContext.inlineMethodGenerationLock`. Used to prevent concurrent generation of inline functions. +1. Global `IrLock` instance. Used in `SymbolTable`, + `lazyVar` instances in `IrLazyDeclaration`, `Fir2IrLazyDeclaration` subclasses, + `Fir2IrDeclarationStorage`. +1. - lock in `ClassBuilderAndSourceFileList.asBytes`. + - lock on `methodNode` in `InlineCodegen.cloneMethodNode`. + - Locks protecting `InlineCache` maps. \ No newline at end of file