IC: yet another embarrassing omission (#17743)
* IC: yet another embarrassing omission * VM: fewer hacks that kept IC from working
This commit is contained in:
parent
201ac2b9c9
commit
8e474fbb57
4 changed files with 12 additions and 10 deletions
|
|
@ -1054,7 +1054,7 @@ const
|
||||||
|
|
||||||
defaultSize = -1
|
defaultSize = -1
|
||||||
defaultAlignment = -1
|
defaultAlignment = -1
|
||||||
defaultOffset = -1
|
defaultOffset* = -1
|
||||||
|
|
||||||
proc getPIdent*(a: PNode): PIdent {.inline.} =
|
proc getPIdent*(a: PNode): PIdent {.inline.} =
|
||||||
## Returns underlying `PIdent` for `{nkSym, nkIdent}`, or `nil`.
|
## Returns underlying `PIdent` for `{nkSym, nkIdent}`, or `nil`.
|
||||||
|
|
|
||||||
|
|
@ -765,7 +765,8 @@ proc symHeaderFromPacked(c: var PackedDecoder; g: var PackedModuleGraph;
|
||||||
kind: s.kind, magic: s.magic, flags: s.flags,
|
kind: s.kind, magic: s.magic, flags: s.flags,
|
||||||
info: translateLineInfo(c, g, si, s.info),
|
info: translateLineInfo(c, g, si, s.info),
|
||||||
options: s.options,
|
options: s.options,
|
||||||
position: s.position,
|
position: if s.kind in {skForVar, skVar, skLet, skTemp}: 0 else: s.position,
|
||||||
|
offset: if s.kind in routineKinds: defaultOffset else: s.offset,
|
||||||
name: getIdent(c.cache, g[si].fromDisk.sh.strings[s.name])
|
name: getIdent(c.cache, g[si].fromDisk.sh.strings[s.name])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
## This module contains the type definitions for the new evaluation engine.
|
## This module contains the type definitions for the new evaluation engine.
|
||||||
## An instruction is 1-3 int32s in memory, it is a register based VM.
|
## An instruction is 1-3 int32s in memory, it is a register based VM.
|
||||||
|
|
||||||
|
import std / tables
|
||||||
|
|
||||||
import ast, idents, options, modulegraphs, lineinfos
|
import ast, idents, options, modulegraphs, lineinfos
|
||||||
|
|
||||||
type TInstrType* = uint64
|
type TInstrType* = uint64
|
||||||
|
|
@ -266,6 +268,7 @@ type
|
||||||
profiler*: Profiler
|
profiler*: Profiler
|
||||||
templInstCounter*: ref int # gives every template instantiation a unique ID, needed here for getAst
|
templInstCounter*: ref int # gives every template instantiation a unique ID, needed here for getAst
|
||||||
vmstateDiff*: seq[(PSym, PNode)] # we remember the "diff" to global state here (feature for IC)
|
vmstateDiff*: seq[(PSym, PNode)] # we remember the "diff" to global state here (feature for IC)
|
||||||
|
procToCodePos*: Table[int, int]
|
||||||
|
|
||||||
PStackFrame* = ref TStackFrame
|
PStackFrame* = ref TStackFrame
|
||||||
TStackFrame* = object
|
TStackFrame* = object
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
# solves the opcLdConst vs opcAsgnConst issue. Of course whether we need
|
# solves the opcLdConst vs opcAsgnConst issue. Of course whether we need
|
||||||
# this copy depends on the involved types.
|
# this copy depends on the involved types.
|
||||||
|
|
||||||
|
import std / tables
|
||||||
|
|
||||||
import
|
import
|
||||||
strutils, ast, types, msgs, renderer, vmdef,
|
strutils, ast, types, msgs, renderer, vmdef,
|
||||||
intsets, magicsys, options, lowerings, lineinfos, transf
|
intsets, magicsys, options, lowerings, lineinfos, transf
|
||||||
|
|
@ -2248,8 +2250,8 @@ proc optimizeJumps(c: PCtx; start: int) =
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
proc genProc(c: PCtx; s: PSym): int =
|
proc genProc(c: PCtx; s: PSym): int =
|
||||||
var x = s.ast[miscPos]
|
let pos = c.procToCodePos.getOrDefault(s.id)
|
||||||
if x.kind == nkEmpty or x[0].kind == nkEmpty:
|
if pos == 0:
|
||||||
#if s.name.s == "outterMacro" or s.name.s == "innerProc":
|
#if s.name.s == "outterMacro" or s.name.s == "innerProc":
|
||||||
# echo "GENERATING CODE FOR ", s.name.s
|
# echo "GENERATING CODE FOR ", s.name.s
|
||||||
let last = c.code.len-1
|
let last = c.code.len-1
|
||||||
|
|
@ -2260,11 +2262,7 @@ proc genProc(c: PCtx; s: PSym): int =
|
||||||
c.debug.setLen(last)
|
c.debug.setLen(last)
|
||||||
#c.removeLastEof
|
#c.removeLastEof
|
||||||
result = c.code.len+1 # skip the jump instruction
|
result = c.code.len+1 # skip the jump instruction
|
||||||
if x.kind == nkEmpty:
|
c.procToCodePos[s.id] = result
|
||||||
x = newTree(nkBracket, newIntNode(nkIntLit, result), x)
|
|
||||||
else:
|
|
||||||
x[0] = newIntNode(nkIntLit, result)
|
|
||||||
s.ast[miscPos] = x
|
|
||||||
# thanks to the jmp we can add top level statements easily and also nest
|
# thanks to the jmp we can add top level statements easily and also nest
|
||||||
# procs easily:
|
# procs easily:
|
||||||
let body = transformBody(c.graph, c.idgen, s, cache = not isCompileTimeProc(s))
|
let body = transformBody(c.graph, c.idgen, s, cache = not isCompileTimeProc(s))
|
||||||
|
|
@ -2297,4 +2295,4 @@ proc genProc(c: PCtx; s: PSym): int =
|
||||||
c.prc = oldPrc
|
c.prc = oldPrc
|
||||||
else:
|
else:
|
||||||
c.prc.maxSlots = s.offset
|
c.prc.maxSlots = s.offset
|
||||||
result = x[0].intVal.int
|
result = pos
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue