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

[VM/eval] Fix pending issues, add unit-tests & cleanup #968

Merged
merged 991 commits into from
Jan 26, 2023

Conversation

drkameleon
Copy link
Collaborator

@drkameleon drkameleon commented Jan 11, 2023

Description

This PR ended up being far more important than initially planned but it was for a very good reason: there were deep-hidden issues that could not have been solved but via a very radical approach.

So, what does this PR do?

  • Introduce a new intermediate representation (AST), between the parser and the evaluator
  • Given this new representation we can:
    • Perform optimizations on the node level (e.g. constant folding, complicated arithmetic simplifications, etc)
    • Optimize the constructs we already were, but in a much safer - and hopefully performant - way
    • All syntactic sugar is/should-be working flawlessly: ->, =>, | (and any combinations thereof) ❗
  • Complete rewrite of the Evaluator (VM/eval), from scratch
  • Added more bytecode optimizations in the evaluator (e.g. opStorl), which was only limited to the now-obsolete optimizer and not even in use before
  • The code is far (far...) cleaner and easier to debug and reason about
  • Re-organized our opCode set
  • Make Built-in functions that correspond to a specific opCode "carry" this opCode as an internal field

Basically, pure bliss! lol 🎉 (seriously now: you cannot imagine how satisfied I am after all of this work!)

Apart from the fixes mentioned below and some general cleanup, this PR - inspired by the awesome work by @RickBarretto - will also attempt to add thorough tests that verify the very important job of the VM's evaluator + AST, as well as revisit previously-written Rosetta Code examples, rewrite any that need rewriting & add the ones that are valid - and perform well enough with the latest version - to our CI builds (= to be executed as part of the Tester tool). 🚀



Type of change

  • Code cleanup
  • Bug fix (non-breaking change which fixes an issue)

@drkameleon drkameleon added bug Something isn't working enhancement New feature or request evaluator Issues related to the evaluator (src/vm/eval.nim) cleanup Code cleanup, comments and micro-optimizations labels Jan 11, 2023
@drkameleon drkameleon self-assigned this Jan 11, 2023
@github-actions github-actions bot added unit-test Unit tests library Issues related to the standard library and removed evaluator Issues related to the evaluator (src/vm/eval.nim) labels Jan 11, 2023
@drkameleon drkameleon changed the title WIP: Fix evaluator issues & cleanup WIP: Fix evaluator issues, add unit-tests & cleanup Jan 12, 2023
@github-actions github-actions bot added evaluator Issues related to the evaluator (src/vm/eval.nim) vm Issues related to the Virtual Machine implementation values Issues related to the core Value type labels Jan 12, 2023
@drkameleon drkameleon changed the title WIP: Fix evaluator issues, add unit-tests & cleanup WIP: [VM/eval] Fix pending issues, add unit-tests & cleanup Jan 13, 2023
@github-actions github-actions bot added bytecode Issues related to the underline VM bytecode documentation Improvements or additions to documentation execution Issues related to the executor (src/vm/exec.nim) helpers Issues related to Helper modules parser Issues related to the evaluator (src/vm/parse.nim) rosetta code Issues and PRs related to Rosetta Code snippets ui Issues related to the UI labels Jan 21, 2023
@github-actions github-actions bot added ci CI-related issues workflows Issues related to GitHub workflows, building, releases, etc installer Issues related to the Installation script labels Jan 23, 2023
@drkameleon
Copy link
Collaborator Author

First successful CI build after 1,234,567 tries! 🎉

@drkameleon drkameleon added the ast Issues related to the intermediate AST representation label Jan 23, 2023
@drkameleon
Copy link
Collaborator Author

As unbelievable as this sounds, this mega-PR is to be considered complete. 🎉

So, until a monster emerges and devours it all, let's say it's...

...ready to merge! 🚀

@drkameleon drkameleon changed the title WIP: [VM/eval] Fix pending issues, add unit-tests & cleanup [VM/eval] Fix pending issues, add unit-tests & cleanup Jan 26, 2023
@drkameleon drkameleon merged commit 2cdb2cb into master Jan 26, 2023
@dumblob
Copy link

dumblob commented Jan 26, 2023

Congratulations!

I did not have the time to look at this and I am pretty sure I will not read everything (it is really long!). But I will at least take a look at certain parts which interest me - maybe arithmetic - decimal vs. floating point, maybe a few bytecode optimizations (will compare to FastVM/minivm and to the approaches in recent Python release bytecode changes and maybe even compared to JIT in clover), maybe even some "reactiveness", etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Issues related to the intermediate AST representation bug Something isn't working bytecode Issues related to the underline VM bytecode ci CI-related issues cleanup Code cleanup, comments and micro-optimizations documentation Improvements or additions to documentation enhancement New feature or request evaluator Issues related to the evaluator (src/vm/eval.nim) execution Issues related to the executor (src/vm/exec.nim) helpers Issues related to Helper modules installer Issues related to the Installation script library Issues related to the standard library parser Issues related to the evaluator (src/vm/parse.nim) rosetta code Issues and PRs related to Rosetta Code snippets ui Issues related to the UI unit-test Unit tests values Issues related to the core Value type vm Issues related to the Virtual Machine implementation workflows Issues related to GitHub workflows, building, releases, etc
Projects
No open projects
2 participants