-
Notifications
You must be signed in to change notification settings - Fork 68
/
SpurCompactor.class.st
128 lines (112 loc) · 4.37 KB
/
SpurCompactor.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"
Abstract common superclass of all compactors to define apis and simulation variables.
The full GC in Spur is split in two, the marking phase and the compactor phase. The subclasses of SpurCompactor are implementations of the second phase, so they are called once the marking phase is finished. SpurCompactor is reponsible for:
- freeing unmarked objects
- compacting the live old space objects (though each subclass define what it does, some spurCompactor may not compact)
- unmarking all objects remaining live
- updating oops directly referred by the VM when they are moved (remapObj:/shouldRemapObj: thingy)
The main apis are the following:
- biasForGC/biasForSnapshot: tells the compactor if the GC is performed for snapshots or not, in general we want to compact more aggressively for snapshots to avoid saving large files with many unused space.
- compact: main API, should free the unmarked object, unmark the objects remaining live and potentially compact the heap
- remapObj:/shouldRemapObj: => Not really sure what this does, it seems it has to do with updating oops directly referred by the VM when they are moved.
- postSwizzleAction: if you want to do something at start-up after swizzle phase (typically useful if your compaction algo uses segInfos)
Instance Variables
coInterpreter: <StackInterpreter>
scavenger: <SpurGenerationScavenger>
manager: <SpurMemoryManager>
"
Class {
#name : #SpurCompactor,
#superclass : #VMClass,
#instVars : [
'coInterpreter',
'manager',
'scavenger'
],
#pools : [
'SpurMemoryManagementConstants',
'VMBasicConstants',
'VMSpurObjectRepresentationConstants'
],
#category : #'VMMaker-SpurMemoryManager'
}
{ #category : #translation }
SpurCompactor class >> classesForTranslation [
"Usually we want to add the SpurCompactor first, followed by the subclass.
SpurHybridCompactor is more complicated."
^(self withAllSuperclasses copyUpThrough: SpurCompactor) reverse
]
{ #category : #translation }
SpurCompactor class >> declareCVarsIn: aCCodeGenerator [
"If subclasses are being used but are not the compactorClass itself
then statically resolve their api selectors."
(self inheritsFrom: SpurCompactor) ifTrue: "leave SpurCompactor methods alone"
[(SpurMemoryManager compactorClass includesBehavior: self) ifFalse: "only map methods not in the compactorClass"
[#(compact biasForGC biasForSnapshot remapObj: shouldRemapObj:) do: "map the public api methods only"
[:selectorToStaticallyResolve|
aCCodeGenerator
staticallyResolveMethodNamed: selectorToStaticallyResolve
forClass: self
to: (self staticallyResolvePolymorphicSelector: selectorToStaticallyResolve)]]]
]
{ #category : #translation }
SpurCompactor class >> implicitReturnTypeFor: aSelector [
"Answer the return type for methods that don't have an explicit return."
^#void
]
{ #category : #api }
SpurCompactor >> biasForGC [
self subclassResponsibility
]
{ #category : #api }
SpurCompactor >> biasForSnapshot [
self subclassResponsibility
]
{ #category : #initialization }
SpurCompactor >> coInterpreter: aVMSimulator [
<doNotGenerate>
coInterpreter := aVMSimulator
]
{ #category : #api }
SpurCompactor >> compact [
self subclassResponsibility
]
{ #category : #initialization }
SpurCompactor >> manager: aSpurNBitMMXEndianSimulator [
<doNotGenerate>
manager := aSpurNBitMMXEndianSimulator.
aSpurNBitMMXEndianSimulator coInterpreter ifNotNil:
[:coint| coInterpreter := coint].
aSpurNBitMMXEndianSimulator scavenger ifNotNil:
[:scav| scavenger := scav]
]
{ #category : #api }
SpurCompactor >> postSwizzleAction [
"do nothing"
]
{ #category : #debugging }
SpurCompactor >> printTheBogons: aBogon [
<inline: true>
coInterpreter
print: 'bogon '; printHexnp: aBogon; cr
]
{ #category : #api }
SpurCompactor >> remapObj: objOop [
<api>
<inline: false>
^manager vanillaRemapObj: objOop
]
{ #category : #initialization }
SpurCompactor >> scavenger: aSpurGenerationScavenger [
<doNotGenerate>
scavenger := aSpurGenerationScavenger
]
{ #category : #api }
SpurCompactor >> shouldRemapObj: objOop [
<api>
"Answer if the obj should be scavenged (or simply followed). The method is called
shouldRemapObj: for compatibility with ObjectMemory. Defer to the compactor
to choose the actual test, there being a difference between the vanilla test and
that used with a sliding compactor where objects are not marked as forwarded."
^manager vanillaShouldRemapObj: objOop
]