Skip to content

Commit

Permalink
Make the new native gc internal only (#696)
Browse files Browse the repository at this point in the history
## Summary
Made the new `native` gc not accessible via command line arguments or
via `compileOption`.

## Details
The latest `native` gc was created to better represent the gc the JS and
VM backends use. But it has no meaning for the C backend and instead
redirected to orc. As there is no reason to explicitly choose the
`native` gc via command-line arguments I removed the option. I also
removed the option for the `compileOption` proc because one should
query the used backend instead.
  • Loading branch information
vc4d-5x2 authored May 9, 2023
1 parent a208234 commit 7f2a42c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compiler/front/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ proc customizeForBackend*(graph: ModuleGraph, conf: ConfigRef,
of excNone, excNative: conf.exc = excGoto
of excGoto: discard

if conf.selectedGC in {gcUnselected, gcNative}:
if conf.selectedGC == gcUnselected:
# the default gc for the C backend is ORC. We can't just set it to
# ``gcOrc`` directly, however, as additional defines, etc. are required
# XXX: the dependency on ``optionsprocessor`` hints that a different
Expand Down
5 changes: 1 addition & 4 deletions compiler/front/optionsprocessor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ proc processCompile(conf: ConfigRef; filename: string) =
# multiple names for the same garbage collector.
const
gcNames = @[
"native", "boehm", "refc", "markandsweep", "destructors", "arc", "orc",
"boehm", "refc", "markandsweep", "destructors", "arc", "orc",
"hooks", "go", "none", "stack", "regions",]

cmdNames = @[
Expand Down Expand Up @@ -644,7 +644,6 @@ func testCompileOptionArg*(conf: ConfigRef; switch, arg: string): CompileOptArgC
case switch.normalize
of "gc":
case arg.normalize
of "native": asResult conf.selectedGC == gcNative
of "boehm": asResult conf.selectedGC == gcBoehm
of "refc": asResult conf.selectedGC == gcRefc
of "markandsweep": asResult conf.selectedGC == gcMarkAndSweep
Expand Down Expand Up @@ -1154,8 +1153,6 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass,
expectArg(switch, arg)
if pass in {passCmd2, passPP}:
case arg.normalize
of "native":
conf.selectedGC = gcNative
of "boehm":
conf.selectedGC = gcBoehm
defineSymbol(conf, "boehmgc")
Expand Down
4 changes: 2 additions & 2 deletions doc/advopt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ Advanced options:
--skipUserCfg:on|off do not read the user's configuration file
--skipParentCfg:on|off do not read the parent dirs' configuration files
--skipProjCfg:on|off do not read the project's configuration file
--gc:native|refc|arc|orc|markAndSweep|boehm|go|none|regions
--gc:refc|arc|orc|markAndSweep|boehm|go|none|regions
select the GC to use; default depends on the selected
backend ('orc' for C, 'native' for Javascript and the VM)
backend ('orc' for C, the native GC for Javascript and the VM)
--exceptions:native|goto
select the exception handling implementation
--index:on|off turn index file generation on|off
Expand Down
3 changes: 0 additions & 3 deletions doc/gc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ Multi-paradigm Memory Management Strategies

To choose the memory management strategy use the `--gc:` switch.

--gc:native The native GC for the selected backend. Redirects to `--gc:orc`
for the C backend.
--gc:refc This is the default GC. It's a
deferred reference counting based garbage collector
with a simple Mark&Sweep backup GC in order to collect cycles. Heaps are thread-local.
Expand Down Expand Up @@ -67,7 +65,6 @@ ORC Shared Cycle Collector No `--gc:orc`
Boehm Shared Cycle Collector Yes `--gc:boehm`
Go Shared Cycle Collector Yes `--gc:go`
None Manual Manual Manual `--gc:none`
Native Depends Depends Depends `--gc:native`
================== ======== ================= ============== ===================

.. default-role:: code
Expand Down

0 comments on commit 7f2a42c

Please sign in to comment.