-
Notifications
You must be signed in to change notification settings - Fork 65
/
CogMethodSurrogate32.class.st
261 lines (224 loc) · 7.18 KB
/
CogMethodSurrogate32.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
"
Here's a doit to generate my code:
| offset crtab |
offset := 1.
crtab := String with: Character cr with: Character tab.
CogMethod instVarNamesAndTypesForTranslationDo:
[:name :type| | isByte class |
(isByte := type = 'unsigned char') ifFalse:
[offset := (offset - 1 + 3 bitAnd: -4) + 1].
class := (CogBlockMethod instVarNames includes: name)
ifTrue: [CogBlockMethodSurrogate32]
ifFalse: [CogMethodSurrogate32].
class
compile: name, crtab, '^memory unsigned', (isByte ifTrue: ['ByteAt:'] ifFalse: ['LongAt:']), ' address + ', offset printString
classified: #accessing.
class
compile: name, ': aValue', crtab, '^memory unsigned', (isByte ifTrue: ['ByteAt:'] ifFalse: ['LongAt:']), ' address + ', offset printString,
' put: aValue'
classified: #accessing.
offset := offset + (isByte ifTrue: [1] ifFalse: [4])].
CogMethodSurrogate32 class compile: 'alignedByteSize', crtab, '^', (offset - 1 + 3 bitAnd: -4) printString classified: #'instance creation'
"
Class {
#name : #CogMethodSurrogate32,
#superclass : #CogMethodSurrogate,
#category : #'VMMaker-JITSimulation'
}
{ #category : #accessing }
CogMethodSurrogate32 class >> alignedByteSize [
^20 + self baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 class >> offsetOf: aByteSymbol [
"These should be generated!!"
| baseHeaderSize |
baseHeaderSize := self objectMemoryClass baseHeaderSize.
^aByteSymbol caseOf:
{ [#methodObject] -> [8 + baseHeaderSize].
[#methodHeader] -> [12 + baseHeaderSize].
[#selector] -> [16 + baseHeaderSize].
[#picUsage] -> [6 + baseHeaderSize].
}
]
{ #category : #accessing }
CogMethodSurrogate32 >> blockSize [
^memory unsignedShortAt: address + 4 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> blockSize: aValue [
^memory
unsignedShortAt: address + baseHeaderSize + 4
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cbUsesInstVars [
^(((memory unsignedByteAt: address + 2 + baseHeaderSize) bitShift: -1) bitAnd: 16r1) ~= 0
]
{ #category : #accessing }
CogMethodSurrogate32 >> cbUsesInstVars: aValue [
memory
unsignedByteAt: address + baseHeaderSize + 2
put: (((memory unsignedByteAt: address + baseHeaderSize + 2) bitAnd: 16rFD) + ((aValue ifTrue: [1] ifFalse: [0]) bitShift: 1)).
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmIsUnlinked [
^(((memory unsignedByteAt: address + 6) bitShift: -4) bitAnd: 16r1) ~= 0
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmIsUnlinked: aValue [
memory
unsignedByteAt: address + 6
put: (((memory unsignedByteAt: address + 6) bitAnd: 16rEF) + ((aValue ifTrue: [1] ifFalse: [0]) bitShift: 4)).
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmNumArgs [
^memory unsignedByteAt: address + 0 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmNumArgs: aValue [
^memory
unsignedByteAt: address + baseHeaderSize + 0
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmRefersToYoung [
^(((memory unsignedByteAt: address + 1 + baseHeaderSize) bitShift: -3) bitAnd: 16r1) ~= 0
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmRefersToYoung: aValue [
memory
unsignedByteAt: address + baseHeaderSize + 1
put: (((memory unsignedByteAt: address + baseHeaderSize + 1) bitAnd: 16rF7) + ((aValue ifTrue: [1] ifFalse: [0]) bitShift: 3)).
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmType [
^(memory unsignedByteAt: address + 1 + baseHeaderSize) bitAnd: 16r7
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmType: aValue [
self assert: (aValue between: 0 and: 16r7).
memory
unsignedByteAt: address + baseHeaderSize + 1
put: ((memory unsignedByteAt: address + baseHeaderSize + 1) bitAnd: 16rF8) + aValue.
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmUsageCount [
^((memory unsignedByteAt: address + 1 + baseHeaderSize) bitShift: -5) bitAnd: 16r7
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmUsageCount: aValue [
self assert: (aValue between: 0 and: 16r7).
memory
unsignedByteAt: address + baseHeaderSize + 1
put: ((memory unsignedByteAt: address + baseHeaderSize + 1) bitAnd: 16r1F) + (aValue bitShift: 5).
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmUsesPenultimateLit [
^((memory unsignedByteAt: address + 2 + baseHeaderSize) bitAnd: 16r1) ~= 0
]
{ #category : #accessing }
CogMethodSurrogate32 >> cmUsesPenultimateLit: aValue [
memory
unsignedByteAt: address + baseHeaderSize + 2
put: (((memory unsignedByteAt: address + baseHeaderSize + 2) bitAnd: 16rFE) + (aValue ifTrue: [1] ifFalse: [0])).
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> cpicHasMNUCaseOrCMIsFullBlock [
^(((memory unsignedByteAt: address + 1 + baseHeaderSize) bitShift: -4) bitAnd: 16r1) ~= 0
]
{ #category : #accessing }
CogMethodSurrogate32 >> cpicHasMNUCaseOrCMIsFullBlock: aValue [
memory
unsignedByteAt: address + baseHeaderSize + 1
put: (((memory unsignedByteAt: address + baseHeaderSize + 1) bitAnd: 16rEF) + ((aValue ifTrue: [1] ifFalse: [0]) bitShift: 4)).
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> homeOffset [
^memory unsignedShortAt: address + 0
]
{ #category : #accessing }
CogMethodSurrogate32 >> homeOffset: aValue [
^memory
unsignedShortAt: address + 0
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodHeader [
^memory unsignedLong32At: address + 12 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodHeader: aValue [
^memory
unsignedLong32At: address + baseHeaderSize + 12
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodObject [
^memory unsignedLong32At: address + 8 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> methodObject: aValue [
^memory
unsignedLong32At: address + baseHeaderSize + 8
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> padToWord [
^memory unsignedLong32At: address + 4
]
{ #category : #accessing }
CogMethodSurrogate32 >> padToWord: aValue [
^memory
unsignedLong32At: address + 4
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> picUsage [
^memory unsignedShortAt: address + 6 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> picUsage: aValue [
^memory
unsignedShortAt: address + baseHeaderSize + 6
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> selector [
^memory unsignedLong32At: address + 16 + baseHeaderSize
]
{ #category : #accessing }
CogMethodSurrogate32 >> selector: aValue [
^memory
unsignedLong32At: address + baseHeaderSize + 16
put: aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> stackCheckOffset [
^((memory unsignedShortAt: address + 2 + baseHeaderSize) bitShift: -4) bitAnd: 16rFFF
]
{ #category : #accessing }
CogMethodSurrogate32 >> stackCheckOffset: aValue [
self assert: (aValue between: 0 and: 16rFFF).
memory
unsignedShortAt: address + baseHeaderSize + 2
put: ((memory unsignedShortAt: address + baseHeaderSize + 2) bitAnd: 16rF) + (aValue bitShift: 4).
^aValue
]
{ #category : #accessing }
CogMethodSurrogate32 >> startpc [
^memory unsignedShortAt: address + 2
]
{ #category : #accessing }
CogMethodSurrogate32 >> startpc: aValue [
^memory
unsignedShortAt: address + 2
put: aValue
]