-
Notifications
You must be signed in to change notification settings - Fork 71
/
VMSpurScavengeWeakTest.class.st
93 lines (71 loc) · 3.05 KB
/
VMSpurScavengeWeakTest.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
Class {
#name : #VMSpurScavengeWeakTest,
#superclass : #VMSpurInitializedOldSpaceTest,
#category : #'VMMakerTests-MemoryTests'
}
{ #category : #'test-format' }
VMSpurScavengeWeakTest >> testNewWeakObjectShouldBeInstanceOfWeakClass [
| weakObjectOop |
self createWeakArrayClass.
weakObjectOop := self newWeakObjectOfSize: 1.
self assert: (memory fetchClassOfNonImm: weakObjectOop) equals: ourWeakClass
]
{ #category : #'test-format' }
VMSpurScavengeWeakTest >> testNewWeakObjectShouldHaveClassIndexOfItsClass [
| weakObjectOop classIndex |
self createWeakArrayClass.
weakObjectOop := self newWeakObjectOfSize: 1.
classIndex := memory classIndexOf: weakObjectOop.
self assert: classIndex equals: (memory ensureBehaviorHash: ourWeakClass)
]
{ #category : #tests }
VMSpurScavengeWeakTest >> testScavengeOldWeakObjectReferencingNonSurvivorShouldBeNilled [
| weakObjectOop nonWeakObjectOop nonWeakObjectHash nilHash |
self createWeakArrayClass.
weakObjectOop := self newWeakObjectOfSize: 1.
"Force object to not be collected by putting them in special variables"
memory coInterpreter newMethod: weakObjectOop.
memory flushNewSpace.
weakObjectOop := memory remapObj: weakObjectOop.
nonWeakObjectOop := self newZeroSizedObject.
nonWeakObjectHash := memory hashBitsOf: nonWeakObjectOop.
memory storePointer: 0 ofObject: weakObjectOop withValue: nonWeakObjectOop.
nilHash := memory hashBitsOf: memory nilObject.
memory doScavenge: 1 "TenureByAge".
self
assert: (memory hashBitsOf: (memory fetchPointer: 0 ofObject: weakObjectOop))
equals: nilHash
]
{ #category : #tests }
VMSpurScavengeWeakTest >> testScavengeWeakObjectReferencingNonSurvivorShouldBeNilled [
| weakObjectOop nonWeakObjectOop nilHash |
self createWeakArrayClass.
weakObjectOop := self newWeakObjectOfSize: 1.
nonWeakObjectOop := self newZeroSizedObject.
memory storePointer: 0 ofObject: weakObjectOop withValue: nonWeakObjectOop.
"Force object to not be collected by putting them in special variables"
memory coInterpreter newMethod: weakObjectOop.
nilHash := memory hashBitsOf: memory nilObject.
memory doScavenge: 1 "TenureByAge".
weakObjectOop := memory remapObj: weakObjectOop.
self
assert: (memory hashBitsOf: (memory fetchPointer: 0 ofObject: weakObjectOop))
equals: nilHash
]
{ #category : #tests }
VMSpurScavengeWeakTest >> testScavengeWeakObjectReferencingSurvivorShouldLeaveWeakObjectAsIs [
| weakObjectOop nonWeakObjectOop nonWeakObjectHash |
self createWeakArrayClass.
weakObjectOop := self newWeakObjectOfSize: 1.
nonWeakObjectOop := self newZeroSizedObject.
nonWeakObjectHash := memory hashBitsOf: nonWeakObjectOop.
memory storePointer: 0 ofObject: weakObjectOop withValue: nonWeakObjectOop.
"Force object to not be collected by putting them in special variables"
memory coInterpreter newMethod: weakObjectOop.
memory coInterpreter profileSemaphore: nonWeakObjectOop.
memory doScavenge: 1 "TenureByAge".
weakObjectOop := memory remapObj: weakObjectOop.
self
assert: (memory hashBitsOf: (memory fetchPointer: 0 ofObject: weakObjectOop))
equals: nonWeakObjectHash
]