Commit 095b1af
authored
Add AOT compilation support for Glojure standard library (#99)
This commit introduces Ahead-Of-Time (AOT) compilation specifically for the
Glojure standard library, significantly improving startup performance by
pre-compiling core modules to Go code.
Key Features:
- Code generation infrastructure in pkg/runtime/codegen.go
- Pre-compiled standard library modules (core, core_print, protocols, etc.)
- Automatic AOT compilation during build via 'make generate'
- Runtime registration and loading of pre-compiled namespaces
- Comprehensive test suite with golden file testing
Implementation Scope (Standard Library Only):
- This initial implementation focuses exclusively on pre-compiling the
Glojure standard library for faster startup
- User code AOT compilation will be added in future updates
- Pre-compiled modules are embedded in the binary at build time
Technical Implementation:
- AST-to-Go code transformation with proper scoping
- Support for all core language constructs used in stdlib
- Special forms: def, set!, case, letfn, try/catch/finally, etc.
- Metadata preservation and symbol/keyword pre-allocation
- Topological sorting for dependency resolution
Performance Benefits:
- Eliminates parse and eval overhead for standard library at runtime
- REPL startup time significantly reduced
- Default enabled with GLOJURE_USE_AOT=true environment variable
Testing:
- Comprehensive test coverage for code generation paths
- Golden file testing for reproducible output verification
- Behavioral testing ensures correctness vs interpreted code
This foundation will enable AOT compilation of user code in future releases,
further improving performance for production Glojure applications.1 parent a2bebb9 commit 095b1af
File tree
96 files changed
+242427
-459
lines changed- cmd/gen-import-interop
- pkg
- gen/gljimports
- gljmain
- lang
- runtime
- codegengotest
- testdata/codegen/test
- case_switch
- const_keyword
- const_number
- const_string
- core
- def_simple
- fn_closure
- fn_recur
- goroutine
- letfn
- loop_simple
- maybe_class
- multifn
- ns_skip
- quote_simple
- ref
- set_bang
- the_var
- throw_simple
- try_advanced
- try_basic
- values
- with_meta
- stdlib/glojure
- core_deftype
- core_print
- core
- async
- go
- protocols
- template
- walk
- scripts/rewrite-core
- test/glojure/test_glojure
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
96 files changed
+242427
-459
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | | - | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | | - | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
0 commit comments