-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMJittedPrimitiveSizeTest.class.st
172 lines (121 loc) · 4.65 KB
/
VMJittedPrimitiveSizeTest.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
Class {
#name : #VMJittedPrimitiveSizeTest,
#superclass : #VMJittedPrimitivesTest,
#instVars : [
'stop'
],
#category : #'VMMakerTests-JitTests'
}
{ #category : #helpers }
VMJittedPrimitiveSizeTest >> assertFallsThrough [
self runFrom: cogInitialAddress until: stop address.
self assert: machineSimulator instructionPointerRegisterValue equals: stop address
]
{ #category : #running }
VMJittedPrimitiveSizeTest >> setUp [
super setUp.
self
compile: [
cogit objectRepresentation genPrimitiveSize.
stop := cogit Stop ]
bytecodes: 10.
]
{ #category : #'tests - bit indexable' }
VMJittedPrimitiveSizeTest >> testPrimitiveSize16bitIndexableShouldReturnNumberOf16bitSlots [
| integerArray |
integerArray := self new16BitIndexableOfSize: 7.
self prepareStackForSendReceiver: integerArray.
machineSimulator baseRegisterValue: cogit varBaseAddress.
self runUntilReturn.
self
assert: (memory integerValueOf: machineSimulator receiverRegisterValue)
equals: 7
]
{ #category : #'tests - bit indexable' }
VMJittedPrimitiveSizeTest >> testPrimitiveSize32bitIndexableShouldReturnNumberOf32bitSlots [
| integerArray |
integerArray := self new32BitIndexableOfSize: 7.
self prepareStackForSendReceiver: integerArray.
machineSimulator baseRegisterValue: cogit varBaseAddress.
self runUntilReturn.
self
assert: (memory integerValueOf: machineSimulator receiverRegisterValue)
equals: 7
]
{ #category : #'tests - bit indexable' }
VMJittedPrimitiveSizeTest >> testPrimitiveSize32bitIndexableWithExtraHeaderShouldReturnNumberOf32bitSlots [
| integerArray aSize bytesPerSlot desiredByteSize numberOfWordSizeSlots padding |
aSize := 32768.
bytesPerSlot := 4.
desiredByteSize := aSize * bytesPerSlot roundUpTo: self wordSize.
numberOfWordSizeSlots := desiredByteSize / self wordSize.
padding := desiredByteSize / bytesPerSlot - aSize.
integerArray := memory
allocateSlotsInOldSpace: numberOfWordSizeSlots
format: memory firstLongFormat + padding
classIndex: self nextOrdinaryClassIndex.
self prepareStackForSendReceiver: integerArray.
machineSimulator baseRegisterValue: cogit varBaseAddress.
self runUntilReturn.
self
assert: (memory integerValueOf: machineSimulator receiverRegisterValue)
equals: 32768
]
{ #category : #'tests - bit indexable' }
VMJittedPrimitiveSizeTest >> testPrimitiveSize64bitIndexableShouldReturnNumberOf64bitSlots [
| integerArray |
integerArray := self new64BitIndexableOfSize: 7.
self prepareStackForSendReceiver: integerArray.
machineSimulator baseRegisterValue: cogit varBaseAddress.
self runUntilReturn.
self
assert: (memory integerValueOf: machineSimulator receiverRegisterValue)
equals: 7
]
{ #category : #'tests - bit indexable' }
VMJittedPrimitiveSizeTest >> testPrimitiveSize8bitIndexableShouldReturnNumberOf8bitSlots [
| integerArray |
integerArray := self new8BitIndexableOfSize: 7.
self prepareStackForSendReceiver: integerArray.
machineSimulator baseRegisterValue: cogit varBaseAddress.
self runUntilReturn.
self
assert: (memory integerValueOf: machineSimulator receiverRegisterValue)
equals: 7
]
{ #category : #'tests - pointer indexable' }
VMJittedPrimitiveSizeTest >> testPrimitiveSizeArrayShouldReturnPointerSizedSlots [
| array |
array := self newArrayWithSlots: 7.
self prepareStackForSendReceiver: array.
machineSimulator baseRegisterValue: cogit varBaseAddress.
self runUntilReturn.
self assert: machineSimulator receiverRegisterValue equals: (memory integerObjectOf: 7)
]
{ #category : #'tests - fixed pointer layout' }
VMJittedPrimitiveSizeTest >> testPrimitiveSizeFixedObjectShouldFallThrough [
| objectWithInstanceVariables |
objectWithInstanceVariables := memory
allocateNewSpaceSlots: 3 "It has slots, but we should not access them"
format: 1 "object with instance variables"
classIndex: self nextOrdinaryClassIndex.
self prepareStackForSendReceiver: objectWithInstanceVariables.
self assertFallsThrough
]
{ #category : #'tests - fixed pointer layout' }
VMJittedPrimitiveSizeTest >> testPrimitiveSizeImmediateCharacterShouldFallThrough [
self prepareStackForSendReceiver: (memory characterObjectOf: $a codePoint).
self assertFallsThrough
]
{ #category : #'tests - fixed pointer layout' }
VMJittedPrimitiveSizeTest >> testPrimitiveSizeImmediateFloatShouldFallThrough [
"Floats are not immediate in 32 bits"
self wordSize = 4 ifTrue: [ ^self skip ].
self prepareStackForSendReceiver: (memory floatObjectOf: 1.0).
self assertFallsThrough
]
{ #category : #'tests - fixed pointer layout' }
VMJittedPrimitiveSizeTest >> testPrimitiveSizeImmediateIntegerShouldFallThrough [
self prepareStackForSendReceiver: (memory integerObjectOf: 17).
self assertFallsThrough
]