Disabled the GC in the entire VM module and updated config.nim

This commit is contained in:
Mattia Giambirtone 2022-10-21 19:50:07 +02:00
parent 9573769868
commit 6c305d6382
3 changed files with 12 additions and 21 deletions

View File

@ -12,6 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
## The Peon runtime environment
import ../config
# Sorry, but there only is enough space
# for one GC in this VM :(
{.push checks:enableVMChecks.} # The VM is a critical point where checks are deleterious
when defined(gcOrc):
GC_disableOrc()
when not defined(gcArc) and not defined(gcOrc):
GC_disable()
GC_disableMarkAndSweep()
import std/math
import std/segfaults
@ -20,7 +31,6 @@ import std/sets
import std/monotimes
import ../config
import ../frontend/meta/bytecode
import ../util/multibyte
@ -31,8 +41,6 @@ when debugVM or debugMem or debugGC:
import std/terminal
{.push checks:enableVMChecks.} # The VM is a critical point where checks are deleterious
type
PeonVM* = ref object
## The Peon Virtual Machine.
@ -1038,13 +1046,6 @@ proc run*(self: PeonVM, chunk: Chunk, breakpoints: seq[uint64] = @[]) =
self.breakpoints = breakpoints
self.results = @[]
self.ip = 0
# Sorry, but there only is enough space
# for one GC in this VM :(
when defined(gcOrc):
GC_disableOrc()
when not defined(gcArc) and not defined(gcOrc):
GC_disable()
GC_disableMarkAndSweep()
try:
self.dispatch()
except NilAccessDefect:
@ -1052,13 +1053,6 @@ proc run*(self: PeonVM, chunk: Chunk, breakpoints: seq[uint64] = @[]) =
quit(1)
# We clean up after ourselves!
self.gc.collect()
# This is unnecessary if we use ARC,
# but *just in case*
when defined(gcOrc):
GC_enable_Orc()
when not defined(gcArc) and not defined(gcOrc):
GC_enable()
GC_enableMarkAndSweep()
{.pop.}

View File

@ -34,7 +34,7 @@ when HeapGrowFactor <= 1:
{.fatal: "Heap growth factor must be > 1".}
const PeonVersion* = (major: 0, minor: 1, patch: 0)
const PeonRelease* = "alpha"
const PeonCommitHash* = "89477319ecae7dd21b02739688b84e96382ca044"
const PeonCommitHash* = "c55725911aefab72639b8743b1edf3f365d2e2ac"
when len(PeonCommitHash) != 40:
{.fatal: "The git commit hash must be exactly 40 characters long".}
const PeonBranch* = "master"

View File

@ -1291,9 +1291,6 @@ proc declareName(self: Compiler, node: ASTNode, mutable: bool = false): Name =
var node = ImportStmt(node)
var name = node.moduleName.token.lexeme.extractFilename().replace(".pn", "")
declaredName = name
for name in self.findByName(name):
if name.kind in [NameKind.Var, NameKind.Module] and name.depth == self.scopeDepth:
self.error(&"attempt to redeclare '{name}', which was previously defined in '{name.owner}' at line {name.line}")
self.names.add(Name(depth: self.scopeDepth,
owner: self.currentModule,
ident: newIdentExpr(Token(kind: Identifier, lexeme: name, line: node.moduleName.token.line)),