-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMSistaSuperSendsTest.class.st
71 lines (60 loc) · 2.46 KB
/
VMSistaSuperSendsTest.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
Class {
#name : #VMSistaSuperSendsTest,
#superclass : #VMStackToRegisterMappingCogitTest,
#category : #'VMMakerTests-JitTests'
}
{ #category : #running }
VMSistaSuperSendsTest >> jitOptions [
^ super jitOptions
at: #bytecodeTableInitializer put: #initializeBytecodeTableForSistaV1;
yourself
]
{ #category : #'tests - sends/super' }
VMSistaSuperSendsTest >> testSuperSendLiteralZeroWithZeroArgsMovesSelectorIndexClassRegisterIn64bits [
| selector binding literalVariableIndex literalSelectorIndex startPC receiver expectedSelector |
sendTrampolineAddress := self compile: [ cogit RetN: 0 ].
cogit
directedBindingSuperSendTrampolineAt: 0
put: sendTrampolineAddress. "num args"
self createFramefulCallFrom: callerAddress.
cogit byte0: 0.
binding := self newObjectWithSlots: 2.
selector := memory falseObject.
cogit methodObj: (methodBuilder newMethod
literalAt: (literalVariableIndex := 0) put: binding;
literalAt: (literalSelectorIndex := 1) put: selector;
numberOfArguments: 1;
bytecodes: #[ 16r11 16rE1 16r40 16rEB 16r00 ];
buildMethod).
"Push literal variable"
"Directed super send"
startPC := interpreter startPCOfMethod: cogit methodObj.
sendAddress := self compile: [
cogit methodOrBlockNumTemps: 0.
cogit initSimStackForFramelessMethod: startPC.
cogit bytecodePC: startPC.
cogit endPC: (memory numBytesOf: cogit methodObj).
"Push receiver and arguments"
cogit genPushReceiverBytecode.
"Push lookup class binding, then send"
cogit genPushLiteralVariable: literalVariableIndex.
cogit
genSendDirectedSuper: literalSelectorIndex
numArgs: 0 ].
"Push receiver, arg, then send"
receiver := memory integerObjectOf: 17.
self
prepareStackForSendReceiver: receiver
arguments: { (memory integerObjectOf: 42) }.
self runFrom: sendAddress until: sendTrampolineAddress.
"In 64 bits we have the literal selector index that will be mapped by the send trampoline.
In 32 bits we have the selector directly."
expectedSelector := self wordSize = 8
ifTrue: [ literalSelectorIndex ]
ifFalse: [ selector ].
self
assert: machineSimulator classRegisterValue
equals: expectedSelector.
self assert: machineSimulator temporaryRegisterValue equals: binding.
self assert: machineSimulator receiverRegisterValue equals: receiver
]