Skip to content

Commit

Permalink
Replace the interpreter with an LLVM compiler
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yorickpeterse committed May 15, 2023
1 parent 77a83c7 commit ebc4e5b
Show file tree
Hide file tree
Showing 288 changed files with 30,859 additions and 30,855 deletions.
7 changes: 5 additions & 2 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))']
rustflags = ['-C', 'target-feature=+aes']
# This is needed for stack traces to work when `panic=abort` is used. See
# https://github.com/rust-lang/rust/issues/94815 and
# https://github.com/rust-lang/backtrace-rs/issues/397 for more details.
[build]
rustflags = ['-C', 'force-unwind-tables']
34 changes: 21 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- 'compiler/**'
- 'inko/**'
- 'ipm/**'
- 'libstd/**'
- 'std/**'
- 'types/**'
- 'vm/**'
- 'Cargo.*'
Expand All @@ -22,7 +22,9 @@ on:
workflow_dispatch:

env:
CARGO_HOME: ${{ github.workspace }}/.cargo
# This directory must be named differently from `.cargo`, otherwise it will
# conflict with our local Cargo configuration.
CARGO_HOME: ${{ github.workspace }}/.cargo-home
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

Expand All @@ -40,15 +42,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.62
- uses: dtolnay/rust-toolchain@1.63
with:
components: 'clippy'
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.cargo
${{ env.CARGO_HOME }}
target
key: ${{ runner.os }}
- name: Install LLVM
run: bash scripts/llvm.sh
- run: 'cargo clippy -- -D warnings'

cargo-fmt:
Expand All @@ -61,7 +65,7 @@ jobs:
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.cargo
${{ env.CARGO_HOME }}
target
key: ${{ runner.os }}
- run: 'cargo fmt --all --check'
Expand All @@ -78,13 +82,13 @@ jobs:

compiler:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
version:
- '1.62'
- '1.63'
- stable
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -95,37 +99,41 @@ jobs:
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.cargo
${{ env.CARGO_HOME }}
target
key: ${{ runner.os }}-stable
- name: Install LLVM
run: bash scripts/llvm.sh
- name: Running tests
run: cargo test

std:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
needs:
- compiler
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.62
- uses: dtolnay/rust-toolchain@1.63
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.cargo
${{ env.CARGO_HOME }}
target
key: ${{ runner.os }}-stable
- name: Install LLVM
run: bash scripts/llvm.sh
- name: Compiling
run: cargo build --release
- name: Running tests
run: |
cd libstd
cargo run --release -p inko -- test
cd std
../target/release/inko test
nightly-container:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
*.egg-info/
__pycache__
/docs/plugins/pygments-inko-lexer/poetry.lock
/build
/std/build
Loading

0 comments on commit ebc4e5b

Please sign in to comment.