Commit Graph

116 Commits

Author SHA1 Message Date
Tail Wag Games
cfdac6666f Freeing critical sections via atexit in system/alloc and system/io (#19062)
* adding new system module sysexitprocs and including system exit procedures when registering exit handlers defined in userland

* fixing failing tests and adding initialization guard to handle cases where the module's global init logic isn't invoked first as is the case with some gc implementaions

* js backend shouldn't try to invoke actual system exit procs

* fixing formatting in sysexitprocs.nim

* 256 was too much - my max number of plugins in my engine is 64 and I require two hooks per runtime it looks like with tls emulation turned off, so for my purposes 128 should be sufficient

* so atExit should be enough here, can get rid of all the extra cruft I had added on top since I didn't realize atExit already provided a stack

* done being cute - since newruntime prevents correct cpp codegen for object variants apparently and breaks tests if I try to use std/exitprocs, ddSysExitProc is just going into both modules. Since system doesn't include system/io, polluting system with it doesn't make sense either... at least it is only importc'd when it is required in either module and we don't have to have any weird when defined(nimOwnedEnabled) with a comment explaining why
2021-10-29 13:42:44 +02:00
Andreas Rumpf
f46569bafd fixes #18494 (#18783) 2021-09-02 17:16:03 +02:00
Andreas Rumpf
af3d2d8ad9 added nimAllocPagesViaMalloc switch (#18490)
* added  switch

* alloc.nim needs page aligned memory blocks
2021-07-15 17:58:47 +02:00
Andreas Rumpf
98cd1671a3 minor cleanups (#17948) 2021-05-06 13:27:40 +02:00
Andreas Rumpf
edce5897a5 fixes #16214 [backport] (#16252) 2020-12-04 17:47:41 +01:00
Andreas Rumpf
da29222f86 init checks and 'out' parameters (#14521)
* I don't care about observable stores
* enforce explicit initializations
* cleaner code for the stdlib
* stdlib: use explicit initializations
* make tests green
* algorithm.nim: set result explicitly
* remove out parameters and bring the PR into a mergable state
* updated the changelog
2020-06-23 10:53:57 +02:00
Arne Döring
4005f0d0e4 forward type alignment information to seqs (#12430) 2020-04-19 07:52:01 +02:00
Andreas Rumpf
be795bbf1a TlSF Alloctor: use less memory for --gc:arc (#13280) 2020-01-28 17:09:48 +01:00
Ico Doornekamp
b68eb1cad0 Removed lib/system/allocators.nim. seqs_v2 and strs_v2 now uses allocShared0. (#13190)
* Cleanup, remove lib/system/allocators.nim. seqs_v2 and strs_v2 now use
allocShared0 by default.

* Fixed -d:useMalloc allocShared / reallocShared / deallocShared. These now use the alloc/dealloc/realloc implementation that also takes care of zeroing memory at realloc.

* Removed debug printfs

* Removed unpairedEnvAllocs() from tests/destructor/tnewruntime_misc

* More mmdisp cleanups. The shared allocators do not need to zero memory or throw since the regular ones already do that

* Introduced realloc0 and reallocShared0, these procs are now used by
strs_v2 and seqs_v2. This also allowed the -d:useMalloc allocator to
drop the extra header with allocation length.

* Moved strs_v2/seqs_v2 'allocated' flag into 'cap' field

* Added 'getAllocStats()' to get low level alloc/dealloc counters. Enable with -d:allocStats

* *allocShared implementations for boehm and go allocators now depend on the proper *allocImpl procs
2020-01-23 14:25:22 +01:00
Andreas Rumpf
fd85a5ae05 more fixes for --cpu:avr [backport] (#12748) 2019-11-27 16:24:21 +01:00
Andreas Rumpf
b07694cd90 new gensym handling (#11985)
* new .gensym implementation
* make astspec test green again
* introduce a --useVersion switch to group compatibility switches
* fixes #10180
* fixes #11494 
* fixes #11483
* object constructor fields and named parameters are also not gensym'ed
* disabled broken package
2019-08-23 16:15:02 +02:00
Araq
c94647aeca styleCheck: make the compiler and large parts of the stdlib compatible with --styleCheck:error 2019-07-10 12:42:41 +02:00
Arne Döring
5b27b263fd Remove immediate pragma (#11308)
* remove immediate from tests
* remove immediate from the compiler
2019-05-29 22:21:51 +02:00
Arne Döring
88b5dd3362 right shift is now by default sign preserving (#11322)
* right shift is now by default sign preserving
* fix hashString and semfold
* enable arithmetic shift right globally for CI
* fix typo
* remove xxx
* use oldShiftRight as flag
* apply feedback
* add changelog entry
2019-05-29 16:48:00 +02:00
Andreas Rumpf
e263702688 --newruntime: progress 2019-03-14 19:53:27 +01:00
Andreas Rumpf
f7c0360aba allocators: introduce --define:nimMinHeapPages for tuning mmap calls (omg they are slow on OSX...) 2019-01-19 12:48:39 +01:00
Christopher Dunn
cc1fd50b27 Try to let memTracker compile (#8502) 2018-08-05 09:53:10 +02:00
jcosborn
8f4c5a8955 fixed #7894 (#8496)
make system tests run properly
2018-08-01 10:57:35 +02:00
Dominik Picheta
5ea3b4d581 Implements alloc/dealloc counters for better leak debugging. (#8384) 2018-07-21 01:43:13 +02:00
Yuriy Glukhov
dfe3f16022 Don't depend on string.h in codegen (#8299) 2018-07-13 17:41:59 +02:00
jcosborn
e39f2a9283 fix allocator corruption for large sizes (#7338)
* fix allocator corruption for large sizes
* allow large chunks to coalesce and added test case
* use correct constants in MaxBigChunkSize
2018-03-17 23:59:04 +01:00
Araq
6d4107b783 make the allocator take a special path for allocations bigger than 2GB; fixes #7120 2018-02-27 01:46:52 +01:00
Andreas Rumpf
8fdc291936 fixes the tracking of 'occupied memory' 2018-01-30 10:30:18 +01:00
Andreas Rumpf
03b7df74a9 alloc.nim: Make 'logAlloc' produce a toy Nim program for easier memory tracing 2018-01-18 10:46:23 +01:00
Araq
f71f9f83c2 GC improvements; distinguish between thread local and globals in the marking step 2018-01-14 17:34:27 +01:00
Andreas Rumpf
e24a3bd0ab allocator: minor fix for deallocOsPages 2017-12-11 09:18:11 +01:00
Araq
7c9a3161da make the new allocator work 2017-12-07 13:24:18 +01:00
Araq
ede38a70fc make allocator use the TLSF algorithm; work in progress 2017-12-07 10:54:46 +01:00
Araq
4a7266e1c1 fixes #3558 2017-10-16 12:29:40 +02:00
Andreas Rumpf
8db37455dd fixes withRegion for --gc:stack 2017-06-19 17:43:12 +02:00
Andreas Rumpf
c785066ee3 memory manager: use less memory; corruption prevention 2017-04-02 21:06:10 +02:00
Eugene Kabanov
254fbcc548 Fixes #4719. (#5585) 2017-03-23 16:13:38 +01:00
Araq
518696f3a7 hotfix: allocator: don't set origSize to 0 2017-03-15 17:51:26 +01:00
Araq
98c7bab8ea make memory tracker work without onThreadCreation 2017-03-14 15:45:35 +01:00
Andreas Rumpf
0bb18d1821 introduce nimMaxHeap define to fight memory overcommit 2017-02-10 09:22:28 +01:00
Araq
346ea6d171 system.nim: don't use deprecated symbols/constructs 2017-02-08 14:55:30 +01:00
Andreas Rumpf
04c4d3d77f critical realloc bugfix; refs #4818 2017-02-03 09:48:52 +01:00
Araq
b3e55e532b allocator: fixes regression: get alignment right for small objects 2017-01-31 21:21:08 +01:00
Araq
d59dd577f8 make AVL tree node part of the memory regions; fixes hard to reproduce channel crashes 2017-01-31 13:08:23 +01:00
Andreas Rumpf
51c764e048 fix the racy allocator properly 2017-01-31 08:55:18 +01:00
Araq
79f4b37d3b added test case; threadex example crashes now 2017-01-30 21:11:37 +01:00
Araq
b26e6e3589 fixes #5301 2017-01-30 19:01:03 +01:00
Andreas Rumpf
05a3c1b10a improvements to memtracking 2017-01-26 11:26:02 +01:00
Andreas Rumpf
9753782f96 memory allocator hotfix: do not allocate tremendous amounts of memory 2017-01-13 12:07:37 +01:00
Andreas Rumpf
847210b799 disable new alloctor behaviour for emscripten 2016-12-27 17:54:09 +01:00
Araq
39ca8b8c8e fixes #4818 2016-12-18 23:11:53 +01:00
Andreas Rumpf
249fd5e56b further memtracking improvements 2016-11-24 08:27:19 +01:00
Andreas Rumpf
bc53d2c9de bugfix: bottom of AVL tree is now threadsafe 2016-09-24 02:27:12 +02:00
Jacek Sieka
b3846124e6 clean up a few stray c_stdout's in gc debug code 2016-07-31 08:34:42 +08:00
Jacek Sieka
64b0485207 fix types of ansi_c/sysio to more closely match C ABI
also fixes some instances of using C library functions when there are
nim alternatives available
2016-06-05 12:03:20 +08:00