fixes #16790; fixes #19075; put big arrays on the constant seqs; don't inline them in the VM; big performance boost (#21318)
* don't inline arrays in VM * add a test for #19075
This commit is contained in:
parent
ebaa07b955
commit
b5f64f55d0
2 changed files with 24 additions and 2 deletions
|
|
@ -32,7 +32,7 @@ when defined(nimPreviewSlimSystem):
|
||||||
import std/assertions
|
import std/assertions
|
||||||
|
|
||||||
import
|
import
|
||||||
strutils, ast, types, msgs, renderer, vmdef,
|
strutils, ast, types, msgs, renderer, vmdef, trees,
|
||||||
intsets, magicsys, options, lowerings, lineinfos, transf, astmsgs
|
intsets, magicsys, options, lowerings, lineinfos, transf, astmsgs
|
||||||
|
|
||||||
from modulegraphs import getBody
|
from modulegraphs import getBody
|
||||||
|
|
@ -2054,6 +2054,9 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) =
|
||||||
genLit(c, n, dest)
|
genLit(c, n, dest)
|
||||||
of skConst:
|
of skConst:
|
||||||
let constVal = if s.astdef != nil: s.astdef else: s.typ.n
|
let constVal = if s.astdef != nil: s.astdef else: s.typ.n
|
||||||
|
if dontInlineConstant(n, constVal):
|
||||||
|
genLit(c, constVal, dest)
|
||||||
|
else:
|
||||||
gen(c, constVal, dest)
|
gen(c, constVal, dest)
|
||||||
of skEnumField:
|
of skEnumField:
|
||||||
# we never reach this case - as of the time of this comment,
|
# we never reach this case - as of the time of this comment,
|
||||||
|
|
|
||||||
19
tests/vm/t19075.nim
Normal file
19
tests/vm/t19075.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
discard """
|
||||||
|
timeout: 10
|
||||||
|
joinable: false
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #19075
|
||||||
|
const size = 50_000
|
||||||
|
|
||||||
|
const stuff = block:
|
||||||
|
var a: array[size, int]
|
||||||
|
a
|
||||||
|
|
||||||
|
const zeugs = block:
|
||||||
|
var zeugs: array[size, int]
|
||||||
|
for i in 0..<size:
|
||||||
|
zeugs[i] = stuff[i]
|
||||||
|
zeugs
|
||||||
|
|
||||||
|
doAssert zeugs[0] == 0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue