-
Notifications
You must be signed in to change notification settings - Fork 67
/
VMSimpleStackBasedCogitMonomorphicPICTest.class.st
106 lines (84 loc) · 3.03 KB
/
VMSimpleStackBasedCogitMonomorphicPICTest.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
Class {
#name : #VMSimpleStackBasedCogitMonomorphicPICTest,
#superclass : #VMSimpleStackBasedCogitAbstractTest,
#category : #'VMMakerTests-JitTests'
}
{ #category : #'tests - PIC' }
VMSimpleStackBasedCogitMonomorphicPICTest >> testCalculateClosePICSize [
"Calculate the size of the Closed Pic"
self setUpCogMethodEntry.
cogit generateClosedPICPrototype.
self assert: cogit closedPICSize isNotNil
]
{ #category : #'tests - PIC' }
VMSimpleStackBasedCogitMonomorphicPICTest >> testLinkCallDuringSendInTrampolineReplacesTheCallTargetWithTheCogMethodAddress [
"This is for the monomorphic case"
| sendingMethod targetCog selector executedTheTrampoline |
self setUpCogMethodEntry.
sendTrampolineAddress := self compile: [ cogit RetN: 0 ].
cogit ordinarySendTrampolineAt: 0 put: sendTrampolineAddress. "num args"
selector := memory falseObject.
targetCog := self
generateCogMethod: [ cogit RetN: 0 ]
selector: selector.
self createFramefulCallFrom: callerAddress.
cogit byte0: 0.
sendingMethod := methodBuilder
newMethod;
literals: { selector };
buildMethod.
cogit methodObj: sendingMethod.
sendAddress := self compile: [
cogit genSendLiteralSelector0ArgsBytecode ].
"Push receiver then send"
self pushAddress: memory falseObject.
self runFrom: sendAddress until: sendTrampolineAddress.
cogit
linkSendAt: machineSimulator getReturnAddress
in: sendingMethod
to: targetCog
offset: cogit entryOffset
receiver: memory falseObject.
self pushAddress: memory falseObject.
executedTheTrampoline := false.
machineSimulator
registerHook: [ executedTheTrampoline := true ]
atAddress: sendTrampolineAddress.
self
runFrom: sendAddress
until: targetCog asInteger + cogit entryOffset.
self deny: executedTheTrampoline
]
{ #category : #'tests - PIC' }
VMSimpleStackBasedCogitMonomorphicPICTest >> testObtainInlineCacheFromLinkedCall [
| sendingMethod targetCog selector executedTheTrampoline |
self setUpCogMethodEntry.
sendTrampolineAddress := self compile: [ cogit RetN: 0 ].
cogit ordinarySendTrampolineAt: 0 put: sendTrampolineAddress. "num args"
selector := memory falseObject.
targetCog := self
generateCogMethod: [ cogit RetN: 0 ]
selector: selector.
self createFramefulCallFrom: callerAddress.
cogit byte0: 0.
sendingMethod := methodBuilder newMethod
literals: { selector };
buildMethod.
cogit methodObj: sendingMethod.
sendAddress := self compile: [
cogit genSendLiteralSelector0ArgsBytecode ].
"Push receiver then send"
self pushAddress: memory falseObject.
self runFrom: sendAddress until: sendTrampolineAddress.
cogit
linkSendAt: machineSimulator getReturnAddress
in: sendingMethod
to: targetCog
offset: cogit entryOffset
receiver: memory falseObject.
self
assert:
(cogit backend inlineCacheTagAt: machineSimulator getReturnAddress)
equals: (cogit objectRepresentation inlineCacheTagForInstance:
memory falseObject)
]