Comments (3)
Backstory: the reason that we don't need to emit primitives that appear only in the head position of a list is because for performance reasons we inline those calls. This leads to a very substantial performance increase.
Something like calling fib(40)
goes from something that takes painfully long to something that happens in under a second with this optimization.
from lisp.
As an example, in the following program we only really need to compile add
and sub
as they are the only primitives that appear.
(let pair (cons add sub))
((car pair) ((cdr pair) 5 4) 41)
from lisp.
For some perspective on why this would be valuable, here's some timing information from the fib test:
parse 254.15µs
emit alloc 1.50ms
emit primitives 506.58ms
symbol renaming pass 65.84µs
data collection pass 4.37µs
data replacement pass 3.94µs
data creation 1.47µs
function collection pass 17.24µs
free variable analysis 77.15µs
function replacement pass 16.09µs
free variable annotation 9.00µs
procedure compilation 162.40ms
lust_entry compilation 15.60ms
program execution 2.15s
total 2.84s
Compiling primitives is by far the slowest operation.
from lisp.
Related Issues (20)
- Write a high level bytecode compiler HOT 1
- Change `import` to `require` HOT 1
- Use Vec more appropriately when representing lists HOT 1
- Use Vec for enviroments instead of HashMap HOT 2
- Update string documentation
- Better support for `LUSTPATH` enviorment variable
- Support compilation to object files HOT 1
- Garbage Collection
- Add char parsing to tokenizer / parser
- Allow non list objects in the tail position of lists HOT 1
- Support new let expression semantics
- Internal error assigning variable of same name in compiler
- Varadic functions in compiler
- Pay for what you use: varadic functions
- Lustc expects compiled programs to return an immediate type
- car and cdr have different behavior when called on empty list
- Type checks are inlined causing code bloat
- Reference guide link broken HOT 2
- License
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lisp.