Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT...
Transcript of Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT...
![Page 1: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/1.jpg)
Cog VM Evolution
Clément Béra
Thursday, August 25, 16
![Page 2: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/2.jpg)
Cog VM ?• Smalltalk virtual machine
• Default VM for
• Pharo
• Squeak
• Newspeak
• Cuis
Thursday, August 25, 16
![Page 3: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/3.jpg)
Cog Philosophy
• Open source (MIT)
• Simple
• Is the optimization / feature worth the added complexity ?
• Cross-Platform (Processors, OS, 32/64 bits)
Thursday, August 25, 16
![Page 4: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/4.jpg)
Execution engine
• VM
• Execution engine
• Plugins: graphics, file, etc.
Thursday, August 25, 16
![Page 5: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/5.jpg)
Execution engine
• Interpreter
• JIT
• Memory Manager (including GC)
Thursday, August 25, 16
![Page 6: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/6.jpg)
Evolution
• User and Customer driven
• Where did we start ?
• What problems did we solve ?
Thursday, August 25, 16
![Page 7: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/7.jpg)
Starting blocks
• Interpreter VM
• Made by Dan Ingalls Team
• Simple Interpreter
• Spaghetti stack
• Smart but simple Memory Manager
Thursday, August 25, 16
![Page 8: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/8.jpg)
Performance !
Short-term delivery
Performance for 3D application
Thursday, August 25, 16
![Page 9: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/9.jpg)
Performance !
Short-term delivery
Performance for 3D application
• Fast Interpreter
Thursday, August 25, 16
![Page 10: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/10.jpg)
• Context-to-stack Mapping
• 85% of context allocation removed
• No copying of arguments
• New hash logic
• Primitive function caching
Stack VM
Thursday, August 25, 16
![Page 11: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/11.jpg)
Issue• Closure implementation
• No temporaries
• BlockAlreadyEvaluated error
• Non obvious bugs
• New implementation
Thursday, August 25, 16
![Page 12: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/12.jpg)
0
2
4
6
8
10
12
14
Interpreter Stack CogV1 CogV2 Spur Sista
Binary Tree benchmark
Thursday, August 25, 16
![Page 13: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/13.jpg)
More Performance !
Short-term delivery
Performance for 3D application
Thursday, August 25, 16
![Page 14: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/14.jpg)
More Performance !
Short-term delivery
Performance for 3D application
• First JIT compiler
Thursday, August 25, 16
![Page 15: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/15.jpg)
Cog VM
• x86 back-end
• Simple machine code generation
• Except inline caches
Thursday, August 25, 16
![Page 16: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/16.jpg)
Binary Tree benchmark
0
2
4
6
8
10
12
14
Interpreter Stack CogV1 CogV2 Spur Sista
Thursday, August 25, 16
![Page 17: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/17.jpg)
JIT Abstractions
V3
Object Representation
SimpleStackCogit
CogitImplementation
x86
Machine back-end
Thursday, August 25, 16
![Page 18: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/18.jpg)
Yet More Performance !
Short-term delivery
Performance for 3D application
Thursday, August 25, 16
![Page 19: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/19.jpg)
Yet More Performance !
Short-term delivery
Performance for 3D application
• Second JIT compiler
Thursday, August 25, 16
![Page 20: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/20.jpg)
Cog VM
• Machine code generation
• Linear scan register allocation
• Avoids many stack operations
• Register-based calling convention
Thursday, August 25, 16
![Page 21: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/21.jpg)
Binary Tree benchmark
0
2
4
6
8
10
12
14
Interpreter Stack CogV1 CogV2 Spur Sista
Thursday, August 25, 16
![Page 22: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/22.jpg)
JIT Abstractions
V3
Object Representation
SimpleStackCogitStackToRegisterMappingCogit
CogitImplementation
x86
Machine back-end
Thursday, August 25, 16
![Page 23: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/23.jpg)
Newspeak support ?
Newspeak is Smalltalk-like
New kind of sends
Thursday, August 25, 16
![Page 24: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/24.jpg)
Newspeak support ?
• Multiple bytecode set support
• Newspeak specific operations
• Interpreter
• Machine code generation
Thursday, August 25, 16
![Page 25: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/25.jpg)
64 bits ? Images larger than 1 or 2 Gb ?
Moving objects during FFI call-backs ?Even more performance !
Ephemerons ?Become is so slow it cannot be used.
Thursday, August 25, 16
![Page 26: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/26.jpg)
64 bits ? Images larger than 1 or 2 Gb ?
Moving objects during FFI call-backs ?Even more performance !
Ephemerons ?Become is so slow it cannot be used.
Short-term delivery
Thursday, August 25, 16
![Page 27: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/27.jpg)
64 bits ? Images larger than 1 or 2 Gb ?
Moving objects during FFI call-backs ?Even more performance !
Ephemerons ?Become is so slow it cannot be used.
Short-term delivery
• New Memory Manager
Thursday, August 25, 16
![Page 28: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/28.jpg)
Spur Memory Manager
• Class-table (efficient caches and compactness)
• Efficient scavenging
• Fast become
• New object layouts (Ephemerons, ShortArrays)
• Memory representation 64-bits compatible
• Pinned objects
• Segmented Memory
Thursday, August 25, 16
![Page 29: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/29.jpg)
Binary Tree benchmark
0
2
4
6
8
10
12
14
Interpreter Stack CogV1 CogV2 Spur Sista
Thursday, August 25, 16
![Page 30: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/30.jpg)
JIT Abstractions
V3Spur32
Spur64
Object Representation
SimpleStackCogitStackToRegisterMappingCogit
CogitImplementation
x86
Machine back-end
V3Spur32
Spur64
Object Representation
x86
Machine back-end
32 bits 64 bits
Thursday, August 25, 16
![Page 31: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/31.jpg)
Raspberry Pi performance ?
Scratch support
Thursday, August 25, 16
![Page 32: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/32.jpg)
• ARMv6 support
Raspberry Pi performance ?
Scratch support
Thursday, August 25, 16
![Page 33: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/33.jpg)
ARMv6 support
• JIT ARMv6 back-end
• JIT abstraction over literal management
• JIT abstraction over CISC / RISC
Thursday, August 25, 16
![Page 34: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/34.jpg)
JIT Abstractions
V3Spur32
Spur64
Object Representation
SimpleStackCogitStackToRegisterMappingCogit
CogitImplementation
x86
Machine back-end
V3Spur32
Spur64
Object Representation
x86ARMv6MIPSEL
Machine back-end
32 bits 64 bits
Inline
Outline
Literal Manager
Thursday, August 25, 16
![Page 35: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/35.jpg)
Ryan (contributor)
Working with the Dart VM
Dart runs on more platform than Newspeak.
Thursday, August 25, 16
![Page 36: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/36.jpg)
Ryan (contributor)
Working with the Dart VM
Dart runs on more platform than Newspeak.
• MIPSEL support
Thursday, August 25, 16
![Page 37: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/37.jpg)
JIT Abstractions
V3Spur32
Spur64
Object Representation
SimpleStackCogitStackToRegisterMappingCogit
CogitImplementation
x86
Machine back-end
V3Spur32
Spur64
Object Representation
x86ARMv6MIPSEL
Machine back-end
32 bits 64 bits
Inline
Outline
Literal Manager
Thursday, August 25, 16
![Page 38: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/38.jpg)
64 bits support ?
64 bits library binding
Heap over 2Gb
Thursday, August 25, 16
![Page 39: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/39.jpg)
64 bits support ?
64 bits library binding
Heap over 2Gb
• x64 support
• Immediate float
Thursday, August 25, 16
![Page 40: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/40.jpg)
JIT Abstractions
V3Spur32
Spur64
Object Representation
Inline
Outline
Literal Manager
SimpleStackCogitStackToRegisterMappingCogit
CogitImplementation
x86ARMv6MIPSEL
x64
Machine back-end
32 bits 64 bits
Thursday, August 25, 16
![Page 41: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/41.jpg)
Yet even more performance !
Computation lasting 3 to 6 hours
Thursday, August 25, 16
![Page 42: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/42.jpg)
Yet even more performance !
Computation lasting 3 to 6 hours
• Speculative optimizations
Thursday, August 25, 16
![Page 43: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/43.jpg)
Sista VM
• The program introspects
• Optimize the code for performance
• Deoptimize when it took incorrect decisions
Thursday, August 25, 16
![Page 44: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/44.jpg)
Issues
• Bytecode set
• Literal mutability
• Closure implementation
Thursday, August 25, 16
![Page 45: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/45.jpg)
Bytecode set limitations ?
Code generator tools
Thursday, August 25, 16
![Page 46: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/46.jpg)
Sista bytecode set
• Lifting encoding limitations
• Encode instructions for the Sista / Lowcode
Thursday, August 25, 16
![Page 47: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/47.jpg)
Efficient modification trackers ?Literal inconsistency ?
Thursday, August 25, 16
![Page 48: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/48.jpg)
• Read-only objects
• IWST talk this afternoon
• Hopefully allows more compiler optimizations
Efficient modification trackers ?Literal inconsistency ?
Thursday, August 25, 16
![Page 49: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/49.jpg)
Closure implementation
• Method and closure get more similar
• Simplifies part of the VM
• Simplifies the runtime compiler
Thursday, August 25, 16
![Page 50: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/50.jpg)
Integration
• Closed alpha version
• Integrating dependencies:
• Bytecode set integrated
• Read-only objects integrated (but disabled)
• Closure implementation in progress
Thursday, August 25, 16
![Page 51: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/51.jpg)
Binary Tree benchmark
0
2
4
6
8
10
12
14
Interpreter Stack CogV1 CogV2 Spur Sista
Thursday, August 25, 16
![Page 52: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/52.jpg)
JIT Abstractions
V3Spur32
Spur64
Object Representation
Inline
Outline
Literal Manager
SimpleStackCogitStackToRegisterMappingCogit
RegisterAllocatingCogitSistaCogit
CogitImplementation
x86ARMv6MIPSEL
x64
Machine back-end
32 bits 64 bits
Thursday, August 25, 16
![Page 53: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/53.jpg)
Image compaction ?
Sometimes, large images when saving
Thursday, August 25, 16
![Page 54: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/54.jpg)
Image compaction ?
Sometimes, large images when saving
• Better compactor
Thursday, August 25, 16
![Page 55: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/55.jpg)
Pauses ?
0.5 second freezes in UI application
Thursday, August 25, 16
![Page 56: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/56.jpg)
Pauses ?
0.5 second freezes in UI application
• Incremental GC
Thursday, August 25, 16
![Page 57: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/57.jpg)
Many hidden parts
...
Thursday, August 25, 16
![Page 58: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/58.jpg)
• C generated from Slang
• Many were fixed
• Towards compilation with -WAll -WError
C compiler warning ?
Thursday, August 25, 16
![Page 59: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/59.jpg)
• LargeInteger plugin more efficient
• Computation moved from 8bits to 32 bits
• Different compilation flags
Faster arithmetic ?
Thursday, August 25, 16
![Page 60: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/60.jpg)
• Slang-to-C compiler
• Many improvements
• Type inference
Slang ?
Thursday, August 25, 16
![Page 61: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/61.jpg)
Contribution
Thursday, August 25, 16
![Page 62: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/62.jpg)
Cog VM team• Started with Eliot Miranda
• Many more contributors now:
• Tim Rowledge
• Clément Béra (myself)
• Nicolas Cellier
• Fabio Niephaus & Tim Felgentreff
• Ryan Macnak
Thursday, August 25, 16
![Page 63: Cog VM Evolution - ESUG: News The cog vm evolution... · • Interpreter • JIT ... • First JIT compiler Thursday, August 25, 16. Cog VM ... Scratch support Thursday, August 25,](https://reader033.fdocuments.in/reader033/viewer/2022042223/5ec9db50f4aa72407772affb/html5/thumbnails/63.jpg)
Conclusion• Lots of new features and improvements over years
• A lot more is incoming
• If you want to support, talk to us !
• ARMv8 ?
• Incremental GC ?
• Performance (escaping, floats) ?
Thursday, August 25, 16