-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMSpurInitializedOldSpaceTest.class.st
187 lines (142 loc) · 4.76 KB
/
VMSpurInitializedOldSpaceTest.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Class {
#name : #VMSpurInitializedOldSpaceTest,
#superclass : #VMSpurMemoryManagerTest,
#category : #'VMMakerTests-MemoryTests'
}
{ #category : #testing }
VMSpurInitializedOldSpaceTest class >> isAbstract [
^ self == VMSpurInitializedOldSpaceTest
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> assertFreeListEmpty: aFreeListOop [
self assert: aFreeListOop equals: 0
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> createEphemeronClass [
ourEphemeronClass := self createEphemeronClassForSlots: 3
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> createEphemeronClassForSlots: fixedSlots [
| theNewClass formatWithSlots hash |
theNewClass := self newOldSpaceObjectWithSlots: 3.
theNewClass := memory pinObject: theNewClass.
self assert: theNewClass ~= 0.
formatWithSlots := memory ephemeronFormat << 16 + fixedSlots.
memory
storePointer: 2
ofObject: theNewClass
withValue: (memory integerObjectOf: formatWithSlots). "InstanceSpecificationIndex"
hash := memory ensureBehaviorHash: theNewClass.
self assert: (hash between: 1 and: 4194303). "1 << 22 - 1"
^ theNewClass
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> createFreeChunkOfSize: aSize [
| address |
address := memory allocateOldSpaceChunkOfBytes: aSize.
memory freeChunkWithBytes: aSize at: address.
^ address
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> denyFreeListEmpty: aFreeListOop [
self deny: aFreeListOop equals: 0
]
{ #category : #tests }
VMSpurInitializedOldSpaceTest >> forgetObject3 [
memory coInterpreter profileMethod: memory nilObject
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> freeListForSize: allocationSize [
^ memory freeLists at: allocationSize / memory allocationUnit
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> freeTreeRootOop [
"Initially the old space has a single big chunk of free memory and no small free chunks.
So
- the free lists are empty
- the single big chunk of memory is the root of the free tree
The root of the free tree has no child nodes"
^ memory freeLists at: 0
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> freeTreeRootStartAddress [
"The free tree lists stores the oop of free tree nodes.
That means that the address stored references the beginning of the base header of the tree node.
This is important because tree nodes can be large objects and have more than one header.
We use #startOfObject: to return invariably the address where the node starts"
^ memory startOfObject: self freeTreeRootOop
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> largerNodeOf: aNode [
^ memory
fetchPointer: memory freeChunkLargerIndex
ofFreeChunk: aNode
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> newEphemeronObjectWithSlots: slots [
| class |
class := self createEphemeronClassForSlots: slots.
^ self
newObjectWithSlots: slots
format: memory ephemeronFormat
classIndex: (memory ensureBehaviorHash: class)
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> newOldEphemeronObject [
"In pharo Ephemerons have 3 slots"
^ self newOldEphemeronObjectWithSlots: 3
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> newOldEphemeronObjectWithSlots: slots [
| class |
class := self createEphemeronClassForSlots: slots.
^ self
newOldSpaceObjectWithSlots: slots
format: memory ephemeronFormat
classIndex: (memory ensureBehaviorHash: class)
]
{ #category : #'instance creation' }
VMSpurInitializedOldSpaceTest >> newPermanentByteObjectOfSize: byteSize [
| oop numSlots instSpec |
numSlots := memory numSlotsForBytes: byteSize.
instSpec := memory byteFormatForNumBytes: byteSize.
oop := memory
allocateSlotsInPermSpace: numSlots
format: instSpec
classIndex: (memory ensureBehaviorHash: memory classByteArray).
0 to: byteSize - 1 do: [ :index |
memory storeByte: index ofObject: oop withValue: 0 ].
^ oop
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> nextNodeOf: aNode [
^ memory
fetchPointer: memory freeChunkNextIndex
ofFreeChunk: aNode
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> parentNodeOf: aNode [
^ memory
fetchPointer: memory freeChunkParentIndex
ofFreeChunk: aNode
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> previousNodeOf: aNode [
^ memory
fetchPointer: memory freeChunkPrevIndex
ofFreeChunk: aNode
]
{ #category : #running }
VMSpurInitializedOldSpaceTest >> setUp [
super setUp.
self initializeOldSpaceForScavenger.
self initializeOldSpaceForFullGC.
memory lastHash: 1.
memory classByteArray: (self newClassInOldSpaceWithSlots: 0 instSpec: (memory byteFormatForNumBytes: 0)).
]
{ #category : #helpers }
VMSpurInitializedOldSpaceTest >> smallerNodeOf: aNode [
^ memory
fetchPointer: memory freeChunkSmallerIndex
ofFreeChunk: aNode
]