This commit is contained in:
Araq
2014-07-08 20:12:07 +02:00
parent 39ce17a73e
commit d80d8aa74d
3 changed files with 18 additions and 5 deletions

View File

@@ -1244,12 +1244,15 @@ proc genRdVar(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
# see tests/t99bott for an example that triggers it:
cannotEval(n)
template needsRegLoad(): expr =
gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar}))
proc genArrAccess2(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
flags: TGenFlags) =
let a = c.genx(n.sons[0], flags)
let b = c.genIndex(n.sons[1], n.sons[0].typ)
if dest < 0: dest = c.getTemp(n.typ)
if gfAddrOf notin flags and fitsRegister(n.typ):
if needsRegLoad():
var cc = c.getTemp(n.typ)
c.gABC(n, opc, cc, a, b)
c.gABC(n, opcNodeToReg, dest, cc)
@@ -1265,7 +1268,7 @@ proc genObjAccess(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
let a = c.genx(n.sons[0], flags)
let b = genField(n.sons[1])
if dest < 0: dest = c.getTemp(n.typ)
if gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar})):
if needsRegLoad():
var cc = c.getTemp(n.typ)
c.gABC(n, opcLdObj, cc, a, b)
c.gABC(n, opcNodeToReg, dest, cc)
@@ -1700,7 +1703,7 @@ proc genProc(c: PCtx; s: PSym): int =
c.gABC(body, opcEof, eofInstr.regA)
c.optimizeJumps(result)
s.offset = c.prc.maxSlots
#if s.name.s == "get_data":
#if s.name.s == "calc":
# echo renderTree(body)
# c.echoCode(result)
c.prc = oldPrc

View File

@@ -11,7 +11,8 @@ true
true
nil'''
output: '''test'''
output: '''test
2'''
"""
type
@@ -78,3 +79,12 @@ macro testnilcheck(): stmt =
discard nilcheck()
testnilcheck()
# bug #1323
proc calc(): array[1, int] =
result[0].inc()
result[0].inc()
const c = calc()
echo c[0]

View File

@@ -7,13 +7,13 @@ version 0.9.6
Concurrency
-----------
- 'gcsafe' inferrence needs to be fixed
- the disjoint checker needs to deal with 'a = spawn f(); g = spawn f()'
- implement 'deepCopy' builtin
- implement 'foo[1..4] = spawn(f[4..7])'
- support for exception propagation
- Minor: The copying of the 'ref Promise' into the thead local storage only
happens to work due to the write barrier's implementation
- 'gcsafe' inferrence needs to be fixed
- implement lock levels --> first without the more complex race avoidance
- document the new 'spawn' and 'parallel' statements