From 83197a77a36d49c3989ea195f09f226f3a476d43 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Sun, 21 Jan 2024 22:58:29 -0800 Subject: [PATCH] add readme and license --- LICENSE | 17 +++++++++++++++++ README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..19b1e9c --- /dev/null +++ b/LICENSE @@ -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. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ecaf83e --- /dev/null +++ b/README.md @@ -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.