Skip to content

Commit

Permalink
Merge #297
Browse files Browse the repository at this point in the history
297: vm: improve aliasing of `slots` under ORC r=saem a=zerbina

Indirectly accessing `slots` via a `TStackFrame` pointer was done to
work around `shallowCopy` not being available for `seq` with ORC.

The shallow copy is now replicated with the `cursor` pragma, saving
one pointer indirection



Co-authored-by: zerbina <100542850+zerbina@users.noreply.github.com>
  • Loading branch information
bors[bot] and zerbina authored May 3, 2022
2 parents 12d585d + 311dc69 commit d6c0ba0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/vm/vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,11 @@ proc rawExecute(c: var TCtx, pc: var int, tos: var StackFrameIndex): TFullReg =
var savedPC = -1
var savedFrame: StackFrameIndex
when defined(gcArc) or defined(gcOrc):
var tosPtr: ptr TStackFrame
template regs: untyped = tosPtr.slots
# Use {.cursor.} as a way to get a shallow copy of the seq. This is safe,
# since `slots` is never changed in length (no add/delete)
var regs {.cursor.}: seq[TFullReg]
template updateRegsAlias =
tosPtr = addr c.sframes[tos]
regs = c.sframes[tos].slots
updateRegsAlias
else:
template updateRegsAlias =
Expand Down

0 comments on commit d6c0ba0

Please sign in to comment.