A JIT Smalltalk VM written in itself. The VM is written entirely in Smalltalk and is compatible with Digitalk's (VS) Smalltalk implementation, leveraging the existing Smalltalk environment. Key components include generating .exe files, object format, memory management including garbage collection, method lookup, primitives, and foreign function interfaces.
14. New Goal
Smalltalk VM
Written in Smalltalk
Compatible with Digitalk's (VS)
Leveraging the environment
15. Smalltalk VM
Written in Smalltalk
.exe generation
Method lookup
Object format
Memory management
Object creation / copy
GC
Become
Primitives
FFI
Processes
Callbacks
etc
17. GCSpace
Object subclass: #GCSpace old
InstanceVariableNames: '
contents
base
nextFree A
commitLimit flip spaces
reservedLimit '
classVariableNames: '' B
poolDictionaries: ''
includes: anObject
^anObject isSmallInteger not
and: [anObject _oop between: self base and: self commitedLimit]
reset
self nextFree: self base
18. GCSpace
old includes: anObject
Object subclass: #GCSpace old
InstanceVariableNames: ' to reset
contents
base from isReferredBy: object
nextFree A
commitLimit old growTo: newLimit
reservedLimit '
classVariableNames: '' B moved := to shallowCopy: object
poolDictionaries: ''
from flipWith: to
includes: anObject
^anObject isSmallInteger not
and: [anObject _oop between: self base and: self commitedLimit]
reset
self nextFree: self base
19. GenerationalGC
Object subclass: #GenerationalGC old
InstanceVariableNames: '
old from to
roots literalsReferences from
weakContainers ephemerons
rescuedEphemerons '
classVariableNames: ''
poolDictionaries: '' to
collect
self
followRoots;
walkStack;
rescueEphemerons;
traverseWeakContainers;
flipSpaces
20. GenerationalGC
flipper purgeRoots
Object subclass: #GenerationalGC old
InstanceVariableNames: ' flipper follow: object
old from to
roots literalsReferences flipper moveToOldOrTo: object
from
weakContainers ephemerons
rescuedEphemerons ' flipper
classVariableNames: '' fixReferencesOrSetTombstone:
poolDictionaries: '' to weakContainer
flipper addInterrupt
collect
self
followRoots;
walkStack;
rescueEphemerons;
traverseWeakContainers;
flipSpaces
25. GenerationalGC
collect
GenerationalGC old from to self
rescueEphemerons
rescueEphemerons
| unknowns rescan |
unknowns := self localStack.
rescan := false.
[ephemerons isEmpty] whileFalse: [
rescan := self followEphemeronsCollectingIn: unknowns.
rescan
ifTrue: [ephemerons addAll: unknowns]
IfFalse: [
unknowns do: [:ephemeron | self rescueEphemeron: ephemeron]].
self reset: unknowns]
[Hayes1997] Barry Hayes, Ephemerons: a new finalization mechanism
26. GenerationalGC
collect
GenerationalGC old from to self
flipSpaces
flipSpaces
fromSpace flipWith: toSpace.
toSpace reset.
GCSpace >> flipWith: space
| aux |
aux := space base.
space base: self base.
self base: aux.
...
27. GenerationalGC
collect
GenerationalGC old from to self
flipSpaces
A B
nextFree := base + size nextFree := base
copy
contents A contents B
28. GenerationalGC
collect
GenerationalGC old from to self
flipSpaces
A B
contents A contents B
29. GenerationalGC
collect
GenerationalGC old from to self
flipSpaces
A B
contents A contents B
VM assumption: from.commitLimit < to.base