Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM: fixes most ran-out-registers problems [backport] #12485

Merged
merged 1 commit into from
Oct 24, 2019
Merged

Conversation

Araq
Copy link
Member

@Araq Araq commented Oct 22, 2019

No description provided.

@zevv
Copy link
Contributor

zevv commented Oct 22, 2019

A pretty hefty test case that used to run out of registers now shows:

Error: unhandled exception: vmgen.nim(354, 20) `false` leaking temporary 10 slotTempInt [AssertionError]

Stack:

/home/ico/external/Nim/compiler/nim.nim(106) nim
/home/ico/external/Nim/compiler/nim.nim(83) handleCmdLine
/home/ico/external/Nim/compiler/cmdlinehelper.nim(98) loadConfigsAndRunMainCommand
/home/ico/external/Nim/compiler/main.nim(188) mainCommand
/home/ico/external/Nim/compiler/main.nim(92) commandCompileToC
/home/ico/external/Nim/compiler/modules.nim(144) compileProject
/home/ico/external/Nim/compiler/modules.nim(85) compileModule
/home/ico/external/Nim/compiler/passes.nim(216) processModule
/home/ico/external/Nim/compiler/passes.nim(86) processTopLevelStmt
/home/ico/external/Nim/compiler/sem.nim(601) myProcess
/home/ico/external/Nim/compiler/sem.nim(569) semStmtAndGenerateGenerics
/home/ico/external/Nim/compiler/semstmts.nim(2214) semStmt
/home/ico/external/Nim/compiler/semexprs.nim(987) semExprNoType
/home/ico/external/Nim/compiler/semexprs.nim(2775) semExpr
/home/ico/external/Nim/compiler/importer.nim(214) evalImport
/home/ico/external/Nim/compiler/importer.nim(184) impMod
/home/ico/external/Nim/compiler/importer.nim(156) myImportModule
/home/ico/external/Nim/compiler/modules.nim(99) importModule
/home/ico/external/Nim/compiler/modules.nim(85) compileModule
/home/ico/external/Nim/compiler/passes.nim(216) processModule
/home/ico/external/Nim/compiler/passes.nim(86) processTopLevelStmt
/home/ico/external/Nim/compiler/sem.nim(601) myProcess
/home/ico/external/Nim/compiler/sem.nim(569) semStmtAndGenerateGenerics
/home/ico/external/Nim/compiler/semstmts.nim(2214) semStmt
/home/ico/external/Nim/compiler/semexprs.nim(987) semExprNoType
/home/ico/external/Nim/compiler/semexprs.nim(2775) semExpr
/home/ico/external/Nim/compiler/importer.nim(214) evalImport
/home/ico/external/Nim/compiler/importer.nim(184) impMod
/home/ico/external/Nim/compiler/importer.nim(156) myImportModule
/home/ico/external/Nim/compiler/modules.nim(99) importModule
/home/ico/external/Nim/compiler/modules.nim(85) compileModule
/home/ico/external/Nim/compiler/passes.nim(210) processModule
/home/ico/external/Nim/compiler/passes.nim(86) processTopLevelStmt
/home/ico/external/Nim/compiler/sem.nim(601) myProcess
/home/ico/external/Nim/compiler/sem.nim(569) semStmtAndGenerateGenerics
/home/ico/external/Nim/compiler/semstmts.nim(2214) semStmt
/home/ico/external/Nim/compiler/semexprs.nim(987) semExprNoType
/home/ico/external/Nim/compiler/semexprs.nim(2742) semExpr
/home/ico/external/Nim/compiler/semstmts.nim(2154) semStmtList
/home/ico/external/Nim/compiler/semexprs.nim(2639) semExpr
/home/ico/external/Nim/compiler/semexprs.nim(969) semDirectOp
/home/ico/external/Nim/compiler/semexprs.nim(861) afterCallActions
/home/ico/external/Nim/compiler/sem.nim(470) semMacroExpr
/home/ico/external/Nim/compiler/vm.nim(2158) evalMacroCall
/home/ico/external/Nim/compiler/vm.nim(1113) rawExecute
/home/ico/external/Nim/compiler/vm.nim(459) compile
/home/ico/external/Nim/compiler/vmgen.nim(2251) genProc
/home/ico/external/Nim/compiler/vmgen.nim(286) gen
/home/ico/external/Nim/compiler/vmgen.nim(2060) gen
/home/ico/external/Nim/compiler/vmgen.nim(286) gen
/home/ico/external/Nim/compiler/vmgen.nim(2047) gen
/home/ico/external/Nim/compiler/vmgen.nim(343) genBlock
/home/ico/external/Nim/compiler/vmgen.nim(2060) gen
/home/ico/external/Nim/compiler/vmgen.nim(286) gen
/home/ico/external/Nim/compiler/vmgen.nim(2060) gen
/home/ico/external/Nim/compiler/vmgen.nim(286) gen
/home/ico/external/Nim/compiler/vmgen.nim(2047) gen
/home/ico/external/Nim/compiler/vmgen.nim(343) genBlock
/home/ico/external/Nim/compiler/vmgen.nim(2060) gen
/home/ico/external/Nim/compiler/vmgen.nim(286) gen
/home/ico/external/Nim/compiler/vmgen.nim(2060) gen
/home/ico/external/Nim/compiler/vmgen.nim(286) gen
/home/ico/external/Nim/compiler/vmgen.nim(2047) gen
/home/ico/external/Nim/compiler/vmgen.nim(354) genBlock
/home/ico/external/Nim/lib/system/assertions.nim(27) failedAssertImpl
/home/ico/external/Nim/lib/system/assertions.nim(20) raiseAssert
/home/ico/external/Nim/lib/system/fatal.nim(39) sysFatal

@krux02
Copy link
Contributor

krux02 commented Oct 22, 2019

@zevv can you tell what code failed specifically?

Comment on lines +349 to +354
if c.prc.slots[i].inUse and c.prc.slots[i].kind in {slotTempUnknown,
slotTempInt,
slotTempFloat,
slotTempStr,
slotTempComplex}:
doAssert false, "leaking temporary " & $i & " " & $c.prc.slots[i].kind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I like this part. Maybe a normal assert is better here. Currently koch boot -d:danger will have this test enabled, even though that is not the desired behavior here.

@narimiran narimiran closed this Oct 24, 2019
@narimiran narimiran reopened this Oct 24, 2019
@Araq Araq merged commit 801a794 into devel Oct 24, 2019
@Araq Araq deleted the araq-vm-improvements branch October 24, 2019 15:29
narimiran pushed a commit that referenced this pull request Oct 24, 2019
@zevv
Copy link
Contributor

zevv commented Oct 28, 2019

sorry for the late response, I thought it was caused by my Nim compiler being in some kind of mixed up state, but I now get the same error on devel.

I'm having a hard time to isolate the issue, but reproducing is easy. Do a nimble install npeg and compile:

import npeg

will give the above error.

@zevv
Copy link
Contributor

zevv commented Oct 28, 2019

Reduced it down to this snippet:

type

  thingKind = enum
    One

  Thing = object
    case op: thingKind
      of One:
        name: int

static:
  var g: seq[Thing]
  for i in g.items:
    if i.op == One:
      var i2 = i
      i2.name = 44

Reported as a separate issue at #12547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants