Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
f1dd722
init interpeter
ancavar Dec 21, 2025
dfeb137
add tests
ancavar Dec 22, 2025
b430fba
remove unused code buffer
ancavar Dec 23, 2025
5e8c539
add calls, stack frames
ancavar Dec 25, 2025
241a9c4
project structure, build with make
ancavar Dec 25, 2025
3804ecd
test with `regressin_check.sh`
ancavar Dec 25, 2025
cb9ba70
separate stack
ancavar Dec 25, 2025
a463b2d
change stack frame organization
ancavar Dec 26, 2025
7e03eab
add jmp, cjmp, comprasion opcodes
ancavar Dec 26, 2025
3366130
statically link runtime functions
ancavar Dec 27, 2025
0566085
first gc, arrays
ancavar Dec 28, 2025
1b35dd9
store global vars on the stack for gc, change makefile
ancavar Dec 29, 2025
10ee89b
add strings, change stack for gc
ancavar Dec 29, 2025
9060d9d
add S-expressions
ancavar Dec 29, 2025
4635e3c
add closures (wip)
ancavar Dec 29, 2025
e40822a
add debug target ot makefile
ancavar Jan 6, 2026
3039a6a
change bytecode loading to mmap
ancavar Jan 7, 2026
1b82803
add working vm
ancavar Feb 8, 2026
d6764e1
attribute unused, remove opcodes for specific calls
ancavar Feb 8, 2026
fe44a93
type naming shenanigans
ancavar Feb 9, 2026
13d7c05
add separate driver `lama.c` to parse `-h` and `-I` options
ancavar Feb 9, 2026
1fc533f
free vm memory
ancavar Feb 9, 2026
b3fb5e0
`_ne` -> `_le`
ancavar Feb 10, 2026
a779549
fix `unescape`
ancavar Feb 10, 2026
d44586d
`close(fd)`
ancavar Feb 10, 2026
4601ee5
add missing `da.h`
ancavar Feb 10, 2026
653e004
cleanup
ancavar Feb 10, 2026
cc6ba3e
add free for stub table
ancavar Feb 10, 2026
3df2183
change vm
ancavar Feb 10, 2026
1be0992
store public symbol flag as 1 byte
ancavar Feb 13, 2026
90b2d62
init globals to 0
ancavar Feb 13, 2026
61a7540
change `loader.c` to handle cyclic import
ancavar Feb 13, 2026
75d27f9
support external globals
ancavar Feb 13, 2026
e91a1d1
remove `is_filepath`
ancavar Feb 13, 2026
8752d73
cleanup
ancavar Feb 15, 2026
9a2694d
use dynamic array
ancavar Feb 15, 2026
e3c53d2
free fixup nodes; cleanup
ancavar Feb 15, 2026
bf93aca
assert for `is_function`
ancavar Feb 15, 2026
5a1847a
add iterator for public symbols and imports
ancavar Feb 16, 2026
dc6fd81
don't use op call ffi stub
ancavar Feb 16, 2026
51e38ef
move everything to `converter.c`
ancavar Feb 16, 2026
efd3165
cache ffi calls
ancavar Feb 26, 2026
787013c
cleanup
ancavar Feb 26, 2026
27d0ed6
SM.ml chore
ancavar Feb 27, 2026
30d47ff
cleanup
ancavar Feb 28, 2026
d275e4d
add bytecode format description
ancavar Feb 28, 2026
3cd8652
change stack validation
ancavar Feb 26, 2026
6300f5f
bring back `opcodes.c` for easier debugging
ancavar Feb 28, 2026
214f6d5
separate stack validation, store max depth for func
ancavar Feb 28, 2026
978a925
add `debug.h`
ancavar Feb 28, 2026
ddcfa1a
cleanup `regression_check.sh`
ancavar Mar 31, 2026
ddc1bb4
stack
ancavar Apr 1, 2026
9675289
load / store globals by a pointer instead of an index
ancavar Apr 1, 2026
1b1d39a
better cleanup
ancavar Apr 1, 2026
0db7ad4
add function and global prefixing
ancavar Apr 2, 2026
e2320fb
track external globals for gc
ancavar Apr 2, 2026
73ddeaa
cleanup
ancavar Apr 2, 2026
3fc2c2d
zero out `op_drop`
ancavar Apr 3, 2026
6655167
remove div/mod by 0 check
ancavar Apr 3, 2026
164f49e
cleanup unused files
ancavar Apr 3, 2026
8edeb25
return `bool` instead of `code`
ancavar Apr 3, 2026
d468a23
memset 0 gc stack range
ancavar Apr 3, 2026
e9fdb5d
stdout to stderr
ancavar Apr 3, 2026
f1f241a
better `README.md`
ancavar Apr 3, 2026
e461bfe
lift branching
ancavar Apr 3, 2026
92ad137
better `is_filepath`
ancavar Apr 3, 2026
716c1c8
prefer static array for path
ancavar Apr 3, 2026
c35e3d3
better
ancavar Apr 3, 2026
d9339e5
move `count_globals` to `bytecode.c`
ancavar Apr 3, 2026
aa84c24
Revert "track external globals for gc"
ancavar Apr 3, 2026
6c78ce2
dedup `emit_st_glo` and `emit_ld_glo`
ancavar Apr 3, 2026
c4fa9c5
move `stack_validation.h` to `converter.c`
ancavar Apr 3, 2026
c5ab009
move `sv` init to `decode_ctx_init`
ancavar Apr 3, 2026
fd3b4b5
fix stack validation by not merging all operations
ancavar Apr 3, 2026
80e5008
remove `func_stack`
ancavar Apr 3, 2026
5962987
hash tag during decoding
ancavar Apr 5, 2026
9aef730
validate `ld/st` operations
ancavar Apr 5, 2026
a8dcd39
refactor `op_call` and `op_closure`
ancavar Apr 5, 2026
4486cee
open files in `loader.c` instead of `bytecode.c`
ancavar Apr 5, 2026
4c64bb7
allocate global `eof_ip` instead of placing it in the converted bytecode
ancavar Apr 5, 2026
70f2f4b
remove `main` from public symbols for bytecode
ancavar Apr 5, 2026
ebbe9f8
barrier that should work
ancavar Apr 5, 2026
a45ed41
remove redundant check
ancavar Apr 6, 2026
58b59b2
fix main module handling
ancavar Apr 7, 2026
2fc0020
set args and init gc in `vm_run`
ancavar Apr 7, 2026
3915242
remove return value from `vm`
ancavar Apr 7, 2026
4e2d138
pop the result in `op_eof`
ancavar Apr 7, 2026
a39202a
remove redundant `__gc_stack_top` setup in `vm.c`
ancavar Apr 7, 2026
6f66df5
remove unused `total_globals` field
ancavar Apr 7, 2026
242fec5
change `OP_LINE` and `OP_FAIL_KEEP` opcodes
ancavar Apr 7, 2026
f603f15
`op_line` chore
ancavar Apr 7, 2026
672d505
check for `EOF`
ancavar Apr 7, 2026
39323a8
undef emits
ancavar Apr 7, 2026
31a5fa7
better error handling for `symbols.c`
ancavar Apr 7, 2026
92911ac
specialize macros
ancavar Apr 7, 2026
b5d9a50
refactor emitting global
ancavar Apr 7, 2026
fc134c3
`op_ld` and `op_st` to `op_ld_glo` and `op_st_glo`
ancavar Apr 7, 2026
3a77e64
some validation
ancavar Apr 8, 2026
a55f9e9
cleanup
ancavar Apr 8, 2026
e9c81d8
add `extern_funcs`
ancavar Apr 8, 2026
c63ebcb
detect cycles
ancavar Apr 8, 2026
e31211d
some validation concerns from `fuzzing`
ancavar Apr 8, 2026
b424774
better `SM.ml`
ancavar Apr 8, 2026
ee9b43c
reversed order `is_loading`
ancavar Apr 8, 2026
30a3f2a
better
ancavar Apr 8, 2026
3036a70
change signature
ancavar Apr 8, 2026
ff6a969
add macros for `op_patt`
ancavar Apr 8, 2026
97d31f2
move `opcode_is_func_begin`
ancavar Apr 8, 2026
3447091
better checks
ancavar Apr 8, 2026
98fde89
point `sp` to the last pushed value, not the first empty slot
ancavar Apr 9, 2026
b81176f
correct `op_fail`
ancavar Apr 9, 2026
9331620
do not include main unit's path as a search path
ancavar Apr 9, 2026
48cc6c7
remove `ifdef debug` for op_line
ancavar Apr 9, 2026
cac7809
group together manipulations with GC before pseudo-registers initiali…
ancavar Apr 9, 2026
68778f2
chore
ancavar Apr 9, 2026
bd7e9b1
remove `op_init`, use `op_call` for main unit's begin
ancavar Apr 9, 2026
b012ef7
change path loading
ancavar Apr 16, 2026
b529993
chore
ancavar Apr 16, 2026
af41961
proper casts for reading bytes
ancavar Apr 16, 2026
8203fdd
change path loading
ancavar Apr 19, 2026
79ea67c
validate closure captures
ancavar Apr 19, 2026
b25464a
add explanation for setting current depth to instruction after `BARRIER`
ancavar Apr 19, 2026
8377431
fix stack operations
ancavar Apr 20, 2026
242347b
unify `is_filepath` and `extract_unit_name`
ancavar Apr 22, 2026
78923ec
cleanup redundant check for closure var
ancavar Apr 22, 2026
03cbacb
change stack mechanics, remove max_depth
ancavar Apr 22, 2026
f2e9968
fix
ancavar Apr 26, 2026
efec8f9
better build
ancavar May 17, 2026
1640d07
add O3 runtime (?) for bench
ancavar May 18, 2026
2863794
first version specification
ancavar May 18, 2026
63dd7c8
lama svg
ancavar May 18, 2026
417a39d
add magic number
ancavar May 20, 2026
574e3b0
add version number to bytecode format
ancavar May 21, 2026
71c3749
clarify `SPEC.md`
ancavar May 21, 2026
34dd5c3
add well-formedish criteria for instructions
ancavar May 21, 2026
42b07c2
fix make error?
ancavar May 23, 2026
0db9308
add disassembly for bytecode, remove `byterun/`
ancavar Jun 13, 2026
2d152dc
better `README.md`
ancavar Jun 14, 2026
4c9d0b4
resolve TODOs
ancavar Jun 14, 2026
8f2508f
fix wording to abstract stack machine
ancavar Jun 25, 2026
9e16c63
add cram tests to vm
ancavar Jun 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BUILDDIR = _build
all: build test

build:
dune b src runtime runtime32 stdlib tutorial
dune b src runtime runtime32 stdlib tutorial virtual_machine

install: all
dune b @install --profile=release
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Lama

![lama](lama.svg) is a programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools.
![lama](lama.svg) is a programming language (initially developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools.
Its general characteristics are:

* procedural with first-class functions - functions can be passed as arguments, placed in data structures,
Expand All @@ -27,10 +27,10 @@ The lack of a type system (a vital feature for a real-world language
for software engineering) is an intensional decision that allows showing the unchained diversity of runtime behaviors, including those that a typical type system is called to prevent.
On the other hand the language can be used in the future as a raw substrate to apply various ways of software verification (including type systems).

The current implementation contains a native code compiler for **x86-64**, written in **OCaml**, a runtime library with garbage-collection support, written in **C**, and a small standard library, written in ![lama](lama.svg) itself.
The current implementation contains a native code compiler for **x86-64**, written in **OCaml**, a runtime library with garbage-collection support and a bytecode virtual machine written in **C**, and a small standard library, written in ![lama](lama.svg) itself.

In addition, a source-level reference interpreter is implemented as well as a compiler to a small stack machine.
The stack machine code can in turn be either interpreted on a stack machine interpreter, or used as an intermediate representation by the native code compiler.
In addition, a source-level reference interpreter is implemented as well as a compiler to a small abstract stack machine.
This abstract stack machine code can in turn be serialized as bytecode for execution by the virtual machine, or used as an intermediate representation by the native code compiler.

## Language Specification

Expand Down
1 change: 0 additions & 1 deletion byterun/.gitignore

This file was deleted.

351 changes: 0 additions & 351 deletions byterun/byterun.c

This file was deleted.

Loading
Loading