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

Replace the interpreter with an LLVM compiler #508

Merged
merged 1 commit into from
May 16, 2023
Merged

Conversation

yorickpeterse
Copy link
Collaborator

@yorickpeterse yorickpeterse commented Mar 18, 2023

This is a recreation of #497 so we have a cleaner comment history, making it a little easier to add notes over time. The original GitLab merge request is located here.


This pull request replaces the Rust based interpreter with an LLVM native code compiler. The motivation for this is explained here.

An explicit non-goal at this time is providing a good native code compiler, instead we're focusing "just" getting rid of the interpreter. This means that we're not focusing on optimisations, a good debugging experience, etc.

For generics we're also sticking with the old approach of basically not specialising functions and doing dynamic dispatch everywhere. This isn't great, but changing this at this time would require even more work. My long-term vision is to specialise by "kinds" or shapes rather than types, as type specialisation won't make sense given most values are heap allocated and thus represented as pointers. The mentioned "kinds" would be:

  • Int
  • Float
  • ref T
  • T for heap allocated values
  • Atomic T values (String, Channel and processes)

This allows us to generate specialised methods/types where this makes sense (e.g. ref T and T use different code for aliasing and dropping aliases). This requires quite a bit of work though, hence it's not included in this PR.

Closes #83, closes #88, closes #117, fixes #317, closes #318, closes #330, closes #332, fixes #351, fixes #516, fixes #361, closed #512, fixes #509, fixes #503, fixes #362.

@yorickpeterse
Copy link
Collaborator Author

Inkwell is updated to the latest version on crates.io, and we now require LLVM 15. Arch Linux appears to no longer include the LLVM static libraries (see https://bugs.archlinux.org/task/77691 and the mentioned bugs), so I guess it's finally time to also move over my desktop to Fedora (which does provide the necessary files). The LLVM code generation is updated to work with LLVM 15's opaque pointers setup, but I'm pretty sure I messed things up here and there.

My plan for next week is to apply the new type checker and get rid of the old type checking code, fix any issues this may reveal, this get back to the LLVM code generator.

@yorickpeterse yorickpeterse marked this pull request as draft March 18, 2023 02:52
@yorickpeterse yorickpeterse added this to the 0.11.0 milestone Mar 18, 2023
@yorickpeterse yorickpeterse self-assigned this Mar 18, 2023
@yorickpeterse yorickpeterse added compiler Changes related to the compiler std Changes related to the standard library runtime Changes related to the Rust-based runtime library feature New things to add to Inko, such as a new standard library module labels Mar 18, 2023
@yorickpeterse yorickpeterse force-pushed the native-compiler branch 5 times, most recently from a98f6ef to 2c80248 Compare March 25, 2023 02:10
@yorickpeterse yorickpeterse force-pushed the native-compiler branch 5 times, most recently from 54ca824 to 054012e Compare March 30, 2023 22:13
@yorickpeterse yorickpeterse force-pushed the native-compiler branch 9 times, most recently from a9f20bf to da82178 Compare April 7, 2023 22:10
@yorickpeterse yorickpeterse force-pushed the native-compiler branch 8 times, most recently from c44dfa9 to 6e1d17f Compare May 12, 2023 13:34
@yorickpeterse yorickpeterse force-pushed the native-compiler branch 4 times, most recently from ac403c3 to 692e916 Compare May 13, 2023 22:50
yorickpeterse added a commit that referenced this pull request May 15, 2023
This replaces the bytecode interpreter with a native code compiled,
backed by LLVM. While this is a massive change, various internals remain
the same. For example, for generics we still rely on runtime pointer
checking and checks. This is a deliberate choice to keep the scope of
changes from expanding even more, and we'll take care of these remaining
issues separately.

As part of these changes we've removed the libffi based FFI, as it makes
no sense to use this API in a native code compiler. As introducing a new
FFI is going to be a lot of work, we'll also take care of this
separately, meaning you temporarily won't be able to interact with C
code.

The package manager (ipm) is also merged into the compiler executable
("inko"), removing the need for a separate command.

For more information, see #508.
This replaces the bytecode interpreter with a native code compiled,
backed by LLVM. While this is a massive change, various internals remain
the same. For example, for generics we still rely on runtime pointer
checking and checks. This is a deliberate choice to keep the scope of
changes from expanding even more, and we'll take care of these remaining
issues separately.

As part of these changes we've removed the libffi based FFI, as it makes
no sense to use this API in a native code compiler. As introducing a new
FFI is going to be a lot of work, we'll also take care of this
separately, meaning you temporarily won't be able to interact with C
code.

The package manager (ipm) is also merged into the compiler executable
("inko"), removing the need for a separate command.

For more information, see #508.
@yorickpeterse yorickpeterse marked this pull request as ready for review May 16, 2023 21:54
@yorickpeterse yorickpeterse merged commit d317002 into main May 16, 2023
11 checks passed
@yorickpeterse yorickpeterse deleted the native-compiler branch May 16, 2023 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module runtime Changes related to the Rust-based runtime library std Changes related to the standard library
Projects
None yet
1 participant