-
Notifications
You must be signed in to change notification settings - Fork 67
/
VMCallingConventionTest.class.st
59 lines (46 loc) · 1.69 KB
/
VMCallingConventionTest.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
Class {
#name : #VMCallingConventionTest,
#superclass : #VMStackToRegisterMappingCogitTest,
#category : #'VMMakerTests-JitTests'
}
{ #category : #tests }
VMCallingConventionTest >> testSendShouldSpillAboveReceiver [
| stop method |
method := self compile: [
cogit methodOrBlockNumTemps: 0.
cogit needsFrame: true.
cogit initSimStackForFramefulMethod: 0.
"This will push 0 and be spilled on the send"
cogit genPushConstantZeroBytecode.
"Let's compile 1 + true, spill what was pushed before"
cogit genPushConstantOneBytecode.
cogit genPushConstantTrueBytecode.
cogit marshallSendArguments: 1.
stop := cogit Stop
].
self runFrom: method until: stop address.
self assert: (memory integerValueOf: self machineSimulator popWord) equals: 0
]
{ #category : #tests }
VMCallingConventionTest >> testSendShouldSpillReceiver [
| stop method |
method := self compile: [
cogit methodOrBlockNumTemps: 0.
cogit needsFrame: true.
cogit initSimStackForFramefulMethod: 0.
"Let's push two constants and spill the stack"
cogit ssPushConstant: 42.
cogit ssPushConstant: 17.
cogit ssFlushTo: cogit simStackPointer.
"Prepare to send a message with 0 arguments.
The top of the stack (receiver) should be in a register and not the stack, to follow the calling convention"
cogit marshallSendArguments: 0.
stop := cogit Stop
].
self prepareStackForSendReceiver: 42 arguments: #().
self runFrom: method until: stop address.
"The receiver register should contain the receiver value"
self assert: self machineSimulator receiverRegisterValue equals: 17.
"The top of the stack should contain the marker value 42"
self assert: self machineSimulator stackValues first value equals: 42
]