From f4a9b258c34a83efb74d9dea6853880e47f45b06 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 14 May 2023 16:58:28 +0200 Subject: [PATCH] isolation spec update; WIP (#21843) * isolation spec update; WIP * wip * docs update, WIP * progress * Update doc/manual.md --- compiler/ast.nim | 5 +- compiler/condsyms.nim | 2 +- compiler/isolation_check.nim | 76 ++++++++++++++++++- compiler/pragmas.nim | 9 ++- compiler/wordrecg.nim | 1 + doc/manual.md | 10 +-- doc/manual_experimental.md | 123 +++++++++++++++++++++++++++++++ lib/std/isolation.nim | 6 +- tests/isolate/tisolated_lock.nim | 67 +++++++++++++++++ 9 files changed, 284 insertions(+), 15 deletions(-) create mode 100644 tests/isolate/tisolated_lock.nim diff --git a/compiler/ast.nim b/compiler/ast.nim index 41e5387427..3ed9bf2b2a 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -515,7 +515,7 @@ type nfSkipFieldChecking # node skips field visable checking TNodeFlags* = set[TNodeFlag] - TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 46) + TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 47) tfVarargs, # procedure has C styled varargs # tyArray type represeting a varargs list tfNoSideEffect, # procedure type does not allow side effects @@ -585,6 +585,7 @@ type tfIsConstructor tfEffectSystemWorkaround tfIsOutParam + tfSendable TTypeFlags* = set[TTypeFlag] @@ -634,7 +635,7 @@ const skError* = skUnknown var - eqTypeFlags* = {tfIterator, tfNotNil, tfVarIsPtr, tfGcSafe, tfNoSideEffect, tfIsOutParam} + eqTypeFlags* = {tfIterator, tfNotNil, tfVarIsPtr, tfGcSafe, tfNoSideEffect, tfIsOutParam, tfSendable} ## type flags that are essential for type equality. ## This is now a variable because for emulation of version:1.0 we ## might exclude {tfGcSafe, tfNoSideEffect}. diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index ea635e52e1..9d9ba1605e 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -154,4 +154,4 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimHasWarnBareExcept") defineSymbol("nimHasDup") defineSymbol("nimHasChecksums") - + defineSymbol("nimHasSendable") diff --git a/compiler/isolation_check.nim b/compiler/isolation_check.nim index 2674605dcf..273bfb7f9f 100644 --- a/compiler/isolation_check.nim +++ b/compiler/isolation_check.nim @@ -72,6 +72,69 @@ proc isValueOnlyType(t: PType): bool = proc wrap(t: PType): bool {.nimcall.} = t.kind in {tyRef, tyPtr, tyVar, tyLent} result = not types.searchTypeFor(t, wrap) +type + SearchResult = enum + NotFound, Abort, Found + +proc containsDangerousRefAux(t: PType; marker: var IntSet): SearchResult + +proc containsDangerousRefAux(n: PNode; marker: var IntSet): SearchResult = + result = NotFound + case n.kind + of nkRecList: + for i in 0..