Commit Graph

195 Commits

Author SHA1 Message Date
Timothee Cour
c17cad0992 close #8015: const array indexing zeroes data in object variants at runtime (#16782) 2021-01-21 11:11:42 +01:00
Timothee Cour
0d0e43469f fix #14340 (#16386) 2021-01-01 22:55:22 +01:00
flywind
6d442a40a6 use doAssert in tests (#16486) 2020-12-28 14:13:21 +01:00
Timothee Cour
bc84d9c8cb [backport => 1.0] fix #16428 vmops now works for generic procs (#16429)
* fix #16428 vmops now works for generic procs

* remove duplication
2020-12-22 02:05:21 +01:00
Andreas Rumpf
d306a04466 fixes #16069; [backport:1.2] [backport:1.4] (#16115)
* fixes #16069; refs https://github.com/nim-lang/RFCs/issues/257 [backport:1.2] [backport:1.4]

* make tests green again
2020-11-24 16:09:00 +01:00
Timothee Cour
b3c3557c33 fix #16025 repr now consistent: does not insert trailing newline (#16034) 2020-11-19 12:12:51 -08:00
Andrey R (cooldome)
632af8afad Revert "follow #16009 VM supports cast nil to ptr (#16012)"
This reverts commit fec19c980e.
2020-11-17 18:54:33 +00:00
flywind
fec19c980e follow #16009 VM supports cast nil to ptr (#16012)
* follow #16009 VM supports cast nil to ptr

* more testcase
2020-11-17 10:47:01 +00:00
flywind
203bddf307 close #11637(add testcase for #11637) (#15879)
* close #11637(add testcase for #11637)

* Update tests/vm/t11637.nim
2020-11-08 11:02:12 +08:00
flywind
a8af664e8b fix #15463 (#15831) 2020-11-05 14:00:08 +01:00
flywind
5b4c17b5e7 Closure iterators are not supported by VM (#15818) 2020-11-02 10:58:14 +01:00
flywind
558115fa29 fixes #15717 2020-11-02 10:27:48 +01:00
Timothee Cour
3bdc000521 [backport] fix #15595 procvar == works in VM (#15724) 2020-10-26 22:19:05 +02:00
Timothee Cour
d4c2e2c53f fix #15704 #15597 wrong VM register was freed (#15705)
* fix #15704 #15597 wrong VM register was freed

* same treatment for nkCheckedFieldExpr

* note concerning HighRegisterPressure

* bump NimPatch

* Update lib/system.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2020-10-26 09:13:37 +01:00
Timothee Cour
bf894ad3eb close #8007 (#15695) 2020-10-23 23:16:47 +02:00
cooldome
ae320b4e7d fix #15662 (#15678)
* fix #15662

* alternative fix

* fix spacing
2020-10-23 11:14:54 +02:00
Danil Yarantsev
d22ab0fb96 Add tests to #15363 (#15633) 2020-10-19 13:16:56 +02:00
Timothee Cour
8a5f550491 followup after #15529 and #15534 (#15536) 2020-10-10 07:05:27 +02:00
Timothee Cour
8fb57d7451 close #13081 (#15529)
* close #13081

* fixup
2020-10-09 08:56:09 +02:00
Miran
e7f280bd26 Remove deprecated stuff from stdlib (#14699)
* update to the latest Jester

* remove deprecated procs from some stdlib modules

* 'criterion' is not maintained anymore and relies on obsolete stuff
2020-06-17 15:25:02 +02:00
Timothee Cour
9502e39b63 nim doc --backend:js, nim doc --doccmd:-d:foo, nim r --backend:js, --doccmd:skip + other improvements (#14278)
* `nim doc --backend:js|cpp...`
`nim doc --doccmd:'-d:foo --threads:on'`
`nim r --backend:cpp...` (implies --run --usenimcache)
* --usenimcache works with all targets
* --docCmd:skip now skips compiling snippets; 50X speedup for doc/manual.rst
2020-05-11 12:01:18 +02:00
alaviss
83435fe696 tslow_tables: wait for an additional 2 seconds (#14266)
This test runtime tends to hover around the 5s mark depending on how
loaded the system currently is. This causes the test to fail a lot
during CI, per analytics:
https://dev.azure.com/nim-lang/Nim/_test/analytics?definitionId=1&contextType=build

Give the test an extra 2 seconds to account for unrelated overhead.
2020-05-07 22:07:08 +02:00
Timothee Cour
330b3c4453 fix regression: -d:nimHasLibFFI was not being tested anymore (#14234)
* * fix regression: -d:nimHasLibFFI was not being tested anymore,
in part because testament was silently treating some errors as easy to overlook messages
* turned that message into an error
* -d:nimHasLibFFI is now being tested with nim cpp
* use correct signatures for importc procs
* workaround for openbsd to unblock ctffi testing
2020-05-06 17:16:54 +02:00
hlaaftana
9b01c6cf48 discardable async procs are now an error (#14176)
* add discard warning in manual
2020-05-01 09:49:13 +02:00
c-blake
a0b33f9408 Add hashWangYi1 (#13823)
* Unwind just the "pseudorandom probing" (whole hash-code-keyed variable
stride double hashing) part of recent sets & tables changes (which has
still been causing bugs over a month later (e.g., two days ago
https://github.com/nim-lang/Nim/issues/13794) as well as still having
several "figure this out" implementation question comments in them (see
just diffs of this PR).

This topic has been discussed in many places:
  https://github.com/nim-lang/Nim/issues/13393
  https://github.com/nim-lang/Nim/pull/13418
  https://github.com/nim-lang/Nim/pull/13440
  https://github.com/nim-lang/Nim/issues/13794

Alternative/non-mandatory stronger integer hashes (or vice-versa opt-in
identity hashes) are a better solution that is more general (no illusion
of one hard-coded sequence solving all problems) while retaining the
virtues of linear probing such as cache obliviousness and age-less tables
under delete-heavy workloads (still untested after a month of this change).

The only real solution for truly adversarial keys is a hash keyed off of
data unobservable to attackers.  That all fits better with a few families
of user-pluggable/define-switchable hashes which can be provided in a
separate PR more about `hashes.nim`.

This PR carefully preserves the better (but still hard coded!) probing
of the  `intsets` and other recent fixes like `move` annotations, hash
order invariant tests, `intsets.missingOrExcl` fixing, and the move of
`rightSize` into `hashcommon.nim`.

* Fix `data.len` -> `dataLen` problem.

* This is an alternate resolution to https://github.com/nim-lang/Nim/issues/13393
(which arguably could be resolved outside the stdlib).

Add version1 of Wang Yi's hash specialized to 8 byte integers.  This gives
simple help to users having trouble with overly colliding hash(key)s.  I.e.,
  A) `import hashes; proc hash(x: myInt): Hash = hashWangYi1(int(x))`
      in the instantiation context of a `HashSet` or `Table`
or
  B) more globally, compile with `nim c -d:hashWangYi1`.

No hash can be all things to all use cases, but this one is A) vetted to
scramble well by the SMHasher test suite (a necessarily limited but far
more thorough test than prior proposals here), B) only a few ALU ops on
many common CPUs, and C) possesses an easy via "grade school multi-digit
multiplication" fall back for weaker deployment contexts.

Some people might want to stampede ahead unbridled, but my view is that a
good plan is to
  A) include this in the stdlib for a release or three to let people try it
     on various key sets nim-core could realistically never access/test
     (maybe mentioning it in the changelog so people actually try it out),
  B) have them report problems (if any),
  C) if all seems good, make the stdlib more novice friendly by adding
     `hashIdentity(x)=x` and changing the default `hash() = hashWangYi1`
     with some `when defined` rearranging so users can `-d:hashIdentity`
     if they want the old behavior back.
This plan is compatible with any number of competing integer hashes if
people want to add them.  I would strongly recommend they all *at least*
pass the SMHasher suite since the idea here is to become more friendly to
novices who do not generally understand hashing failure modes.

* Re-organize to work around `when nimvm` limitations; Add some tests; Add
a changelog.md entry.

* Add less than 64-bit CPU when fork.

* Fix decl instead of call typo.

* First attempt at fixing range error on 32-bit platforms; Still do the
arithmetic in doubled up 64-bit, but truncate the hash to the lower
32-bits, but then still return `uint64` to be the same.  So, type
correct but truncated hash value.  Update `thashes.nim` as well.

* A second try at making 32-bit mode CI work.

* Use a more systematic identifier convention than Wang Yi's code.

* Fix test that was wrong for as long as `toHashSet` used `rightSize` (a
very long time, I think).  `$a`/`$b` depend on iteration order which
varies with table range reduced hash order which varies with range for
some `hash()`.  With 3 elements, 3!=6 is small and we've just gotten
lucky with past experimental `hash()` changes.  An alternate fix here
would be to not stringify but use the HashSet operators, but it is not
clear that doesn't alter the "spirit" of the test.

* Fix another stringified test depending upon hash order.

* Oops - revert the string-keyed test.

* Fix another stringify test depending on hash order.

* Add a better than always zero `defined(js)` branch.

* It turns out to be easy to just work all in `BigInt` inside JS and thus
guarantee the same low order bits of output hashes (for `isSafeInteger`
input numbers).  Since `hashWangYi1` output bits are equally random in
all their bits, this means that tables will be safely scrambled for table
sizes up to 2**32 or 4 gigaentries which is probably fine, as long as the
integer keys are all < 2**53 (also likely fine).  (I'm unsure why the
infidelity with C/C++ back ends cut off is 32, not 53 bits.)

Since HashSet & Table only use the low order bits, a quick corollary of
this is that `$` on most int-keyed sets/tables will be the same in all
the various back ends which seems a nice-to-have trait.

* These string hash tests fail for me locally.  Maybe this is what causes
the CI hang for testament pcat collections?

* Oops. That failure was from me manually patching string hash in hashes.  Revert.

* Import more test improvements from https://github.com/nim-lang/Nim/pull/13410

* Fix bug where I swapped order when reverting the test.  Ack.

* Oh, just accept either order like more and more hash tests.

* Iterate in the same order.

* `return` inside `emit` made us skip `popFrame` causing weird troubles.

* Oops - do Windows branch also.

* `nimV1hash` -> multiply-mnemonic, type-scoped `nimIntHash1` (mnemonic
resolutions are "1 == identity", 1 for Nim Version 1, 1 for
first/simplest/fastest in a series of possibilities.  Should be very
easy to remember.)

* Re-organize `when nimvm` logic to be a strict `when`-`else`.

* Merge other changes.

* Lift constants to a common area.

* Fall back to identity hash when `BigInt` is unavailable.

* Increase timeout slightly (probably just real-time perturbation of CI
system performance).
2020-04-15 20:11:18 +02:00
Timothee Cour
ab5e26c53c fix some codegen bugs: NIM_BOOL, NIM_STATIC_ASSERT, --passc:-std=... (etc) (#13798)
* fix cgen bool D20200328T203812
* --passc:std=c++17 (etc) now works instead of silently ignored
* document caveats for NIM_NIL
2020-04-07 15:17:30 +02:00
Timothee Cour
f1fd3ef7f4 fix https://github.com/timotheecour/Nim/issues/88 (#13865) [backport:1.2] 2020-04-06 00:24:35 +02:00
Timothee Cour
af9c852701 fix nim doc subdir/foo which was generating broken css; + other fixes (#13647)
* docgen: minor refactoring via docOutDir
* fix css for `nim doc subdir/foo` without --outdir nor -o
* tcompilesetting.nim: keep `git status` clean
* re-enable pkg nimgame2 that got fixed upstream
2020-03-17 13:44:37 +01:00
Andreas Rumpf
614fb7567c std/compilesettings implementation (#13584)
* Implement compileSetting() and compileSettingSeq()
* Change from magic to vmop
* better design for querySetting

Co-authored-by: genotrance <dev@genotrance.com>
2020-03-04 13:46:42 +01:00
Timothee Cour
e70294dff2 enable testing -d:nimHasLibFFI mode (#13091) 2020-02-04 14:08:56 +01:00
Timothee Cour
b462baed65 VM: allow overriding MaxLoopIterations without rebuilding nim (#13233) 2020-01-23 10:53:30 +01:00
Timothee Cour
ee1563ef33 VM FFI: write(stderr, msg) and fprintf(cstderr, msg) now work at CT (#13083) 2020-01-12 13:44:43 +01:00
cooldome
a3df1b55f3 fixes #13013, reverts previous changes to readLines() (#13036) [backport]
* Revert "remove default argument for readLines (#12807) [backport]"

This reverts commit c949b81efd.
2020-01-05 09:22:41 +01:00
cooldome
c949b81efd remove default argument for readLines (#12807) [backport] 2020-01-02 23:27:37 +01:00
Ico Doornekamp
e61d702206 Increased TInstr field sizes: allow long jumps and 65535 VM registers (#12777)
* Increased regBx size from 16 to 24 bits to increase jump range in the VM
from 32K to 8M instructions. Fixes #12727

* Increased VM TInst register field sizes to 16 bits to allow up to 65535 VM registers per proc

* Added test case for >255 VM registers
2019-12-10 19:04:02 +01:00
Araq
87f0d534d6 fixes #12488 [backport] 2019-11-28 23:00:34 +01:00
Andreas Rumpf
abe07eb75d VM: improvements for var T/addr (#12667); fixes #12489 2019-11-28 09:56:02 +01:00
Andreas Rumpf
78e02d174d fixes #12670 [backport] (#12693) 2019-11-20 19:08:16 +01:00
Andreas Rumpf
38b3590e40 fixes #12310 [backport] (#12470) 2019-10-20 22:37:31 +02:00
Araq
7f904e2c66 fixes #12244 [backport] 2019-10-10 10:00:57 +02:00
Clyybber
85db42ad8c Fixes #10514 (#12268)
* Fixes #10514

(cherry picked from commit f6f789bb4d)

* Add comment

* Add changelog entry
2019-09-28 19:50:20 +02:00
Federico Ceratto
39290cf88c Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
Andreas Rumpf
162d74db91 fixes #10981; fixes #7261 (#12217) 2019-09-19 14:34:56 +02:00
Arne Döring
638a4d9d9f rename cast opcodes, fix for 32bit cast, fix python pretty printer (#12207) 2019-09-18 09:04:37 +02:00
Araq
ea8a049af3 fixes the testcase 2019-09-17 15:15:12 +02:00
Araq
c9f3a8b269 added a testcase for #12195; testament now supports a 'timeout' spec field 2019-09-17 15:15:12 +02:00
Andreas Rumpf
a5e2db2ac5 allows access to .compileTime vars at runtime (#12128) 2019-09-05 11:56:32 +02:00
Andreas Rumpf
d70e292571 makes more tests green 2019-09-02 22:03:06 +02:00
Araq
18ca1788f0 makes test green again 2019-09-02 14:23:05 +02:00
Arne Döring
6e01be34ef fixes #11903 (#11908) 2019-08-31 19:32:59 +02:00