Skip to content

Commit

Permalink
add readme and license
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeng committed Jan 22, 2024
1 parent 37bb6ef commit 83197a7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
17 changes: 17 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MIT License

Copyright (c) 2024 Tianyu Geng

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Archon VM

Low level IR and runtime for [Archon](https://github.com/tgeng/archon).

## What is this?

Archon is a work-in-progress experimental language that combines dependent types, algebraic effects and handlers, and
quantitative types. Since Archon has algebraic effects and handlers, which supports multi-shot continuations, compiling
it to machine code is not straightforward. The low level IR in this project is close enough to the core type theory of
Archon so that compiling Archon to this low level IR should be straightforward: basically just erase unneeded
information.

## Some Design Choices

* **Selective CPS transformation** Functions with complex effects (e.g. effects whose handlers may capture the
continuation and manipulate it) are compiled into state machines with CPS transformation. Delimited continuation is
then represented as a singly linked list of continuation objects. Functions that only performs simple effects (e.g.
`State`, `IO`, non-resumable exception) are not CPS-transformed and hence can run as fast as normal functions with
little additional overhead.
* **Uniform value representation** All values have a uniform representation so that everything has the same size. That
is, larger values that cannot fit 8 bytes are represented as pointers. Pointers are 4 byte-aligned and the lowest two
bits are used to tag the value. Native integer is 63-bit because the last bit is used to tag the value as integer.
* **Conservative GC** A conservative GC is used for simplicity of implementation and also flexibility of calling foreign
functions.
* **Typeless** The low level IR has no type information and no type checking is done on it. This is because Archon is
already type-checked and there is no need to do type checking in low level IR again. In fact, adding type checking to
the low level IR is not trivial because Archon supports dependent types, which means one can easily create a function
whose argument can have any types.

## Getting Started

`cargo build` to build the project. `cargo test` to run tests.

See `src/ast/term.rs` and `src/ast/signature.rs` for the low level IR. One can create a `Signature` and then compile it
with `src/backend/compiler.rs` to machine code. Currently only ARM64 macOS is supported. Also, there is no plan to
support 32-bit architectures.

A simpler frontend IR and parser is also provided in `src/frontend/f_term.rs` and it's used in tests.
See `resources/frontend/transpiler_tests/*.input.txt` for examples.

## TODOs

* Integrate Boehm's GC for memory management.
* Support more OS/architectures.
* Add some FFI support.
* Add more built-in types in addition to 63-bit integers.
* Add more built-in functions for primitive manipulations.

0 comments on commit 83197a7

Please sign in to comment.