summary refs log tree commit diff stats
path: root/compiler/vmgen.nim
Commit message (Collapse)AuthorAgeFilesLines
* rework `wasMoved`, `move` on the JS backend (#23577)ringabout2024-05-081-7/+0
| | | | | `reset`, `wasMoved` and `move` doesn't support primitive types, which generate `null` for these types. It is now produce `x = default(...)` in the backend. Ideally it should be done by ast2ir in the future
* remove unused magics: mIntToStr, mInt64ToStr, mFloatToStr (#23486)ringabout2024-04-091-1/+1
| | | mIntToStr, mInt64ToStr, mFloatToStr,
* fixes #13481; fixes #22708; disable using union objects in VM (#23362)ringabout2024-03-031-0/+2
| | | | | | fixes #13481; fixes #22708 Otherwise it gives implicit results or bad codegen
* give typedesc param nodes type T not typedesc[T] [backport:2.0] (#23115)metagn2024-01-181-1/+1
| | | | | | | fixes https://github.com/nim-lang/Nim/issues/23112, fixes a mistake in https://github.com/nim-lang/Nim/pull/22581 This makes `getType(t)` where `t` is a typedesc param with value `T` equal to `getType(T)`.
* type refactor: part 4 (#23077)Andreas Rumpf2023-12-151-4/+4
|
* type refactoring: part 2 (#23059)Andreas Rumpf2023-12-131-1/+1
|
* Types: Refactorings; step 1 (#23055)Andreas Rumpf2023-12-121-2/+2
|
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-3/+3
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* NIR: progress (#22817)Andreas Rumpf2023-10-121-1/+1
| | | | | | Done: - [x] Implement conversions to openArray/varargs. - [x] Implement index/range checking.
* NIR: Nim intermediate representation (#22777)Andreas Rumpf2023-10-111-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Theoretical Benefits / Plans: - Typed assembler-like language. - Allows for a CPS transformation. - Can replace the existing C backend by a new C backend. - Can replace the VM. - Can do more effective "not nil" checking and static array bounds checking. - Can be used instead of the DFA. - Easily translatable to LLVM. - Reasonably easy to produce native code from. - Tiny memory consumption. No pointers, no cry. **In very early stages of development.** Todo: - [x] Map Nim types to IR types. - [ ] Map Nim AST to IR instructions: - [x] Map bitsets to bitops. - [ ] Implement string cases. - [ ] Implement range and index checks. - [x] Implement `default(T)` builtin. - [x] Implement multi string concat. - [ ] Write some analysis passes. - [ ] Write a backend. - [x] Integrate into the compilation pipeline.
* allows cast int to bool/enum in VM (#22809)ringabout2023-10-111-2/+2
| | | | | Since they are integer types, by mean of allowing cast integer to enums in VM, we can suppress some enum warnings in the stdlib in the unified form, namely using a cast expression.
* fixes the `discVal` register is used after free in vmgen (#22688)ringabout2023-09-111-1/+1
| | | follow up https://github.com/nim-lang/Nim/pull/11955
* [minor] merge similar branches in vmgen (#22683)ringabout2023-09-101-3/+1
|
* Instantiates generics in the module that uses it (#22513)Juan M Gómez2023-09-091-1/+1
| | | | | | | | | | Attempts to move the generic instantiation to the module that uses it. This should decrease re-compilation times as the source module where the generic lives doesnt need to be recompiled --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* use dummy dest for void branches to fix noreturn in VM (#22617)metagn2023-09-011-9/+30
| | | fixes #22216
* handle typedesc params in VM (#22581)metagn2023-08-301-1/+7
| | | | | | | | | * handle typedesc params in VM fixes #15760 * add test * fix getType(typedesc) test
* clearer error for different size int/float cast in VM (#22582)metagn2023-08-291-3/+11
| | | refs #16547
* fix getNullValue for cstring in VM, make other VM code aware of nil cstring ↵metagn2023-08-211-3/+4
| | | | | | | | | | | | | (#22527) * fix getNullValue for cstring in VM fixes #22524 * very ugly fixes, but fix #15730 * nil cstring len works, more test lines * fix high
* replaces `doAssert false` with `raiseAssert` for unreachable branches, which ↵ringabout2023-08-101-2/+2
| | | | | works better with strictdefs (#22436) replaces `doAssert false` with `raiseAssert`, which works better with strictdefs
* use strictdefs for compiler (#22365)ringabout2023-08-061-3/+17
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* implement `ensureMove` (#22339)ringabout2023-07-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * implement `ensureMove` * use an additional flag * improve some logics * progress: fixes discard ensureMove * forbids nested expressions * improve error messages * checkpoint * fixes cursor * ADD MORE TESTS * fixes cursorinference again * tiny cleanup * improve error messages * fixes docs * implement comments add more tests * fixes js
* alternative to #22183; nimscript shares the same compileTime sym with VM ↵ringabout2023-06-291-1/+5
| | | | (#22184)
* fix #9423 followup #17594: distinct generics now work in VM (#21816)ringabout2023-05-101-3/+12
| | | | | | | | | * fix #9423 distinct generics now work in vm * fixes cpp tests --------- Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
* implement `=dup` hook eliminating `wasMoved` and `=copy` pairs (#21586)ringabout2023-05-061-0/+6
| | | | | | | | | | | | | | | | | | | * import `=dup` hook eliminating `wasMoved` and `=copy` pairs * add dup * add a test for dup * fixes documentation * fixes signature * resolve comments * fixes tests * fixes tests * clean up
* fixes #21704; remove nfIsRef for genLit in VM (#21765)ringabout2023-05-061-0/+1
| | | | | | | | | | | | | * fixes #21704; remove `nfIsRef` for genLit * remove nfIsRef from the output of macros * make the logic better * try again * act together * excl nfIsRef
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-2/+2
| | | | | | | | | | | (#21667) * refactoring in preparation for better, simpler name mangling that works with IC flawlessly * use new disamb field * see if this makes tests green * make tests green again
* warn on set types bigger than max size, default to 0..255 for int literals ↵metagn2023-04-171-1/+2
| | | | | | | | | | | | | | | | | | | (#21659) * test implicitly huge set types refs https://github.com/nim-lang/RFCs/issues/298 * oh my god * boot at least * don't error, fix remaining issues, no 2 len arrays * fix runnable example * test assuming 0..255 for int literal * test refactor, add changelog, test
* fixes #3770; templates with untyped parameters resolve private fields ↵ringabout2023-03-211-1/+1
| | | | | | | | | wrongly in generics (#21554) * fixes #3770; templates with untyped parameters resolve private fields wrongly * add a test case for #3770 * rename to `nfSkipFieldChecking`
* fixes explicit globals in macros (#21502)ringabout2023-03-121-1/+2
|
* fixes #10938; fixes #13312; fixes #13918; fixes #20985; always initializes ↵ringabout2023-03-011-0/+12
| | | | | | | | | | | global variables with null values in VM (#21351) * fixes #10938; always initialize global variable in VM * fixes importc vars * there is a pre-existing issue regarding closure types in the VM * add tests
* fixes #16790; fixes #19075; put big arrays on the constant seqs; don't ↵ringabout2023-01-311-2/+5
| | | | | | | inline them in the VM; big performance boost (#21318) * don't inline arrays in VM * add a test for #19075
* fixes #14409; fixes #10674 VM callbacks switch to table-index seqs (#21297)ringabout2023-01-261-15/+19
| | | | | | | * fixes #14409; fixes#10674 VM callbacks switch to table-index seqs * fixes package name * reduce runtime cost
* remove dead code in VM (#21296)ringabout2023-01-251-3/+0
| | | remove deadcode in VM
* Implement setLineInfo (#21153)Peter Munch-Ellingsen2022-12-221-1/+13
| | | | | * Implement setLineInfo * Add tests
* fixes regression #17121; adding doc comment in importc proc makes it ↵ringabout2022-11-061-1/+10
| | | | | | | | | silently noop at CT (#20766) * fixes regression #17121; adding doc comment in importc proc makes it silently noop at CT * Update compiler/vmgen.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #20740; fixes pre-existing field visibility issues and removes ↵ringabout2022-11-031-1/+3
| | | | | `efSkipFieldVisibilityCheck` (#20741) fixes #20740 pre-existing field visibility and refactoring
* fixes #19201; fixes sink causes crash in VM (#20658)ringabout2022-10-251-1/+1
|
* Added 'openArray[char]' overloads to 'std/parseutils' (#20527)Jason Beetham2022-10-241-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Fixed VM op to work with new 'opcSlice' * Corrected captureBetween's logic to work with openarray * js sys's parsefloat logic now uses openarray Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* Implemented `mSlice` on the VM allowing `toOpenArray` to work at compile ↵Jason Beetham2022-10-201-14/+46
| | | | | | | | | | | | | | | | | | | | | | | | | time. (#20586) * Implemented opcSlice to make 'toOpenArray' work on the VM * Added nkOpenArray for VM to reduce bodgeness * Fixed range issues and erraneous comments * Range check correctly for openArrays in opcLdArr * Inverted logic for ldArr checking * vm now supports slicing strings * Added string tests * Removed usage of 'nkOpenArray' and redundant operations * Refactored vmSlice implementation, removing redundant and incorrect code * Made tuples go throw opcWrObj for field assignment * All strkinds should be considered for openarrays
* fixes #20572 (#20585)Andreas Rumpf2022-10-171-1/+1
| | | | | * fixes #20572 * added a test case
* refactorings (#20536)Andreas Rumpf2022-10-101-1/+1
| | | | | | | * refactoring * refactoring: removed unused macroUsagesSection * enum instead of bool for better readability
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fresh start * add cpp target * add result support * add nimPreviewRangeDefault * reduce * use orc * refactor common parts * add tuple support * add testcase for tuple * cleanup; fixes nimsuggest tests * there is something wrong with cpp * remove * add support for seqs * fixes style * addd initial distinct support * remove links * typo * fixes tuple defaults * add rangedefault * add cpp support * fixes one more bugs * add more hasDefaults * fixes ordinal types * add testcase for #16744 * add testcase for #3608 * fixes docgen * small fix * recursive * fixes * cleanup and remove tuple support * fixes nimsuggest * fixes generics procs * refactor * increases timeout * refactor hasDefault * zero default; disable i386 * add tuples back * fixes bugs * fixes tuple * add more tests * fix one more bug regarding tuples * more tests and cleanup * remove messy distinct types which must be initialized by original types * add tests * fixes zero default * fixes grammar * fixes tests * fixes tests * fixes tests * fixes comments * fixes and add testcase * undo default values for results Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * continue #9582 for consts, close #9331, fix #20114 also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc * changelog correctly * fix jsgen * update tgetimpl * fix sighashes * fix #19766, add comment about postfix * fix noRewrite LOL refs #16620 * fix changelog * fix destructors
* Markdown code blocks part 6 (#20292)Andrey Makarov2022-08-311-5/+4
|
* top-down type inference, implements rfc 149 (#20091)metagn2022-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * micro implementation of rfc 149 refs https://github.com/nim-lang/RFCs/issues/149 * number/array/seq literals, more statements * try fix number literal alias issue * renew expectedType with if/case/try branch types * fix (nerf) index type handling and float typed int * use typeAllowed * tweaks + const test (tested locally) [skip ci] * fill out more of the checklist * more literals, change @ order, type conversions Not copying the full call tree before the typedesc call check in `semIndirectOp` is also a small performance improvement. * disable self-conversion warning * revert type conversions (maybe separate op later) * deal with CI for now (seems unrelated), try enums * workaround CI different way * proper fix * again * see sizes * lol * overload selection, simplify int literal -> float * range, new @ solution, try use fitNode for nil * use new magic * try fix ranges, new magic, deal with #20193 * add documentation, support templates Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* [vm]fixes #15974 #12551 #19464 #16020 #16780 #16613 #14553 #19909 #18641 ↵flywind2022-06-221-3/+0
| | | | | | | | | | | | | | | (#19902) [backport] * revert #12217 since the root problem seems to have been fixed; fix #15974;fix #12551; fix #19464 * fix #16020; fix #16780 * fix tests and #16613 * fix #14553 * fix #19909; skip skipRegisterAddr * fix #18641
* [cleanup] remove unnecessary procs in vm (#19888)flywind2022-06-131-5/+2
| | | remove unused procs
* fix #19680; check if stderr is static (#19709)flywind2022-04-121-1/+1
|
* move assertions out of system (#19599)flywind2022-03-231-0/+3
|
* register callback for marshal in VM (#19578)flywind2022-03-081-27/+0
| | | | | | | | | | | | | * register callback for marshal in VM * remove unrelated code * polish * more tests * more tests * add loadVM and toVM