-
Notifications
You must be signed in to change notification settings - Fork 67
/
CogMethodSurrogate.class.st
213 lines (178 loc) · 5.42 KB
/
CogMethodSurrogate.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
Class {
#name : #CogMethodSurrogate,
#superclass : #VMClass,
#instVars : [
'address',
'memory',
'baseHeaderSize',
'cogit'
],
#pools : [
'CogMethodConstants',
'VMBytecodeConstants'
],
#category : #'VMMaker-JITSimulation'
}
{ #category : #accessing }
CogMethodSurrogate class >> alignedByteSizeOf: anObject forClient: aVMClass [
^self alignedByteSize
]
{ #category : #accessing }
CogMethodSurrogate class >> baseHeaderSize [
^self objectMemoryClass baseHeaderSize
]
{ #category : #arithmetic }
CogMethodSurrogate >> + anInteger [
"N.B. Mimic C semantics so that aCogMethod + 1 is a pointer to the byte past the CogMethod header."
^address + (anInteger * self class alignedByteSize)
]
{ #category : #comparing }
CogMethodSurrogate >> < aCogMethodOrAddress [
^address < aCogMethodOrAddress asInteger
]
{ #category : #comparing }
CogMethodSurrogate >> <= aCogMethodOrAddress [
^address <= aCogMethodOrAddress asInteger
]
{ #category : #comparing }
CogMethodSurrogate >> = aCogMethodOrAddressOrNil [
^address = (aCogMethodOrAddressOrNil
ifNil: [0]
ifNotNil: [aCogMethodOrAddressOrNil asInteger])
]
{ #category : #comparing }
CogMethodSurrogate >> > aCogMethodOrAddress [
^address > aCogMethodOrAddress asInteger
]
{ #category : #comparing }
CogMethodSurrogate >> >= aCogMethodOrAddress [
^address >= aCogMethodOrAddress asInteger
]
{ #category : #arithmetic }
CogMethodSurrogate >> adaptToInteger: rcvr andSend: selector [
"If no method has been provided for adapting an object to a Integer,
then it may be adequate to simply adapt it to a number."
^rcvr perform: selector with: address
]
{ #category : #accessing }
CogMethodSurrogate >> address [
^address
]
{ #category : #accessing }
CogMethodSurrogate >> asInteger [
"Answer the surrogate's adress. This is equivalent to a C cast to sqInt,
which is precisely what Slang generates for asInteger"
^address
]
{ #category : #accessing }
CogMethodSurrogate >> asIntegerPtr [
"Answer the surrogate's adress. This is equivalent to a C cast to usqIntptr_t,
which is precisely what Slang generates for asIntegerPtr"
^address
]
{ #category : #accessing }
CogMethodSurrogate >> asUnsignedInteger [
"Answer the surrogate's adress. This is equivalent to a C cast to usqInt,
which is precisely what Slang generates for asUnsignedInteger"
^address
]
{ #category : #accessing }
CogMethodSurrogate >> asUnsignedIntegerPtr [
"Answer the surrogate's adress. This is equivalent to a C cast to usqIntptr_t,
which is precisely what Slang generates for asUnsignedIntegerPtr"
^address
]
{ #category : #coercing }
CogMethodSurrogate >> asVoidPointer [
^self
]
{ #category : #'instance initialization' }
CogMethodSurrogate >> at: anAddress memory: memoryArray headerSize: headerSize cogit: aCogit [
address := anAddress.
memory := memoryArray.
baseHeaderSize := headerSize.
cogit := aCogit
]
{ #category : #'instance initialization' }
CogMethodSurrogate >> at: anAddress objectMemory: objectMemory cogit: aCogit [
address := anAddress.
memory := objectMemory memoryManager.
baseHeaderSize := objectMemory baseHeaderSize.
cogit := aCogit
]
{ #category : #accessing }
CogMethodSurrogate >> cPICNumCases [
^self stackCheckOffset
]
{ #category : #accessing }
CogMethodSurrogate >> cPICNumCases: n [
^self stackCheckOffset: n
]
{ #category : #accessing }
CogMethodSurrogate >> cmHomeMethod [
^cogit cogMethodSurrogateAt: ((SistaV1BytecodeSet and: [self cmIsFullBlock])
ifTrue: [address]
ifFalse: [address - self homeOffset])
]
{ #category : #accessing }
CogMethodSurrogate >> cmIsFullBlock [
"Answer the value of cpicHasMNUCaseOrCMIsFullBlock"
^SistaV1BytecodeSet
ifTrue: [self cpicHasMNUCaseOrCMIsFullBlock]
ifFalse: [false]
]
{ #category : #testing }
CogMethodSurrogate >> containsAddress: anAddress [
^address <= anAddress asUnsignedInteger
and: [address + self blockSize >= anAddress asUnsignedInteger]
]
{ #category : #accessing }
CogMethodSurrogate >> cpicHasMNUCase [
"Answer if the receiver has an MNU case."
<inline: true>
^SistaV1BytecodeSet
ifTrue: [self cpicHasMNUCaseOrCMIsFullBlock and: [self cmType = CMPolymorphicIC]]
ifFalse: [self cpicHasMNUCaseOrCMIsFullBlock]
]
{ #category : #accessing }
CogMethodSurrogate >> cpicHasMNUCase: anObject [
"Set if the receiver has an MNU case."
^self cpicHasMNUCaseOrCMIsFullBlock: anObject
]
{ #category : #testing }
CogMethodSurrogate >> isVMSimulationAddress [
"Answer a boolean indicating whether the receiver is a kind of address in the VM simulation"
^true
]
{ #category : #comparing }
CogMethodSurrogate >> isZero [
^address = 0
]
{ #category : #accessing }
CogMethodSurrogate >> nextOpenPIC [
| moField |
moField := self methodObject.
^moField ~= 0 ifTrue:
[cogit cogMethodSurrogateAt: moField]
]
{ #category : #accessing }
CogMethodSurrogate >> nextOpenPIC: cogMethodSurrogateOrNil [
^self methodObject: (cogMethodSurrogateOrNil ifNil: [0] ifNotNil: [cogMethodSurrogateOrNil asUnsignedInteger])
]
{ #category : #accessing }
CogMethodSurrogate >> objectHeader [
^baseHeaderSize = 8
ifTrue: [memory long64At: address]
ifFalse: [memory longAt: address]
]
{ #category : #accessing }
CogMethodSurrogate >> objectHeader: aValue [
^baseHeaderSize = 8
ifTrue: [memory long64At: address put: aValue]
ifFalse: [memory longAt: address put: aValue]
]
{ #category : #printing }
CogMethodSurrogate >> printOn: aStream [
super printOn: aStream.
aStream nextPutAll: ' @'; print: address; nextPut: $/; nextPutAll: address hex
]