summary refs log tree commit diff stats
path: root/lib/system/gc_ms.nim
Commit message (Expand)AuthorAgeFilesLines
* specialize genericReset (#14398)Andreas Rumpf2020-05-191-1/+1
* fixes #13881Andreas Rumpf2020-05-121-3/+4
* Error -> Defect for defects (#13908)Jacek Sieka2020-04-281-1/+1
* forward type alignment information to seqs (#12430)Arne Döring2020-04-191-7/+8
* catchable defects (#13626)Andreas Rumpf2020-03-121-2/+4
* first implementation of the new --seqsv2 switchAraq2019-10-201-2/+2
* gc:destructors progressAraq2019-09-011-1/+1
* styleCheck: make the compiler and large parts of the stdlib compatible with -...Araq2019-07-101-4/+4
* gc: removed dead codeAndreas Rumpf2019-03-141-3/+0
* code cleanup: there is no tyOptRefAndreas Rumpf2019-02-221-4/+4
* system refactorings (#10559)Andreas Rumpf2019-02-061-1/+2
* fixes #10271 [backport]Araq2019-01-131-1/+2
* Remove dead code (#9777)Jacek Sieka2018-11-261-22/+2
* more progress on destructor based stringsAndreas Rumpf2018-07-131-47/+49
* M&S GC: collect earlier under memory pressureAndreas Rumpf2018-01-301-6/+7
* M&S GC: minor code cleanupAndreas Rumpf2018-01-211-6/+0
* Mark&Sweep GC: introduce nimTracing define for debuggingAndreas Rumpf2018-01-191-1/+38
* GC: enable precise global/thread local storage tracingAraq2018-01-151-10/+5
* GC improvements; distinguish between thread local and globals in the marking ...Araq2018-01-141-17/+6
* Fixed mutex usage in SharedList and SharedTable. Closes #6988 (#6990)Yuriy Glukhov2017-12-311-1/+1
* more replacements for the deprecated '<'Andreas Rumpf2017-10-291-2/+2
* GCs: use add instead of &Andreas Rumpf2017-09-291-3/+3
* first steps of making 'opt' a first class type for NimAndreas Rumpf2017-09-251-4/+4
* added system.deallocHeap feature for Nim's native GCsAndreas Rumpf2017-07-221-12/+0
* make the GCs more robustAndreas Rumpf2017-07-201-7/+7
* added logic to the M&S GC to detect logical leaksAraq2017-06-161-0/+55
* Cleanup of gc codeRokas Kupstys2017-02-201-14/+16
* system.nim: don't use deprecated symbols/constructsAraq2017-02-081-1/+1
* M&S GC gets the heap dump featureAndreas Rumpf2017-01-151-14/+17
* Add `import sharedlist` when `hasThreadSupport`James Boyden2016-04-051-0/+3
* GCs support ForeignCellsAndreas Rumpf2016-03-051-0/+7
* fixes #3245Araq2015-08-251-1/+2
* Coroutine support for i386/amd64 platforms unix/windows OSes markAndSweep/ref...rku2015-07-311-153/+23
* Fixes compilation with --gc:markandsweep.Dominik Picheta2015-06-041-1/+1
* lib/system/g-w - Dropped 'T' from typespdw2015-06-041-47/+48
* Fix GC scanning of registers on x86_64 architectures.Reimer Behrends2015-05-071-0/+9
* Fix proc call in gc_msdef2015-03-261-1/+1
* fixed the tester; more tests greenAraq2015-03-101-18/+22
* Fix typosFederico Ceratto2015-02-151-1/+1
* fixes #2070Araq2015-02-101-4/+6
* Happy new year!Guillaume Gelin2015-01-061-1/+1
* added 'setupGcForForeignThread' for better C interopAraq2014-12-111-0/+14
* introduced 'benign' pragmaAraq2014-10-251-8/+8
* make tests greenAraq2014-08-311-26/+26
* the big renamefest: first stepsAraq2014-08-221-2/+2
* implemented builtin noncopying sliceAraq2014-05-021-0/+1
* bugfix: MS-GC GC_unrefAraq2014-04-301-1/+2
* bugfix: MS GC acknowledges GC_ref/unref properlyAraq2014-04-301-6/+45
* marked markAndSweep GC thread safeAraq2014-04-201-8/+8
* mark and sweep GC compiles with --cs:partialAraq2014-02-021-14/+14
n' href='/ahoang/Nim/blame/compiler/enumtostr.nim?h=devel&id=b662842bd04852a751993ed506f9e38155a4e4aa'>^
8bb1a6b04 ^






721396990 ^
7e747d11c ^
8bb1a6b04 ^

7e747d11c ^
8bb1a6b04 ^







7e747d11c ^




8bb1a6b04 ^

d375120c4 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109


                                                     



                                   
                                                                                             
                                                                                 
 
                                                                                   

              
                                                                                        

                                         
                                                         

                                               
                                               







                                                                          
                       









                                                                                       




                                                    

                                  
                                  
 
                                                        



                        
                                                  




                                                                              
                                            

                               





                                                                                         
                                                                                                               
                                                                                              
 
                                                                                   

                      
                                                                                        

                                        
                                                         

                                               
                                               






                                           
                                      
                          

                                                          
                                







                                                                                                     




                                                    

                                  
                                  
import ast, idents, lineinfos, modulegraphs, magicsys

when defined(nimPreviewSlimSystem):
  import std/assertions


proc genEnumToStrProc*(t: PType; info: TLineInfo; g: ModuleGraph; idgen: IdGenerator): PSym =
  result = newSym(skProc, getIdent(g.cache, "$"), nextSymId idgen, t.owner, info)

  let dest = newSym(skParam, getIdent(g.cache, "e"), nextSymId idgen, result, info)
  dest.typ = t

  let res = newSym(skResult, getIdent(g.cache, "result"), nextSymId idgen, result, info)
  res.typ = getSysType(g, info, tyString)

  result.typ = newType(tyProc, nextTypeId idgen, t.owner)
  result.typ.n = newNodeI(nkFormalParams, info)
  rawAddSon(result.typ, res.typ)
  result.typ.n.add newNodeI(nkEffectList, info)

  result.typ.addParam dest

  var body = newNodeI(nkStmtList, info)
  var caseStmt = newNodeI(nkCaseStmt, info)
  caseStmt.add(newSymNode dest)

  # copy the branches over, but replace the fields with the for loop body:
  for i in 0..<t.n.len:
    assert(t.n[i].kind == nkSym)
    var field = t.n[i].sym
    let val = if field.ast == nil: field.name.s else: field.ast.strVal
    caseStmt.add newTree(nkOfBranch, newSymNode(field),
      newTree(nkStmtList, newTree(nkFastAsgn, newSymNode(res), newStrNode(val, info))))
    #newIntTypeNode(nkIntLit, field.position, t)

  body.add(caseStmt)

  var n = newNodeI(nkProcDef, info, bodyPos+2)
  for i in 0..<n.len: n[i] = newNodeI(nkEmpty, info)
  n[namePos] = newSymNode(result)
  n[paramsPos] = result.typ.n
  n[bodyPos] = body
  n[resultPos] = newSymNode(res)
  result.ast = n
  incl result.flags, sfFromGeneric
  incl result.flags, sfNeverRaises

proc searchObjCaseImpl(obj: PNode; field: PSym): PNode =
  case obj.kind
  of nkSym:
    result = nil
  of nkElse, nkOfBranch:
    result = searchObjCaseImpl(obj.lastSon, field)
  else:
    if obj.kind == nkRecCase and obj[0].kind == nkSym and obj[0].sym == field:
      result = obj
    else:
      for x in obj:
        result = searchObjCaseImpl(x, field)
        if result != nil: break

proc searchObjCase(t: PType; field: PSym): PNode =
  result = searchObjCaseImpl(t.n, field)
  if result == nil and t.len > 0:
    result = searchObjCase(t[0].skipTypes({tyAlias, tyGenericInst, tyRef, tyPtr}), field)
  doAssert result != nil

proc genCaseObjDiscMapping*(t: PType; field: PSym; info: TLineInfo; g: ModuleGraph; idgen: IdGenerator): PSym =
  result = newSym(skProc, getIdent(g.cache, "objDiscMapping"), nextSymId idgen, t.owner, info)

  let dest = newSym(skParam, getIdent(g.cache, "e"), nextSymId idgen, result, info)
  dest.typ = field.typ

  let res = newSym(skResult, getIdent(g.cache, "result"), nextSymId idgen, result, info)
  res.typ = getSysType(g, info, tyUInt8)

  result.typ = newType(tyProc, nextTypeId idgen, t.owner)
  result.typ.n = newNodeI(nkFormalParams, info)
  rawAddSon(result.typ, res.typ)
  result.typ.n.add newNodeI(nkEffectList, info)

  result.typ.addParam dest

  var body = newNodeI(nkStmtList, info)
  var caseStmt = newNodeI(nkCaseStmt, info)
  caseStmt.add(newSymNode dest)

  let subObj = searchObjCase(t, field)
  for i in 1..<subObj.len:
    let ofBranch = subObj[i]
    var newBranch = newNodeI(ofBranch.kind, ofBranch.info)
    for j in 0..<ofBranch.len-1:
      newBranch.add ofBranch[j]

    newBranch.add newTree(nkStmtList, newTree(nkFastAsgn, newSymNode(res), newIntNode(nkInt8Lit, i)))
    caseStmt.add newBranch

  body.add(caseStmt)

  var n = newNodeI(nkProcDef, info, bodyPos+2)
  for i in 0..<n.len: n[i] = newNodeI(nkEmpty, info)
  n[namePos] = newSymNode(result)
  n[paramsPos] = result.typ.n
  n[bodyPos] = body
  n[resultPos] = newSymNode(res)
  result.ast = n
  incl result.flags, sfFromGeneric
  incl result.flags, sfNeverRaises