Does anyone know how I can convert AST into stream of bytecodes? Are there any good example language implementations to learn?
Write Your Own Virtual Machine
31–40 of 79 posts
Re: Write Your Own Virtual Machine
#32 /* 65536 locations */
uint16_t memory[UINT16_MAX];
Spot the leak.Re: Write Your Own Virtual Machine
#33Writing a VM is very fun and addictive. Especially writing in different language can learn a lot!
Re: Write Your Own Virtual Machine
#34One of my favorite techniques for implementing VMs is the "computed goto": https://eli.thegreenplace.net/2012/07/12/computed-goto-for-e... Consider this example for dispatching instructions from the article: while (running) { uint16_t op = mem_read(reg[R_PC]++) >> 12; switch (op) { case OP_ADD: {ADD, 6} break; case OP_AND: {AND, 7} break; case OP_NOT: {NOT, 7} break; case OP_BR: {BR, 7} break; ... } } That code has a…
Re: Write Your Own Virtual Machine
#35Earlier quoted context omitted.
Where can I learn about techniques like that? Any recommendation would be very appreciated!
Look up work by Stefan Brunthaler, like this overview paper ("Virtual-Machine Abstraction and Optimization Techniques"): https://www.sba-research.org/wp-content/uploads/publications... Make sure to check out the references. I especially like "Ertl, M. A. and D. Gregg, The structure and performance of efficient interpreters, Journal of Instruction-Level Parallelism 5 (2003)"
Do you know of any recent efforts to combine ML and VM optimizations ?
(I read about the VS compiler and profile-based optimizations)
Re: Write Your Own Virtual Machine
#36One of my favorite techniques for implementing VMs is the "computed goto": https://eli.thegreenplace.net/2012/07/12/computed-goto-for-e... Consider this example for dispatching instructions from the article: while (running) { uint16_t op = mem_read(reg[R_PC]++) >> 12; switch (op) { case OP_ADD: {ADD, 6} break; case OP_AND: {AND, 7} break; case OP_NOT: {NOT, 7} break; case OP_BR: {BR, 7} break; ... } } That code has a…
Do you know where i can find thrse implementations in ruby or python??
https://github.com/python/cpython/blob/d7538dd5e3e04a8db22e1...
Re: Write Your Own Virtual Machine
#37Earlier quoted context omitted.
Look up work by Stefan Brunthaler, like this overview paper ("Virtual-Machine Abstraction and Optimization Techniques"): https://www.sba-research.org/wp-content/uploads/publications... Make sure to check out the references. I especially like "Ertl, M. A. and D. Gregg, The structure and performance of efficient interpreters, Journal of Instruction-Level Parallelism 5 (2003)"
There goes the weekend... Do you know of any recent efforts to combine ML and VM optimizations ? (I read about the VS compiler and profile-based optimizations)
Though you might not think of hill climbing as "machine learning".
Re: Write Your Own Virtual Machine
#38I like this tutorial but it should be mentioned that before implementing a virtual machine one should understand that there are many computing models and many alternative mechanisms within each of them. Implementing VM for sequential program execution is relatively easy. What is more (conceptually) difficult is concurrency, asynchronous processes etc.
Re: Write Your Own Virtual Machine
#39One of my favorite techniques for implementing VMs is the "computed goto": https://eli.thegreenplace.net/2012/07/12/computed-goto-for-e... Consider this example for dispatching instructions from the article: while (running) { uint16_t op = mem_read(reg[R_PC]++) >> 12; switch (op) { case OP_ADD: {ADD, 6} break; case OP_AND: {AND, 7} break; case OP_NOT: {NOT, 7} break; case OP_BR: {BR, 7} break; ... } } That code has a…
Re: Write Your Own Virtual Machine
#40Off-topic. Does anyone know how I can convert AST into stream of bytecodes? Are there any good example language implementations to learn?