VM: allow overriding MaxLoopIterations without rebuilding nim (#13233)

This commit is contained in:
Timothee Cour 2020-01-23 01:53:30 -08:00 • committed by Andreas Rumpf
commit b462baed65
6 changed files with 13 additions and 10 deletions

View file

@ -23,8 +23,6 @@ const
byteExcess* = 128 # we use excess-K for immediates
MaxLoopIterations* = 10_000_000 # max iterations of all loops
# Calculate register shifts, masks and ranges
const
@ -259,14 +257,14 @@ type
proc newCtx*(module: PSym; cache: IdentCache; g: ModuleGraph): PCtx =
PCtx(code: @[], debug: @[],
globals: newNode(nkStmtListExpr), constants: newNode(nkStmtList), types: @[],
prc: PProc(blocks: @[]), module: module, loopIterations: MaxLoopIterations,
prc: PProc(blocks: @[]), module: module, loopIterations: g.config.maxLoopIterationsVM,
comesFromHeuristic: unknownLineInfo, callbacks: @[], errorFlag: "",
cache: cache, config: g.config, graph: g)
proc refresh*(c: PCtx, module: PSym) =
c.module = module
c.prc = PProc(blocks: @[])
c.loopIterations = MaxLoopIterations
c.loopIterations = c.config.maxLoopIterationsVM
proc registerCallback*(c: PCtx; name: string; callback: VmCallback): int {.discardable.} =
result = c.callbacks.len