fixes --gc:none regression; made some tests green

This commit is contained in:
Araq 2015-03-10 02:09:55 +01:00
commit ee57bb3e3e
7 changed files with 49 additions and 41 deletions

View file

@ -461,6 +461,9 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap): pointer =
{.pop.} {.pop.}
proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
result = rawNewObj(typ, size, gch)
proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} = proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
result = rawNewObj(typ, size, gch) result = rawNewObj(typ, size, gch)
zeroMem(result, size) zeroMem(result, size)

View file

@ -1,7 +1,7 @@
# #
# #
# Nim's Runtime Library # Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf # (c) Copyright 2015 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -240,6 +240,8 @@ elif defined(nogc) and defined(useMalloc):
result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize)) result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize))
cast[PGenericSeq](result).len = len cast[PGenericSeq](result).len = len
cast[PGenericSeq](result).reserved = len cast[PGenericSeq](result).reserved = len
proc newObjNoInit(typ: PNimType, size: int): pointer =
result = alloc(size)
proc growObj(old: pointer, newsize: int): pointer = proc growObj(old: pointer, newsize: int): pointer =
result = realloc(old, newsize) result = realloc(old, newsize)
@ -289,6 +291,10 @@ elif defined(nogc):
proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} = proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
result = alloc0(size) result = alloc0(size)
proc newObjNoInit(typ: PNimType, size: int): pointer =
result = alloc(size)
proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} = proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize)) result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize))
cast[PGenericSeq](result).len = len cast[PGenericSeq](result).len = len

View file

@ -43,7 +43,7 @@ else:
cast[NimString](newObj(addr(strDesc), size)) cast[NimString](newObj(addr(strDesc), size))
template allocStrNoInit(size: expr): expr = template allocStrNoInit(size: expr): expr =
cast[NimString](rawNewObj(addr(strDesc), size, gch)) cast[NimString](newObjNoInit(addr(strDesc), size))
proc rawNewStringNoInit(space: int): NimString {.compilerProc.} = proc rawNewStringNoInit(space: int): NimString {.compilerProc.} =
var s = space var s = space

View file

@ -1,5 +1,5 @@
discard """ discard """
nimout: "'a' is deprecated [Deprecated]" nimout: "a is deprecated [Deprecated]"
""" """
var var

View file

@ -1,6 +1,6 @@
discard """ discard """
line: 7 line: 7
errormsg: "expression 'items' cannot be called" errormsg: "undeclared identifier: 'items'"
""" """
type a = enum b,c,d type a = enum b,c,d

View file

@ -1,7 +1,7 @@
discard """ discard """
file: "tissue710.nim" file: "tissue710.nim"
line: 8 line: 8
errorMsg: "expression '||' cannot be called" errorMsg: "undeclared identifier: '||'"
""" """
var sum = 0 var sum = 0
for x in 3..1000: for x in 3..1000:

View file

@ -1,12 +1,11 @@
discard """ discard """
file: "tnoop.nim" file: "tnoop.nim"
line: 11 line: 11
errormsg: "expression \'a()\' cannot be called" errormsg: "undeclared identifier: 'a'"
""" """
# Tests the new check in the semantic pass
var var
a: int a: int
a() #ERROR_MSG expression 'a()' cannot be called a()