disable sink inference, only enable it for the stdlib. Reason: better source code compatibility (#15105)
This commit is contained in:
parent
e4e4931432
commit
86c9b78339
6 changed files with 18 additions and 5 deletions
|
|
@ -265,6 +265,10 @@ proc mydiv(a, b): int {.raises: [].} =
|
||||||
- Removed the `--oldast` switch.
|
- Removed the `--oldast` switch.
|
||||||
- `$getType(untyped)` is now "untyped" instead of "expr", `$getType(typed)` is
|
- `$getType(untyped)` is now "untyped" instead of "expr", `$getType(typed)` is
|
||||||
now "typed" instead of "stmt".
|
now "typed" instead of "stmt".
|
||||||
|
- Sink inference is now disabled per default and has to enabled explicitly via
|
||||||
|
`--sinkInference:on`. *Note*: For the standard library sink inference remains
|
||||||
|
enabled. This change is most relevant for the `--gc:arc`, `--gc:orc` memory
|
||||||
|
management modes.
|
||||||
|
|
||||||
|
|
||||||
## Tool changes
|
## Tool changes
|
||||||
|
|
|
||||||
|
|
@ -373,7 +373,7 @@ const
|
||||||
DefaultOptions* = {optObjCheck, optFieldCheck, optRangeCheck,
|
DefaultOptions* = {optObjCheck, optFieldCheck, optRangeCheck,
|
||||||
optBoundsCheck, optOverflowCheck, optAssert, optWarns, optRefCheck,
|
optBoundsCheck, optOverflowCheck, optAssert, optWarns, optRefCheck,
|
||||||
optHints, optStackTrace, optLineTrace, # consider adding `optStackTraceMsgs`
|
optHints, optStackTrace, optLineTrace, # consider adding `optStackTraceMsgs`
|
||||||
optTrMacros, optStyleCheck, optSinkInference}
|
optTrMacros, optStyleCheck}
|
||||||
DefaultGlobalOptions* = {optThreadAnalysis,
|
DefaultGlobalOptions* = {optThreadAnalysis,
|
||||||
optExcessiveStackTrace, optListFullPaths}
|
optExcessiveStackTrace, optListFullPaths}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -261,8 +261,14 @@ optimizations (and the current implementation does not).
|
||||||
Sink parameter inference
|
Sink parameter inference
|
||||||
========================
|
========================
|
||||||
|
|
||||||
The current implementation does a limited form of sink parameter
|
The current implementation can do a limited form of sink parameter
|
||||||
inference. The `.nosinks`:idx: pragma can be used to disable this inference
|
inference. But it has to be enabled via `--sinkInference:on`, either
|
||||||
|
on the command line or via a `push` pragma.
|
||||||
|
|
||||||
|
To enable it for a section of code, one can
|
||||||
|
use `{.push sinkInference: on.}`...`{.pop.}`.
|
||||||
|
|
||||||
|
The `.nosinks`:idx: pragma can be used to disable this inference
|
||||||
for a single routine:
|
for a single routine:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
|
|
@ -270,8 +276,6 @@ for a single routine:
|
||||||
proc addX(x: T; child: T) {.nosinks.} =
|
proc addX(x: T; child: T) {.nosinks.} =
|
||||||
x.s.add child
|
x.s.add child
|
||||||
|
|
||||||
To disable it for a section of code, one can
|
|
||||||
use `{.push sinkInference: off.}`...`{.pop.}`.
|
|
||||||
|
|
||||||
The details of the inference algorithm are currently undocumented.
|
The details of the inference algorithm are currently undocumented.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,3 +48,6 @@ when defined(nimlocks):
|
||||||
{.pragma: benign, gcsafe, locks: 0.}
|
{.pragma: benign, gcsafe, locks: 0.}
|
||||||
else:
|
else:
|
||||||
{.pragma: benign, gcsafe.}
|
{.pragma: benign, gcsafe.}
|
||||||
|
|
||||||
|
when defined(nimHasSinkInference):
|
||||||
|
{.push sinkInference: on.}
|
||||||
|
|
|
||||||
1
tests/arc/nim.cfg
Normal file
1
tests/arc/nim.cfg
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
--sinkInference:on
|
||||||
1
tests/destructor/nim.cfg
Normal file
1
tests/destructor/nim.cfg
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
--sinkInference:on
|
||||||
Loading…
Add table
Add a link
Reference in a new issue