Implementing Software Machines in Go and C
summary
Shows how to implement a tiny VM in C and Go: constructs a contiguous heap using unsafe+reflection heap trick, implements two stack styles (array stack and a cactus stack), builds a chained hashmap and simple GC stub, and compares dispatch strategies—switch interpreter, function-pointer threading and computed-goto dispatch—with working example programs that add and print values. C examples compile and run, Go ports are shorter and leverage the garbage collector; channels are reused as a clock/tick mechanism for synchronized execution.
AI-written summary · about
chapters (20)
- 0:00Intro
- 1:30Virtual Machines
- 2:00Hardware emulation
- 3:25Abstract virtual machines
- 4:15Stateful
- 5:10Performance
- 8:30Memory Models
- 14:50Stacks
- 16:00Stack Pointer
- 20:40Cactus Stacking
- 22:10Boring Maps
- 23:35Associative Arrays
- 25:50Map Algorithm
- 28:20Switch Interpreter
- 31:30Direct Course Reading
- 33:25Indirect Threading
- 35:55Compiler
- 37:00Timing
- 38:20Transport Triggering
- 40:00Books
related talks
44mImplementing Software Machines in Go and C
51mFrom assembler to C++: structure and optimization of CGo ☠️
40mCreating efficient VM with JIT in Go
50mAn insight into Go Garbage Collection
43mUnderstanding the Go Compiler
49m“Which Machine Am I Coding To?”
39mIs Go A Good Language to Build Compilers?
01h 00mHow to write a programming language and shell in Go with 92% test coverage and instant CI/CD
