-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMPrimitiveCallAbstractTest.class.st
202 lines (143 loc) · 5.76 KB
/
VMPrimitiveCallAbstractTest.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
Class {
#name : #VMPrimitiveCallAbstractTest,
#superclass : #VMSimpleStackBasedCogitAbstractTest,
#instVars : [
'baseMethodIP',
'baseFrame',
'baseMethod'
],
#category : #'VMMakerTests-JitTests'
}
{ #category : #helpers }
VMPrimitiveCallAbstractTest >> callCogMethod: callingMethod receiver: receiver arguments: arguments returnAddress: returnAddress [
machineSimulator receiverRegisterValue: receiver.
self pushAddress: receiver.
arguments do: [ :e | self pushAddress: e ].
arguments size = 1
ifTrue: [ machineSimulator arg0RegisterValue: (arguments at: 1) ].
arguments size = 2
ifTrue: [
machineSimulator arg0RegisterValue: (arguments at: 1).
machineSimulator arg1RegisterValue: (arguments at: 2). ].
self prepareCall.
machineSimulator instructionPointerRegisterValue: callingMethod address + cogit noCheckEntryOffset.
self runFrom: callingMethod address + cogit noCheckEntryOffset until: returnAddress.
]
{ #category : #helpers }
VMPrimitiveCallAbstractTest >> findMethod: aSelector [
^ self class lookupSelector: aSelector
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> jitCompilerClass [
^ StackToRegisterMappingCogit
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> jitOptions [
^ super jitOptions
at: #IMMUTABILITY put: true;
yourself
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodReturningNil [
^ nil
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodSendingCharacterArgument [
"This method is used to test sends.
This send can be unlinked, linked to a method, or to a PIC"
^ self methodWithSend: $7
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodSendingLiteralVariableArgument [
"This method is used to test sends.
This send can be unlinked, linked to a method, or to a PIC"
^ self methodWithSend: Object
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodSendingNilArgument [
"This method is used to test sends.
This send can be unlinked, linked to a method, or to a PIC"
^ self methodWithSend: nil
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodThatCallNamedPrimitive: anArg [
"This method is used to test the invocation of a primitive.
The primitive to invoke is later changed in the primitive table of the interpreter used in the test"
<primitive: 'primitiveThatDoNothingWithOneArgument'>
^ 84
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodThatCallNamedPrimitiveCounting: anArg [
"This method is used to test the invocation of a primitive.
The primitive to invoke is later changed in the primitive table of the interpreter used in the test"
<primitive: 'primitiveFailCounting'>
^ 84
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodThatCallPrimitive159 [
<primitive: 159>
^ 42
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodThatCallPrimitive173: anArg [
"This method is used to test the invocation of a primitive.
The primitive to invoke is later changed in the primitive table of the interpreter used in the test"
<primitive: 173>
^ 42
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodThatCallPrimitive1: anArg [
"This method is used to test the invocation of a primitive.
The primitive to invoke is later changed in the primitive table of the interpreter used in the test"
<primitive: 1>
^ 42
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodToCompile1 [
^ 42
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodWithSend [
"This method is used to test sends.
This send can be unlinked, linked to a method, or to a PIC"
^ self send
]
{ #category : #'methods under test' }
VMPrimitiveCallAbstractTest >> methodWithSend: arg [
"This method is used to test sends.
This send can be unlinked, linked to a method, or to a PIC"
^ arg send
]
{ #category : #running }
VMPrimitiveCallAbstractTest >> setUp [
| primitiveAccessorDepthTable |
super setUp.
self setUpCogMethodEntry.
cogit generateClosedPICPrototype.
cogit methodZone manageFrom: cogit methodZoneBase to: cogit methodZone effectiveLimit.
"Initializing the accessor depth table with a value for the first primitive"
primitiveAccessorDepthTable := Array new: interpreter primitiveTable size.
1 to: interpreter primitiveTable size
do: [ :i | primitiveAccessorDepthTable at: i put: -1 ].
interpreter primitiveAccessorDepthTable: primitiveAccessorDepthTable.
cogit lastNInstructions: OrderedCollection new.
cogit guardPageSize: cogit class guardPageSize.
]
{ #category : #running }
VMPrimitiveCallAbstractTest >> setUpTrampolines [
super setUpTrampolines.
cogit methodAbortTrampolines at: 0 put: cogit ceMethodAbortTrampoline.
cogit methodAbortTrampolines at: 1 put: cogit ceMethodAbortTrampoline.
cogit methodAbortTrampolines at: 2 put: cogit ceMethodAbortTrampoline.
cogit methodAbortTrampolines at: 3 put: cogit ceMethodAbortTrampoline.
cogit picMissTrampolines at: 0 put: cogit ceCPICMissTrampoline.
cogit picMissTrampolines at: 1 put: cogit ceCPICMissTrampoline.
cogit picMissTrampolines at: 2 put: cogit ceCPICMissTrampoline.
cogit picMissTrampolines at: 3 put: cogit ceCPICMissTrampoline.
cogit picAbortTrampolines at: 0 put: cogit cePICAbortTrampoline.
cogit picAbortTrampolines at: 1 put: cogit cePICAbortTrampoline.
cogit picAbortTrampolines at: 2 put: cogit cePICAbortTrampoline.
cogit picAbortTrampolines at: 3 put: cogit cePICAbortTrampoline.
cogit ceStoreCheckTrampoline: (self compileTrampoline: [ cogit RetN: 0 ] named:#ceStoreCheckTrampoline).
cogit objectRepresentation setAllStoreTrampolinesWith: (self compileTrampoline: [ cogit RetN: 0 ] named: #ceStoreTrampoline).
]