Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
commit
210955c3b6
5 changed files with 43 additions and 4 deletions
|
|
@ -826,7 +826,23 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||||
of mSubF64: genBinaryABC(c, n, dest, opcSubFloat)
|
of mSubF64: genBinaryABC(c, n, dest, opcSubFloat)
|
||||||
of mMulF64: genBinaryABC(c, n, dest, opcMulFloat)
|
of mMulF64: genBinaryABC(c, n, dest, opcMulFloat)
|
||||||
of mDivF64: genBinaryABC(c, n, dest, opcDivFloat)
|
of mDivF64: genBinaryABC(c, n, dest, opcDivFloat)
|
||||||
of mShrI: genBinaryABCnarrowU(c, n, dest, opcShrInt)
|
of mShrI:
|
||||||
|
# the idea here is to narrow type if needed before executing right shift
|
||||||
|
# inlined modified: genNarrowU(c, n, dest)
|
||||||
|
let t = skipTypes(n.typ, abstractVar-{tyTypeDesc})
|
||||||
|
# uint is uint64 in the VM, we we only need to mask the result for
|
||||||
|
# other unsigned types:
|
||||||
|
let tmp = c.genx(n.sons[1])
|
||||||
|
if t.kind in {tyUInt8..tyUInt32, tyInt8..tyInt32}:
|
||||||
|
c.gABC(n, opcNarrowU, tmp, TRegister(t.size*8))
|
||||||
|
|
||||||
|
# inlined modified: genBinaryABC(c, n, dest, opcShrInt)
|
||||||
|
let tmp2 = c.genx(n.sons[2])
|
||||||
|
if dest < 0: dest = c.getTemp(n.typ)
|
||||||
|
c.gABC(n, opcShrInt, dest, tmp, tmp2)
|
||||||
|
c.freeTemp(tmp)
|
||||||
|
c.freeTemp(tmp2)
|
||||||
|
|
||||||
of mShlI: genBinaryABCnarrowU(c, n, dest, opcShlInt)
|
of mShlI: genBinaryABCnarrowU(c, n, dest, opcShlInt)
|
||||||
of mBitandI: genBinaryABCnarrowU(c, n, dest, opcBitandInt)
|
of mBitandI: genBinaryABCnarrowU(c, n, dest, opcBitandInt)
|
||||||
of mBitorI: genBinaryABCnarrowU(c, n, dest, opcBitorInt)
|
of mBitorI: genBinaryABCnarrowU(c, n, dest, opcBitorInt)
|
||||||
|
|
|
||||||
|
|
@ -590,8 +590,11 @@ proc enlarge[A, B](t: var OrderedTable[A, B]) =
|
||||||
swap(t.data, n)
|
swap(t.data, n)
|
||||||
while h >= 0:
|
while h >= 0:
|
||||||
var nxt = n[h].next
|
var nxt = n[h].next
|
||||||
if isFilled(n[h].hcode):
|
let eh = n[h].hcode
|
||||||
var j = -1 - rawGetKnownHC(t, n[h].key, n[h].hcode)
|
if isFilled(eh):
|
||||||
|
var j: Hash = eh and maxHash(t)
|
||||||
|
while isFilled(t.data[j].hcode):
|
||||||
|
j = nextTry(j, maxHash(t))
|
||||||
rawInsert(t, t.data, n[h].key, n[h].val, n[h].hcode, j)
|
rawInsert(t, t.data, n[h].key, n[h].val, n[h].hcode, j)
|
||||||
h = nxt
|
h = nxt
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,4 +69,4 @@ proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
|
||||||
result = affinitySpaceTotal().int
|
result = affinitySpaceTotal().int
|
||||||
else:
|
else:
|
||||||
result = sysconf(SC_NPROCESSORS_ONLN)
|
result = sysconf(SC_NPROCESSORS_ONLN)
|
||||||
if result <= 0: result = 1
|
if result <= 0: result = 0
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,5 @@ proc T() =
|
||||||
|
|
||||||
|
|
||||||
T()
|
T()
|
||||||
|
static:
|
||||||
|
T()
|
||||||
|
|
|
||||||
18
tests/stdlib/torderedtable.nim
Normal file
18
tests/stdlib/torderedtable.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import tables, random
|
||||||
|
var t = initOrderedTable[int,string]()
|
||||||
|
|
||||||
|
# this tests issue #5917
|
||||||
|
var data = newSeq[int]()
|
||||||
|
for i in 0..<1000:
|
||||||
|
var x = random(1000)
|
||||||
|
if x notin t: data.add(x)
|
||||||
|
t[x] = "meh"
|
||||||
|
|
||||||
|
# this checks that keys are re-inserted
|
||||||
|
# in order when table is enlarged.
|
||||||
|
var i = 0
|
||||||
|
for k, v in t:
|
||||||
|
doAssert(k == data[i])
|
||||||
|
doAssert(v == "meh")
|
||||||
|
inc(i)
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue