-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combined AOT + arguments by memory. (#390)
* add ffi to translate to llvm ir * better * progress * module to object * ld * compile * add compile * clean * fix ci * fix macos * progress * progress * progress * try * investigate * needed 1 more argument * changes * weird * realloc * clean a bit * cleanup * AOT preview. * Fix ARM trampoline. * Fix stuff. * Fix support for any number of arguments (stack alignment). * Prepare for x86_64 support. * Make it work on x86_64 linux. * Document x86_64 trampoline assembly. * Add call arguments flattening. * Updates. * Fix return values in `aarch64`. * Add AOT versions of NativeExecutor and ProgramCache. * Rename `JITValue` to `JitValue` to comply with Rust's naming convention. * Add enum ABI testing. * Fix docs. * Handle enum arguments. * Refactor enums into the stack. * Minor fix. * Make structures optionally memory-allocated. * Fix tail recursion with memory-allocated arguments. * Fix JIT value deserialization when memory allocated. * Fix typo. * Fix bool libfuncs. * Add `print_i8` debug utillity. * Fix invocation arguments. * Register debug utils on integration tests. * Fix memory-allocated enum payloads. * Fix JitValue deserialization. * Add `print_i128` debug utility. * Fix JIT invoke return pointer offsets. * Fix stuff. * Merge `src/jit_runtime.rs` into `src/executor/jit.rs`. Unify APIs. Various fixes. * Fix stuff. * It seems to be working now. * Support stack-allocated C-style enums. * Remove unused file. * Remove builtins from function signatures. Fix `enum_init` for non-memory-allocated enums. * Fix boolean libfuncs (bools are not memory-allocated). * Implement multi-variant non-memory-allocated enum support. * Support non-memory-allocated enum matches. * Fix gas handling. * Fix `enum_match` libfunc for C-style and single-variant non-memory-allocated enums. * Add support for `sint8`, `sint16` and `sint32`. * Lots of fixes. * Reorganize code for DRY. Support Starknet contracts. * Support `EcPoint`, `EcState` and `NonZero<T>` return types. * Support the syscall handler when calling `invoke_dynamic` directly. * Make contracts accept only felts and convert to `Span<felt252>` internally. Support snapshot arguments. Various fixes. * Fix gas on integration tests. * Minor fix. * Fix non-syscall-handler Starknet types. * Support dictionaries. Minor fixes. * Fix non-syscall-handler Starknet types support. * Minor fix. * Fix linker. * Merge branch 'main' into aot-with-stack-enums * Remove irrelevant autogenerated files. * Remove calling convention discovery testing code. * Revert "Remove irrelevant autogenerated files.". Reason: those files weren't autogenerated by my testing. This reverts commit 53f65ed. * Undo conditional benchmark execution. * Fix formatting and clippy issues. * Remove unsafe transmute that is no longer necessary. * Sort dependencies alphabetically. * Implement `Debug` for the contract caches. * Refactor out the necessary refcell. * Actually remove the refcell. * Fix stuff from previous changes. * Fix stuff. * Fix warnings. * Fix errors. * Fix argument stack align. * Fix warnings. * use env var to add aditional dir to search for runtime lib (#400) * use env var to add aditional dir to search for runtime lib * oops * Ignore failing tests. * Rename env var to something that makes more sense. Set the variable on the CI runners. * Fix macOS and coverage CI runs. * Fix CI again. * Remove debug utils commented code. * Fix merge errors. --------- Co-authored-by: Edgar Luque <[email protected]>
- Loading branch information
1 parent
2e861d6
commit 6b244ff
Showing
84 changed files
with
4,979 additions
and
2,583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ jobs: | |
name: test (linux, amd64) | ||
runs-on: ubuntu-latest | ||
env: | ||
CAIRO_NATIVE_RUNTIME_LIBDIR: ${{ github.workspace }}/target/optimized-dev | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | ||
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/ | ||
LLVM_SYS_170_PREFIX: /usr/lib/llvm-17/ | ||
|
@@ -116,12 +117,15 @@ jobs: | |
run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools | ||
- name: Install deps | ||
run: make deps | ||
- name: Build cairo-native-runtime library. | ||
run: cargo build --profile=optimized-dev --package=cairo-native-runtime | ||
- name: test | ||
run: make test | ||
test_macos: | ||
name: Test (macOS, Apple silicon) | ||
runs-on: [self-hosted, macOS] | ||
env: | ||
CAIRO_NATIVE_RUNTIME_LIBDIR: ${{ github.workspace }}/target/optimized-dev | ||
CARGO_TERM_COLOR: always | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | ||
MLIR_SYS_170_PREFIX: /opt/homebrew/opt/llvm@17 | ||
|
@@ -134,18 +138,21 @@ jobs: | |
uses: dtolnay/[email protected] | ||
with: | ||
components: clippy | ||
- name: Install scarb | ||
- name: Install scarb | ||
uses: software-mansion/setup-scarb@v1 | ||
with: | ||
scarb-version: "2.4.0" | ||
- name: Install deps | ||
run: make deps | ||
- name: Build cairo-native-runtime library. | ||
run: cargo build --profile=optimized-dev --package=cairo-native-runtime | ||
- name: Run tests | ||
run: make test | ||
coverage: | ||
name: coverage | ||
runs-on: [self-hosted, macOS] | ||
env: | ||
CAIRO_NATIVE_RUNTIME_LIBDIR: ${{ github.workspace }}/target/optimized-dev | ||
CARGO_TERM_COLOR: always | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | ||
MLIR_SYS_170_PREFIX: /opt/homebrew/opt/llvm@17 | ||
|
@@ -160,12 +167,14 @@ jobs: | |
uses: Swatinem/rust-cache@v2 | ||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
- name: Install scarb | ||
- name: Install scarb | ||
uses: software-mansion/setup-scarb@v1 | ||
with: | ||
scarb-version: "2.4.0" | ||
- name: Install deps | ||
run: make deps | ||
- name: Build cairo-native-runtime library. | ||
run: cargo build --profile=optimized-dev --package=cairo-native-runtime | ||
- name: test and generate coverage | ||
run: make coverage | ||
- name: Upload coverage to Codecov | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# AOT calling convention: | ||
|
||
## Arguments | ||
|
||
- Written on registers, then the stack. | ||
- Structs' fields are treated as individual arguments (flattened). | ||
- Enums are structs internally, therefore they are also flattened (including the padding). | ||
- The default payload works as expected since it has the correct signature. | ||
- All other payloads require breaking it down into bytes and scattering it through the padding | ||
and default payload's space. | ||
|
||
## Return values | ||
|
||
- Indivisible values that do not fit within a single register (ex. felt252) use multiple registers | ||
(x0-x3 for felt252). | ||
- Struct arguments, etc... use the stack. | ||
|
||
In other words, complex values require a return pointer while simple values do not but may still use | ||
multiple registers if they don't fit within one. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.