diff options
author | Araq <rumpf_a@web.de> | 2019-09-20 17:46:03 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-09-21 06:43:37 +0200 |
commit | 05e80e1cda2b5c955027eff5b41f22f6c17ada08 (patch) | |
tree | 837e01d592f20cee0096e6d6a05a5b8c81b124a8 /lib/core | |
parent | 78396583234d0902d9cad095f81c44c8e32e2db7 (diff) | |
download | Nim-05e80e1cda2b5c955027eff5b41f22f6c17ada08.tar.gz |
lib\pure\htmlgen.nim
avoid callsite for htmlgen
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/refs.nim | 97 | ||||
-rw-r--r-- | lib/core/typelayouts.nim | 19 |
2 files changed, 0 insertions, 116 deletions
diff --git a/lib/core/refs.nim b/lib/core/refs.nim deleted file mode 100644 index e1575b68c..000000000 --- a/lib/core/refs.nim +++ /dev/null @@ -1,97 +0,0 @@ -# -# -# Nim's Runtime Library -# (c) Copyright 2017 Nim contributors -# -# See the file "copying.txt", included in this -# distribution, for details about the copyright. -# - -## Default ref implementation used by Nim's core. - -# We cannot use the allocator interface here as we require a heap walker to -# exist. Thus we import 'alloc' directly here to get our own heap that is -# all under the GC's control and can use the ``allObjects`` iterator which -# is crucial for the "sweep" phase. -import typelayouts, alloc - -type - TracingGc = ptr object of Allocator - visit*: proc (fieldAddr: ptr pointer; a: Allocator) {.nimcall.} - - GcColor = enum - white = 0, black = 1, grey = 2 ## to flip the meaning of white/black - ## perform (1 - col) - - GcHeader = object - t: ptr TypeLayout - color: GcColor - Cell = ptr GcHeader - - GcFrame {.core.} = object - prev: ptr GcFrame - marker: proc (self: GcFrame; a: Allocator) - - Phase = enum - None, Marking, Sweeping - - GcHeap = object - r: MemRegion - phase: Phase - currBlack, currWhite: GcColor - greyStack: seq[Cell] - -var - gch {.threadvar.}: GcHeap - -proc `=trace`[T](a: ref T) = - if not marked(a): - mark(a) - `=trace`(a[]) - -template usrToCell(p: pointer): Cell = - -template cellToUsr(cell: Cell): pointer = - cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(GcHeader))) - -template usrToCell(usr: pointer): Cell = - cast[Cell](cast[ByteAddress](usr)-%ByteAddress(sizeof(GcHeader))) - -template markGrey(x: Cell) = - if x.color == gch.currWhite and phase == Marking: - x.color = grey - add(gch.greyStack, x) - -proc `=`[T](dest: var ref T; src: ref T) = - ## full write barrier implementation. - if src != nil: - let s = usrToCell(src) - markGrey(s) - system.`=`(dest, src) - -proc linkGcFrame(f: ptr GcFrame) {.core.} -proc unlinkGcFrame() {.core.} - -proc setGcFrame(f: ptr GcFrame) {.core.} - -proc registerGlobal(p: pointer; t: ptr TypeLayout) {.core.} -proc unregisterGlobal(p: pointer; t: ptr TypeLayout) {.core.} - -proc registerThreadvar(p: pointer; t: ptr TypeLayout) {.core.} -proc unregisterThreadvar(p: pointer; t: ptr TypeLayout) {.core.} - -proc newImpl(t: ptr TypeLayout): pointer = - let r = cast[Cell](rawAlloc(t.size + sizeof(GcHeader))) - r.typ = t - result = r +! sizeof(GcHeader) - -template new*[T](x: var ref T) = - x = newImpl(getTypeLayout(x)) - - -when false: - # implement these if your GC requires them: - proc writeBarrierLocal() {.core.} - proc writeBarrierGlobal() {.core.} - - proc writeBarrierGeneric() {.core.} diff --git a/lib/core/typelayouts.nim b/lib/core/typelayouts.nim deleted file mode 100644 index 445ce77c4..000000000 --- a/lib/core/typelayouts.nim +++ /dev/null @@ -1,19 +0,0 @@ -# -# -# Nim's Runtime Library -# (c) Copyright 2017 Nim contributors -# -# See the file "copying.txt", included in this -# distribution, for details about the copyright. -# - -type - TypeLayout* = object - size*, alignment*: int - destructor*: proc (self: pointer; a: Allocator) {.nimcall.} - trace*: proc (self: pointer; a: Allocator) {.nimcall.} - when false: - construct*: proc (self: pointer; a: Allocator) {.nimcall.} - copy*, deepcopy*, sink*: proc (self, other: pointer; a: Allocator) {.nimcall.} - -proc getTypeLayout(t: typedesc): ptr TypeLayout {.magic: "getTypeLayout".} |