Commit Graph

1563 Commits

Author SHA1 Message Date
Andreas Rumpf
fd8b79707c Revert "system/excpt: check if the exception is not nil before pop (#18247)" (#18265)
This reverts commit 0adb47aa15.
2021-06-17 08:20:10 +02:00
alaviss
0adb47aa15 system/excpt: check if the exception is not nil before pop (#18247)
In CPS we would consume an exception in the except branch by stashing it
into a local then remove the exception from Nim environment so as not to
leak it to other code that would be running before the continuation
continues

However since popCurrentException() assumes that the exception always
exist, removing the exception from an except branch will cause a
SIGSEGV to happen. This commit fixes that.
2021-06-14 18:26:12 +02:00
Timothee Cour
c871e22da2 fix #7717 roundtrip float to string; fix parseFloat for js (#18248)
* refs #7717 roundtrip float to string
* make parseFloat more correct
* improve float tests
* improve float tests
* cleanup
2021-06-13 07:32:47 +02:00
Miran
57609902c4 use more meaningful name than "workaround14447" (#18237) 2021-06-11 10:07:23 +02:00
slangmgh
e7aa41ff3f fix 18186 with adding importc _umul128 (#18200) 2021-06-07 11:42:32 +02:00
Andreas Rumpf
daaa40973c added float32 schubfach algorithm; wip (#18155)
* added float32 schubfach algorithm; wip

* fixes #18418
2021-06-03 12:09:40 +02:00
Timothee Cour
0de3d4292f fix #16993, #18054, #17835 runnableExamples now works with templates and nested templates (#18082) 2021-06-02 09:02:14 -07:00
Andreas Rumpf
63db2b19bf use dragonbox algorithm; alternative to #18008 (#18139)
* use dragonbox algorithm; alternative to #18008
* removed unsafe code
2021-06-01 22:29:53 +02:00
flywind
c2e3dc0ed1 close #18129 Add setCurrentException for JS backend (#18145)
* [std/re] make interface consistent

* tiny

* revert

* close #18129  add setCurrentException

* changelog entry
2021-06-01 18:16:25 +02:00
Ștefan Talpalaru
a1c82c39af asyncdispatch+stackTraceOverride: fix premature collection (#18039) [backport:1.2]
Copying StackTraceEntry instances when nimStackTraceOverride is defined
breaks the link between a cstring field that's supposed to point at
another string field in the same object.

Sometimes, the original object is garbage collected, that memory region
reused for storing other strings, so when the StackTraceEntry copy tries
to use its cstring pointer to construct a traceback message, it accesses
unrelated strings.

This only happens for async tracebacks and this patch prevents that by
making sure we only use the string fields when nimStackTraceOverride is
defined.

Async tracebacks also beautified slightly by getting rid of an extra line
that was supposed to be commented out, along with the corresponding debugging output.

There's also a micro-optimisation to avoid concatenating two strings just
to get their combined length.
2021-05-19 19:19:11 +02:00
Andreas Rumpf
53935b8b27 ARC: fixes memory leaks with newSeq used in a loop [backport:1.4] (#18040)
* ARC: fixes memory leaks with newSeq used in a loop [backport:1.4]
* Update tests/arc/tnewseq_legacy.nim
2021-05-18 21:45:37 +02:00
Andreas Rumpf
4857c462d5 Revert "fix #14873 properly by skipping abi field in importc type (#17944)" (#17992)
This reverts commit 98c29c01eb.
2021-05-15 06:50:39 +02:00
Andreas Rumpf
3bc625aff1 ORC: progress (#18000)
* ORC: progress

* ORC: bugfix; don't follow acyclic data even if only at runtime the subtype is marked as acyclic

* progress

* minor style changes
2021-05-12 22:00:37 +02:00
Timothee Cour
38b41f893a fix #17941: UnusedImport works for var/let/const/type invoked inside a generic (#17942)
* fix #17941: UnusedImport works for var/let/const/type invoked inside a generic

* fixup
2021-05-08 09:56:46 +02:00
Timothee Cour
98c29c01eb fix #14873 properly by skipping abi field in importc type (#17944)
* fix #14873 properly by skipping `abi` field in importc type

* add test

* fix test for windows
2021-05-07 19:36:41 +02:00
Timothee Cour
0b4b9b3ad0 remove unsused OsPlatform.nimVM (#17953) 2021-05-07 06:55:46 +02:00
Danil Yarantsev
9b126de65c Fix C++ compilation error in excpt.nim (#17951) 2021-05-06 22:33:57 +02:00
Andreas Rumpf
98cd1671a3 minor cleanups (#17948) 2021-05-06 13:27:40 +02:00
Andreas Rumpf
fb86271556 system.nim cleanup some exported constants which should never have be… (#17909)
* system.nim cleanup some exported constants which should never have been exported
2021-05-01 11:10:40 +02:00
flywind
22e06ee95a Ref #17831(synchapi.h: No such file or directory) (#17832)
* Ref #17831 use windows.h

* use header: "windows.h"

* Update syslocks.nim

* Update lib/system/syslocks.nim
2021-04-25 10:34:53 +02:00
flywind
53c898de41 fix #17812 (repr fails to compile with ARC/ORC) (#17816) 2021-04-22 08:08:56 +02:00
Clyybber
6de5aa1971 Rename = to =copy in stdlib (#17781) 2021-04-19 13:16:10 +02:00
flywind
dc89b21257 [std/locks]close #7998(complete condition variables) (#17711)
* close #7998
* workaround genode

* Update lib/system/syslocks.nim
2021-04-19 10:51:13 +02:00
Timothee Cour
42c6eec4ef fix #17749 ignore SIGPIPE signals, fix nim CI #17748 (#17752)
* fix #17749 SIGPIPE

* fix for windows
2021-04-18 15:34:29 +02:00
Timothee Cour
7e94420847 cString => cSourceString; tyCString => tyCstring so that error msgs show cstring, not cString (#17744) 2021-04-17 11:14:09 +02:00
flywind
12783dbcf0 make the copy operation of Thread an error (#17734) 2021-04-16 08:50:44 +02:00
zah
3b47a689cf Remove the use of usrToCell in gcMark [backport:1.2] (#17709)
* Remove the use of usrToCell in gcMark [backport:1.2]

Recently, we've discovered a GC crash resulting from inlining of
the memory allocation procs that allowed the compiler to avoid
maintaining any references to the "user pointer" on the stack.
Instead, a "cell pointer" appeared there and all field accesses
were performed with adjusted offsets. This interfered with the
ability of the GC to mark the correct cell in the conservative
stack scans which lead to premature collection of objects.

More details here:
af69b3ceae

This commit closes another theoretical loophole that may lead to
the same problem. If a short proc is accessing both the object and
its reference count in a short sequence of instructions, the compiler
may be enticed to reduce the number of registers being used by storing
only a single pointer to the object and using offsets when reading
and writing fields. A perfectly good strategy would be to store only
the cell pointer, so the reference count updates can be performed
without applying offsets. Accessing the fields of the object requires
offsets anyway, but these can be adjusted at compile-time without any
loss. Following this strategy will lead to the same problem of marking
a wrong cell during the conservative stack scan, leading to premature
collection.

The problem is avoided by not using `usrToCell` in `gcMark`. Since
the cell discovery logic can already handle interior pointers, the
user pointers don't need to be adjusted for the GC to function correctly.
2021-04-14 12:10:01 +02:00
Emery Hemingway
8aa5991bea Genode platform fixes (#17521)
* Genode: move dyncall failures to runtime

Do not use the "error" pragma to warn that dynamic library loading is
not implemented, print a message at runtime and exit.

* Genode: use stricter dataspace type in page allocator

* Genode: remove compiler configuration from nim.cfg

Self-hosting Nim is not supported on Genode and defining the
cross-compilation environment can be done externally.

* Genode: use new mutex API

* Genode: call nim_component_construct as a C procedure

* Genode: implement echo for NimStringV2
2021-04-09 16:29:10 +02:00
Andrey Makarov
42687457b0 further progress on rst roles & directives (fix #17646) (#17659)
* further progress on rst roles & dir-s (fix #17646)

* fix documents according to the messages

* fix bug 17 from #17340
2021-04-08 19:00:14 +02:00
Andreas Rumpf
bd7807de4c fixes #17647 (#17667) 2021-04-07 23:26:53 +02:00
Andreas Rumpf
939df8cbda ensure the avr example keeps compiling (#17663)
* ensure the avr example keeps compiling

* Update tests/avr/thello.nim

* now compiles properly
2021-04-07 13:40:57 +02:00
Timothee Cour
aa4f18eff0 items(array)+friends: remove a RT comparison (#17650) 2021-04-06 11:11:30 +02:00
Timothee Cour
270964c487 implement RFCs/294 ; disallow enum <=> enum conversion (#16351)
* fix https://github.com/nim-lang/RFCs/issues/294 ; disallow enum <=> enum conversion
* fix the runnableExamples that was the instigator of this RFC
* legacy -d:nimLegacyConvEnumEnum
* use -d:nimLegacyConvEnumEnum in important_package nimgame2
* add test for enum cast
* improve changelog
* add changelog: Changes affecting backward compatibility
* cleanup changelog
* fix changelog
2021-04-03 07:15:21 +02:00
flywind
7c09e0c757 fix #15617(fix compilation failure on -d:useMalloc --gc:none) (#17555)
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-03-30 20:15:14 +02:00
Miran
40093b4a93 [backport:1.2] Avoid inlining of newObj and newObjRC1 calls (#17582)
This is taken from:
af69b3ceae

Full original comment:

This is to avoid heavy inlining happening when two allocation calls
would occur shortly after each other.

This inlining would sometimes be accompanied with an optimisation
as the compiler is able to see that cellToUsr ending the first
allocation call is shortly followed by an usrToCell call. The
pointer arithmetic is redundant and the compiler can eliminate it,
leaving only the cell address in a register (and later the stack)
instead of the actual pointer to the user data, as one would expect.

This combined with a GC collect cycle will cause the stack scan to
only notice the cell address, which is of no good due to a usrToCell
in the gcMark call which shifts that address to an adjacent cell.
This means that the actual cell of importance will not get marked
and thus cause a premature collection of that cell. BOOM.
2021-03-30 10:20:58 +02:00
Clyybber
a672ec3c9e Fix #17299, fix setAffinity for android (#17574)
* Fix #17299

* Comment

* Fix typo
2021-03-30 08:05:37 +02:00
flywind
7ad49950bd [os:standalone]fix #14011 (#17564) 2021-03-29 17:54:28 +02:00
flywind
e5be216ccb [docs]close #12580 (#17549) 2021-03-28 20:21:27 -07:00
flywind
a36816fc04 follow up #17539 (#17548)
* fix nim js cmp fails at CT

* follow up #17539
2021-03-29 09:11:07 +08:00
rockcavera
b77a420d3e set const arch64 to fix compiling with vcc/icc (#17539) 2021-03-28 13:11:51 +08:00
Andreas Rumpf
3e03f67335 cleaned up the internal documentation (#17524) 2021-03-26 16:27:55 +01:00
flywind
c8dda867f2 close #11330 sets uses optimized countSetBits (#17334)
* Update lib/pure/bitops.nim
* Update lib/system/sets.nim
* Apply suggestions from code review

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-03-22 00:36:48 +01:00
Derek 呆
fd09ace557 prevent bitmasks double included in mmdist if -d:nimArcDebug added (#17436) 2021-03-21 14:29:39 +01:00
Andreas Rumpf
6c1c8f51b3 IC: green tests (#17311)
* IC: renamed to_packed_ast module to ic module

* IC: don't store the --forceBuild flag, makes it easier to test

* IC: enable hello world test

* Codegen: refactorings for IC; changed the name mangling algorithm

* fixed the HCR regressions

* life is too short for HCR

* tconvexhull is now allowed to use deepCopy

* IC exposed a stdlib bug, required a refactoring

* codegen: code cleanups

* IC: even if a module is outdated, its dependencies might come from disk

* IC: progress

* IC: better name mangling, module IDs are not stable

* IC: another refactoring helping with --ic:on --gc:arc

* disable arraymancer on Windows for the time being

* disable arraymancer altogether

* IC: make basic test work with 'nim cpp'

* IC: progress on --ic:on --gc:arc

* wip; name mangling for type info
2021-03-19 16:53:38 +01:00
flywind
2e730f1452 rename channels to channels_builtin (#17330)
* improve test coverage for isolation

* a bit better

* rename channels to channels_builtin
2021-03-12 13:04:32 +01:00
konsumlamm
9819fb21d8 Use .. warning:: (#17320) 2021-03-10 10:39:23 -08:00
flywind
0e3ea16554 use lowercase --define switches (#17283) 2021-03-07 12:08:41 +01:00
Andreas Rumpf
8f1fa3e5b0 IC: further progress (#17150)
* IC: respect the -f switch

* IC: better rod file inspection

* progress
2021-03-05 09:58:55 +01:00
Jason Beetham
f28dc2c61e Added assertion to clamp (#17248)
Co-authored-by: flywind <xzsflywind@gmail.com>
2021-03-04 17:27:02 -08:00
Timothee Cour
f561afae41 followup #17225: simplify code after removing gc2, generational (#17242) 2021-03-03 13:37:42 +01:00