IR: synchronize on SymbolTable operations
This commit is contained in:
@@ -76,6 +76,7 @@ class SymbolTable(
|
||||
abstract fun get(sig: IdSignature): S?
|
||||
|
||||
inline fun declare(d: D, createSymbol: () -> S, createOwner: (S) -> B): B {
|
||||
synchronized(this) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val d0 = d.original as D
|
||||
assert(d0 === d) {
|
||||
@@ -92,9 +93,11 @@ class SymbolTable(
|
||||
}
|
||||
return createOwner(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
inline fun declare(sig: IdSignature, createSymbol: () -> S, createOwner: (S) -> B): B {
|
||||
synchronized(this) {
|
||||
val existing = get(sig)
|
||||
val symbol = if (existing == null) {
|
||||
createSymbol()
|
||||
@@ -107,8 +110,10 @@ class SymbolTable(
|
||||
set(symbol)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
inline fun declareIfNotExists(d: D, createSymbol: () -> S, createOwner: (S) -> B): B {
|
||||
synchronized(this) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val d0 = d.original as D
|
||||
assert(d0 === d) {
|
||||
@@ -125,8 +130,10 @@ class SymbolTable(
|
||||
}
|
||||
return if (symbol.isBound) symbol.owner else createOwner(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun declare(sig: IdSignature, d: D?, createSymbol: () -> S, createOwner: (S) -> B): B {
|
||||
synchronized(this) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val d0 = d?.original as D
|
||||
assert(d0 === d) {
|
||||
@@ -143,8 +150,10 @@ class SymbolTable(
|
||||
}
|
||||
return createOwner(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun referenced(d: D, orElse: () -> S): S {
|
||||
synchronized(this) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val d0 = d.original as D
|
||||
assert(d0 === d) {
|
||||
@@ -161,9 +170,11 @@ class SymbolTable(
|
||||
}
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
inline fun referenced(sig: IdSignature, orElse: () -> S): S {
|
||||
synchronized(this) {
|
||||
return get(sig) ?: run {
|
||||
val new = orElse()
|
||||
assert(unboundSymbols.add(new)) {
|
||||
@@ -174,6 +185,7 @@ class SymbolTable(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private open inner class FlatSymbolTable<D : DeclarationDescriptor, B : IrSymbolOwner, S : IrBindableSymbol<D, B>> :
|
||||
SymbolTableBase<D, B, S>() {
|
||||
|
||||
Reference in New Issue
Block a user