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

take the one good idea from --os:standalone and enable it via -d:Stan… #13077

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/system/mmdisp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const

proc raiseOutOfMem() {.noinline.} =
if outOfMemHook != nil: outOfMemHook()
cstderr.rawWrite("out of memory")
cstderr.rawWrite("out of memory\n")
quit(1)

when defined(boehmgc):
Expand Down
14 changes: 7 additions & 7 deletions lib/system/osalloc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const doNotUnmap = not (defined(amd64) or defined(i386)) or
defined(windows) or defined(nimAllocNoUnmap)


when defined(emscripten):
when defined(emscripten) and not defined(StandaloneHeapSize):
const
PROT_READ = 1 # page can be read
PROT_WRITE = 2 # page can be written
Expand Down Expand Up @@ -77,10 +77,10 @@ when defined(emscripten):
var mmapDescr = cast[EmscriptenMMapBlock](mmapDescrPos)
munmap(mmapDescr.realPointer, mmapDescr.realSize)

elif defined(genode):
elif defined(genode) and not defined(StandaloneHeapSize):
include genode/alloc # osAllocPages, osTryAllocPages, osDeallocPages

elif defined(nintendoswitch):
elif defined(nintendoswitch) and not defined(StandaloneHeapSize):

import nintendoswitch/switch_memory

Expand Down Expand Up @@ -191,7 +191,7 @@ elif defined(nintendoswitch):
when reallyOsDealloc:
freeMem(p)

elif defined(posix):
elif defined(posix) and not defined(StandaloneHeapSize):
const
PROT_READ = 1 # page can be read
PROT_WRITE = 2 # page can be written
Expand Down Expand Up @@ -234,7 +234,7 @@ elif defined(posix):
proc osDeallocPages(p: pointer, size: int) {.inline.} =
when reallyOsDealloc: discard munmap(p, cast[csize_t](size))

elif defined(windows):
elif defined(windows) and not defined(StandaloneHeapSize):
const
MEM_RESERVE = 0x2000
MEM_COMMIT = 0x1000
Expand Down Expand Up @@ -274,10 +274,10 @@ elif defined(windows):
quit 1
#VirtualFree(p, size, MEM_DECOMMIT)

elif hostOS == "standalone":
elif hostOS == "standalone" or defined(StandaloneHeapSize):
const StandaloneHeapSize {.intdefine.}: int = 1024 * PageSize
var
theHeap: array[StandaloneHeapSize, float64] # 'float64' for alignment
theHeap: array[StandaloneHeapSize div sizeof(float64), float64] # 'float64' for alignment
bumpPointer = cast[int](addr theHeap)

proc osAllocPages(size: int): pointer {.inline.} =
Expand Down